快速开发平台快速开发程序

快速开发平台快速开发程序

1.数据字典如下图:


2.界面设计器代码如下

  1 <object name="" assembly="System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" TreasuryVersion="1">
  2   <Font>宋体, 9pt</Font>
  3   <BackColor>Control</BackColor>
  4   <RightToLeft>No</RightToLeft>
  5   <AutoValidate>EnablePreventFocusChange</AutoValidate>
  6   <Cursor>Default</Cursor>
  7   <Text>部门设置-设计</Text>
  8   <ShowInTaskbar>False</ShowInTaskbar>
  9   <Name />
 10   <KeyPreview>True</KeyPreview>
 11   <ForeColor>ControlText</ForeColor>
 12   <ClientSize>602, 511</ClientSize>
 13   <object name="UltraCombo2" assembly="Infragistics.Win.UltraWinGrid.UltraCombo, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 14     <Name>UltraCombo2</Name>
 15     <DisplayStyle>Office2007</DisplayStyle>
 16     <CheckedListSettings control="true">
 17       <object name="CheckedListSettings1" assembly="Infragistics.Win.UltraWinGrid.CheckedListSettings, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 18         <CheckStateMember />
 19       </object>
 20     </CheckedListSettings>
 21     <DisplayLayout control="true">
 22       <object name="UltraGridDisplayLayout1" assembly="Infragistics.Win.UltraWinGrid.UltraGridDisplayLayout, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 23         <Appearance mode="constructor">
 24           <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 25           <BackColor>White</BackColor>
 26           <BackColor2>61, 149, 255</BackColor2>
 27           <BackGradientStyle>ForwardDiagonal</BackGradientStyle>
 28         </Appearance>
 29         <Override control="true">
 30           <object name="UltraGridOverride1" assembly="Infragistics.Win.UltraWinGrid.UltraGridOverride, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 31             <CardAreaAppearance mode="constructor">
 32               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 33               <BackColor>Transparent</BackColor>
 34             </CardAreaAppearance>
 35             <HeaderAppearance mode="constructor">
 36               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 37               <BackColor>61, 149, 255</BackColor>
 38               <BackColor2>1, 68, 208</BackColor2>
 39               <BackGradientStyle>Vertical</BackGradientStyle>
 40               <ForeColor>White</ForeColor>
 41               <ThemedElementAlpha>Transparent</ThemedElementAlpha>
 42               <TextHAlignAsString>Left</TextHAlignAsString>
 43             </HeaderAppearance>
 44             <RowSelectorAppearance mode="constructor">
 45               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 46               <BackColor>61, 149, 255</BackColor>
 47               <BackColor2>1, 68, 208</BackColor2>
 48               <BackGradientStyle>Vertical</BackGradientStyle>
 49             </RowSelectorAppearance>
 50             <SelectedRowAppearance mode="constructor">
 51               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 52               <BackColor>129, 169, 226</BackColor>
 53               <BackColor2>221, 235, 254</BackColor2>
 54               <BackGradientStyle>Vertical</BackGradientStyle>
 55               <ForeColor>Black</ForeColor>
 56             </SelectedRowAppearance>
 57             <RowAppearance mode="constructor">
 58               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 59               <BorderColor>1, 68, 208</BorderColor>
 60             </RowAppearance>
 61             <AllowRowFiltering>True</AllowRowFiltering>
 62             <RowSpacingBefore>2</RowSpacingBefore>
 63             <RowSelectorWidth>12</RowSelectorWidth>
 64             <FixedRowIndicator>Button</FixedRowIndicator>
 65             <FixedRowStyle>Top</FixedRowStyle>
 66           </object>
 67         </Override>
 68         <InterBandSpacing>10</InterBandSpacing>
 69         <RowConnectorColor>1, 68, 208</RowConnectorColor>
 70         <RowConnectorStyle>Solid</RowConnectorStyle>
 71         <UseFixedHeaders>True</UseFixedHeaders>
 72       </object>
 73     </DisplayLayout>
 74     <Location>211, 298</Location>
 75     <Size>100, 22</Size>
 76     <TabIndex>2</TabIndex>
 77   </object>
 78   <object name="UltraCombo1" assembly="Infragistics.Win.UltraWinGrid.UltraCombo, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 79     <Name>UltraCombo1</Name>
 80     <DisplayStyle>Office2007</DisplayStyle>
 81     <CheckedListSettings control="true">
 82       <object name="CheckedListSettings1" assembly="Infragistics.Win.UltraWinGrid.CheckedListSettings, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 83         <CheckStateMember />
 84       </object>
 85     </CheckedListSettings>
 86     <DisplayLayout control="true">
 87       <object name="UltraGridDisplayLayout1" assembly="Infragistics.Win.UltraWinGrid.UltraGridDisplayLayout, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 88         <Appearance mode="constructor">
 89           <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 90           <BackColor>White</BackColor>
 91           <BackColor2>61, 149, 255</BackColor2>
 92           <BackGradientStyle>ForwardDiagonal</BackGradientStyle>
 93         </Appearance>
 94         <Override control="true">
 95           <object name="UltraGridOverride1" assembly="Infragistics.Win.UltraWinGrid.UltraGridOverride, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
 96             <CardAreaAppearance mode="constructor">
 97               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
 98               <BackColor>Transparent</BackColor>
 99             </CardAreaAppearance>
