Ejemplo n.º 1
0
        private TreeNode AddGroupItem(TreeNode node, MewsDataBase data)
        {
            TreeNode subNode = new TreeNode();

            subNode.Name = data.Code.ToString();
            subNode.Text = data.Name;
            subNode.Tag  = data;

            if (data is TermData)
            {
                TermData term = data as TermData;
                subNode.ImageIndex         = 3;
                subNode.SelectedImageIndex = 3;
            }
            else if (data is DistData)
            {
                DistData dist = data as DistData;
                subNode.ImageIndex         = 2;
                subNode.SelectedImageIndex = 2;

                //if (dbMng.DicDist.ContainsKey(dist.Code.ToString()))
                //{
                //    foreach (KeyValuePair<string, TermData> pairTerm in dbMng.DicDist[dist.Code.ToString()].dicTermData)
                //    {
                //        AddGroupItem(subNode, pairTerm.Value);
                //    }
                //}
            }
            else if (data is ProvData)
            {
                ProvData prov = data as ProvData;
                subNode.ImageIndex         = 1;
                subNode.SelectedImageIndex = 1;

                //if (dbMng.DicProv.ContainsKey(prov.Code.ToString()))
                //{
                //    foreach (KeyValuePair<string, DistData> pairDist in dbMng.DicProv[prov.Code.ToString()].dicDistData)
                //    {
                //        AddGroupItem(subNode, pairDist.Value);
                //    }
                //}
            }

            node.Nodes.Add(subNode);

            return(subNode);
        }
Ejemplo n.º 2
0
        private void btnMove_Click(object sender, EventArgs e)
        {
            Dictionary <string, TermData> dicTermTemp = new Dictionary <string, TermData>();
            Dictionary <string, DistData> dicDistTemp = new Dictionary <string, DistData>();
            Dictionary <string, ProvData> dicProvTemp = new Dictionary <string, ProvData>();

            foreach (TreeNode nodeProv in tvAll.Nodes[0].Nodes)
            {
                // Add Prov All
                if (nodeProv.Checked)
                {
                    ProvData prov = nodeProv.Tag as ProvData;
                    dicProvTemp.Add(prov.Code.ToString(), prov);
                }
                else
                {
                    foreach (TreeNode nodeDist in nodeProv.Nodes)
                    {
                        //  Add Dist All
                        if (nodeDist.Checked)
                        {
                            DistData dist = nodeDist.Tag as DistData;
                            dicDistTemp.Add(dist.Code.ToString(), dist);
                        }
                        else
                        {
                            foreach (TreeNode nodeTerm in nodeDist.Nodes)
                            {
                                // Add Term One
                                if (nodeTerm.Checked)
                                {
                                    TermData term = nodeTerm.Tag as TermData;
                                    dicTermTemp.Add(term.Code.ToString(), term);
                                }
                            }
                        }
                    }
                }
            }

            if (dicTermTemp.Count == 0 && dicDistTemp.Count == 0 && dicProvTemp.Count == 0)
            {
                MessageBox.Show(LangPack.GetMongolian("Please select terminal/province/district."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            TreeNode grpNode = tvGrp.SelectedNode;

            if (grpNode == null || !(grpNode.Tag is Group))
            {
                MessageBox.Show(LangPack.GetMongolian("Please select group."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (grpNode.Nodes.Count >= 17)
            {
                MessageBox.Show(LangPack.GetMongolian("A group of up to sixteen members."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if ((grpNode.Nodes.Count + dicProvTemp.Count + dicDistTemp.Count + dicTermTemp.Count) > 16)
            {
                MessageBox.Show(LangPack.GetMongolian("A group of up to sixteen members."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Group gp = grpNode.Tag as Group;

            grpMng.UpdateGrpProv(gp.Key, dicProvTemp);
            grpMng.UpdateGrpDist(gp.Key, dicDistTemp);
            grpMng.UpdateGrpTerm(gp.Key, dicTermTemp);

            DisplayGroupTree();

            tvAll.Nodes[0].Checked = false;
        }
Ejemplo n.º 3
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            bool bRult = false;

            TreeNode node    = tvGrp.SelectedNode;
            TreeNode prtNode = node;

            if (node == null)
            {
                MessageBox.Show(LangPack.GetMongolian("Please select the items to delete."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (DialogResult.No == MessageBox.Show(LangPack.GetMongolian("Want to delete?"), LangPack.GetMongolian(this.Name), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2))
            {
                return;
            }

            if (node.Tag is Group)
            {
                Group gp = node.Tag as Group;
                bRult = grpMng.DeleteGrp(gp.Key);
            }
            else
            {
                int    iCnt   = 0;
                string grpKey = string.Empty;

                while (true)
                {
                    // 무한 Loop 방지
                    iCnt++;
                    if (iCnt > 100)
                    {
                        return;
                    }

                    prtNode = prtNode.Parent;

                    if (prtNode.Tag is Group)
                    {
                        grpKey = (prtNode.Tag as Group).Key;
                        break;
                    }
                }

                if (node.Tag is ProvData)
                {
                    ProvData prov = node.Tag as ProvData;
                    bRult = grpMng.DeleteGrpProv(grpKey, prov);
                }
                else if (node.Tag is DistData)
                {
                    DistData dist = node.Tag as DistData;
                    bRult = grpMng.DeleteGrpDist(grpKey, dist);
                }
                else if (node.Tag is TermData)
                {
                    TermData term = node.Tag as TermData;
                    bRult = grpMng.DeleteGrpTerm(grpKey, term);
                }
            }

            tvGrp.Nodes.Remove(node);

            if (bRult)
            {
                MessageBox.Show(LangPack.GetMongolian("Deleted."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(LangPack.GetMongolian("Failed."), LangPack.GetMongolian(this.Name), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DisplayGroupTree();
        }