Пример #1
0
        private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.CancelEdit)
            {
                return;
            }

            if (e.Node.Tag.GetType() == typeof(CalModel))
            {
                CalModel model = e.Node.Tag as CalModel;
                if (model != null)
                {
                    model.ModelName = e.Label;
                }
            }

            if (e.Node.Tag.GetType() == typeof(CalOrg))
            {
                CalOrg org = e.Node.Tag as CalOrg;
                if (org != null)
                {
                    org.OrgName = e.Label;
                }
            }
        }
Пример #2
0
        private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                string clipTags = Clipboard.GetData(DataFormats.UnicodeText).ToString();
                System.IO.StringReader strReader = new System.IO.StringReader(clipTags);
                string tagName = null;
                while ((tagName = strReader.ReadLine()) != null)
                {
                    if (node.Tag.GetType() == typeof(CalModel))
                    {
                        CalModel model = node.Tag as CalModel;
                        if (model != null)
                        {
                            CalTag nTag = model.AddTag(tagName);
                        }
                    }
                    else if (node.Tag.GetType() == typeof(CalOrg))
                    {
                        CalOrg org = node.Tag as CalOrg;
                        if (org != null)
                        {
                            CalTag nTag = org.AddTag(tagName);
                        }
                    }
                }
                strReader.Close();
                bindingSource1.ResetBindings(false);
            }
        }
Пример #3
0
        private void  除组织ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                if (node.Tag.GetType() == typeof(CalOrg))
                {
                    if (node.Parent != null)
                    {
                        if (node.Parent.Tag.GetType() == typeof(CalModel))
                        {
                            if (MessageBox.Show("确实要删除吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                CalModel model = node.Parent.Tag as CalModel;
                                model.RemoveOrg(node.Tag as CalOrg);
                                treeView1.SelectedNode.Remove();
                            }
                        }
                        else if (node.Parent.Tag.GetType() == typeof(CalOrg))
                        {
                            if (MessageBox.Show("确实要删除吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                CalOrg parentOrg = node.Parent.Tag as CalOrg;
                                parentOrg.RemoveOrg(node.Tag as CalOrg);
                                treeView1.SelectedNode.Remove();
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                if (node.Tag.GetType() == typeof(CalModel))
                {
                    CalModel model = node.Tag as CalModel;
                    if (ckbViewType.Checked)
                    {
                        oriData = model.AllCalTags;
                    }
                    else
                    {
                        oriData = model.RootTags;
                    }
                }
                else if (node.Tag.GetType() == typeof(CalOrg))
                {
                    CalOrg org = node.Tag as CalOrg;
                    oriData = org.CalTags;
                }

                Filter();
            }
        }
Пример #5
0
        private void 添加标签_Click(object sender, EventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                NameDialog dialog = new NameDialog();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (node.Tag.GetType() == typeof(CalModel))
                    {
                        CalModel model = node.Tag as CalModel;
                        if (model != null)
                        {
                            model.AddTag(dialog.Result);
                        }
                    }
                    else if (node.Tag.GetType() == typeof(CalOrg))
                    {
                        CalOrg org = node.Tag as CalOrg;
                        if (org != null)
                        {
                            org.AddTag(dialog.Result);
                        }
                    }
                    bindingSource1.ResetBindings(false);
                }
            }
        }
Пример #6
0
        private void 添加组织结构ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                NameDialog dialog = new NameDialog();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (node.Tag.GetType() == typeof(CalModel))
                    {
                        CalModel model = node.Tag as CalModel;
                        if (model != null)
                        {
                            CalOrg   nOrg  = model.AddOrg(dialog.Result);
                            TreeNode nNode = node.Nodes.Add(nOrg.OrgName);
                            nNode.Tag = nOrg;
                        }
                    }
                    else if (node.Tag.GetType() == typeof(CalOrg))
                    {
                        CalOrg org = node.Tag as CalOrg;
                        if (org != null)
                        {
                            CalOrg   nOrg  = org.AddOrg(dialog.Result);
                            TreeNode nNode = node.Nodes.Add(nOrg.OrgName);
                            nNode.Tag = nOrg;
                        }
                    }
                }
            }
        }
Пример #7
0
        private void AddOrgNode(TreeNode node, CalOrg org)
        {
            TreeNode orgNode = node.Nodes.Add(org.OrgName);

            orgNode.Tag = org;
            foreach (var subOrg in org.ChildCalOrgs)
            {
                AddOrgNode(orgNode, subOrg);
            }
        }
Пример #8
0
        private CalOrg getSelectedCalOrg()
        {
            CalOrg   result = null;
            TreeNode node   = this.treeView1.SelectedNode;

            if (node != null)
            {
                if (node.Tag.GetType() == typeof(CalOrg))
                {
                    result = node.Tag as CalOrg;
                }
            }
            return(result);
        }
