Beispiel #1
0
        void LoadTab()
        {
            if (WindowControl == null)
            {
                return;
            }
            tabControl.TabPages.Clear();
            List <CBaseObject> lstObj = WindowControl.TableInWindowControlMgr.GetList();

            foreach (CBaseObject obj in lstObj)
            {
                CTableInWindowControl tiwc = (CTableInWindowControl)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);

                TableGridEl te = new TableGridEl();
                te.WindowControl        = WindowControl;
                te.TableInWindowControl = tiwc;
                te.CaptionText          = table.Name;
                te.ShowTitleBar         = tiwc.ShowTitleBar;
                te.ShowToolBar          = tiwc.ShowToolBar;
                te.Tag = WindowControl;
                page.Controls.Add(te);
                te.Dock = DockStyle.Fill;
                te.BringToFront();
            }
        }
Beispiel #2
0
        void LoadData()
        {
            if (m_WindowControl == null)
            {
                TableTreeNodeSet ctrl = new TableTreeNodeSet();
                ctrl.Idx              = 0;
                ctrl.toolStrip.Click += new EventHandler(toolStrip_Click);
                flowLayoutPanel.Controls.Add(ctrl);

                CTableInWindowControl TableInWindowControl = new CTableInWindowControl();
                TableInWindowControl.Ctx = Program.Ctx;
                ctrl.Tag = TableInWindowControl;
            }
            else
            {
                txtName.Text = m_WindowControl.Name;
                List <CBaseObject> lstObj = m_WindowControl.TableInWindowControlMgr.GetList();
                foreach (CBaseObject obj in lstObj)
                {
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)obj;

                    TableTreeNodeSet ctrl = new TableTreeNodeSet();
                    ctrl.Idx              = flowLayoutPanel.Controls.Count;
                    ctrl.Tag              = TableInWindowControl;
                    ctrl.toolStrip.Click += new EventHandler(toolStrip_Click);
                    flowLayoutPanel.Controls.Add(ctrl);
                }
            }
        }
Beispiel #3
0
        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 = ChildenWindow.GetDistinctName(frm.m_SelTable.Name, (CWindowControlMgr)WindowControl.m_ObjectMgr);


            WindowControl.TableInWindowControlMgr.RemoveAll();
            string sText = string.Format("[{0}]", frm2.m_SelColumn.Code);
            CTableInWindowControl tiwc = new CTableInWindowControl();

            tiwc.Ctx                 = Program.Ctx;
            tiwc.FW_Table_id         = frm.m_SelTable.Id;
            tiwc.UI_WindowControl_id = WindowControl.Id;
            tiwc.Text                = sText;
            WindowControl.TableInWindowControlMgr.AddNew(tiwc);

            CaptionText = sCtrlName;
        }
Beispiel #4
0
        public void OnEdit()
        {
            SelTableForm frm = new SelTableForm();

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            WindowControl.TableInWindowControlMgr.RemoveAll();

            CTableInWindowControl tiwc = new CTableInWindowControl();

            tiwc.Ctx                 = Program.Ctx;
            tiwc.FW_Table_id         = frm.m_SelTable.Id;
            tiwc.UI_WindowControl_id = WindowControl.Id;
            tiwc.Text                = frm.m_SelTable.Name;
            WindowControl.TableInWindowControlMgr.AddNew(tiwc);

            foreach (CColumn col in frm.m_SelTable.ColumnMgr.GetList())
            {
                //if (!col.IsVisible)
                //    continue;
                CColumnInTableInWindowControl ciwc = new CColumnInTableInWindowControl();
                ciwc.Ctx          = Program.Ctx;
                ciwc.FW_Column_id = col.Id;
                ciwc.UI_TableInWindowControl_id = tiwc.Id;
                tiwc.ColumnInTableInWindowControlMgr.AddNew(ciwc);
            }
            foreach (ToolStripItem tbutton in toolStrip.Items)
            {
                CTButtonInTableInWindowControl tbiwc = new CTButtonInTableInWindowControl();
                tbiwc.Ctx   = Program.Ctx;
                tbiwc.Title = tbutton.Text;
                tbiwc.UI_TableInWindowControl_id = tiwc.Id;
                tiwc.TButtonInTableInWindowControlMgr.AddNew(tbiwc);
            }

            TableInWindowControl = tiwc;
        }
Beispiel #5
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            foreach (Control ctrl in flowLayoutPanel.Controls)
            {
                TableTreeNodeSet ttns = (TableTreeNodeSet)ctrl;
                ttns.Selected = false;
            }
            TableTreeNodeSet NodeSet = new TableTreeNodeSet();

            NodeSet.Idx = flowLayoutPanel.Controls.Count;
            CTableInWindowControl TableInWindowControl = new CTableInWindowControl();

            TableInWindowControl.m_CmdType = CmdType.AddNew;
            TableInWindowControl.Ctx       = Program.Ctx;
            NodeSet.Tag = TableInWindowControl;

            NodeSet.toolStrip.Click += new EventHandler(toolStrip_Click);
            flowLayoutPanel.Controls.Add(NodeSet);
            NodeSet.Selected = true;

            m_SelTableTreeNodeSet = NodeSet;
        }
Beispiel #6
0
        public void OnEdit()
        {
            SelMultTableForm frm = new SelMultTableForm();

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            WindowControl.TableInWindowControlMgr.RemoveAll();

            foreach (CTable table in frm.m_lstSelTable)
            {
                CTableInWindowControl tiwc = new CTableInWindowControl();
                tiwc.Ctx                 = Program.Ctx;
                tiwc.FW_Table_id         = table.Id;
                tiwc.UI_WindowControl_id = WindowControl.Id;
                tiwc.Text                = table.Name;
                WindowControl.TableInWindowControlMgr.AddNew(tiwc);
            }

            LoadTab();
        }
