コード例 #1
0
        private void FillBranches()
        {
            objInv       = new InvoiceDB();
            objUtilityDB = new UtilityDB();
            DataSet ds = new DataSet();

            if (CommonData.LogUserId.ToUpper() == "ADMIN")
            {
                ds = objInv.AdminBranchCursor_Get("", "", "PARENT");
            }
            else
            {
                ds = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, "", "", "PARENT");
            }
            ttvBranch.Nodes.Add("Branches", "Branches");
            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ttvBranch.Nodes[0].Nodes.Add(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), ds.Tables[0].Rows[i]["COMPANY_NAME"].ToString());
                    DataSet dschild = new DataSet();
                    if (CommonData.LogUserId.ToUpper() == "ADMIN")
                    {
                        //if (sRep_Type == "SP_CHECKLIST")
                        //    dschild = objInv.AdminBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "SP", "CHILD");
                        //else
                        dschild = objInv.AdminBranchCursor_Get(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD");
                    }
                    else
                    {
                        //if (sRep_Type == "SP_CHECKLIST")
                        //    dschild = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "SP", "CHILD");
                        //else
                        dschild = objUtilityDB.UserBranchCursor_Get(CommonData.LogUserId, ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "BR", "CHILD");
                    }
                    //tvBranches.Nodes[i].Nodes.Add("BRANCHES" + "(" + dschild.Tables[0].Rows.Count + ")");
                    if (dschild.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < dschild.Tables[0].Rows.Count; j++)
                        {
                            ttvBranch.Nodes[0].Nodes[i].Nodes.Add(dschild.Tables[0].Rows[j]["BRANCH_CODE"].ToString(), dschild.Tables[0].Rows[j]["BRANCH_NAME"].ToString());
                        }
                    }
                }
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ttvBranch.SelectedNode = ttvBranch.Nodes[0];
                this.ttvBranch.SelectedNode.Expand();
            }
        }