Пример #9
0
 private void  移ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (c1FlexGrid1.RowSel >= 0)
     {
         Row    row = c1FlexGrid1.Rows[c1FlexGrid1.RowSel];
         CalTag tag = row.DataSource as CalTag;
         if (tag != null)
         {
             CalOrg parent = tag.MyCalOrg;
             if (parent != null)
             {
                 parent.DownIdx(tag);
             }
         }
         c1FlexGrid1.Refresh();
     }
 }
Пример #10
0
        private void 添加标签ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.treeView1.SelectedNode;

            if (node != null)
            {
                NameDialog dialog = new NameDialog();
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    //string tagName = dialog.Result;
                    //string formula = "";
                    //int splitIdx = dialog.Result.IndexOf('=');
                    //if (splitIdx > 0)
                    //{
                    //    tagName = dialog.Result.Substring(0, splitIdx);
                    //    formula = dialog.Result.Substring(splitIdx, dialog.Result.Length - splitIdx - 1);
                    //}

                    if (node.Tag.GetType() == typeof(CalModel))
                    {
                        CalModel model = node.Tag as CalModel;
                        if (model != null)
                        {
                            model.AddTagGroup(dialog.Result);
                        }
                    }
                    else if (node.Tag.GetType() == typeof(CalOrg))
                    {
                        CalOrg org = node.Tag as CalOrg;
                        if (org != null)
                        {
                            org.AddTagGroup(dialog.Result);
                        }
                    }
                    bindingSource1.ResetBindings(false);
                }
            }
        }
Пример #11
0
        public CalModel GetModel(string modelName)
        {
            CalModel model = null;

            Dictionary <string, CalOrg> allOrgs = new Dictionary <string, CalOrg>();

            conn.Open();
            OracleCommand selectModelCmd = new OracleCommand();

            selectModelCmd.Connection  = conn;
            selectModelCmd.CommandText = "Select EID,MODELNAME From CALF_CALMODEL Where MODELNAME='" + modelName + "'";
            OracleDataReader drModel = selectModelCmd.ExecuteReader();

            if (drModel.Read())
            {
                model           = new CalModel();
                model.EID       = drModel.GetString(0);
                model.ModelName = drModel.IsDBNull(1) ? "" : drModel.GetString(1);
                model.ReSet();
            }
            drModel.Close();

            if (model != null)
            {
                OracleCommand selectOrgCmd = new OracleCommand();
                selectOrgCmd.Connection  = conn;
                selectOrgCmd.CommandText = "Select EID,CALMODELID,PARENTID,ORGNAME From CALF_CALORG Where CALMODELID='" + model.EID + "' ORDER By ORGNAME";
                OracleDataReader drOrg = selectOrgCmd.ExecuteReader();
                while (drOrg.Read())
                {
                    CalOrg org = new CalOrg();
                    org.EID = drOrg.GetString(0);
                    if (allOrgs.ContainsKey(org.EID))
                    {
                        org = allOrgs[org.EID];
                    }
                    else
                    {
                        allOrgs.Add(org.EID, org);
                    }
                    org.MyModel = model;
                    model.AllCalOrgs.Add(org);
                    if (!drOrg.IsDBNull(2))
                    {
                        string parentOrgID = drOrg.GetString(2);
                        if (allOrgs.ContainsKey(parentOrgID))
                        {
                            org.ParentCalOrg = allOrgs[parentOrgID];
                            org.ParentCalOrg.ChildCalOrgs.Add(org);
                        }
                        else
                        {
                            CalOrg parentOrg = new CalOrg();
                            parentOrg.EID    = parentOrgID;
                            org.ParentCalOrg = parentOrg;
                            parentOrg.ChildCalOrgs.Add(org);
                            allOrgs.Add(parentOrgID, parentOrg);
                        }
                    }
                    else
                    {
                        model.RootOrgs.Add(org);
                    }
                    org.OrgName = drOrg.IsDBNull(3) ? "" : drOrg.GetString(3);
                    org.ReSet();
                }
                drOrg.Close();

                OracleCommand selectTagCmd = new OracleCommand();
                selectTagCmd.Connection  = conn;
                selectTagCmd.CommandText = "Select EID,CALMODELID,CALORGID,TAGNAME,FORMA,DEC From CALF_CALTAG Where CALMODELID='" + model.EID + "' order by IDX";
                OracleDataReader drTag = selectTagCmd.ExecuteReader();
                while (drTag.Read())
                {
                    CalTag tag = new CalTag();
                    tag.EID = drTag.GetString(0);
                    model.AllCalTags.Add(tag);
                    tag.MyModel = model;

                    if (!drTag.IsDBNull(2) && allOrgs.ContainsKey(drTag.GetString(2)))
                    {
                        string parentOrgID = drTag.GetString(2);
                        allOrgs[parentOrgID].CalTags.Add(tag);
                        tag.MyCalOrg = allOrgs[parentOrgID];
                    }
                    else
                    {
                        model.RootTags.Add(tag);
                    }

                    tag.TagName = drTag.IsDBNull(3) ? "" : drTag.GetString(3);
                    tag.Forma   = drTag.IsDBNull(4) ? "" : drTag.GetString(4);
                    if (!drTag.IsDBNull(5))
                    {
                        tag.Dec = drTag.GetInt32(5);
                    }
                    tag.ReSet();
                }
                drTag.Close();
            }
            conn.Close();
            return(model);
        }