Beispiel #7
0
        private void richTextFilter_TextChanged(object sender, EventArgs e)
        {
            CWindowControl WindowControl = (CWindowControl)ControlEl.Tag;
            IDesignEl      designEl      = (IDesignEl)ControlEl;

            if (designEl.GetCtrlType() == ControlType.TableGrid)
            {
                CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                TableInWindowControl.QueryFilter = richTextFilter.Text.Trim();
                TableInWindowControl.m_CmdType   = CmdType.Update;
            }
            else if (designEl.GetCtrlType() == ControlType.ListBox)
            {
                CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                TableInWindowControl.QueryFilter = richTextFilter.Text.Trim();
                TableInWindowControl.m_CmdType   = CmdType.Update;
            }
            else if (designEl.GetCtrlType() == ControlType.ComboBox)
            {
                CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                TableInWindowControl.QueryFilter = richTextFilter.Text.Trim();
                TableInWindowControl.m_CmdType   = CmdType.Update;
            }
        }
Beispiel #8
0
        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++)
            {
                TableTreeNodeSet NodeSet = (TableTreeNodeSet)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_WindowControl == null)
            {
                m_WindowControl           = new CWindowControl();
                m_WindowControl.Ctx       = Program.Ctx;
                m_WindowControl.m_CmdType = CmdType.AddNew;
                m_WindowControl.Name      = txtName.Text.Trim();
                for (int i = 0; i < flowLayoutPanel.Controls.Count; i++)
                {
                    TableTreeNodeSet      NodeSet = (TableTreeNodeSet)flowLayoutPanel.Controls[i];
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)NodeSet.Tag;
                    TableInWindowControl.Idx         = i;
                    TableInWindowControl.FW_Table_id = NodeSet.m_Table.Id;
                    TableInWindowControl.IsLoop      = NodeSet.ckIsLoop.Checked;
                    TableInWindowControl.QueryFilter = NodeSet.txtQueryFilter.Text.Trim();
                    TableInWindowControl.RootFilter  = NodeSet.txtRootFilter.Text.Trim();
                    TableInWindowControl.Text        = NodeSet.txtText.Text.Trim();
                    if (NodeSet.ckIsLoop.Checked)
                    {
                        DataItem item   = (DataItem)NodeSet.cbNodeIDCol.SelectedItem;
                        CColumn  column = (CColumn)item.Data;
                        TableInWindowControl.NodeIDCol = column.Id;

                        DataItem item2   = (DataItem)NodeSet.cbPNodeIDCol.SelectedItem;
                        CColumn  column2 = (CColumn)item2.Data;
                        TableInWindowControl.PNodeIDCol = column2.Id;
                    }
                    TableInWindowControl.UI_WindowControl_id = m_WindowControl.Id;
                    m_WindowControl.TableInWindowControlMgr.AddNew(TableInWindowControl);
                }
            }
            else
            {
                //删除
                List <CTableInWindowControl> lstDel = new List <CTableInWindowControl>();
                List <CBaseObject>           lstObj = m_WindowControl.TableInWindowControlMgr.GetList();
                foreach (CBaseObject obj in lstObj)
                {
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)obj;
                    bool bHas = false;
                    for (int i = 0; i < flowLayoutPanel.Controls.Count; i++)
                    {
                        TableTreeNodeSet      NodeSet = (TableTreeNodeSet)flowLayoutPanel.Controls[i];
                        CTableInWindowControl tiwc    = (CTableInWindowControl)NodeSet.Tag;
                        if (TableInWindowControl == tiwc)
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        lstDel.Add(TableInWindowControl);
                    }
                }
                foreach (CTableInWindowControl tiwc in lstDel)
                {
                    m_WindowControl.TableInWindowControlMgr.Delete(tiwc);
                }
                //添加、修改
                for (int i = 0; i < flowLayoutPanel.Controls.Count; i++)
                {
                    TableTreeNodeSet      NodeSet = (TableTreeNodeSet)flowLayoutPanel.Controls[i];
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)NodeSet.Tag;
                    TableInWindowControl.Idx         = i;
                    TableInWindowControl.FW_Table_id = NodeSet.m_Table.Id;
                    TableInWindowControl.IsLoop      = NodeSet.ckIsLoop.Checked;
                    TableInWindowControl.QueryFilter = NodeSet.txtQueryFilter.Text.Trim();
                    TableInWindowControl.RootFilter  = NodeSet.txtRootFilter.Text.Trim();
                    TableInWindowControl.Text        = NodeSet.txtText.Text.Trim();
                    if (NodeSet.ckIsLoop.Checked)
                    {
                        DataItem item   = (DataItem)NodeSet.cbNodeIDCol.SelectedItem;
                        CColumn  column = (CColumn)item.Data;
                        TableInWindowControl.NodeIDCol = column.Id;

                        DataItem item2   = (DataItem)NodeSet.cbPNodeIDCol.SelectedItem;
                        CColumn  column2 = (CColumn)item2.Data;
                        TableInWindowControl.PNodeIDCol = column2.Id;
                    }
                    TableInWindowControl.UI_WindowControl_id = m_WindowControl.Id;
                    if (TableInWindowControl.m_CmdType == CmdType.AddNew)
                    {
                        m_WindowControl.TableInWindowControlMgr.AddNew(TableInWindowControl);
                    }
                    else
                    {
                        m_WindowControl.TableInWindowControlMgr.Update(TableInWindowControl);
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #9
0
        //生成自引用树节点
        List <TreeNode> SelfLoop(CTableInWindowControl 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;
                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);
        }
