protected void FillSites() { iUCCommonFilterClient objService = new iUCCommonFilterClient(); try { CustomProfile profile = CustomProfile.GetProfile(); List <mCompany> CompanyLst = new List <mCompany>(); string UserType = profile.Personal.UserType.ToString(); long UID = profile.Personal.UserID; if (UserType == "Admin") { // CompanyLst = objService.GetCompanyName(profile.DBConnection._constr).ToList(); // CompanyLst = objService.GetUserCompanyName(UID, profile.DBConnection._constr).ToList(); CompanyLst = objService.GetUserCompanyNameNEW(UID, profile.DBConnection._constr).ToList(); } else if (UserType == "User" || UserType == "Requester And Approver" || UserType == "Requester" || profile.Personal.UserType == "Requestor" || profile.Personal.UserType == "Requestor And Approver") { CompanyLst = objService.GetUserCompanyName(UID, profile.DBConnection._constr).ToList(); } else { CompanyLst = objService.GetCompanyName(profile.DBConnection._constr).ToList(); } ddlCompany.DataSource = CompanyLst; ddlCompany.DataBind(); if (UserType == "Admin") { // ListItem lstCmpny = new ListItem { Text = "-Select-", Value = "0" }; //ddlCompany.Items.Insert(0, lstCmpny); if (ddlCompany.Items.Count > 0) { ddlCompany.SelectedIndex = 0; //1; } hdnselectedCompany.Value = ddlCompany.SelectedValue.ToString(); List <mTerritory> SiteLst = new List <mTerritory>(); iUCCommonFilterClient UCCommonFilter = new iUCCommonFilterClient(); // SiteLst = UCCommonFilter.GetSiteNameByUserID(Convert.ToInt16(UID), profile.DBConnection._constr).ToList(); int Cmpny = int.Parse(hdnselectedCompany.Value); SiteLst = WMGetSelDept(Cmpny, profile.Personal.UserID); ddlSites.DataSource = SiteLst; ddlSites.DataBind(); if (ddlSites.Items.Count > 0) { ddlSites.SelectedIndex = 0; // 1; } hdnselectedDept.Value = ddlSites.SelectedValue.ToString(); Session["DeptID"] = ddlSites.SelectedValue.ToString(); //long DeptID = UCCommonFilter.GetSiteIdOfUser(UID, profile.DBConnection._constr); hdnselectedDept.Value = DeptID.ToString(); Session["DeptID"] = DeptID.ToString(); //long CompanyID = UCCommonFilter.GetCompanyIDFromSiteID(DeptID, profile.DBConnection._constr); hdnselectedCompany.Value = CompanyID.ToString(); //ddlContact1.DataSource = WMGetContactPersonLst(CompanyID); //WMGetContactPersonLst(DeptID); //ddlContact1.DataBind(); //ListItem lstContact = new ListItem { Text = "-Select-", Value = "0" }; //ddlContact1.Items.Insert(0, lstContact); //ddlAddress.DataSource = WMGetDeptAddress(CompanyID); //WMGetDeptAddress(DeptID); //ddlAddress.DataBind(); //ListItem lstAdrs = new ListItem { Text = "-Select-", Value = "0" }; //ddlAddress.Items.Insert(0, lstAdrs); } else if (UserType == "User" || UserType == "Requester And Approver" || UserType == "Requester" || profile.Personal.UserType == "Requestor" || profile.Personal.UserType == "Requestor And Approver") { ddlCompany.Enabled = false; List <mTerritory> SiteLst = new List <mTerritory>(); iUCCommonFilterClient UCCommonFilter = new iUCCommonFilterClient(); //SiteLst = UCCommonFilter.GetDepartmentListUserWise(Convert.ToInt16(UID), profile.DBConnection._constr).ToList(); SiteLst = UCCommonFilter.GetSiteNameByUserID(Convert.ToInt16(UID), profile.DBConnection._constr).ToList(); ddlSites.DataSource = SiteLst; ddlSites.DataBind(); if (ddlSites.Items.Count > 0) { ddlSites.SelectedIndex = 1; } // ddlSites.Enabled = false; long DeptID = UCCommonFilter.GetSiteIdOfUser(UID, profile.DBConnection._constr); hdnselectedDept.Value = DeptID.ToString(); Session["DeptID"] = DeptID.ToString(); long CompanyID = UCCommonFilter.GetCompanyIDFromSiteID(DeptID, profile.DBConnection._constr); hdnselectedCompany.Value = CompanyID.ToString(); //ddlContact1.DataSource = WMGetContactPersonLst(CompanyID); //WMGetContactPersonLst(DeptID); //ddlContact1.DataBind(); //ListItem lstContact = new ListItem { Text = "-Select-", Value = "0" }; //ddlContact1.Items.Insert(0, lstContact); //ddlAddress.DataSource = WMGetDeptAddress(CompanyID); //WMGetDeptAddress(DeptID); //ddlAddress.DataBind(); //ListItem lstAdrs = new ListItem { Text = "-Select-", Value = "0" }; //ddlAddress.Items.Insert(0, lstAdrs); } else { ListItem lstCmpny = new ListItem { Text = "-Select-", Value = "0" }; ddlCompany.Items.Insert(0, lstCmpny); if (ddlCompany.Items.Count > 0) { ddlCompany.SelectedIndex = 1; } List <mTerritory> SiteLst = new List <mTerritory>(); iUCCommonFilterClient UCCommonFilter = new iUCCommonFilterClient(); SiteLst = UCCommonFilter.GetSiteNameByUserID(Convert.ToInt16(UID), profile.DBConnection._constr).ToList(); ddlSites.DataSource = SiteLst; ddlSites.DataBind(); if (ddlSites.Items.Count > 0) { ddlSites.SelectedIndex = 1; } long DeptID = UCCommonFilter.GetSiteIdOfUser(UID, profile.DBConnection._constr); hdnselectedDept.Value = DeptID.ToString(); Session["DeptID"] = DeptID.ToString(); long CompanyID = UCCommonFilter.GetCompanyIDFromSiteID(DeptID, profile.DBConnection._constr); hdnselectedCompany.Value = CompanyID.ToString(); //ddlContact1.DataSource = WMGetContactPersonLst(CompanyID); //WMGetContactPersonLst(DeptID); //ddlContact1.DataBind(); //ListItem lstContact = new ListItem { Text = "-Select-", Value = "0" }; //ddlContact1.Items.Insert(0, lstContact); //ddlAddress.DataSource = WMGetDeptAddress(CompanyID); //WMGetDeptAddress(DeptID); //ddlAddress.DataBind(); //ListItem lstAdrs = new ListItem { Text = "-Select-", Value = "0" }; //ddlAddress.Items.Insert(0, lstAdrs); } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "Request Template", "FillSites"); } finally { objService.Close(); } }