void LoadTab() { if (FormControl == null) { return; } tabControl.TabPages.Clear(); List <CBaseObject> lstObj = FormControl.TableInFormControlMgr.GetList(); foreach (CBaseObject obj in lstObj) { CTableInFormControl tiwc = (CTableInFormControl)obj; CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { continue; } TabPage page = new TabPage(table.Name); page.Tag = tiwc; tabControl.TabPages.Add(page); TableGridFEl te = new TableGridFEl(); te.FormControl = FormControl; te.TableInFormControl = tiwc; te.CaptionText = table.Name; te.ShowTitleBar = tiwc.ShowTitleBar; te.ShowToolBar = tiwc.ShowToolBar; te.Tag = FormControl; page.Controls.Add(te); te.Dock = DockStyle.Fill; te.BringToFront(); } }
public void OnEdit() { SelTableForm frm = new SelTableForm(); if (frm.ShowDialog() != DialogResult.OK) { return; } SelColumnForm frm2 = new SelColumnForm(); frm2.m_Table = frm.m_SelTable; if (frm2.ShowDialog() != DialogResult.OK) { return; } string sCtrlName = ChildenForm.GetDistinctName(frm.m_SelTable.Name, (CFormControlMgr)FormControl.m_ObjectMgr); FormControl.TableInFormControlMgr.RemoveAll(); string sText = string.Format("[{0}]", frm2.m_SelColumn.Code); CTableInFormControl tiwc = new CTableInFormControl(); tiwc.Ctx = Program.Ctx; tiwc.FW_Table_id = frm.m_SelTable.Id; tiwc.UI_FormControl_id = FormControl.Id; tiwc.Text = sText; FormControl.TableInFormControlMgr.AddNew(tiwc); CaptionText = sCtrlName; }
void LoadData() { if (m_FormControl == null) { TableTreeNodeSetF ctrl = new TableTreeNodeSetF(); ctrl.Idx = 0; ctrl.toolStrip.Click += new EventHandler(toolStrip_Click); flowLayoutPanel.Controls.Add(ctrl); CTableInFormControl TableInFormControl = new CTableInFormControl(); TableInFormControl.Ctx = Program.Ctx; ctrl.Tag = TableInFormControl; } else { txtName.Text = m_FormControl.Name; List <CBaseObject> lstObj = m_FormControl.TableInFormControlMgr.GetList(); foreach (CBaseObject obj in lstObj) { CTableInFormControl TableInFormControl = (CTableInFormControl)obj; TableTreeNodeSetF ctrl = new TableTreeNodeSetF(); ctrl.Idx = flowLayoutPanel.Controls.Count; ctrl.Tag = TableInFormControl; ctrl.toolStrip.Click += new EventHandler(toolStrip_Click); flowLayoutPanel.Controls.Add(ctrl); } } }
public void OnEdit() { SelTableForm frm = new SelTableForm(); if (frm.ShowDialog() != DialogResult.OK) { return; } FormControl.TableInFormControlMgr.RemoveAll(); CTableInFormControl tiwc = new CTableInFormControl(); tiwc.Ctx = Program.Ctx; tiwc.FW_Table_id = frm.m_SelTable.Id; tiwc.UI_FormControl_id = FormControl.Id; tiwc.Text = frm.m_SelTable.Name; FormControl.TableInFormControlMgr.AddNew(tiwc); foreach (CColumn col in frm.m_SelTable.ColumnMgr.GetList()) { //if (!col.IsVisible) // continue; CColumnInTableInFormControl ciwc = new CColumnInTableInFormControl(); ciwc.Ctx = Program.Ctx; ciwc.FW_Column_id = col.Id; ciwc.UI_TableInFormControl_id = tiwc.Id; tiwc.ColumnInTableInFormControlMgr.AddNew(ciwc); } foreach (ToolStripItem tbutton in toolStrip.Items) { CTButtonInTableInFormControl tbiwc = new CTButtonInTableInFormControl(); tbiwc.Ctx = Program.Ctx; tbiwc.Title = tbutton.Text; tbiwc.UI_TableInFormControl_id = tiwc.Id; tiwc.TButtonInTableInFormControlMgr.AddNew(tbiwc); } TableInFormControl = tiwc; }
private void btAdd_Click(object sender, EventArgs e) { foreach (Control ctrl in flowLayoutPanel.Controls) { TableTreeNodeSetF ttns = (TableTreeNodeSetF)ctrl; ttns.Selected = false; } TableTreeNodeSetF NodeSet = new TableTreeNodeSetF(); NodeSet.Idx = flowLayoutPanel.Controls.Count; CTableInFormControl TableInFormControl = new CTableInFormControl(); TableInFormControl.m_CmdType = CmdType.AddNew; TableInFormControl.Ctx = Program.Ctx; NodeSet.Tag = TableInFormControl; NodeSet.toolStrip.Click += new EventHandler(toolStrip_Click); flowLayoutPanel.Controls.Add(NodeSet); NodeSet.Selected = true; m_SelTableTreeNodeSet = NodeSet; }
public void OnEdit() { SelMultTableForm frm = new SelMultTableForm(); if (frm.ShowDialog() != DialogResult.OK) { return; } FormControl.TableInFormControlMgr.RemoveAll(); foreach (CTable table in frm.m_lstSelTable) { CTableInFormControl tiwc = new CTableInFormControl(); tiwc.Ctx = Program.Ctx; tiwc.FW_Table_id = table.Id; tiwc.UI_FormControl_id = FormControl.Id; tiwc.Text = table.Name; FormControl.TableInFormControlMgr.AddNew(tiwc); } LoadTab(); }
private void richTextFilter_TextChanged(object sender, EventArgs e) { CFormControl FormControl = (CFormControl)ControlEl.Tag; IDesignEl designEl = (IDesignEl)ControlEl; if (designEl.GetCtrlType() == ControlType.TableGrid) { CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); TableInFormControl.QueryFilter = richTextFilter.Text.Trim(); TableInFormControl.m_CmdType = CmdType.Update; } else if (designEl.GetCtrlType() == ControlType.ListBox) { CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); TableInFormControl.QueryFilter = richTextFilter.Text.Trim(); TableInFormControl.m_CmdType = CmdType.Update; } else if (designEl.GetCtrlType() == ControlType.ComboBox) { CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); TableInFormControl.QueryFilter = richTextFilter.Text.Trim(); TableInFormControl.m_CmdType = CmdType.Update; } }
void LoopTreeNode(int iLevel, List <CBaseObject> lstTIWC, TreeNode pnode) { if (iLevel >= lstTIWC.Count) { return; } CTableInFormControl tiwc = (CTableInFormControl)lstTIWC[iLevel]; CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { return; } if (!tiwc.IsLoop) { CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.Ctx = Program.Ctx; BaseObjectMgr.TbCode = table.Code; List <CBaseObject> lstObj = BaseObjectMgr.GetList(tiwc.QueryFilter); foreach (CBaseObject obj in lstObj) { string sText = tiwc.Text.ToLower(); int iStart = 0; while (sText.IndexOf('[', iStart) > -1) { int idx1 = sText.IndexOf('[', iStart); int idx2 = sText.IndexOf(']', idx1); iStart = idx1 + 1; if (idx2 > idx1) { string sCodeN = sText.Substring(idx1, idx2 - idx1 + 1); string sCode = sCodeN.Substring(1, sCodeN.Length - 2); CColumn column = table.ColumnMgr.FindByCode(sCode); if (column == null) { continue; } string sVal = obj.GetColValue(column).ToString(); sText = sText.Replace(sCodeN, sVal); } } TreeNode node = new TreeNode(); node.Text = sText; node.Tag = obj; if (pnode == null) { treeView.Nodes.Add(node); } else { pnode.Nodes.Add(node); } LoopTreeNode(iLevel + 1, lstTIWC, node); } } else { string sFilter = tiwc.QueryFilter; if (sFilter.Trim() != "") { sFilter += " and "; } sFilter += tiwc.RootFilter; List <TreeNode> lstTreeNode = SelfLoop(tiwc, sFilter, pnode); foreach (TreeNode node in lstTreeNode) { LoopTreeNode(iLevel + 1, lstTIWC, node); } } }
//生成自引用树节点 List <TreeNode> SelfLoop(CTableInFormControl tiwc, string sFilter, TreeNode pnode) { List <TreeNode> lstTreeNode = new List <TreeNode>(); CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { return(lstTreeNode); } CBaseObjectMgr BaseObjectMgr = new CBaseObjectMgr(); BaseObjectMgr.Ctx = Program.Ctx; BaseObjectMgr.TbCode = table.Code; List <CBaseObject> lstObj = BaseObjectMgr.GetList(sFilter); foreach (CBaseObject obj in lstObj) { string sText = tiwc.Text.ToLower(); int iStart = 0; while (sText.IndexOf('[', iStart) > -1) { int idx1 = sText.IndexOf('[', iStart); int idx2 = sText.IndexOf(']', idx1); iStart = idx1 + 1; if (idx2 > idx1) { string sCodeN = sText.Substring(idx1, idx2 - idx1 + 1); string sCode = sCodeN.Substring(1, sCodeN.Length - 2); CColumn column = table.ColumnMgr.FindByCode(sCode); if (column == null) { continue; } string sVal = obj.GetColValue(column).ToString(); sText = sText.Replace(sCodeN, sVal); } } TreeNode node = new TreeNode(); node.Text = sText; node.Tag = obj; if (pnode == null) { treeView.Nodes.Add(node); } else { pnode.Nodes.Add(node); } CColumn col = (CColumn)table.ColumnMgr.Find(tiwc.NodeIDCol); CColumn pcol = (CColumn)table.ColumnMgr.Find(tiwc.PNodeIDCol); string sVal2 = obj.GetColValue(col).ToString(); if (col.ColType == ColumnType.string_type || col.ColType == ColumnType.ref_type || col.ColType == ColumnType.guid_type || col.ColType == ColumnType.datetime_type || col.ColType == ColumnType.text_type) { sVal2 = "'" + sVal2 + "'"; } string sSubFilter2 = string.Format(" {0}={1}", pcol.Code, sVal2); string sFilter2 = tiwc.QueryFilter; if (sFilter2.Trim() != "") { sFilter2 += " and "; } sFilter2 += sSubFilter2; SelfLoop(tiwc, sFilter2, node); lstTreeNode.Add(node); } return(lstTreeNode); }
private void btOk_Click(object sender, EventArgs e) { if (flowLayoutPanel.Controls.Count == 0) { MessageBox.Show("请添加表!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < flowLayoutPanel.Controls.Count; i++) { TableTreeNodeSetF NodeSet = (TableTreeNodeSetF)flowLayoutPanel.Controls[i]; if (NodeSet.m_Table == null) { MessageBox.Show("请设置表!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (NodeSet.txtText.Text.Trim() == "") { MessageBox.Show("请设置显示文本!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (NodeSet.ckIsLoop.Checked) { if (NodeSet.cbNodeIDCol.SelectedItem == null) { MessageBox.Show("请设置本节点字段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (NodeSet.cbPNodeIDCol.SelectedItem == null) { MessageBox.Show("请设置父节点字段!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } if (m_FormControl == null) { m_FormControl = new CFormControl(); m_FormControl.Ctx = Program.Ctx; m_FormControl.m_CmdType = CmdType.AddNew; m_FormControl.Name = txtName.Text.Trim(); for (int i = 0; i < flowLayoutPanel.Controls.Count; i++) { TableTreeNodeSetF NodeSet = (TableTreeNodeSetF)flowLayoutPanel.Controls[i]; CTableInFormControl TableInFormControl = (CTableInFormControl)NodeSet.Tag; TableInFormControl.Idx = i; TableInFormControl.FW_Table_id = NodeSet.m_Table.Id; TableInFormControl.IsLoop = NodeSet.ckIsLoop.Checked; TableInFormControl.QueryFilter = NodeSet.txtQueryFilter.Text.Trim(); TableInFormControl.RootFilter = NodeSet.txtRootFilter.Text.Trim(); TableInFormControl.Text = NodeSet.txtText.Text.Trim(); if (NodeSet.ckIsLoop.Checked) { DataItem item = (DataItem)NodeSet.cbNodeIDCol.SelectedItem; CColumn column = (CColumn)item.Data; TableInFormControl.NodeIDCol = column.Id; DataItem item2 = (DataItem)NodeSet.cbPNodeIDCol.SelectedItem; CColumn column2 = (CColumn)item2.Data; TableInFormControl.PNodeIDCol = column2.Id; } TableInFormControl.UI_FormControl_id = m_FormControl.Id; m_FormControl.TableInFormControlMgr.AddNew(TableInFormControl); } } else { //删除 List <CTableInFormControl> lstDel = new List <CTableInFormControl>(); List <CBaseObject> lstObj = m_FormControl.TableInFormControlMgr.GetList(); foreach (CBaseObject obj in lstObj) { CTableInFormControl TableInFormControl = (CTableInFormControl)obj; bool bHas = false; for (int i = 0; i < flowLayoutPanel.Controls.Count; i++) { TableTreeNodeSetF NodeSet = (TableTreeNodeSetF)flowLayoutPanel.Controls[i]; CTableInFormControl tiwc = (CTableInFormControl)NodeSet.Tag; if (TableInFormControl == tiwc) { bHas = true; break; } } if (!bHas) { lstDel.Add(TableInFormControl); } } foreach (CTableInFormControl tiwc in lstDel) { m_FormControl.TableInFormControlMgr.Delete(tiwc); } //添加、修改 for (int i = 0; i < flowLayoutPanel.Controls.Count; i++) { TableTreeNodeSetF NodeSet = (TableTreeNodeSetF)flowLayoutPanel.Controls[i]; CTableInFormControl TableInFormControl = (CTableInFormControl)NodeSet.Tag; TableInFormControl.Idx = i; TableInFormControl.FW_Table_id = NodeSet.m_Table.Id; TableInFormControl.IsLoop = NodeSet.ckIsLoop.Checked; TableInFormControl.QueryFilter = NodeSet.txtQueryFilter.Text.Trim(); TableInFormControl.RootFilter = NodeSet.txtRootFilter.Text.Trim(); TableInFormControl.Text = NodeSet.txtText.Text.Trim(); if (NodeSet.ckIsLoop.Checked) { DataItem item = (DataItem)NodeSet.cbNodeIDCol.SelectedItem; CColumn column = (CColumn)item.Data; TableInFormControl.NodeIDCol = column.Id; DataItem item2 = (DataItem)NodeSet.cbPNodeIDCol.SelectedItem; CColumn column2 = (CColumn)item2.Data; TableInFormControl.PNodeIDCol = column2.Id; } TableInFormControl.UI_FormControl_id = m_FormControl.Id; if (TableInFormControl.m_CmdType == CmdType.AddNew) { m_FormControl.TableInFormControlMgr.AddNew(TableInFormControl); } else { m_FormControl.TableInFormControlMgr.Update(TableInFormControl); } } } this.DialogResult = DialogResult.OK; this.Close(); }
void LoadData() { if (FormF == null) { return; } this.Width = FormF.Width; this.Height = FormF.Height; List <CBaseObject> lstFormControl = FormF.FormControlMgr.GetList(); foreach (CBaseObject obj in lstFormControl) { CFormControl FormControl = (CFormControl)obj; if (FormControl.CtrlType == (int)ControlType.TableGrid) { if (FormControl.TableInFormControlMgr.GetList().Count == 0) { continue; } CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInFormControl.FW_Table_id); if (table == null) { continue; } CBaseObjectMgr objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; TableGridF te = new TableGridF(); te.TableInFormControl = TableInFormControl; te.BaseObjectMgr = objMgr; te.Name = FormControl.Name; te.ShowToolBar = TableInFormControl.ShowToolBar; te.ShowTitleBar = TableInFormControl.ShowTitleBar; te.CaptionText = FormControl.Name; te.Tag = FormControl; flowPanel.Controls.Add(te); te.dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick); } else if (FormControl.CtrlType == (int)ControlType.TableTree) { TableTreeF tt = new TableTreeF(); tt.CaptionText = FormControl.Name; tt.ShowTitleBar = FormControl.ShowTitleBar; tt.FormControl = FormControl; tt.Name = FormControl.Name; tt.Tag = FormControl; flowPanel.Controls.Add(tt); tt.Dock = DockStyle.Fill; tt.BringToFront(); tt.treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView_NodeMouseClick); } else if (FormControl.CtrlType == (int)ControlType.TableTab) { TableTabF tab = new TableTabF(); tab.FormControl = FormControl; tab.CaptionText = FormControl.Name; tab.Name = FormControl.Name; tab.ShowTitleBar = FormControl.ShowTitleBar; tab.Tag = FormControl; flowPanel.Controls.Add(tab); tab.Dock = DockStyle.Fill; tab.BringToFront(); } else if (FormControl.CtrlType == (int)ControlType.ComboBox) { if (FormControl.TableInFormControlMgr.GetList().Count == 0) { continue; } CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInFormControl.FW_Table_id); if (table == null) { continue; } CBaseObjectMgr objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; UIComboBoxF cb = new UIComboBoxF(); cb.CaptionText = FormControl.Name + ":"; cb.TableInFormControl = TableInFormControl; cb.BaseObjectMgr = objMgr; cb.Name = FormControl.Name; cb.Tag = FormControl; flowPanel.Controls.Add(cb); cb.Dock = DockStyle.Top; cb.BringToFront(); cb.comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged); } else if (FormControl.CtrlType == (int)ControlType.ListBox) { if (FormControl.TableInFormControlMgr.GetList().Count == 0) { continue; } CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInFormControl.FW_Table_id); if (table == null) { continue; } CBaseObjectMgr objMgr = new CBaseObjectMgr(); objMgr.TbCode = table.Code; objMgr.Ctx = Program.Ctx; UIListBoxF listBox = new UIListBoxF(); listBox.CaptionText = FormControl.Name; listBox.TableInFormControl = TableInFormControl; listBox.BaseObjectMgr = objMgr; listBox.Name = FormControl.Name; listBox.Tag = FormControl; flowPanel.Controls.Add(listBox); listBox.Dock = DockStyle.Fill; listBox.BringToFront(); listBox.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged); } } }
void LoadTable() { dataGridView.Columns.Clear(); if (FormControl == null) { return; } CTableInFormControl tiwc = null; if (TableInFormControl == null) { tiwc = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); if (tiwc == null) { return; } } else { tiwc = TableInFormControl; } CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id); if (table == null) { return; } { bool bHas = false; List <CBaseObject> lstCIWC = tiwc.ColumnInTableInFormControlMgr.GetList(); if (lstCIWC.Count > 0) { bHas = true; foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; CColumn col = (CColumn)table.ColumnMgr.Find(ciwc.FW_Column_id); dataGridView.Columns.Add(col.Code, col.Name); } } if (!bHas) { List <CBaseObject> lstCol = table.ColumnMgr.GetList(); foreach (CColumn col in lstCol) { //if (!col.IsVisible) // continue; DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn(); column.Name = col.Code; column.HeaderText = col.Name; column.Tag = col; dataGridView.Columns.Add(column); } } } List <CBaseObject> lstTButton = tiwc.TButtonInTableInFormControlMgr.GetList(); foreach (ToolStripItem tbutton in toolStrip.Items) { bool bHas = false; foreach (CBaseObject obj in lstTButton) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase)) { bHas = true; break; } } if (!bHas) { tbutton.Visible = false; } } }
private void listToolBarButton_ItemCheck(object sender, ItemCheckEventArgs e) { if (e.CurrentValue == e.NewValue) { return; } CFormControl FormControl = (CFormControl)ControlEl.Tag; IDesignEl designEl = (IDesignEl)ControlEl; if (designEl.GetCtrlType() == ControlType.TableGrid) { TableGridFEl te = (TableGridFEl)ControlEl; CTableInFormControl tiwc = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); List <CBaseObject> lstTBIWC = tiwc.TButtonInTableInFormControlMgr.GetList(); if (e.NewValue == CheckState.Checked) { bool bHas = false; foreach (CBaseObject obj in lstTBIWC) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase)) { bHas = true; break; } } if (!bHas) { CTButtonInTableInFormControl tbiwc = new CTButtonInTableInFormControl(); tbiwc.Title = listToolBarButton.Items[e.Index].Text; tbiwc.UI_TableInFormControl_id = tiwc.Id; tbiwc.Ctx = Program.Ctx; tiwc.TButtonInTableInFormControlMgr.AddNew(tbiwc); te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, true); } } else { foreach (CBaseObject obj in lstTBIWC) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase)) { tiwc.TButtonInTableInFormControlMgr.Delete(tbiwc); te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, false); break; } } } } else if (designEl.GetCtrlType() == ControlType.TableTree) { TableTreeFEl treeEl = (TableTreeFEl)ControlEl; } else if (designEl.GetCtrlType() == ControlType.TableTab) { TableTabFEl tab = (TableTabFEl)ControlEl; TableGridFEl te = tab.GetCurTableGridEl(); CTableInFormControl tiwc = te.TableInFormControl; List <CBaseObject> lstTBIWC = tiwc.TButtonInTableInFormControlMgr.GetList(); if (e.NewValue == CheckState.Checked) { bool bHas = false; foreach (CBaseObject obj in lstTBIWC) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase)) { bHas = true; break; } } if (!bHas) { CTButtonInTableInFormControl tbiwc = new CTButtonInTableInFormControl(); tbiwc.Title = listToolBarButton.Items[e.Index].Text; tbiwc.UI_TableInFormControl_id = tiwc.Id; tbiwc.Ctx = Program.Ctx; tiwc.TButtonInTableInFormControlMgr.AddNew(tbiwc); te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, true); } } else { foreach (CBaseObject obj in lstTBIWC) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase)) { tiwc.TButtonInTableInFormControlMgr.Delete(tbiwc); te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, false); break; } } } } }
private void listColumn_ItemCheck(object sender, ItemCheckEventArgs e) { if (e.CurrentValue == e.NewValue) { return; } ListViewItem item = listColumn.Items[e.Index]; CFormControl FormControl = (CFormControl)ControlEl.Tag; IDesignEl designEl = (IDesignEl)ControlEl; CColumn col = (CColumn)item.Tag; if (designEl.GetCtrlType() == ControlType.TableGrid) { TableGridFEl te = (TableGridFEl)ControlEl; CTableInFormControl tiwc = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); List <CBaseObject> lstCIWC = tiwc.ColumnInTableInFormControlMgr.GetList(); if (e.NewValue == CheckState.Checked) { bool bHas = false; foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; if (ciwc.FW_Column_id == col.Id) { bHas = true; break; } } if (!bHas) { CColumnInTableInFormControl ciwc = new CColumnInTableInFormControl(); ciwc.FW_Column_id = col.Id; ciwc.UI_TableInFormControl_id = tiwc.Id; ciwc.Ctx = Program.Ctx; tiwc.ColumnInTableInFormControlMgr.AddNew(ciwc); if (te.dataGridView.Columns[col.Code] == null) { te.dataGridView.Columns.Add(col.Code, col.Name); } } } else { foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; if (ciwc.FW_Column_id == col.Id) { tiwc.ColumnInTableInFormControlMgr.Delete(ciwc); if (te.dataGridView.Columns[col.Code] != null) { te.dataGridView.Columns.Remove(col.Code); } break; } } } } else if (designEl.GetCtrlType() == ControlType.TableTab) { TableTabFEl tab = (TableTabFEl)ControlEl; TableGridFEl te = tab.GetCurTableGridEl(); CTableInFormControl tiwc = te.TableInFormControl; List <CBaseObject> lstCIWC = tiwc.ColumnInTableInFormControlMgr.GetList(); if (e.NewValue == CheckState.Checked) { bool bHas = false; foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; if (ciwc.FW_Column_id == col.Id) { bHas = true; break; } } if (!bHas) { CColumnInTableInFormControl ciwc = new CColumnInTableInFormControl(); ciwc.FW_Column_id = col.Id; ciwc.UI_TableInFormControl_id = tiwc.Id; ciwc.Ctx = Program.Ctx; tiwc.ColumnInTableInFormControlMgr.AddNew(ciwc); if (te.dataGridView.Columns[col.Code] == null) { te.dataGridView.Columns.Add(col.Code, col.Name); } } } else { foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; if (ciwc.FW_Column_id == col.Id) { tiwc.ColumnInTableInFormControlMgr.Delete(ciwc); if (te.dataGridView.Columns[col.Code] != null) { te.dataGridView.Columns.Remove(col.Code); } break; } } } } }
public void LoadData() { if (m_AttrType == AttrType.FormControl) { if (ControlEl == null || ControlEl.Tag == null) { return; } } else { if (FormEl == null || FormEl.Form == null) { return; } } m_bIsLoading = true; UpdateTabCtrl(); UpdatePropertyGrid(); if (m_AttrType == AttrType.FormControl) { CFormControl FormControl = (CFormControl)ControlEl.Tag; if (FormControl.DomainType == DomainControlType.Data) { IDesignEl designEl = (IDesignEl)ControlEl; if (designEl.GetCtrlType() == ControlType.TableGrid) { TableGridFEl tableGridEl = (TableGridFEl)ControlEl; CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInFormControl.FW_Table_id); if (table != null) { listColumn.Items.Clear(); List <CBaseObject> lstColumn = table.ColumnMgr.GetList(); foreach (CBaseObject obj in lstColumn) { CColumn col = (CColumn)obj; ListViewItem item = new ListViewItem(); item.Text = col.Name; item.Tag = col; listColumn.Items.Add(item); List <CBaseObject> lstCIWC = TableInFormControl.ColumnInTableInFormControlMgr.GetList(); bool bHas = false; foreach (CBaseObject obj2 in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj2; if (ciwc.FW_Column_id == col.Id) { item.Checked = true; if (tableGridEl.dataGridView.Columns[col.Code] == null) { tableGridEl.dataGridView.Columns.Add(col.Code, col.Name); } bHas = true; break; } } if (!bHas) { if (tableGridEl.dataGridView.Columns[col.Code] != null) { tableGridEl.dataGridView.Columns.Remove(col.Code); } } } } List <CBaseObject> lstTButton = TableInFormControl.TButtonInTableInFormControlMgr.GetList(); listToolBarButton.Items.Clear(); foreach (ToolStripItem tbutton in tableGridEl.toolStrip.Items) { ListViewItem item = new ListViewItem(); item.Text = tbutton.Text; listToolBarButton.Items.Add(item); bool bHas = false; foreach (CBaseObject obj in lstTButton) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase)) { item.Checked = true; bHas = true; break; } } if (!bHas) { tbutton.Visible = false; } } richTextFilter.Text = TableInFormControl.QueryFilter; } else if (designEl.GetCtrlType() == ControlType.TableTree) { TableTreeFEl treeEl = (TableTreeFEl)ControlEl; } else if (designEl.GetCtrlType() == ControlType.ListBox) { CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); richTextFilter.Text = TableInFormControl.QueryFilter; } else if (designEl.GetCtrlType() == ControlType.ComboBox) { CTableInFormControl TableInFormControl = (CTableInFormControl)FormControl.TableInFormControlMgr.GetFirstObj(); richTextFilter.Text = TableInFormControl.QueryFilter; } else if (designEl.GetCtrlType() == ControlType.TableTab) { TableTabFEl tab = (TableTabFEl)ControlEl; TableGridFEl tableGridEl = tab.GetCurTableGridEl(); CTableInFormControl TableInFormControl = tableGridEl.TableInFormControl; CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInFormControl.FW_Table_id); if (table != null) { listColumn.Items.Clear(); List <CBaseObject> lstColumn = table.ColumnMgr.GetList(); foreach (CBaseObject obj in lstColumn) { CColumn col = (CColumn)obj; ListViewItem item = new ListViewItem(); item.Text = col.Name; item.Tag = col; listColumn.Items.Add(item); bool bHas = false; List <CBaseObject> lstCIWC = TableInFormControl.ColumnInTableInFormControlMgr.GetList(); foreach (CBaseObject obj2 in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj2; if (ciwc.FW_Column_id == col.Id) { item.Checked = true; bHas = true; if (tableGridEl.dataGridView.Columns[col.Code] == null) { tableGridEl.dataGridView.Columns.Add(col.Code, col.Name); } break; } } if (!bHas) { if (tableGridEl.dataGridView.Columns[col.Code] != null) { tableGridEl.dataGridView.Columns.Remove(col.Code); } } } } List <CBaseObject> lstTButton = TableInFormControl.TButtonInTableInFormControlMgr.GetList(); listToolBarButton.Items.Clear(); foreach (ToolStripItem tbutton in tableGridEl.toolStrip.Items) { ListViewItem item = new ListViewItem(); item.Text = tbutton.Text; listToolBarButton.Items.Add(item); bool bHas = false; foreach (CBaseObject obj in lstTButton) { CTButtonInTableInFormControl tbiwc = (CTButtonInTableInFormControl)obj; if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase)) { item.Checked = true; bHas = true; break; } } if (!bHas) { tbutton.Visible = false; } } richTextFilter.Text = TableInFormControl.QueryFilter; } } else //if (FormControl.DomainType == DomainControlType.Form) { } } else { } m_bIsLoading = false; }