void LoadHeader() { if (BaseObjectMgr == null) { return; } if (dataGridView == null) { return; } dataGridView.Columns.Clear(); bool bHas = false; if (TableInFormControl != null) { List <CBaseObject> lstCIWC = TableInFormControl.ColumnInTableInFormControlMgr.GetList(); if (lstCIWC.Count > 0) { bHas = true; foreach (CBaseObject obj in lstCIWC) { CColumnInTableInFormControl ciwc = (CColumnInTableInFormControl)obj; CColumn col = (CColumn)BaseObjectMgr.Table.ColumnMgr.Find(ciwc.FW_Column_id); if (col == null) { continue; } DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn(); column.Name = col.Code; column.HeaderText = col.Name; column.Tag = col; dataGridView.Columns.Add(column); } } } if (!bHas) { List <CBaseObject> lstCol = baseObjectMgr.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); } } }
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 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; } } } } }
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; } } }
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; }