Beispiel #10
0
        void LoadData()
        {
            if (Window == null)
            {
                return;
            }

            this.Width          = Window.Width;
            this.Height         = Window.Height;
            panelTop.Height     = Window.TopPanelHeight;
            panelBottom.Height  = Window.BottomPanelHeight;
            panelLeft.Width     = Window.LeftPanelWidth;
            panelRight.Width    = Window.RightPanelWidth;
            panelTop.Visible    = Window.TopPanelVisible;
            panelBottom.Visible = Window.BottomPanelVisible;
            panelLeft.Visible   = Window.LeftPanelVisible;
            panelRight.Visible  = Window.RightPanelVisible;

            List <CBaseObject> lstWindowControl = Window.WindowControlMgr.GetList();

            foreach (CBaseObject obj in lstWindowControl)
            {
                CWindowControl WindowControl = (CWindowControl)obj;
                Panel          panel         = null;
                if (WindowControl.Dock == (int)DockStyle.Top)
                {
                    panel = panelTop;
                }
                else if (WindowControl.Dock == (int)DockStyle.Bottom)
                {
                    panel = panelBottom;
                }
                else if (WindowControl.Dock == (int)DockStyle.Left)
                {
                    panel = panelLeft;
                }
                else if (WindowControl.Dock == (int)DockStyle.Right)
                {
                    panel = panelRight;
                }
                else
                {
                    panel = panelFill;
                }

                if (WindowControl.CtrlType == ControlType.NavBar)
                {
                    UIToolbar toolbar = new UIToolbar();
                    toolbar.WindowControl = WindowControl;
                    toolbar.Name          = WindowControl.Name;
                    panel.Controls.Add(toolbar);
                    toolbar.Dock = DockStyle.Fill;
                    toolbar.SendToBack();
                }
                else if (WindowControl.CtrlType == ControlType.TableGrid)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;
                    TableGrid te = new TableGrid();
                    te.TableInWindowControl = TableInWindowControl;
                    te.BaseObjectMgr        = objMgr;
                    te.Name         = WindowControl.Name;
                    te.ShowToolBar  = TableInWindowControl.ShowToolBar;
                    te.ShowTitleBar = TableInWindowControl.ShowTitleBar;
                    te.CaptionText  = WindowControl.Name;
                    te.Tag          = WindowControl;
                    panel.Controls.Add(te);
                    te.Dock = (DockStyle)WindowControl.Dock;
                    te.BringToFront();
                    te.dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTree)
                {
                    TableTree tt = new TableTree();
                    tt.CaptionText   = WindowControl.Name;
                    tt.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tt.WindowControl = WindowControl;
                    tt.Name          = WindowControl.Name;
                    tt.Tag           = WindowControl;
                    panel.Controls.Add(tt);
                    tt.Dock = DockStyle.Fill;
                    tt.BringToFront();

                    tt.treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView_NodeMouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTab)
                {
                    TableTab tab = new TableTab();
                    tab.WindowControl = WindowControl;
                    tab.CaptionText   = WindowControl.Name;
                    tab.Name          = WindowControl.Name;
                    tab.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tab.Tag           = WindowControl;
                    panel.Controls.Add(tab);
                    tab.Dock = DockStyle.Fill;
                    tab.BringToFront();
                }
                else if (WindowControl.CtrlType == ControlType.ComboBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIComboBox cb = new UIComboBox();
                    cb.CaptionText          = WindowControl.Name + ":";
                    cb.TableInWindowControl = TableInWindowControl;
                    cb.BaseObjectMgr        = objMgr;
                    cb.Name = WindowControl.Name;
                    cb.Tag  = WindowControl;
                    panel.Controls.Add(cb);
                    cb.Dock = DockStyle.Top;
                    cb.BringToFront();

                    cb.comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
                }
                else if (WindowControl.CtrlType == ControlType.ListBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIListBox listBox = new UIListBox();
                    listBox.CaptionText          = WindowControl.Name;
                    listBox.TableInWindowControl = TableInWindowControl;
                    listBox.BaseObjectMgr        = objMgr;
                    listBox.Name = WindowControl.Name;
                    listBox.Tag  = WindowControl;
                    panel.Controls.Add(listBox);
                    listBox.Dock = DockStyle.Fill;
                    listBox.BringToFront();

                    listBox.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged);
                }
            }
        }
