Exemplo n.º 1
0
        private void f_Load_Tree()
        {
            treeView1.Nodes.Clear();
            TreeNode anode, anode1;
            DataSet  adsloai, adsgia;

            adsgia  = m_v.f_get_v_giavp_frmgiavp();
            adsloai = m_v.f_get_v_loaivp_frmgiavp();
            foreach (DataRow r in adsloai.Tables[0].Rows)
            {
                anode     = new TreeNode(r["ten"].ToString());
                anode.Tag = r["id"].ToString() + ":?";
                treeView1.Nodes.Add(anode);
                foreach (DataRow r1 in adsgia.Tables[0].Select("id_loai=" + r["id"].ToString()))
                {
                    anode1     = new TreeNode(r1["ten"].ToString());
                    anode1.Tag = r1["id"].ToString();
                    anode.Nodes.Add(anode1);
                    //treeView1.SelectedNode = anode1;
                }
            }
            //treeView1.ExpandAll();
        }
Exemplo n.º 2
0
        private void f_Load_Tree()
        {
            try
            {
                treeView1.Nodes.Clear();
                TreeNode anode, anode1;

                string asort = "ten";
                anode     = new TreeNode("Tất cả");
                anode.Tag = "";
                //anode.ImageIndex = 2;
                //anode.SelectedImageIndex = 2;
                treeView1.Nodes.Add(anode);

                adsnhom = m_v.f_get_v_nhomvp_frmgiavp();
                adsloai = m_v.f_get_v_loaivp_frmgiavp();
                int i = 0;
                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))
                    {
                        if (m_dsgiavp.Tables[0].Select("id_loai=" + r1["id"].ToString()).Length > 0)
                        {
                            anode1     = new TreeNode(r1["ten"].ToString());
                            anode1.Tag = r1["id"].ToString();
                            //anode1.ImageIndex = 1;
                            //anode1.SelectedImageIndex = 1;
                            anode.Nodes.Add(anode1);
                            i++;
                        }
                    }
                    if (r["ten"].ToString().Trim() == "Thuốc")
                    {
                        //foreach (DataRow r1 in adsloai.Tables[0].Select("id_nhom=" + r["ma"].ToString(), asort))
                        //{
                        if (m_dsgiavp.Tables[0].Select("id_loai=-999").Length > 0)
                        {
                            anode1     = new TreeNode("Thuốc");
                            anode1.Tag = "-999";    // r1["id"].ToString();
                            //anode1.ImageIndex = 1;
                            //anode1.SelectedImageIndex = 1;
                            anode.Nodes.Add(anode1);
                            i++;
                        }
                        //}
                    }
                }

                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
            {
            }
        }