100             <HeaderAppearance mode="constructor">
101               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
102               <BackColor>61, 149, 255</BackColor>
103               <BackColor2>1, 68, 208</BackColor2>
104               <BackGradientStyle>Vertical</BackGradientStyle>
105               <ForeColor>White</ForeColor>
106               <ThemedElementAlpha>Transparent</ThemedElementAlpha>
107               <TextHAlignAsString>Left</TextHAlignAsString>
108             </HeaderAppearance>
109             <RowSelectorAppearance mode="constructor">
110               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
111               <BackColor>61, 149, 255</BackColor>
112               <BackColor2>1, 68, 208</BackColor2>
113               <BackGradientStyle>Vertical</BackGradientStyle>
114             </RowSelectorAppearance>
115             <SelectedRowAppearance mode="constructor">
116               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
117               <BackColor>129, 169, 226</BackColor>
118               <BackColor2>221, 235, 254</BackColor2>
119               <BackGradientStyle>Vertical</BackGradientStyle>
120               <ForeColor>Black</ForeColor>
121             </SelectedRowAppearance>
122             <RowAppearance mode="constructor">
123               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
124               <BorderColor>1, 68, 208</BorderColor>
125             </RowAppearance>
126             <AllowRowFiltering>True</AllowRowFiltering>
127             <RowSpacingBefore>2</RowSpacingBefore>
128             <RowSelectorWidth>12</RowSelectorWidth>
129             <FixedRowIndicator>Button</FixedRowIndicator>
130             <FixedRowStyle>Top</FixedRowStyle>
131           </object>
132         </Override>
133         <InterBandSpacing>10</InterBandSpacing>
134         <RowConnectorColor>1, 68, 208</RowConnectorColor>
135         <RowConnectorStyle>Solid</RowConnectorStyle>
136         <UseFixedHeaders>True</UseFixedHeaders>
137       </object>
138     </DisplayLayout>
139     <Location>90, 299</Location>
140     <Size>100, 22</Size>
141     <TabIndex>1</TabIndex>
142   </object>
143   <object name="UltraGrid1" assembly="Infragistics.Win.UltraWinGrid.UltraGrid, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
144     <DisplayLayout control="true">
145       <object name="UltraGridDisplayLayout1" assembly="Infragistics.Win.UltraWinGrid.UltraGridDisplayLayout, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
146         <Appearance mode="constructor">
147           <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
148           <BackColor>White</BackColor>
149           <BackColor2>61, 149, 255</BackColor2>
150           <BackGradientStyle>ForwardDiagonal</BackGradientStyle>
151         </Appearance>
152         <Override control="true">
153           <object name="UltraGridOverride1" assembly="Infragistics.Win.UltraWinGrid.UltraGridOverride, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
154             <CardAreaAppearance mode="constructor">
155               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
156               <BackColor>Transparent</BackColor>
157             </CardAreaAppearance>
158             <HeaderAppearance mode="constructor">
159               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
160               <BackColor>61, 149, 255</BackColor>
161               <BackColor2>1, 68, 208</BackColor2>
162               <BackGradientStyle>Vertical</BackGradientStyle>
163               <ForeColor>White</ForeColor>
164               <ThemedElementAlpha>Transparent</ThemedElementAlpha>
165               <TextHAlignAsString>Left</TextHAlignAsString>
166             </HeaderAppearance>
167             <RowSelectorAppearance mode="constructor">
168               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
169               <BackColor>61, 149, 255</BackColor>
170               <BackColor2>1, 68, 208</BackColor2>
171               <BackGradientStyle>Vertical</BackGradientStyle>
172             </RowSelectorAppearance>
173             <SelectedRowAppearance mode="constructor">
174               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
175               <BackColor>129, 169, 226</BackColor>
176               <BackColor2>221, 235, 254</BackColor2>
177               <BackGradientStyle>Vertical</BackGradientStyle>
178               <ForeColor>Black</ForeColor>
179             </SelectedRowAppearance>
180             <RowAppearance mode="constructor">
181               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
182               <BorderColor>1, 68, 208</BorderColor>
183             </RowAppearance>
184             <AllowAddNew>TemplateOnBottom</AllowAddNew>
185             <AllowColSwapping>WithinGroup</AllowColSwapping>
186             <AllowDelete>True</AllowDelete>
187             <AllowRowFiltering>True</AllowRowFiltering>
188             <AllowRowSummaries>True</AllowRowSummaries>
189             <AllowUpdate>True</AllowUpdate>
190             <HeaderClickAction>SortMulti</HeaderClickAction>
191             <RowSpacingBefore>2</RowSpacingBefore>
192             <RowSelectorWidth>12</RowSelectorWidth>
193           </object>
194         </Override>
195         <GroupByBox control="true">
196           <object name="GroupByBox1" assembly="Infragistics.Win.UltraWinGrid.GroupByBox, Infragistics2.Win.UltraWinGrid.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb">
197             <PromptAppearance mode="constructor">
198               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
199               <BackColor>Transparent</BackColor>
200               <ForeColor>Blue</ForeColor>
201             </PromptAppearance>
202             <Appearance mode="constructor">
203               <assembly>Infragistics.Win.Appearance, Infragistics2.Win.v10.1, Version=10.1.20101.1007, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb</assembly>
204               <BackColor>White</BackColor>
205               <BackColor2>61, 149, 255</BackColor2>
206               <BackGradientStyle>ForwardDiagonal</BackGradientStyle>
207             </Appearance>
208             <Prompt>拖动列到这里进行分类......</Prompt>
209           </object>
210         </GroupByBox>
211         <InterBandSpacing>10</InterBandSpacing>
212         <RowConnectorColor>1, 68, 208</RowConnectorColor>
213         <RowConnectorStyle>Solid</RowConnectorStyle>
214         <ViewStyleBand>OutlookGroupBy</ViewStyleBand>
215         <UseFixedHeaders>True</UseFixedHeaders>
216       </object>
217     </DisplayLayout>
218     <Dock>Fill</Dock>
219     <Name>UltraGrid1</Name>
220     <Location>0, 0</Location>
221     <Size>602, 511</Size>
222     <TabIndex>0</TabIndex>
223   </object>
224 </object>