Beispiel #11
0
        void LoadTable()
        {
            dataGridView.Columns.Clear();
            if (WindowControl == null)
            {
                return;
            }
            CTableInWindowControl tiwc = null;

            if (TableInWindowControl == null)
            {
                tiwc = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                if (tiwc == null)
                {
                    return;
                }
            }
            else
            {
                tiwc = TableInWindowControl;
            }

            CTable table = (CTable)Program.Ctx.TableMgr.Find(tiwc.FW_Table_id);

            if (table == null)
            {
                return;
            }

            {
                bool bHas = false;
                List <CBaseObject> lstCIWC = tiwc.ColumnInTableInWindowControlMgr.GetList();
                if (lstCIWC.Count > 0)
                {
                    bHas = true;
                    foreach (CBaseObject obj in lstCIWC)
                    {
                        CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)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.TButtonInTableInWindowControlMgr.GetList();

            foreach (ToolStripItem tbutton in toolStrip.Items)
            {
                bool bHas = false;
                foreach (CBaseObject obj in lstTButton)
                {
                    CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                    if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        bHas = true;
                        break;
                    }
                }
                if (!bHas)
                {
                    tbutton.Visible = false;
                }
            }
        }
Beispiel #12
0
        void RefreshLinkageWindowControl(CWindowControl WindowControl)
        {
            List <Control> lstCtrls = new List <Control>();

            foreach (Control ctrl in panelTop.Controls)
            {
                lstCtrls.Add(ctrl);
            }
            foreach (Control ctrl in panelBottom.Controls)
            {
                lstCtrls.Add(ctrl);
            }
            foreach (Control ctrl in panelLeft.Controls)
            {
                lstCtrls.Add(ctrl);
            }
            foreach (Control ctrl in panelRight.Controls)
            {
                lstCtrls.Add(ctrl);
            }
            foreach (Control ctrl in panelFill.Controls)
            {
                lstCtrls.Add(ctrl);
            }

            List <CBaseObject> lstLT = WindowControl.LinkageWindowControlMgr.GetList();

            foreach (CBaseObject obj in lstLT)
            {
                CLinkageWindowControl LinkageWindowControl = (CLinkageWindowControl)obj;
                CWindowControl        swc = (CWindowControl)WindowControl.m_ObjectMgr.Find(LinkageWindowControl.SlaveID);
                if (swc != null)
                {
                    foreach (Control ctrl in lstCtrls)
                    {
                        if ((CWindowControl)(ctrl.Tag) == swc)
                        {
                            IWindowCtrl winCtrl = (IWindowCtrl)ctrl;
                            if (winCtrl.GetCtrlType() == ControlType.TableGrid)
                            {
                                TableGrid teLT = (TableGrid)ctrl;

                                CTableInWindowControl tiw = teLT.TableInWindowControl;
                                string sQueryFilter       = tiw.QueryFilter;
                                if (CalcUIFormula(ref sQueryFilter))
                                {
                                    teLT.BaseObjectMgr.GetList(sQueryFilter);
                                    teLT.LoadData();
                                }
                            }
                            else if (winCtrl.GetCtrlType() == ControlType.TableTab)
                            {
                                TableTab tabLT = (TableTab)ctrl;
                                foreach (TabPage page in tabLT.tabControl.TabPages)
                                {
                                    TableGrid             teLT = (TableGrid)page.Controls[0];
                                    CTableInWindowControl tiw  = teLT.TableInWindowControl;
                                    string sQueryFilter        = tiw.QueryFilter;
                                    if (CalcUIFormula(ref sQueryFilter))
                                    {
                                        teLT.BaseObjectMgr.GetList(sQueryFilter);
                                        teLT.LoadData();
                                    }
                                }
                            }
                            else if (winCtrl.GetCtrlType() == ControlType.ListBox)
                            {
                                UIListBox listBoxLT = (UIListBox)ctrl;

                                CTableInWindowControl tiw = listBoxLT.TableInWindowControl;
                                string sQueryFilter       = tiw.QueryFilter;
                                if (CalcUIFormula(ref sQueryFilter))
                                {
                                    listBoxLT.BaseObjectMgr.GetList(sQueryFilter);
                                    listBoxLT.LoadData();
                                }
                            }
                            else if (winCtrl.GetCtrlType() == ControlType.ComboBox)
                            {
                                UIComboBox combBoxLT = (UIComboBox)ctrl;

                                CTableInWindowControl tiw = combBoxLT.TableInWindowControl;
                                string sQueryFilter       = tiw.QueryFilter;
                                if (CalcUIFormula(ref sQueryFilter))
                                {
                                    combBoxLT.BaseObjectMgr.GetList(sQueryFilter);
                                    combBoxLT.LoadData();
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #13
0
        private void listToolBarButton_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.CurrentValue == e.NewValue)
            {
                return;
            }

            CWindowControl WindowControl = (CWindowControl)ControlEl.Tag;
            IDesignEl      designEl      = (IDesignEl)ControlEl;

            if (designEl.GetCtrlType() == ControlType.TableGrid)
            {
                TableGridEl           te       = (TableGridEl)ControlEl;
                CTableInWindowControl tiwc     = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                List <CBaseObject>    lstTBIWC = tiwc.TButtonInTableInWindowControlMgr.GetList();
                if (e.NewValue == CheckState.Checked)
                {
                    bool bHas = false;
                    foreach (CBaseObject obj in lstTBIWC)
                    {
                        CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                        if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase))
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        CTButtonInTableInWindowControl tbiwc = new CTButtonInTableInWindowControl();
                        tbiwc.Title = listToolBarButton.Items[e.Index].Text;
                        tbiwc.UI_TableInWindowControl_id = tiwc.Id;
                        tbiwc.Ctx = Program.Ctx;
                        tiwc.TButtonInTableInWindowControlMgr.AddNew(tbiwc);
                        te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, true);
                    }
                }
                else
                {
                    foreach (CBaseObject obj in lstTBIWC)
                    {
                        CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                        if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase))
                        {
                            tiwc.TButtonInTableInWindowControlMgr.Delete(tbiwc);
                            te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, false);
                            break;
                        }
                    }
                }
            }
            else if (designEl.GetCtrlType() == ControlType.TableTree)
            {
                TableTreeEl treeEl = (TableTreeEl)ControlEl;
            }
            else if (designEl.GetCtrlType() == ControlType.TableTab)
            {
                TableTabEl            tab      = (TableTabEl)ControlEl;
                TableGridEl           te       = tab.GetCurTableGridEl();
                CTableInWindowControl tiwc     = te.TableInWindowControl;
                List <CBaseObject>    lstTBIWC = tiwc.TButtonInTableInWindowControlMgr.GetList();
                if (e.NewValue == CheckState.Checked)
                {
                    bool bHas = false;
                    foreach (CBaseObject obj in lstTBIWC)
                    {
                        CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                        if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase))
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        CTButtonInTableInWindowControl tbiwc = new CTButtonInTableInWindowControl();
                        tbiwc.Title = listToolBarButton.Items[e.Index].Text;
                        tbiwc.UI_TableInWindowControl_id = tiwc.Id;
                        tbiwc.Ctx = Program.Ctx;
                        tiwc.TButtonInTableInWindowControlMgr.AddNew(tbiwc);
                        te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, true);
                    }
                }
                else
                {
                    foreach (CBaseObject obj in lstTBIWC)
                    {
                        CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                        if (tbiwc.Title.Equals(listToolBarButton.Items[e.Index].Text, StringComparison.OrdinalIgnoreCase))
                        {
                            tiwc.TButtonInTableInWindowControlMgr.Delete(tbiwc);
                            te.SetToolBarButtonVisible(listToolBarButton.Items[e.Index].Text, false);
                            break;
                        }
                    }
                }
            }
        }
Beispiel #14
0
        private void listColumn_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.CurrentValue == e.NewValue)
            {
                return;
            }
            ListViewItem item = listColumn.Items[e.Index];

            CWindowControl WindowControl = (CWindowControl)ControlEl.Tag;
            IDesignEl      designEl      = (IDesignEl)ControlEl;
            CColumn        col           = (CColumn)item.Tag;

            if (designEl.GetCtrlType() == ControlType.TableGrid)
            {
                TableGridEl           te      = (TableGridEl)ControlEl;
                CTableInWindowControl tiwc    = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                List <CBaseObject>    lstCIWC = tiwc.ColumnInTableInWindowControlMgr.GetList();
                if (e.NewValue == CheckState.Checked)
                {
                    bool bHas = false;
                    foreach (CBaseObject obj in lstCIWC)
                    {
                        CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)obj;
                        if (ciwc.FW_Column_id == col.Id)
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        CColumnInTableInWindowControl ciwc = new CColumnInTableInWindowControl();
                        ciwc.FW_Column_id = col.Id;
                        ciwc.UI_TableInWindowControl_id = tiwc.Id;
                        ciwc.Ctx = Program.Ctx;
                        tiwc.ColumnInTableInWindowControlMgr.AddNew(ciwc);

                        if (te.dataGridView.Columns[col.Code] == null)
                        {
                            te.dataGridView.Columns.Add(col.Code, col.Name);
                        }
                    }
                }
                else
                {
                    foreach (CBaseObject obj in lstCIWC)
                    {
                        CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)obj;
                        if (ciwc.FW_Column_id == col.Id)
                        {
                            tiwc.ColumnInTableInWindowControlMgr.Delete(ciwc);
                            if (te.dataGridView.Columns[col.Code] != null)
                            {
                                te.dataGridView.Columns.Remove(col.Code);
                            }
                            break;
                        }
                    }
                }
            }
            else if (designEl.GetCtrlType() == ControlType.TableTab)
            {
                TableTabEl            tab     = (TableTabEl)ControlEl;
                TableGridEl           te      = tab.GetCurTableGridEl();
                CTableInWindowControl tiwc    = te.TableInWindowControl;
                List <CBaseObject>    lstCIWC = tiwc.ColumnInTableInWindowControlMgr.GetList();
                if (e.NewValue == CheckState.Checked)
                {
                    bool bHas = false;
                    foreach (CBaseObject obj in lstCIWC)
                    {
                        CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)obj;
                        if (ciwc.FW_Column_id == col.Id)
                        {
                            bHas = true;
                            break;
                        }
                    }
                    if (!bHas)
                    {
                        CColumnInTableInWindowControl ciwc = new CColumnInTableInWindowControl();
                        ciwc.FW_Column_id = col.Id;
                        ciwc.UI_TableInWindowControl_id = tiwc.Id;
                        ciwc.Ctx = Program.Ctx;
                        tiwc.ColumnInTableInWindowControlMgr.AddNew(ciwc);

                        if (te.dataGridView.Columns[col.Code] == null)
                        {
                            te.dataGridView.Columns.Add(col.Code, col.Name);
                        }
                    }
                }
                else
                {
                    foreach (CBaseObject obj in lstCIWC)
                    {
                        CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)obj;
                        if (ciwc.FW_Column_id == col.Id)
                        {
                            tiwc.ColumnInTableInWindowControlMgr.Delete(ciwc);
                            if (te.dataGridView.Columns[col.Code] != null)
                            {
                                te.dataGridView.Columns.Remove(col.Code);
                            }
                            break;
                        }
                    }
                }
            }
        }
Beispiel #15
0
        void LoadData()
        {
            //this.Controls.Clear();
            m_AttributeToolWindow.listLinkageWindowControl.Items.Clear();
            if (Window == null)
            {
                return;
            }

            this.Width          = Window.Width;
            this.Height         = Window.Height;
            panelTop.Height     = Window.TopPanelHeight;
            panelBottom.Height  = Window.BottomPanelHeight;
            panelLeft.Width     = Window.LeftPanelWidth;
            panelRight.Width    = Window.RightPanelWidth;
            panelTop.Visible    = Window.TopPanelVisible;
            panelBottom.Visible = Window.BottomPanelVisible;
            panelLeft.Visible   = Window.LeftPanelVisible;
            panelRight.Visible  = Window.RightPanelVisible;

            List <CBaseObject> lstWindowControl = Window.WindowControlMgr.GetList();

            foreach (CBaseObject obj in lstWindowControl)
            {
                CWindowControl WindowControl = (CWindowControl)obj;
                Panel          panel         = null;
                if (WindowControl.Dock == (int)DockStyle.Top)
                {
                    panel = panelTop;
                }
                else if (WindowControl.Dock == (int)DockStyle.Bottom)
                {
                    panel = panelBottom;
                }
                else if (WindowControl.Dock == (int)DockStyle.Left)
                {
                    panel = panelLeft;
                }
                else if (WindowControl.Dock == (int)DockStyle.Right)
                {
                    panel = panelRight;
                }
                else
                {
                    panel = panelFill;
                }


                //联动控件
                ListViewItem itemLT = new ListViewItem();
                itemLT.Text = WindowControl.Name;
                itemLT.Tag  = WindowControl;
                m_AttributeToolWindow.listLinkageWindowControl.Items.Add(itemLT);
                //

                if (WindowControl.CtrlType == ControlType.NavBar)
                {
                    UIToolbarEl toolbar = new UIToolbarEl();
                    toolbar.WindowControl = WindowControl;
                    toolbar.Tag           = WindowControl;
                    panel.Controls.Add(toolbar);
                    toolbar.Dock = DockStyle.Fill;

                    toolbar.MouseClick += new MouseEventHandler(ctrl_MouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableGrid)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    TableGridEl te = new TableGridEl();
                    te.WindowControl        = WindowControl;
                    te.Name                 = table.Code;
                    te.TableInWindowControl = TableInWindowControl;
                    te.ShowToolBar          = TableInWindowControl.ShowToolBar;
                    te.ShowTitleBar         = TableInWindowControl.ShowTitleBar;
                    te.CaptionText          = WindowControl.Name;
                    te.Tag = WindowControl;
                    panel.Controls.Add(te);
                    te.Dock = (DockStyle)WindowControl.Dock;
                    te.BringToFront();



                    te.tbTitle.MouseClick    += new MouseEventHandler(childCtrl_MouseClick);
                    te.toolStrip.MouseClick  += new MouseEventHandler(childCtrl_MouseClick);
                    te.dataGridView.GotFocus += new EventHandler(ctrl_GotFocus);
                }
                else if (WindowControl.CtrlType == ControlType.TableTree)
                {
                    TableTreeEl tt = new TableTreeEl();
                    tt.CaptionText   = WindowControl.Name;
                    tt.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tt.WindowControl = WindowControl;
                    tt.Tag           = WindowControl;
                    panel.Controls.Add(tt);
                    tt.Dock = DockStyle.Fill;
                    tt.BringToFront();

                    tt.tbTitle.MouseClick       += new MouseEventHandler(childCtrl_MouseClick);
                    tt.treeView.GotFocus        += new EventHandler(ctrl_GotFocus);
                    tt.treeView.ContextMenuStrip = contextMenuStrip1;
                }
                else if (WindowControl.CtrlType == ControlType.TableTab)
                {
                    TableTabEl tab = new TableTabEl();
                    tab.WindowControl = WindowControl;
                    tab.CaptionText   = "TabCtrl";
                    tab.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tab.Tag           = WindowControl;
                    panel.Controls.Add(tab);
                    tab.Dock = DockStyle.Fill;
                    tab.BringToFront();

                    tab.tabControl.MouseClick += new MouseEventHandler(childCtrl_MouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.ComboBox)
                {
                    UIComboBoxEl cb = new UIComboBoxEl();
                    cb.CaptionText   = WindowControl.Name + ":";
                    cb.WindowControl = WindowControl;
                    cb.ShowTitleBar  = WindowControl.ShowTitleBar;
                    cb.Tag           = WindowControl;
                    panel.Controls.Add(cb);
                    cb.Dock = DockStyle.Top;
                    cb.BringToFront();

                    cb.lbTitle.MouseClick  += new MouseEventHandler(childCtrl_MouseClick);
                    cb.comboBox.MouseClick += new MouseEventHandler(childCtrl_MouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.ListBox)
                {
                    UIListBoxEl listBox = new UIListBoxEl();
                    listBox.CaptionText   = WindowControl.Name;
                    listBox.WindowControl = WindowControl;
                    listBox.ShowTitleBar  = WindowControl.ShowTitleBar;
                    listBox.Tag           = WindowControl;
                    panel.Controls.Add(listBox);
                    listBox.Dock = DockStyle.Fill;
                    listBox.BringToFront();

                    listBox.tbTitle.MouseClick += new MouseEventHandler(childCtrl_MouseClick);
                    listBox.listBox.MouseClick += new MouseEventHandler(childCtrl_MouseClick);
                    listBox.ContextMenuStrip    = contextMenuStrip1;
                }
            }
        }
Beispiel #16
0
        void LoopTreeNode(int iLevel, List <CBaseObject> lstTIWC, TreeNode pnode)
        {
            if (iLevel >= lstTIWC.Count)
            {
                return;
            }
            CTableInWindowControl tiwc = (CTableInWindowControl)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;
                    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);
                }
            }
        }
