Exemple #1
0
        private void f_Load_Tree()
        {
            try
            {
                treeView1.Nodes.Clear();
                TreeNode anode, anode1;
                DataSet  adsloai, adsnhom;
                string   asort = "ten";
                asort                    = "stt";
                anode                    = new TreeNode(lan.Change_language_MessageText("Tất cả"));
                anode.Tag                = "?:?";
                anode.ImageIndex         = 2;
                anode.SelectedImageIndex = 2;
                treeView1.Nodes.Add(anode);

                adsnhom = v.f_get_v_nhomvp_frmgiavp();
                adsloai = v.f_get_v_loaivp_frmgiavp();
                foreach (DataRow r in adsnhom.Tables[0].Select("", asort))
                {
                    anode                    = new TreeNode(r["ten"].ToString());
                    anode.Tag                = r["ma"].ToString() + ":?";
                    anode.ImageIndex         = 0;
                    anode.SelectedImageIndex = 0;
                    treeView1.Nodes.Add(anode);
                    foreach (DataRow r1 in adsloai.Tables[0].Select("id_nhom=" + r["ma"].ToString(), asort))
                    {
                        anode1                    = new TreeNode(r1["ten"].ToString());
                        anode1.Tag                = r["ma"].ToString() + ":" + r1["id"].ToString();
                        anode1.ImageIndex         = 1;
                        anode1.SelectedImageIndex = 1;
                        anode.Nodes.Add(anode1);
                    }
                }

                if (adsnhom.Tables[0].Select("ma=-1").Length < 0)
                {
                    DataRow ar = adsnhom.Tables[0].NewRow();
                    ar["ma"]         = -1;
                    ar["ten"]        = "...";
                    ar["idnhombhyt"] = -1;
                    adsloai.Tables[0].Rows.InsertAt(ar, adsnhom.Tables[0].Rows.Count);
                }
                if (adsloai.Tables[0].Select("id=-1").Length < 0)
                {
                    DataRow ar1 = adsnhom.Tables[0].NewRow();
                    ar1["id"]      = -1;
                    ar1["ten"]     = "...";
                    ar1["id_nhom"] = -1;
                    adsloai.Tables[0].Rows.InsertAt(ar1, adsloai.Tables[0].Rows.Count);
                }
            }
            catch
            {
            }
        }