3.代码设计器代码如下:

import clr
clr.AddReference("System")
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Data")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Win.UltraWinGrid.v10.1.dll")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Excel.v10.1.dll")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Shared.v10.1.dll")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Win.v10.1.dll")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Win.UltraWinDock.v10.1")
clr.AddReferenceToFileAndPath(Path+"\Infragistics2.Win.UltraWinToolbars.v10.1")
clr.AddReferenceToFileAndPath(Path+"\Utility.dll")

from Utility import *
from System.Windows.Forms import *
from System.Drawing import *
from System import *
from System.ComponentModel import *
from System.Data.OleDb import *
from System.Data.SqlClient import *
from System.Data import *
from Infragistics.Shared import *
from Infragistics.Win import *
from Infragistics.Win.UltraWinGrid import *
from Infragistics.Win.UltraWinToolbars import *

import Infragistics.Win.UltraWinGrid
import System 
import Utility 

Tool=UltraToolbarsManager() #初始化菜单控件
Tool=Object_Tool #变量赋值菜单控件
TableName="单位设置"
this.Text="单位设置" #修改界面名称
SQL_Code=UGrid.InitDataSQL(FormName,UserID,Folder,TableName) #加载数据字典的SQL语句
FindSQL="" #初始化查询参数
TableCol=UGrid.InitDataCol(FormName,UserID,Folder,TableName) #加载数据字典的表信息

Stat=""
UltraCombo1.Visible=False
UltraCombo2.Visible=False
Ds=System.Data.DataSet()
DataParm=appcs.Arraylist()
UGrid.InitGrid(UltraGrid1,True) #初始化表格
UGrid.GridKeyDown(UltraGrid1,True) #初始化表格键盘事件
#系统封装复制Excel表格中信息;点击Ctrl+T批量粘贴到表格中;一次性输入数据
UGrid.GridAfterRowActivate(UltraGrid1) #初始化表格活动事件

def Load():
    global Ds
    global SQL_Code
    global TableName
    Ds.Clear()
    Ds=dataserver.Db_CreateDataSet("select "+appcs.Find("Combox Count")+" * from ( "+SQL_Code +" ) as a",TableName) #查询数据库中数据
    UGrid.LoadDataCol(Ds,TableCol) #加载数据集列信息
    UltraGrid1.DataSource=Ds #表格赋值记录集
    UGrid.LoadGridCol(UltraGrid1.DisplayLayout.Bands[0],TableCol) #加载表格列信息
    UGrid.Layout(FormName,"Default",Folder,UltraGrid1) #加载表格自定义
    Tool.Toolbars[0].Tools["添加"].SharedProps.Enabled=True #设置菜单控件使用状态
    Tool.Toolbars[0].Tools["删除"].SharedProps.Enabled=True
    Tool.Toolbars[0].Tools["保存"].SharedProps.Enabled=True
    Tool.Toolbars[0].Tools["导出"].SharedProps.Enabled=True
    Tool.Toolbars[0].Tools["编辑样式:"].SharedProps.Enabled=True
    Tool.Toolbars[0].Tools["设置空值"].SharedProps.Enabled=True
Load()

def Tool_ToolClick(sender,e):
    global Ds
    global SQL_Code
    global FindSQL
    global TableName
    if e.Tool.Key.ToString()=="查找(F)" and Tool.Toolbars[0].Tools["添加"].SharedProps.Enabled==True:
        find=FindSearch() #加载通用查询界面
        find.SQLTable=Ds.Tables[0]
        find.FormName=FormName
        find.UserID=UserID
        find.Folder=Folder
        find.Icon=this.Icon
        find.ShowDialog() #显示通用查询界面
        if find.DialogResult != DialogResult.OK:return
        FindSQL = find.SQLDialogResult
        SQL= SQL_Code
        if FindSQL<>"":
            SQL= "select "+appcs.Find("Combox Count")+" * from ( " + SQL + " ) " + TableName +" " + FindSQL
        Ds.Clear()
        Ds=dataserver.Db_CreateDataSet(SQL,TableName) #查询数据库数据
        UGrid.LoadDataCol(Ds,TableCol)
        UltraGrid1.DataSource=Ds
        UGrid.LoadGridCol(UltraGrid1.DisplayLayout.Bands[0],TableCol)
    elif e.Tool.Key.ToString()=="添加":
        for col in UltraGrid1.DisplayLayout.Bands[0].Columns:
            MessageBox.Show(col.Index.ToString()+"-"+col.Header.Caption,col.Header.VisiblePosition.ToString())
        row = UltraGrid1.Rows.TemplateAddRow
        UltraGrid1.ActiveRow = row
        UltraGrid1.ActiveCell=row.Cells[0]
        UltraGrid1.Focus()
        UltraGrid1.PerformAction(UltraGridAction.EnterEditMode, False, False)
    elif e.Tool.Key.ToString()=="删除":
        if UltraGrid1.ActiveRow<>null:
            UltraGrid1.DeleteSelectedRows(False)
        else: appcs.Msg("请选择行再删除!", "信息")
    elif e.Tool.Key.ToString()=="导出":
        UGrid.GridExcel(UltraGrid1,UGrid.ExcelFile.MessageBox) #导出表格信息到Excel中
    elif e.Tool.Key.ToString()=="保存":
        if Ds.Tables.Count<1:return
        UGrid.ProcessGrid(UltraGrid1)
        SQL= SQL_Code
        Adpt = SqlDataAdapter(SQL + " where 1=1", dataserver.Conn)
        Adpt.SelectCommand.CommandTimeout = 120
        Adpt.SelectCommand.CommandType = CommandType.Text
        try:
            custCBr = SqlCommandBuilder(Adpt)
            Adpt.FillSchema(Ds, SchemaType.Mapped, TableName)
            Adpt.Update(Ds, TableName)
            Ds.AcceptChanges()
            Adpt.SelectCommand.Parameters.Clear()
            dataserver.close()
            Stat=""
            appcs.Msg("保存数据成功[单位]!","信息")
            return
        except:
            Stat=""
            Adpt.SelectCommand.Parameters.Clear()
            appcs.Msg("保存数据失败[单位]!","信息")
    elif e.Tool.Key.ToString()=="返回":
        this.Close()
    elif e.Tool.Key.ToString()=="设置空值":
        UltraGrid1.ActiveCell.Value=DBNull.Value
    elif e.Tool.Key.ToString()=="报表":
        UltraGrid1.Text="单 位 信 息" 
        Rpt=appcs.GridReport(UltraGrid1,"单位信息") #加载根据列自动生成报表界面
        Rpt.MdiParent=this.MdiParent
        Rpt.Show() #显示报表页面
        UltraGrid1.Text=""
Tool.ToolClick+=Tool_ToolClick

 

4.使用界面

此功能使用开发平台开发10分钟(使用界面和代码模板开发)。

posted @ 2012-06-25 22:14  IvanDesign  阅读(2058)  评论(0编辑  收藏  举报