void lbxDetailEntities_SelectedIndexChanged(object sender, EventArgs e) { var obj = this.lbxDetailEntities.SelectedItem as EntitySetConfig; if (obj == null) obj = new EntitySetConfig(); this.detailConfigControl.EntitySetConfig = obj; }
public CommonBillConfig() { QueryConfig = new Framework.Controls.QueryConfig(); IndexEntitySetConfig = new EntitySetConfig(); MainEntitySetConfig = new EntitySetConfig(); DetailEntitySetConfigs = new List<EntitySetConfig>(); }
private TreeList CreateTreeList(EntitySetConfig config) { var treeList = new TreeList(); treeList.KeyFieldName = config.ControlKeyFieldName; treeList.ParentFieldName = config.ControlParentFieldName; treeList.OptionsBehavior.AutoPopulateColumns = false; if (config.Fields.Count <= 1) { treeList.OptionsView.ShowColumns = false; treeList.OptionsView.ShowHorzLines = false; treeList.OptionsView.ShowIndicator = false; treeList.OptionsView.ShowVertLines = false; } for (int i = 0; i < config.Fields.Count; i++) { var field = config.Fields[0]; var colName = treeList.Columns.Add(); colName.Caption = field.Caption.IsEmpty() ? field.FieldName : field.Caption; colName.FieldName = field.FieldName; colName.Name = "treeList_col_" + Guid.NewGuid().ToString("N"); colName.OptionsColumn.AllowEdit = false; colName.OptionsColumn.AllowMove = false; colName.OptionsColumn.AllowSort = false; colName.OptionsColumn.ReadOnly = true; colName.Visible = true; colName.VisibleIndex = i; } return treeList; }
private GridControl CreateGridControl(EntitySetConfig config) { var grd = new GridControl() { Name = "grd_" + config.UniqueId.ToString("N") }; var grv = new GridView(grd) { Name = "grv_" + config.UniqueId.ToString("N") }; gridViews.Add(grv); grv.OptionsView.ColumnAutoWidth = false; grd.ViewCollection.Add(grv); grd.MainView = grv; foreach (var field in config.Fields) { var column = grv.Columns.AddField(field.FieldName); column.Caption = field.Caption.IsEmpty() ? field.FieldName : field.Caption; column.Visible = true; } return grd; }
private void CreateIndexControl(EntitySetConfig indexConfig) { if (indexConfig == null) return; this.ViewModel.IndexEntitySet.TableName = indexConfig.DbTableName; this.ViewModel.IndexEntitySet.PrimaryKeyName = indexConfig.PrimaryKeyName; this.ViewModel.IndexEntitySet.IsReadOnly = indexConfig.IsReadOnly; this.ViewModel.IndexEntitySet.SetBindingSource(this.bsIndex); if (indexConfig.ControlType == EntitySetControlType.GridControl) { var grdIndex = this.CreateGridControl(indexConfig); var grvIndex = grdIndex.MainView as GridView; grvIndex.FocusedRowChanged += (s, e) => { this.IndexRowChange(); }; this.splitMain.Panel1.Controls.Add(grdIndex); grdIndex.Dock = DockStyle.Fill; grdIndex.DataSource = this.bsIndex; grvIndex.OptionsBehavior.Editable = false; } else if (indexConfig.ControlType == EntitySetControlType.TreeList) { var treeList = this.CreateTreeList(indexConfig); treeList.FocusedNodeChanged += (s, e) => { this.IndexRowChange(); }; this.splitMain.Panel1.Controls.Add(treeList); treeList.Dock = DockStyle.Fill; treeList.DataSource = this.bsIndex; treeList.OptionsBehavior.Editable = false; } else { MessageService.ShowError("索引区控件类型只支持GridControl和TreeList"); } }
private void CreateMainControl(EntitySetConfig mainConfig) { if (mainConfig == null) return; this.ViewModel.MainEntitySet.TableName = mainConfig.DbTableName; this.ViewModel.MainEntitySet.PrimaryKeyName = mainConfig.PrimaryKeyName; this.ViewModel.MainEntitySet.IsReadOnly = mainConfig.IsReadOnly; this.ViewModel.MainEntitySet.SetBindingSource(this.bsMain); if (mainConfig.ControlType == EntitySetControlType.LayoutControl) { foreach (var field in mainConfig.Fields) { LayoutControlItem lci = this.lcMain.Root.AddItem(field.Caption.IsEmpty() ? field.FieldName : field.Caption); var name = Guid.NewGuid().ToString("N"); lci.Name = "lci_" + name; var edt = new TextEdit() { Name = "lci_edt_" + name }; edt.DataBindings.Add("EditValue", this.bsMain, field.FieldName); lci.Control = edt; } } else { MessageService.ShowError("索引区控件类型只支持LayoutControl"); } }
private Bar CreateDetailToolbar(EntitySetConfig dtlConfig) { var bar = new Bar(); bar.BarName = "bar_" + dtlConfig.UniqueId.ToString("N"); bar.Text = "bar" + dtlConfig.Caption; bar.CanDockStyle = BarCanDockStyle.Standalone; bar.DockStyle = BarDockStyle.Standalone; bar.DockCol = 0; bar.DockRow = 0; bar.OptionsBar.AllowQuickCustomization = false; bar.OptionsBar.DrawDragBorder = false; bar.OptionsBar.UseWholeRow = true; this.bmMain.Bars.Add(bar); BarButtonItem bbiDtl = new BarButtonItem(bmMain, "新增"); bbiDtl.Glyph = Resources.Action_New_16x16; bbiDtl.Id = 1; bbiDtl.Name = "bbiDtl_" + dtlConfig.UniqueId.ToString("N"); bbiDtl.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph; bbiDtl.Tag = dtlConfig.UniqueId; bar.LinksPersistInfo.Add(new LinkPersistInfo(bbiDtl, true)); bbiDtl = new BarButtonItem(bmMain, "删除"); bbiDtl.Glyph = Resources.Action_Delete_16x16; bbiDtl.Id = 2; bbiDtl.Name = "bbiDtl_" + dtlConfig.UniqueId.ToString("N"); bbiDtl.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph; bbiDtl.Tag = dtlConfig.UniqueId; bar.LinksPersistInfo.Add(new LinkPersistInfo(bbiDtl)); return bar; }
private StandaloneBarDockControl CreateStandaloneBarDockControl(EntitySetConfig dtlConfig) { var standalone = new StandaloneBarDockControl(); standalone.Name = "barStandalone_" + dtlConfig.UniqueId.ToString("N"); standalone.Text = "barStandalone_" + dtlConfig.Caption; standalone.Height = 28; bmMain.DockControls.Add(standalone); return standalone; }