public SplitterControl CreateASplitter(FieldModel fm) { SplitterControl sc = new SplitterControl(fm); fields.Add(sc); sc.DrawingControlBaseSelectedEvent += Fc_FieldControlClickEvent; this.Controls.Add(sc); sc.SizePercentNow = SizePercentNow; sc.BringToFront(); sc.FixedLocationInPage = sc.FixedLocationInPage; return(sc); }
private void InitializeLayout(List <Sys_Layout> sys_Layouts, Control parentControl) { try { DataTable dt = (DataTable)gdb.DataSource; parentControl.Visible = false; parentControl.Controls.Clear(); foreach (Sys_Layout sys_Layout in sys_Layouts.OrderBy(s => s.Layout_Sort)) { Control contain = parentControl; if (!string.IsNullOrEmpty(sys_Layout.Layout_Parent)) { Control[] cks = parentControl.Controls.Find(sys_Layout.Layout_Parent, true); if (cks.Length > 0) { contain = cks[0]; } } contain.ControlAdded += delegate(object sender, ControlEventArgs e) { e.Control.Paint += Layout_SizeChanged; e.Control.Click += Layout_Select; }; switch (sys_Layout.Layout_Type) { case 0: //Query GroupControl qry = new GroupControl(); InitializeControl(qry, sys_Layout); contain.Controls.Add(qry); qry.BringToFront(); //this.QueryControl = qry; break; case 12: //GroupControl GroupControl grp = new GroupControl(); InitializeControl(grp, sys_Layout); contain.Controls.Add(grp); grp.BringToFront(); break; case 14: //PanelControl PanelControl panel = new PanelControl(); InitializeControl(panel, sys_Layout); contain.Controls.Add(panel); panel.BorderStyle = BorderStyles.NoBorder; panel.BringToFront(); break; case 13: SplitterControl OneSpli = new SplitterControl(); OneSpli.Dock = (DockStyle)sys_Layout.Layout_Dock; OneSpli.Name = sys_Layout.Layout_Name; contain.Controls.Add(OneSpli); OneSpli.BringToFront(); break; case 1: //Grid case 6: //Submit case 7: //Tree 这三个都只有Grid 是在Grid上覆盖控件实现 Submit 和 Tree 效果 GridControl gd = new GridControl(); InitializeControl(gd, sys_Layout); GridView gv = (GridView)gd.CreateView("GridView"); gv.Name = gd.Name.Replace("d", "v"); gv.OptionsView.ShowGroupPanel = false; gv.OptionsView.ShowFooter = true; gv.OptionsSelection.MultiSelect = true; gd.MainView = gv; contain.Controls.Add(gd); gd.BringToFront(); break; case 9: //TabPage TabEx ntabs = new TabEx(); InitializeControl(ntabs, sys_Layout); ntabs.BorderStyle = BorderStyles.NoBorder; ntabs.BorderStylePage = BorderStyles.NoBorder; contain.Controls.Add(ntabs); ntabs.BringToFront(); break; case 10: DevExpress.XtraTab.XtraTabPage tab = new DevExpress.XtraTab.XtraTabPage(); tab.Name = sys_Layout.Layout_Name; tab.Text = sys_Layout.Layout_Nick; if (contain.GetType() == typeof(TabEx)) { TabEx tabs = (TabEx)contain; tabs.TabPages.Add(tab); } break; case 11: Pagination pagination = new Pagination(); pagination.Name = sys_Layout.Layout_Name; pagination.Dock = (DockStyle)sys_Layout.Layout_Dock; contain.Controls.Add(pagination); pagination.BringToFront(); break; case 2: //Chart ChartControl chart = new ChartControl(); InitializeControl(chart, sys_Layout); chart.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False; contain.Controls.Add(chart); chart.BringToFront(); break; case 3: //text MemoEdit memoEdit = new MemoEdit(); InitializeControl(memoEdit, sys_Layout); memoEdit.BorderStyle = BorderStyles.NoBorder; contain.Controls.Add(memoEdit); memoEdit.BringToFront(); break; case 4: //RichText RichEditControl rtf = new RichEditControl(); InitializeControl(rtf, sys_Layout); rtf.BorderStyle = BorderStyles.NoBorder; rtf.ActiveViewType = RichEditViewType.Simple; contain.Controls.Add(rtf); rtf.BringToFront(); break; case 5: //image PictureEdit pictureEdit = new PictureEdit(); InitializeControl(pictureEdit, sys_Layout); pictureEdit.BorderStyle = BorderStyles.NoBorder; pictureEdit.Properties.PictureStoreMode = PictureStoreMode.ByteArray; pictureEdit.Properties.SizeMode = PictureSizeMode.Squeeze; contain.Controls.Add(pictureEdit); pictureEdit.BringToFront(); break; case 8: //BarCode BarCodeControl barCodeControl = new BarCodeControl(); InitializeControl(barCodeControl, sys_Layout); barCodeControl.BorderStyle = BorderStyles.NoBorder; barCodeControl.BackColor = Color.White; barCodeControl.AutoModule = true; barCodeControl.ShowText = false; //QRCodeGenerator DevExpress.XtraPrinting.BarCode.QRCodeGenerator qrCodeGenerator1 = new DevExpress.XtraPrinting.BarCode.QRCodeGenerator(); qrCodeGenerator1.CompactionMode = DevExpress.XtraPrinting.BarCode.QRCodeCompactionMode.Byte; qrCodeGenerator1.ErrorCorrectionLevel = DevExpress.XtraPrinting.BarCode.QRCodeErrorCorrectionLevel.H; qrCodeGenerator1.Version = DevExpress.XtraPrinting.BarCode.QRCodeVersion.Version1; //Code128Generator DevExpress.XtraPrinting.BarCode.Code128Generator code128Generator1 = new DevExpress.XtraPrinting.BarCode.Code128Generator(); //根据长宽比切换二维码 条码显示 if (barCodeControl.Width > barCodeControl.Height * 2) { barCodeControl.Symbology = code128Generator1; } else { barCodeControl.Symbology = qrCodeGenerator1; } contain.Controls.Add(barCodeControl); barCodeControl.BringToFront(); break; default: break; } } parentControl.Visible = true; } catch (Exception ex) { SharedFunc.RaiseError(ex); } }
private void RecursiveForm(ComponentDataGrid parentGrid, DataTable dtRelation, string mainName) { DataRow[] drs = dtRelation.Select($"fFatherName ='{mainName}'"); //第二级是否有多个gird bool bSecondOnly = drs?.Count() > 1 ? true : false; ComponentPanel tmpMain = new ComponentPanel(); var rows = parentGrid.SelectedRows; var row = rows[0]; //二级存在多个 if (bSecondOnly) { MainTab.SelectedTab.Controls.Add(tmpMain); tmpMain.Dock = DockStyle.Fill; tmpMain.BringToFront(); foreach (DataRow dr in drs) { string smainSql = $@"select * from t_program where fname ='{dr["fchildname"] + "" }'"; DataTable dtProgramInfo = DBHelper.GetDataTable(smainSql); DataRow drProgramInfo = dtProgramInfo.Rows[0]; string smainSql1 = drProgramInfo["fSql"].ToString().TrimEnd(); DataTable dtMain = DBHelper.GetDataTable(smainSql1); dtMain.TableName = drProgramInfo["fTable"] + ""; dtMain.Namespace = $"select * from (\r\n{smainSql1}\r\n) tfinal \r\nwhere 1=1"; ComponentDataGrid childGrid = tmpMain.InitializeNewTabPage(drProgramInfo["fcnname"] + "", drProgramInfo["fname"] + "", dtMain); var Keys = GetPrimary(dr); childGrid.PreGrid = parentGrid; childGrid.PrimaryKey = Keys.ChildKeys; childGrid.PrePrimaryKey = Keys.ParentKeys; parentGrid.AddNextGrid(childGrid); } } else { //从属表数据 DataRow drRelation = drs[0]; var Keys = GetPrimary(drRelation); string smainSql = $@"select * from t_program where fname ='{drRelation["fchildname"] + "" }'"; DataTable dtProgramInfo = DBHelper.GetDataTable(smainSql); DataRow drProgramInfo = dtProgramInfo.Rows[0]; string smainSql1 = drProgramInfo["fSql"] + ""; DataTable dtMain = DBHelper.GetDataTable(smainSql1); dtMain.TableName = drProgramInfo["fTable"] + ""; dtMain.Namespace = $"select * from (\r\n{smainSql1}\r\n) tfinal \r\nwhere 1=1"; ComponentDataGrid childGrid = tmpMain.InitializeNewTabPage(drProgramInfo["fcnname"] + "", drProgramInfo["fname"] + "", dtMain); MainTab.SelectedTab.Controls.Add(tmpMain); tmpMain.BringToFront(); childGrid.PreGrid = parentGrid; childGrid.PrimaryKey = Keys.ChildKeys; childGrid.PrePrimaryKey = Keys.ParentKeys; parentGrid.AddNextGrid(childGrid); DataRow[] drNeedRecursive = dtRelation.Select($"ffathername='{drProgramInfo["fname"] + ""}'"); if (drNeedRecursive.Count() > 0) { tmpMain.Dock = DockStyle.Top; SplitterControl splitter = new SplitterControl(); MainTab.SelectedTab.Controls.Add(splitter); splitter.Dock = DockStyle.Top; splitter.BringToFront(); RecursiveForm(childGrid, dtRelation, drProgramInfo["fname"] + ""); } else { tmpMain.Dock = DockStyle.Fill; } } }
/// <summary> /// 初始化窗体 /// </summary> /// <param name="SourceFormName">窗体Name</param> private void InitForm(string SourceFormName) { string smainSql = $@"select * from t_program where fname ='{SourceFormName}'"; DataTable dtProgramInfo = DBHelper.GetDataTable(smainSql); DataRow drProgramInfo = dtProgramInfo.Rows[0]; string smainSql1 = $"select * from (\r\n {drProgramInfo["fSql"] + ""}\r\n)t1 where 1=1"; DataTable dtMain = DBHelper.GetDataTable(smainSql1); dtMain.TableName = drProgramInfo["fTable"] + ""; dtMain.Namespace = smainSql1; ComponentPanel panel = new ComponentPanel(true); ComponentDataGrid grid = panel.InitializeNewTabPage(drProgramInfo["fCNName"] + "", SourceFormName, dtMain); panel.Dock = DockStyle.Top; MainTab.SelectedTab.Controls.Add(panel); panel.BringToFront(); string srelationSql = $@"select * from T_FormRelationships with(nolock) where fmainname = '{SourceFormName}'"; DataTable dtRelationShip = DBHelper.GetDataTable(srelationSql); //无从属关系 if (dtRelationShip == null || dtRelationShip.Rows.Count == 0) { panel.Dock = DockStyle.Fill; EventHelper eventHelperOnly = new EventHelper(); eventHelperOnly.BindingCellClickEvent(grid); return; } SplitterControl splitter = new SplitterControl(); MainTab.SelectedTab.Controls.Add(splitter); splitter.Dock = DockStyle.Top; splitter.BringToFront(); RecursiveForm(grid, dtRelationShip, SourceFormName); #region 设置高度 int ictrlCount = MainTab.SelectedTab.Controls.OfType <ComponentPanel>().Count(); int ipageHeigh = MainTab.SelectedTab.Height; int iResult = ipageHeigh / ictrlCount; foreach (Control ctrl in MainTab.SelectedTab.Controls) { if (!(ctrl is ComponentPanel)) { continue; } ComponentPanel frm = ctrl as ComponentPanel; frm.Height = iResult; } #endregion #region 点击事件绑定 EventHelper eventHelper = new EventHelper(); eventHelper.BindingCellClickEvent(grid); #endregion }