public int CountAdvisorBranch()
        {
            AdvisorBranchBo        advisorBranchBo   = new AdvisorBranchBo();
            List <AdvisorBranchVo> advisorBranchList = null;
            int count;

            try
            {
                advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "");
                count             = advisorBranchList.Count;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AdvisorDashBoard.ascx:CountAdvisorBranch()");


                object[] objects = new object[2];
                objects[0] = advisorBranchBo;
                objects[1] = advisorBranchList;


                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(count);
        }
        public void setAdvisorBranch()
        {
            AdvisorBranchBo        advisorBranchBo   = new AdvisorBranchBo();
            List <AdvisorBranchVo> advisorBranchList = null;
            AdvisorBranchVo        advisorBranchVo   = null;

            try
            {
                advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "");
                DataTable dtAdvisorBranch = new DataTable();
                dtAdvisorBranch.Columns.Add("Sl.No.");

                dtAdvisorBranch.Columns.Add("Branch Name");
                dtAdvisorBranch.Columns.Add("Email");


                DataRow drAdvisorBranch;
                for (int i = 0; i < advisorBranchList.Count; i++)
                {
                    drAdvisorBranch    = dtAdvisorBranch.NewRow();
                    advisorBranchVo    = new AdvisorBranchVo();
                    advisorBranchVo    = advisorBranchList[i];
                    drAdvisorBranch[0] = (i + 1).ToString();
                    drAdvisorBranch[1] = advisorBranchVo.BranchName;
                    drAdvisorBranch[2] = advisorBranchVo.Email;
                    dtAdvisorBranch.Rows.Add(drAdvisorBranch);
                }

                gvAdvisorBranch.DataSource = dtAdvisorBranch;
                gvAdvisorBranch.DataBind();
                gvAdvisorBranch.Visible = true;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AdvisorDashBoard.ascx:setAdvisorLOB()");


                object[] objects = new object[4];
                objects[0] = advisorBranchBo;
                objects[1] = advisorBranchList;
                objects[2] = advisorVo;
                objects[3] = advisorBranchVo;


                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        protected void BindGrid()
        {
            try
            {
                if (hdnCurrentPage.Value.ToString() != "")
                {
                    mypager.CurrentPage  = Int32.Parse(hdnCurrentPage.Value.ToString());
                    hdnCurrentPage.Value = "";
                }

                advisorVo = (AdvisorVo)Session["advisorVo"];
                int Count;


                if (Session["Branch"] != null)
                {
                    lblMessage.Visible = false;
                    string branch = Session["Branch"].ToString();
                    if (branch.ToLower().Trim() == "find branch" || branch.ToLower().Trim() == "")
                    {
                        branch = "";
                    }
                    branchList        = advisorBranchBo.FindBranch(branch, advisorVo.advisorId, mypager.CurrentPage, hdnSort.Value, out Count);
                    lblTotalRows.Text = hdnCount.Value = Count.ToString();
                    LoadBranches(branchList);
                    Session.Remove("Branch");
                }
                else
                {
                    advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, hdnSort.Value, mypager.CurrentPage, out Count);
                    lblTotalRows.Text = hdnCount.Value = Count.ToString();
                    //if (Count > 0)
                    //{
                    //    tblPager.Visible = true;
                    //    lblTotalRows.Text = hdnCount.Value = Count.ToString();
                    //}
                    if (advisorBranchList.Count == 0)
                    {
                        lblMessage.Visible     = true;
                        tblPager.Visible       = false;
                        lblCurrentPage.Visible = false;
                        lblTotalRows.Visible   = false;
                    }
                    else
                    {
                        lblMessage.Visible = false;
                        DataTable dtAdvisorBranch2 = new DataTable();
                        dtAdvisorBranch2.Columns.Add("Sl.No.");
                        dtAdvisorBranch2.Columns.Add("BranchId");
                        dtAdvisorBranch2.Columns.Add("BranchName");
                        dtAdvisorBranch2.Columns.Add("BranchCode");
                        dtAdvisorBranch2.Columns.Add("Email");
                        dtAdvisorBranch2.Columns.Add("Phone");
                        dtAdvisorBranch2.Columns.Add("BranchHead");
                        dtAdvisorBranch2.Columns.Add("BranchType");

                        DataRow drAdvisorBranch;
                        for (int i = 0; i < advisorBranchList.Count; i++)
                        {
                            drAdvisorBranch    = dtAdvisorBranch2.NewRow();
                            advisorBranchVo    = new AdvisorBranchVo();
                            advisorBranchVo    = advisorBranchList[i];
                            drAdvisorBranch[0] = (i + 1).ToString();
                            drAdvisorBranch[1] = advisorBranchVo.BranchId.ToString();
                            drAdvisorBranch[2] = advisorBranchVo.BranchName.ToString();
                            drAdvisorBranch[3] = advisorBranchVo.BranchCode.ToString();
                            drAdvisorBranch[4] = advisorBranchVo.Email;
                            drAdvisorBranch[5] = advisorBranchVo.Phone1Isd.ToString() + "-" + advisorBranchVo.Phone1Std.ToString() + "-" + advisorBranchVo.Phone1Number.ToString();
                            drAdvisorBranch[6] = advisorBranchVo.BranchHead.ToString();
                            drAdvisorBranch[7] = advisorBranchVo.BranchType.ToString();
                            dtAdvisorBranch2.Rows.Add(drAdvisorBranch);
                        }

                        gvBranchList.DataSource = dtAdvisorBranch2;
                        gvBranchList.DataBind();
                        gvBranchList.Visible = true;
                    }
                }
                this.GetPageCount();
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "ViewBranches.ascx:Page_Load()");
                object[] objects = new object[4];
                objects[0]   = advisorVo;
                objects[1]   = advisorBranchVo;
                objects[2]   = advisorBranchBo;
                objects[3]   = advisorBranchList;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        public void setBranchList1(string IsExternal)
        {
            UserVo    rmUserVo = null;
            DataRow   drAdvisorBranch;
            DataTable dtAdvisorBranch = new DataTable();

            try
            {
                rmUserVo = (UserVo)Session["rmUserVo"];
                if (IsExternal == "Y")
                {
                    advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "Y");
                }
                else if (IsExternal == "N")
                {
                    advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "N");
                }

                if (advisorBranchList == null)
                {
                    lblError.Visible        = true;
                    lblError.Text           = "Add some Branches..";
                    gvBranchList.DataSource = null;
                    gvBranchList.DataBind();
                }
                else
                {
                    gvBranchList.Visible = true;
                    lblError.Visible     = false;

                    dtAdvisorBranch.Columns.Add("Sl.No.");
                    dtAdvisorBranch.Columns.Add("BranchId");
                    dtAdvisorBranch.Columns.Add("Branch Name");
                    dtAdvisorBranch.Columns.Add("Branch Address");
                    dtAdvisorBranch.Columns.Add("Branch Phone");

                    for (int i = 0; i < advisorBranchList.Count; i++)
                    {
                        drAdvisorBranch    = dtAdvisorBranch.NewRow();
                        advisorBranchVo    = new AdvisorBranchVo();
                        advisorBranchVo    = advisorBranchList[i];
                        drAdvisorBranch[0] = (i + 1).ToString();
                        drAdvisorBranch[1] = advisorBranchVo.BranchId.ToString();
                        drAdvisorBranch[2] = advisorBranchVo.BranchName.ToString();
                        if (advisorBranchVo.State != "" && advisorBranchVo.State != "Select a State")
                        {
                            drAdvisorBranch[3] = advisorBranchVo.AddressLine1.ToString() + "'" + advisorBranchVo.AddressLine2.ToString() + "'" + advisorBranchVo.AddressLine3.ToString() + "," + advisorBranchVo.City.ToString() + "'" + XMLBo.GetStateName(path, advisorBranchVo.State.ToString());
                        }
                        else
                        {
                            drAdvisorBranch[3] = advisorBranchVo.AddressLine1.ToString() + "'" + advisorBranchVo.AddressLine2.ToString() + "'" + advisorBranchVo.AddressLine3.ToString() + "," + advisorBranchVo.City.ToString() + "'";
                        }

                        drAdvisorBranch[4] = advisorBranchVo.Phone1Isd + "-" + advisorBranchVo.Phone1Std + "-" + advisorBranchVo.Phone1Number;
                        dtAdvisorBranch.Rows.Add(drAdvisorBranch);
                    }

                    gvBranchList.DataSource = dtAdvisorBranch;
                    gvBranchList.DataBind();
                    gvBranchList.Visible = true;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "RMBranchAssocistion.ascx:setBranchList()");
                object[] objects = new object[3];
                objects[0]   = rmUserVo;
                objects[1]   = advisorBranchList;
                objects[2]   = advisorBranchVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        public void setBranchList(string IsExternal)
        {
            UserVo    rmUserVo = null;
            DataRow   drAdvisorBranch;
            DataTable dtAdvisorBranch = new DataTable();
            bool      tracker         = false;

            try
            {
                rmUserVo = (UserVo)Session["rmUserVo"];
                if (IsExternal == "Y")
                {
                    advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "Y");
                }
                else if (IsExternal == "N")
                {
                    advisorBranchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "N");
                }

                dtAdvisorBranch.Columns.Add("Branch");
                dtAdvisorBranch.Columns.Add("Branch Code");

                if (advisorBranchList != null)
                {
                    for (int i = 0; i < advisorBranchList.Count; i++)
                    {
                        drAdvisorBranch = dtAdvisorBranch.NewRow();
                        advisorBranchVo = new AdvisorBranchVo();
                        advisorBranchVo = advisorBranchList[i];

                        if (associatedBranch.Items.FindByValue(advisorBranchVo.BranchId.ToString()) == null)
                        {
                            //if (tracker)
                            //{
                            if (drAdvisorBranch["Branch"] != null && drAdvisorBranch["Branch Code"] != null)
                            {
                                drAdvisorBranch["Branch"]      = advisorBranchVo.BranchName.ToString() + "," + advisorBranchVo.BranchId.ToString();
                                drAdvisorBranch["Branch Code"] = advisorBranchVo.BranchId.ToString();
                                dtAdvisorBranch.Rows.Add(drAdvisorBranch);
                            }
                        }
                    }
                }
                //_commondatasetSource.Tables.Add(dtAdvisorBranch);
                availableBranch.DataSource     = dtAdvisorBranch;
                availableBranch.DataTextField  = "Branch";
                availableBranch.DataValueField = "Branch Code";
                availableBranch.DataBind();
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "RMBranchAssocistion.ascx:setBranchList()");
                object[] objects = new object[3];
                objects[0]   = rmUserVo;
                objects[1]   = advisorBranchList;
                objects[2]   = advisorBranchVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        public void SetBranches()
        {
            bool bResult = false;

            try
            {
                branchList = advisorBranchBo.GetAdvisorBranches(advisorVo.advisorId, "");
                for (int i = 0; i < branchList.Count; i++)
                {
                    advisorBranchVo = new AdvisorBranchVo();
                    advisorBranchVo = branchList[i];
                    bResult         = advisorBranchBo.ChkBranchManagerAvail(advisorBranchVo.BranchId);
                    if (bResult)
                    {
                        newBranchList.Add(advisorBranchVo);
                    }
                }

                if (newBranchList.Count == 0)
                {
                    lblIllegal.Visible     = true;
                    lnkAddBranch.Visible   = true;
                    btnAssociateBM.Visible = false;
                }
                else
                {
                    lblIllegal.Visible     = false;
                    lnkAddBranch.Visible   = false;
                    btnAssociateBM.Visible = true;
                    DataTable dtAdvisorBranch = new DataTable();
                    dtAdvisorBranch.Columns.Add("Sl.No.");
                    dtAdvisorBranch.Columns.Add("BranchId");
                    dtAdvisorBranch.Columns.Add("Branch Name");
                    dtAdvisorBranch.Columns.Add("Branch Address");
                    dtAdvisorBranch.Columns.Add("Branch Phone");
                    DataRow drAdvisorBranch;
                    for (int i = 0; i < newBranchList.Count; i++)
                    {
                        drAdvisorBranch    = dtAdvisorBranch.NewRow();
                        advisorBranchVo    = new AdvisorBranchVo();
                        advisorBranchVo    = newBranchList[i];
                        drAdvisorBranch[0] = (i + 1).ToString();
                        drAdvisorBranch[1] = advisorBranchVo.BranchId.ToString();
                        drAdvisorBranch[2] = advisorBranchVo.BranchName.ToString();
                        drAdvisorBranch[3] = advisorBranchVo.AddressLine1.ToString() + "'" + advisorBranchVo.AddressLine2.ToString() + "'" + advisorBranchVo.AddressLine3.ToString() + "," + advisorBranchVo.City.ToString() + "'" + advisorBranchVo.State.ToString();
                        drAdvisorBranch[4] = advisorBranchVo.Phone1Isd + "-" + advisorBranchVo.Phone1Std + "-" + advisorBranchVo.Phone1Number;
                        dtAdvisorBranch.Rows.Add(drAdvisorBranch);
                    }
                    gvBranchListBM.DataSource = dtAdvisorBranch;
                    gvBranchListBM.DataBind();
                    gvBranchListBM.Visible = true;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "BMBranchAssociation.ascx.cs:SetBranches()");
                object[] objects = new object[3];
                objects[0]   = advisorBranchVo;
                objects[1]   = branchList;
                objects[2]   = newBranchList;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }