Beispiel #1
0
        private void 多语言配置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SDPCRL.COM.ModelManager.LibDataSource            ds = null;
            SDPCRL.COM.ModelManager.FormTemplate.LibFormPage fm = null;
            SDPCRL.COM.ModelManager.LibKeyValueCollection    keyvaluecollection = null;
            TabPage page = this.libTabControl1.SelectedTab;

            if (page != null)
            {
                string[] nameAndtype = page.Name.Split(SysConstManage.Underline);
                NodeType ntype       = LibSysUtils.ConvertToEnumType <NodeType>(nameAndtype[1]);
                switch (ntype)
                {
                case NodeType.DataModel:
                    ds = ModelDesignProject.GetDataSourceById(nameAndtype[0]);
                    break;

                case NodeType.FormModel:
                    fm = ModelDesignProject.GetFormSourceByFormId(nameAndtype[0]);
                    if (fm != null && !string.IsNullOrEmpty(fm.DSID))
                    {
                        ds = ModelDesignProject.GetDataSourceById(fm.DSID);
                    }
                    break;

                case NodeType.KeyValues:
                    keyvaluecollection = ModelDesignProject.GetKeyvaluesByid(nameAndtype[0]);
                    break;
                }
            }
            WakeUpForm <LanguageConfig>("language", ds, fm, keyvaluecollection);
        }
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            LibTreeNode curentNode = (LibTreeNode)this.treeView1.SelectedNode;

            switch (e.ClickedItem.Name)
            {
            case "andTransField":     //添加转单字段
                if (this._Trans.TransFields == null)
                {
                    _Trans.TransFields = new LibCollection <LibTransFieldMap>();
                }
                var existfields = _Trans.TransFields.Tolist();
                if (string.IsNullOrEmpty(_Trans.SrcProgId))
                {
                    ExceptionManager.ThrowError("来源单progid 必填");
                    //MessageHandle.ShowMessage("来源单progid 必填",false);
                }
                var           formpage = ModelDesignProject.GetFormSourceByFormId(_Trans.SrcProgId);
                LibDataSource ds       = ModelDesignProject.GetDataSourceById(formpage.DSID);
                Panel         p        = new Panel();
                p.Dock       = DockStyle.Fill;
                p.Name       = "pfieldcollection";
                p.AutoScroll = true;
                TreeView tree = new TreeView();
                //tree.AfterCheck += new TreeViewEventHandler(Gridtree_AfterCheck);
                tree.CheckBoxes = true;
                tree.Dock       = DockStyle.Fill;
                p.Controls.Add(tree);
                LibTreeNode _node;
                if (ds.DefTables != null)
                {
                    List <ExistField> exists = new List <ExistField>();
                    foreach (var item in existfields)
                    {
                        exists.Add(new ExistField {
                            Name = item.SrcFieldNm, FromTableNm = item.SrcTableNm
                        });
                    }
                    DSUtiles.GetAllFieldsByDS(ds, tree, exists);
                }
                FieldCollectionForm fielsform = new FieldCollectionForm(p);
                DialogResult        dialog    = fielsform.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    curentNode.Nodes.Clear();
                    if (_Trans.TransFields != null && _Trans.TransFields.Count > 0)
                    {
                        _Trans.TransFields.RemoveAll();
                    }
                    foreach (LibTreeNode deftb in tree.Nodes)
                    {
                        foreach (LibTreeNode tbstruct in deftb.Nodes)
                        {
                            foreach (LibTreeNode f in tbstruct.Nodes)
                            {
                                if (!f.Checked)
                                {
                                    continue;
                                }
                                #region 添加节点
                                //树节点

                                LibTreeNode fieldNode = new LibTreeNode();
                                fieldNode.NodeId   = Guid.NewGuid().ToString();
                                fieldNode.NodeType = NodeType.TransField;
                                fieldNode.Name     = f.Name;
                                fieldNode.Text     = fieldNode.Name;
                                curentNode.Nodes.Add(fieldNode);

                                //控件属性
                                TransFieldProperty fieldProperty = new TransFieldProperty(fieldNode.NodeId);
                                _transFieldlst.Add(fieldProperty);
                                fieldProperty.Dock = DockStyle.Fill;
                                this.splitContainer1.Panel2.Controls.Add(fieldProperty);

                                //对应实体
                                LibTransFieldMap libtransfield = new LibTransFieldMap();
                                libtransfield.ID         = fieldNode.NodeId;
                                libtransfield.SrcFieldNm = f.Name;
                                libtransfield.SrcTableNm = (bool)f.Tag ? tbstruct.Name : string.Empty;
                                //libtransfield.FromDefTableNm = (bool)f.Tag ? deftb.Name : string.Empty;
                                libtransfield.SrcTableIndex   = Convert.ToInt32(tbstruct.NodeId);
                                libtransfield.SrcFieldDisplay = f.Text;
                                //libtransfield.Isdefine = !(bool)f.Tag;

                                _Trans.TransFields.Add(libtransfield);

                                fieldProperty.SetPropertyValue(libtransfield, fieldNode);

                                #endregion
                            }
                        }
                    }
                    UpdateTabPageText();
                }
                break;
            }
        }
        public override void TextAndBotton_Click(object sender, EventArgs e)
        {
            base.TextAndBotton_Click(sender, e);
            Control ctl   = sender as Control;
            string  ctrNm = ctl.Name.Replace(SysConstManage.BtnCtrlNmPrefix, "");

            if (_Node != null)
            {
                var            pnode       = _Node.Parent as TreeNode;
                LibTransSource transSource = pnode.Tag as LibTransSource;
                if (string.Compare(ctrNm, "tranfld_TargetFieldNm") == 0)
                {
                    if (string.IsNullOrEmpty(transSource.TargetProgId))
                    {
                        ExceptionManager.ThrowError("目标单progid 必填");
                        //MessageHandle.ShowMessage("来源单progid 必填",false);
                    }
                    var           formpage = ModelDesignProject.GetFormSourceByFormId(transSource.TargetProgId);
                    LibDataSource ds       = ModelDesignProject.GetDataSourceById(formpage.DSID);
                    Panel         p        = new Panel();
                    p.Dock       = DockStyle.Fill;
                    p.Name       = "pfieldcollection";
                    p.AutoScroll = true;
                    TreeView tree = new TreeView();
                    tree.AfterCheck += new TreeViewEventHandler(tree_AfterCheck);
                    tree.CheckBoxes  = true;
                    tree.Dock        = DockStyle.Fill;
                    p.Controls.Add(tree);
                    //LibTreeNode _node;
                    if (ds.DefTables != null)
                    {
                        List <ExistField> exists = new List <ExistField>();
                        exists.Add(new ExistField {
                            Name = this.entity.TargetFieldNm, FromTableNm = this.entity.TargetTableNm
                        });
                        DSUtiles.GetAllFieldsByDS(ds, tree, exists);
                    }

                    FieldCollectionForm fielsform = new FieldCollectionForm(p);
                    DialogResult        dialog    = fielsform.ShowDialog(this);
                    if (dialog == DialogResult.OK)
                    {
                        foreach (LibTreeNode deftb in tree.Nodes)
                        {
                            foreach (LibTreeNode tbstruct in deftb.Nodes)
                            {
                                foreach (LibTreeNode f in tbstruct.Nodes)
                                {
                                    if (!f.Checked)
                                    {
                                        continue;
                                    }
                                    this.entity.TargetFieldNm      = f.Name;
                                    this.entity.TargetFieldDisplay = f.Text;
                                    this.entity.TargetTableNm      = (bool)f.Tag ? tbstruct.Name : string.Empty;
                                    this.entity.TargetTableIndex   = Convert.ToInt32(tbstruct.NodeId);
                                    break;
                                }
                            }
                        }
                        this.SetPropertyValue(this.entity, _Node);
                        UpdateTabPageText();
                    }
                }
            }
        }
Beispiel #4
0
        private void contextMenuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            LibTreeNode   curentNode        = (LibTreeNode)this.treeView1.SelectedNode;
            LibReportGrid currentlibrptgrid = _rpt.GridGroups.FindFirst("GridGroupID", curentNode.NodeId);

            switch (e.ClickedItem.Name)
            {
            case "AddFromDSField":     //添加数据源字段
                if (currentlibrptgrid.ReportFields == null)
                {
                    currentlibrptgrid.ReportFields = new LibCollection <LibReportField>();
                }
                var           existfields = currentlibrptgrid.ReportFields.Tolist();
                LibDataSource ds          = ModelDesignProject.GetDataSourceById(currentlibrptgrid.DSID);
                Panel         p           = new Panel();
                p.Dock       = DockStyle.Fill;
                p.Name       = "pfieldcollection";
                p.AutoScroll = true;
                TreeView tree = new TreeView();
                tree.AfterCheck += new TreeViewEventHandler(Gridtree_AfterCheck);
                tree.CheckBoxes  = true;
                tree.Dock        = DockStyle.Fill;
                p.Controls.Add(tree);
                LibTreeNode _node;
                if (ds.DefTables != null)
                {
                    List <ExistField> exists = new List <ExistField>();
                    foreach (var item in existfields)
                    {
                        exists.Add(new ExistField {
                            Name = item.Name, FromTableNm = item.FromTableNm
                        });
                    }
                    DSUtiles.GetAllFieldsByDS(ds, tree, exists);
                    #region 收集数据源字段
                    //foreach (LibDefineTable deftb in ds.DefTables)
                    //{
                    //    LibTreeNode deftbnode = new LibTreeNode();
                    //    deftbnode.Name = deftb.TableName;
                    //    deftbnode.Text = string.Format("{0}({1})", deftb.DisplayName, deftb.TableName);
                    //    tree.Nodes.Add(deftbnode);
                    //    if (deftb.TableStruct != null)
                    //    {
                    //        foreach (LibDataTableStruct dtstruct in deftb.TableStruct)
                    //        {
                    //            LibTreeNode dtstructnode = new LibTreeNode();
                    //            dtstructnode.Name = dtstruct.Name;
                    //            dtstructnode.Text = string.Format("{0}({1})", dtstruct.DisplayName, dtstruct.Name);
                    //            dtstructnode.NodeId = dtstruct.TableIndex.ToString();
                    //            deftbnode.Nodes.Add(dtstructnode);
                    //            if (dtstruct.Fields != null)
                    //            {
                    //                foreach (LibField fld in dtstruct.Fields)
                    //                {
                    //                    if (!fld.IsActive) continue;
                    //                    _node = new LibTreeNode();
                    //                    _node.Name = fld.Name;
                    //                    _node.Text = fld.DisplayName;
                    //                    _node.Tag = true;
                    //                    _node.Checked = existfields.FirstOrDefault(i => i.Name == fld.Name && i.FromTableNm == dtstruct.Name) != null;
                    //                    dtstructnode.Nodes.Add(_node);
                    //                    if (fld.SourceField != null && fld.SourceField.Count > 0)
                    //                    {
                    //                        foreach (LibFromSourceField fromfld in fld.SourceField)
                    //                        {
                    //                            if (fromfld.RelateFieldNm != null && fromfld.RelateFieldNm.Count > 0)
                    //                            {
                    //                                foreach (LibRelateField relateField in fromfld.RelateFieldNm)
                    //                                {
                    //                                    if (relateField != null)
                    //                                    {
                    //                                        _node = new LibTreeNode();
                    //                                        _node.Name = string.IsNullOrEmpty(relateField.AliasName) ? relateField.FieldNm : relateField.AliasName;
                    //                                        _node.Text = relateField.DisplayNm;
                    //                                        _node.Tag = false;
                    //                                        _node.Checked = existfields.FirstOrDefault(i => i.Name == _node.Name && i.FromTableNm == dtstruct.Name) != null;
                    //                                        dtstructnode.Nodes.Add(_node);
                    //                                    }
                    //                                }
                    //                            }
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                    #endregion
                }
                FieldCollectionForm fielsform = new FieldCollectionForm(p);
                DialogResult        dialog    = fielsform.ShowDialog(this);

                if (dialog == DialogResult.OK)
                {
                    curentNode.Nodes.Clear();
                    if (currentlibrptgrid.ReportFields != null && currentlibrptgrid.ReportFields.Count > 0)
                    {
                        currentlibrptgrid.ReportFields.RemoveAll();
                    }
                    foreach (LibTreeNode deftb in tree.Nodes)
                    {
                        foreach (LibTreeNode tbstruct in deftb.Nodes)
                        {
                            foreach (LibTreeNode f in tbstruct.Nodes)
                            {
                                if (!f.Checked)
                                {
                                    continue;
                                }
                                #region 添加节点
                                //树节点

                                LibTreeNode fieldNode = new LibTreeNode();
                                fieldNode.NodeId   = Guid.NewGuid().ToString();
                                fieldNode.NodeType = NodeType.GridGroup_Field;
                                fieldNode.Name     = f.Name;
                                fieldNode.Text     = fieldNode.Name;
                                curentNode.Nodes.Add(fieldNode);

                                //控件属性
                                ReportFieldProperty rptfieldProperty = new ReportFieldProperty(fieldNode.NodeId);
                                _reportFieldlst.Add(rptfieldProperty);
                                rptfieldProperty.Dock = DockStyle.Fill;
                                this.splitContainer1.Panel2.Controls.Add(rptfieldProperty);

                                //对应实体
                                LibReportField librptfield = new LibReportField();
                                librptfield.ID             = fieldNode.NodeId;
                                librptfield.Name           = f.Name;
                                librptfield.FromTableNm    = (bool)f.Tag? tbstruct.Name:string.Empty;
                                librptfield.FromDefTableNm = (bool)f.Tag ? deftb.Name:string.Empty;
                                librptfield.FromTableIndex = Convert.ToInt32(tbstruct.NodeId);
                                librptfield.DisplayName    = f.Text;
                                librptfield.Isdefine       = !(bool)f.Tag;

                                currentlibrptgrid.ReportFields.Add(librptfield);

                                rptfieldProperty.SetPropertyValue(librptfield, fieldNode);

                                #endregion
                            }
                        }
                    }
                    UpdateTabPageText();
                }
                break;

            case "AddDefineField":    //添加自定义字段
                break;
            }
        }
        public override void TextAndBotton_Click(object sender, EventArgs e)
        {
            base.TextAndBotton_Click(sender, e);
            Control ctl   = sender as Control;
            string  ctrNm = ctl.Name.Replace(SysConstManage.BtnCtrlNmPrefix, "");
            Panel   p     = new Panel();

            p.Dock       = DockStyle.Fill;
            p.Name       = "pfieldcollection";
            p.AutoScroll = true;
            ListBox listBox = new ListBox();

            listBox.Dock = DockStyle.Fill;
            p.Controls.Add(listBox);
            if (string.Compare(ctrNm, "rptGrid_DSID") == 0) //选择数据源ID
            {
                string[] dsarray = ModelManager.GetAllDataSourceNm(string.Empty);
                if (dsarray != null && dsarray.Length > 0)
                {
                    foreach (string item in dsarray)
                    {
                        listBox.Items.Add(item);
                    }
                }
                FieldCollectionForm fielsform = new FieldCollectionForm(p);
                DialogResult        dialog    = fielsform.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    if (listBox.SelectedItem == null)
                    {
                        return;
                    }
                    if (this.Controls[ctrNm].Text.Trim() != listBox.SelectedItem.ToString())
                    {
                        this.Controls[ctrNm].Text = listBox.SelectedItem.ToString();
                        this.entity.DSID          = listBox.SelectedItem.ToString();
                    }
                }
            }
            else if (string.Compare(ctrNm, "rptGrid_FromTable") == 0) //来源表
            {
                if (!string.IsNullOrEmpty(this.entity.DSID))
                {
                    LibDataSource ds = ModelDesignProject.GetDataSourceById(this.entity.DSID);
                    if (ds != null && ds.DefTables != null)
                    {
                        foreach (LibDefineTable deftb in ds.DefTables)
                        {
                            if (deftb.TableStruct != null)
                            {
                                foreach (LibDataTableStruct tb in deftb.TableStruct)
                                {
                                    listBox.Items.Add(tb.Name);
                                }
                            }
                        }
                    }
                }
                FieldCollectionForm fielsform = new FieldCollectionForm(p);
                DialogResult        dialog    = fielsform.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    if (listBox.SelectedItem == null)
                    {
                        return;
                    }
                    if (this.Controls[ctrNm].Text.Trim() != listBox.SelectedItem.ToString())
                    {
                        this.Controls[ctrNm].Text = listBox.SelectedItem.ToString();
                        this.entity.FromTable     = listBox.SelectedItem.ToString();
                    }
                }
            }
        }
Beispiel #6
0
        private void DataSourceControl_Load(object sender, EventArgs e)
        {
            _ds = ModelDesignProject.GetDataSourceById(_funNode.Name);
            //数据集节点
            LibTreeNode dsNode = new LibTreeNode();

            dsNode.Name     = _funNode.Name;
            dsNode.Text     = ReSourceManage.GetResource(NodeType.DefDataSet);
            dsNode.NodeType = NodeType.DefDataSet;

            if (_ds.DefTables == null)
            {
                _ds.DefTables = new LibCollection <LibDefineTable>();
                //自定义表节点
                #region
                LibTreeNode defTBNode = new LibTreeNode();
                defTBNode.NodeId   = Guid.NewGuid().ToString();
                defTBNode.Name     = string.Format("{0}", _funNode.Name);
                defTBNode.Text     = string.Format("{0}({1})", _funNode.Text, defTBNode.Name);
                defTBNode.NodeType = NodeType.DefindTable;
                dsNode.Nodes.Add(defTBNode);

                //this._defTBPropertylst = new List<DefTBProperty>();
                DefTBProperty deftbp = new DefTBProperty(defTBNode.NodeId);
                deftbp.Dock = DockStyle.Fill;
                this._defTBPropertylst.Add(deftbp);
                this.splitContainer1.Panel2.Controls.Add(deftbp);

                LibDefineTable definetb = new LibDefineTable();
                definetb.ID          = defTBNode.NodeId;
                definetb.TableName   = defTBNode.Name;
                definetb.DisplayName = defTBNode.Text;
                _ds.DefTables.Add(definetb);

                deftbp.SetPropertyValue(definetb, defTBNode);
                #endregion

                //数据结构表
                #region
                LibTreeNode tablestruc = new LibTreeNode();
                tablestruc.NodeId   = Guid.NewGuid().ToString();
                tablestruc.Name     = string.Format("{0}", _funNode.Name);
                tablestruc.Text     = string.Format("{0}-{1}", "数据表", _funNode.Name);
                tablestruc.NodeType = NodeType.TableStruct;
                defTBNode.Nodes.Add(tablestruc);

                //this._tbStructPropertylst = new List<TBStructProperty>();
                TBStructProperty tbstructP = new TBStructProperty(tablestruc.NodeId);
                tbstructP.Dock = DockStyle.Fill;
                this._tbStructPropertylst.Add(tbstructP);
                this.splitContainer1.Panel2.Controls.Add(tbstructP);


                LibDataTableStruct tbstruct = new LibDataTableStruct();
                tbstruct.ID          = tablestruc.NodeId;
                tbstruct.Name        = tablestruc.Name;
                tbstruct.DisplayName = tablestruc.Text;
                definetb.TableStruct = new LibCollection <LibDataTableStruct>();
                definetb.TableStruct.Add(tbstruct);

                tbstructP.SetPropertyValue(tbstruct, tablestruc);
                #endregion
            }
            else
            {
                LibTreeNode node         = null;
                LibTreeNode dtstructNode = null;
                LibTreeNode fieldNode    = null;
                foreach (LibDefineTable item in _ds.DefTables)
                {
                    node          = new LibTreeNode();
                    node.NodeId   = item.ID;
                    node.Name     = item.TableName;
                    node.Text     = string.Format("{0}({1})", item.DisplayName, item.TableName);
                    node.NodeType = NodeType.DefindTable;
                    dsNode.Nodes.Add(node);
                    if (item.TableStruct != null)
                    {
                        foreach (LibDataTableStruct dtstruct in item.TableStruct)
                        {
                            #region 添加表结构节点
                            dtstructNode          = new LibTreeNode();
                            dtstructNode.NodeId   = dtstruct.ID;
                            dtstructNode.Name     = dtstruct.Name;
                            dtstructNode.Text     = string.Format("{0}-{1}", "数据表", dtstruct.Name);
                            dtstructNode.NodeType = NodeType.TableStruct;
                            node.Nodes.Add(dtstructNode);
                            #endregion
                            if (dtstruct.Fields != null)
                            {
                                foreach (LibField field in dtstruct.Fields)
                                {
                                    #region 添加字段节点
                                    fieldNode          = new LibTreeNode();
                                    fieldNode.NodeId   = field.ID;
                                    fieldNode.Name     = field.Name;
                                    fieldNode.Text     = string.Format("{0}({1})", field.Name, field.DisplayName);
                                    fieldNode.NodeType = NodeType.Field;
                                    dtstructNode.Nodes.Add(fieldNode);
                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
            this.treeView1.Nodes.Add(dsNode);
            this.treeView1.SelectedNode = dsNode;
        }