Beispiel #17
0
        public void OnDragDrop(DockStyle dock, ListViewItem item)
        {
            Panel panel = panelFill;

            if (dock == DockStyle.Top)
            {
                panel = panelTop;
            }
            else if (dock == DockStyle.Bottom)
            {
                panel = panelBottom;
            }
            else if (dock == DockStyle.Left)
            {
                panel = panelLeft;
            }
            else if (dock == DockStyle.Right)
            {
                panel = panelRight;
            }

            if (item.Text.Equals("ToolBar", StringComparison.OrdinalIgnoreCase))
            {
                string sCtrlName = GetDistinctName("导航栏", Window.WindowControlMgr);

                CWindowControl WindowControl = new CWindowControl();
                WindowControl.CtrlType     = ControlType.NavBar;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Name         = sCtrlName;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);

                NavigateBarEl nb = new NavigateBarEl();
                nb.WindowControl = WindowControl;
                nb.Tag           = WindowControl;
                panel.Controls.Add(nb);
                nb.Dock = DockStyle.Fill;
                nb.BringToFront();

                nb.flowLayoutPanel.MouseClick += new MouseEventHandler(childCtrl_MouseClick);

                SelectElement(nb);
            }
            else if (item.Text.Equals("DataGrid", StringComparison.OrdinalIgnoreCase))
            {
                SelTableForm frm = new SelTableForm();
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string sCtrlName = GetDistinctName(frm.m_SelTable.Name, Window.WindowControlMgr);

                CWindowControl WindowControl = new CWindowControl();
                WindowControl.CtrlType     = ControlType.TableGrid;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Name         = sCtrlName;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);

                CTableInWindowControl tiwc = new CTableInWindowControl();
                tiwc.Ctx                 = Program.Ctx;
                tiwc.FW_Table_id         = frm.m_SelTable.Id;
                tiwc.UI_WindowControl_id = WindowControl.Id;
                tiwc.Text                = frm.m_SelTable.Name;
                WindowControl.TableInWindowControlMgr.AddNew(tiwc);

                TableGridEl te = new TableGridEl();
                te.WindowControl = WindowControl;
                te.CaptionText   = sCtrlName;
                te.ShowTitleBar  = true;
                te.ShowToolBar   = true;
                te.Tag           = WindowControl;
                panel.Controls.Add(te);
                te.Dock = DockStyle.Fill;
                te.BringToFront();


                //联动表
                ListViewItem itemLT = new ListViewItem();
                itemLT.Text = te.CaptionText;
                itemLT.Tag  = WindowControl;
                m_AttributeToolWindow.listLinkageWindowControl.Items.Add(itemLT);
                //

                //List<CBaseObject> lstColumn = table.ColumnMgr.GetList();
                //foreach (CBaseObject obj in lstColumn)
                //{
                //    CColumn col = (CColumn)obj;
                //    CColumnInWindowControl ciw = new CColumnInWindowControl();
                //    ciw.FW_Column_id = col.Id;
                //    ciw.UI_TableInWindow_id = TableInWindow.Id;
                //    if (!TableInWindow.ColumnInWindowMgr.AddNew(ciw))
                //    {
                //        MessageBox.Show("设置显示字段失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //        //return false;
                //    }
                //    te.m_lstShowColumn.Add(ciw.FW_Column_id);
                //}
                //foreach (ToolStripItem tbutton in te.tableCtrlEl.toolStrip.Items)
                //{
                //    CToolbarButtonInWindowControl tbiw = new CToolbarButtonInWindowControl();
                //    tbiw.Title = tbutton.Text;
                //    tbiw.UI_TableInWindow_id = TableInWindow.Id;
                //    if (!TableInWindow.ToolbarButtonInWindowMgr.AddNew(tbiw))
                //    {
                //        MessageBox.Show("设置工具栏按钮失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //        //return false;
                //    }
                //    te.m_lstShowToolBarButton.Add(tbiw.Title);
                //}

                te.tbTitle.MouseClick += new MouseEventHandler(childCtrl_MouseClick);

                SelectElement(te);
            }
            else if (item.Text.Equals("TreeCtrl", StringComparison.OrdinalIgnoreCase))
            {
                TableTreeSet frm = new TableTreeSet();
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string sCtrlName = GetDistinctName(frm.m_WindowControl.Name, Window.WindowControlMgr);

                CWindowControl WindowControl = frm.m_WindowControl;
                WindowControl.Name         = sCtrlName;
                WindowControl.CtrlType     = ControlType.TableTree;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);


                TableTreeEl tt = new TableTreeEl();
                tt.CaptionText  = sCtrlName;
                tt.ShowTitleBar = true;
                tt.Tag          = WindowControl;
                panel.Controls.Add(tt);
                tt.Dock = DockStyle.Fill;
                tt.BringToFront();

                tt.tbTitle.MouseClick += new MouseEventHandler(childCtrl_MouseClick);

                SelectElement(tt);
            }
            else if (item.Text.Equals("TabCtrl", StringComparison.OrdinalIgnoreCase))
            {
                SelMultTableForm frm = new SelMultTableForm();
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                string sCtrlName = GetDistinctName("标签", Window.WindowControlMgr);

                CWindowControl WindowControl = new CWindowControl();
                WindowControl.CtrlType     = ControlType.TableTab;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Name         = sCtrlName;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);

                foreach (CTable table in frm.m_lstSelTable)
                {
                    CTableInWindowControl tiwc = new CTableInWindowControl();
                    tiwc.Ctx                 = Program.Ctx;
                    tiwc.FW_Table_id         = table.Id;
                    tiwc.UI_WindowControl_id = WindowControl.Id;
                    tiwc.Text                = table.Name;
                    WindowControl.TableInWindowControlMgr.AddNew(tiwc);
                }

                TableTabEl tab = new TableTabEl();
                tab.WindowControl = WindowControl;
                tab.CaptionText   = sCtrlName;
                tab.ShowTitleBar  = false;
                tab.Tag           = WindowControl;
                panel.Controls.Add(tab);
                tab.Dock = DockStyle.Fill;
                tab.BringToFront();

                tab.tabControl.MouseClick += new MouseEventHandler(childCtrl_MouseClick);
                SelectElement(tab);
            }
            else if (item.Text.Equals("ComboBox", StringComparison.OrdinalIgnoreCase))
            {
                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 = GetDistinctName(frm.m_SelTable.Name, Window.WindowControlMgr);

                CWindowControl WindowControl = new CWindowControl();
                WindowControl.CtrlType     = ControlType.ComboBox;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Name         = sCtrlName;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);


                string sText = string.Format("[{0}]", frm2.m_SelColumn.Code);

                CTableInWindowControl tiwc = new CTableInWindowControl();
                tiwc.Ctx                 = Program.Ctx;
                tiwc.FW_Table_id         = frm.m_SelTable.Id;
                tiwc.UI_WindowControl_id = WindowControl.Id;
                tiwc.Text                = sText;
                WindowControl.TableInWindowControlMgr.AddNew(tiwc);

                UIComboBoxEl cb = new UIComboBoxEl();
                cb.CaptionText   = frm.m_SelTable.Name + ":";
                cb.WindowControl = WindowControl;
                cb.Tag           = WindowControl;
                panel.Controls.Add(cb);
                cb.Dock = DockStyle.Top;
                cb.BringToFront();

                cb.lbTitle.MouseClick  += new MouseEventHandler(childCtrl_MouseClick);
                cb.comboBox.MouseClick += new MouseEventHandler(childCtrl_MouseClick);

                SelectElement(cb);
            }
            else if (item.Text.Equals("ListBox", StringComparison.OrdinalIgnoreCase))
            {
                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 = GetDistinctName(frm.m_SelTable.Name, Window.WindowControlMgr);

                CWindowControl WindowControl = new CWindowControl();
                WindowControl.CtrlType     = ControlType.ListBox;
                WindowControl.Ctx          = Program.Ctx;
                WindowControl.Name         = sCtrlName;
                WindowControl.Dock         = (int)dock;
                WindowControl.UI_Window_id = Window.Id;
                Window.WindowControlMgr.AddNew(WindowControl);


                string sText = string.Format("[{0}]", frm2.m_SelColumn.Code);
                //string sText = "";
                //List<CBaseObject> lstObj = frm.m_SelTable.ColumnMgr.GetList();
                //bool bHasName = false, bHasCode = false;
                //foreach (CBaseObject obj in lstObj)
                //{
                //    CColumn column = (CColumn)obj;
                //    if (column.Code.Equals("name", StringComparison.OrdinalIgnoreCase))
                //    {
                //        bHasName = true;
                //    }
                //    if (column.Code.Equals("code", StringComparison.OrdinalIgnoreCase))
                //    {
                //        bHasCode = true;
                //    }
                //}
                //if (bHasName)
                //    sText = "[Name]";
                //else if (bHasCode)
                //    sText = "[Code]";

                CTableInWindowControl tiwc = new CTableInWindowControl();
                tiwc.Ctx                 = Program.Ctx;
                tiwc.FW_Table_id         = frm.m_SelTable.Id;
                tiwc.UI_WindowControl_id = WindowControl.Id;
                tiwc.Text                = sText;
                WindowControl.TableInWindowControlMgr.AddNew(tiwc);

                UIListBoxEl listBox = new UIListBoxEl();
                listBox.CaptionText   = sCtrlName;
                listBox.WindowControl = WindowControl;
                listBox.Tag           = WindowControl;
                panel.Controls.Add(listBox);
                listBox.Dock = DockStyle.Fill;
                listBox.BringToFront();

                listBox.tbTitle.MouseClick += new MouseEventHandler(childCtrl_MouseClick);

                SelectElement(listBox);
            }
        }