Пример #12
0
        public List <CalModel> GetAllModels()
        {
            Dictionary <string, CalModel> allModels = new Dictionary <string, CalModel>();
            Dictionary <string, CalOrg>   allOrgs   = new Dictionary <string, CalOrg>();

            conn.Open();
            OracleCommand selectModelCmd = new OracleCommand();

            selectModelCmd.Connection  = conn;
            selectModelCmd.CommandText = "Select EID,MODELNAME From CALF_CALMODEL order by MODELNAME";
            OracleDataReader drModel = selectModelCmd.ExecuteReader();

            while (drModel.Read())
            {
                CalModel model = new CalModel();
                model.EID       = drModel.GetString(0);
                model.ModelName = drModel.IsDBNull(1) ? "" : drModel.GetString(1);
                allModels.Add(model.EID, model);
                model.ReSet();
            }
            drModel.Close();

            OracleCommand selectOrgCmd = new OracleCommand();

            selectOrgCmd.Connection  = conn;
            selectOrgCmd.CommandText = "Select EID,CALMODELID,PARENTID,ORGNAME From CALF_CALORG order by orgname";
            OracleDataReader drOrg = selectOrgCmd.ExecuteReader();

            while (drOrg.Read())
            {
                CalOrg org = new CalOrg();
                org.EID = drOrg.GetString(0);
                if (allOrgs.ContainsKey(org.EID))
                {
                    org = allOrgs[org.EID];
                }
                else
                {
                    allOrgs.Add(org.EID, org);
                }
                CalModel myModel = allModels[drOrg.GetString(1)];
                org.MyModel = myModel;
                myModel.AllCalOrgs.Add(org);
                if (!drOrg.IsDBNull(2))
                {
                    string parentOrgID = drOrg.GetString(2);
                    if (allOrgs.ContainsKey(parentOrgID))
                    {
                        org.ParentCalOrg = allOrgs[parentOrgID];
                        org.ParentCalOrg.ChildCalOrgs.Add(org);
                    }
                    else
                    {
                        CalOrg parentOrg = new CalOrg();
                        parentOrg.EID    = parentOrgID;
                        org.ParentCalOrg = parentOrg;
                        parentOrg.ChildCalOrgs.Add(org);
                        allOrgs.Add(parentOrgID, parentOrg);
                    }
                }
                else
                {
                    myModel.RootOrgs.Add(org);
                }
                org.OrgName = drOrg.IsDBNull(3) ? "" : drOrg.GetString(3);

                org.ReSet();
            }
            drOrg.Close();

            OracleCommand selectTagCmd = new OracleCommand();

            selectTagCmd.Connection  = conn;
            selectTagCmd.CommandText = "Select EID,CALMODELID,CALORGID,TAGNAME,FORMA,DEC From CALF_CALTAG order by CALMODELID,CALORGID,IDX";
            OracleDataReader drTag = selectTagCmd.ExecuteReader();

            while (drTag.Read())
            {
                CalTag tag = new CalTag();
                tag.EID = drTag.GetString(0);
                CalModel myModel = allModels[drTag.GetString(1)];
                myModel.AllCalTags.Add(tag);
                tag.MyModel = myModel;

                if (!drTag.IsDBNull(2))
                {
                    string parentOrgID = drTag.GetString(2);
                    allOrgs[parentOrgID].CalTags.Add(tag);
                    tag.MyCalOrg = allOrgs[parentOrgID];
                }
                else
                {
                    myModel.RootTags.Add(tag);
                }

                tag.TagName = drTag.IsDBNull(3) ? "" : drTag.GetString(3);
                tag.Forma   = drTag.IsDBNull(4) ? "" : drTag.GetString(4);
                if (!drTag.IsDBNull(5))
                {
                    tag.Dec = drTag.GetInt32(5);
                }
                tag.ReSet();
            }
            drTag.Close();

            conn.Close();

            List <CalModel> result = new List <CalModel>();

            result.AddRange(allModels.Values);
            return(result);
        }