Beispiel #18
0
        public void LoadData()
        {
            if (m_AttrType == AttrType.WindowControl)
            {
                if (ControlEl == null || ControlEl.Tag == null)
                {
                    return;
                }
            }
            else
            {
                if (WindowEl == null || WindowEl.Window == null)
                {
                    return;
                }
            }

            m_bIsLoading = true;

            UpdateTabCtrl();

            UpdatePropertyGrid();

            if (m_AttrType == AttrType.WindowControl)
            {
                IDesignEl      designEl      = (IDesignEl)ControlEl;
                CWindowControl WindowControl = (CWindowControl)ControlEl.Tag;
                if (designEl.GetCtrlType() == ControlType.NavBar)
                {
                }
                else if (designEl.GetCtrlType() == ControlType.TableGrid)
                {
                    TableGridEl           tableGridEl          = (TableGridEl)ControlEl;
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.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 = TableInWindowControl.ColumnInTableInWindowControlMgr.GetList();
                            bool bHas = false;
                            foreach (CBaseObject obj2 in lstCIWC)
                            {
                                CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)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 = TableInWindowControl.TButtonInTableInWindowControlMgr.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)
                        {
                            CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                            if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase))
                            {
                                item.Checked = true;
                                bHas         = true;
                                break;
                            }
                        }
                        if (!bHas)
                        {
                            tbutton.Visible = false;
                        }
                    }

                    richTextFilter.Text = TableInWindowControl.QueryFilter;


                    List <CBaseObject> lstLWC = WindowControl.LinkageWindowControlMgr.GetList();
                    for (int i = 0; i < listLinkageWindowControl.Items.Count; i++)
                    {
                        listLinkageWindowControl.Items[i].Checked = false;
                    }
                    foreach (ListViewItem item in listLinkageWindowControl.Items)
                    {
                        CWindowControl wc = (CWindowControl)item.Tag;
                        foreach (CBaseObject obj in lstLWC)
                        {
                            CLinkageWindowControl lwc = (CLinkageWindowControl)obj;
                            if (lwc.SlaveID == wc.Id)
                            {
                                item.Checked = true;
                                break;
                            }
                        }
                    }
                }
                else if (designEl.GetCtrlType() == ControlType.TableTree)
                {
                    TableTreeEl treeEl = (TableTreeEl)ControlEl;

                    List <CBaseObject> lstLWC = WindowControl.LinkageWindowControlMgr.GetList();
                    for (int i = 0; i < listLinkageWindowControl.Items.Count; i++)
                    {
                        listLinkageWindowControl.Items[i].Checked = false;
                    }
                    foreach (ListViewItem item in listLinkageWindowControl.Items)
                    {
                        CWindowControl wc = (CWindowControl)item.Tag;
                        foreach (CBaseObject obj in lstLWC)
                        {
                            CLinkageWindowControl lwc = (CLinkageWindowControl)obj;
                            if (lwc.SlaveID == wc.Id)
                            {
                                item.Checked = true;
                                break;
                            }
                        }
                    }
                }
                else if (designEl.GetCtrlType() == ControlType.ListBox)
                {
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();

                    richTextFilter.Text = TableInWindowControl.QueryFilter;


                    List <CBaseObject> lstLWC = WindowControl.LinkageWindowControlMgr.GetList();
                    for (int i = 0; i < listLinkageWindowControl.Items.Count; i++)
                    {
                        listLinkageWindowControl.Items[i].Checked = false;
                    }
                    foreach (ListViewItem item in listLinkageWindowControl.Items)
                    {
                        CWindowControl wc = (CWindowControl)item.Tag;
                        foreach (CBaseObject obj in lstLWC)
                        {
                            CLinkageWindowControl lwc = (CLinkageWindowControl)obj;
                            if (lwc.SlaveID == wc.Id)
                            {
                                item.Checked = true;
                                break;
                            }
                        }
                    }
                }
                else if (designEl.GetCtrlType() == ControlType.ComboBox)
                {
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();

                    richTextFilter.Text = TableInWindowControl.QueryFilter;


                    List <CBaseObject> lstLWC = WindowControl.LinkageWindowControlMgr.GetList();
                    for (int i = 0; i < listLinkageWindowControl.Items.Count; i++)
                    {
                        listLinkageWindowControl.Items[i].Checked = false;
                    }
                    foreach (ListViewItem item in listLinkageWindowControl.Items)
                    {
                        CWindowControl wc = (CWindowControl)item.Tag;
                        foreach (CBaseObject obj in lstLWC)
                        {
                            CLinkageWindowControl lwc = (CLinkageWindowControl)obj;
                            if (lwc.SlaveID == wc.Id)
                            {
                                item.Checked = true;
                                break;
                            }
                        }
                    }
                }
                else if (designEl.GetCtrlType() == ControlType.TableTab)
                {
                    TableTabEl            tab                  = (TableTabEl)ControlEl;
                    TableGridEl           tableGridEl          = tab.GetCurTableGridEl();
                    CTableInWindowControl TableInWindowControl = tableGridEl.TableInWindowControl;
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.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 = TableInWindowControl.ColumnInTableInWindowControlMgr.GetList();
                            foreach (CBaseObject obj2 in lstCIWC)
                            {
                                CColumnInTableInWindowControl ciwc = (CColumnInTableInWindowControl)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 = TableInWindowControl.TButtonInTableInWindowControlMgr.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)
                        {
                            CTButtonInTableInWindowControl tbiwc = (CTButtonInTableInWindowControl)obj;
                            if (tbiwc.Title.Equals(tbutton.Text, StringComparison.OrdinalIgnoreCase))
                            {
                                item.Checked = true;
                                bHas         = true;
                                break;
                            }
                        }
                        if (!bHas)
                        {
                            tbutton.Visible = false;
                        }
                    }

                    richTextFilter.Text = TableInWindowControl.QueryFilter;


                    List <CBaseObject> lstLWC = WindowControl.LinkageWindowControlMgr.GetList();
                    for (int i = 0; i < listLinkageWindowControl.Items.Count; i++)
                    {
                        listLinkageWindowControl.Items[i].Checked = false;
                    }
                    foreach (ListViewItem item in listLinkageWindowControl.Items)
                    {
                        CWindowControl wc = (CWindowControl)item.Tag;
                        foreach (CBaseObject obj in lstLWC)
                        {
                            CLinkageWindowControl lwc = (CLinkageWindowControl)obj;
                            if (lwc.SlaveID == wc.Id)
                            {
                                item.Checked = true;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
            }

            m_bIsLoading = false;
        }