private void BindGridViewSection(string search) { FiltersModel fm = Session["FiltersModel"] as FiltersModel; List <ViewSection> _View = new List <ViewSection>(); List <ViewSection> _TempView = new List <ViewSection>(); User LoggedInUser = HttpContext.Current.Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); string query = qb.QueryForSectionRptFilters(LoggedInUser); DataTable dt = qb.GetValuesfromDB("select * from ViewSection " + query); _View = dt.ToList <ViewSection>().AsQueryable().SortBy("DeptName").ToList(); if (fm.DepartmentFilter.Count > 0) { _TempView.Clear(); foreach (var Sec in fm.DepartmentFilter) { short _SecID = Convert.ToInt16(Sec.ID); _TempView.AddRange(_View.Where(aa => aa.SectionID == _SecID).ToList()); } _View = _TempView.ToList(); } GridViewSection.DataSource = _View.Where(aa => aa.SectionName.ToUpper().Contains(search.ToUpper()) || aa.DeptName.ToUpper().Contains(search.ToUpper())).ToList(); GridViewSection.DataBind(); }
private void BindGridViewSection(string search) { using (var db = new HRMEntities()) { FiltersModel fm = Session["FiltersModel"] as FiltersModel; List <ViewHRSection> _View = new List <ViewHRSection>(); List <ViewHRSection> _TempView = new List <ViewHRSection>(); ViewUserEmp LoggedInUser = HttpContext.Current.Session["LoggedUser"] as ViewUserEmp; List <ViewHRSection> secList = new List <ViewHRSection>(); secList = db.ViewHRSections.Where(aa => aa.Status == true).ToList(); if (LoggedInUser.UserType == "A" || LoggedInUser.UserType == "H" || LoggedInUser.UserType == "E" || LoggedInUser.HRModule == true) { _View = secList.ToList(); } else { List <EmpView> emps = new List <EmpView>(); emps = OTHelperManager.GetEmployees(db.EmpViews.Where(aa => aa.Status == "Active").ToList(), LoggedInUser); List <short?> secids = emps.Select(aa => aa.SectionID).Distinct().ToList(); List <ViewHRSection> tempSecs = new List <ViewHRSection>(); foreach (var secid in secids) { tempSecs.AddRange(secList.Where(aa => aa.SecID == secid).ToList()); } _View = tempSecs.ToList(); } if (fm.DepartmentFilter.Count > 0) { _TempView.Clear(); foreach (var dept in fm.DepartmentFilter) { short _deptID = Convert.ToInt16(dept.ID); _TempView.AddRange(_View.Where(aa => aa.DeptID == _deptID).ToList()); } _View = _TempView.ToList(); } if (fm.LocationFilter.Count > 0) { _TempView.Clear(); foreach (var dept in fm.LocationFilter) { short _deptID = Convert.ToInt16(dept.ID); _TempView.AddRange(_View.Where(aa => aa.LocID == _deptID).ToList()); } _View = _TempView.ToList(); } GridViewSection.DataSource = _View.Where(aa => aa.SectionName.ToUpper().Contains(search.ToUpper())).OrderBy(aa => aa.SectionName).ToList(); GridViewSection.DataBind(); } }
private void BindGridViewSection(string search) { FiltersModel fm = Session["FiltersModel"] as FiltersModel; List <ViewSection> _View = new List <ViewSection>(); List <ViewSection> _TempView = new List <ViewSection>(); User LoggedInUser = HttpContext.Current.Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); // string query = qb.QueryForCompanyFilters(LoggedInUser); DataTable dt = qb.GetValuesfromDB("select * from ViewSection" + " order by SectionName asc"); _View = dt.ToList <ViewSection>(); //if (fm.CompanyFilter.Count > 0) //{ // foreach (var comp in fm.CompanyFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.CompanyID == _compID).ToList()); // } // _View = _TempView.ToList(); //} //if (fm.DivisionFilter.Count > 0) //{ // _TempView.Clear(); // foreach (var comp in fm.DivisionFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.DivID == _compID).ToList()); // } // _View = _TempView.ToList(); //} if (fm.DepartmentFilter.Count > 0) { _TempView.Clear(); foreach (var comp in fm.DepartmentFilter) { short _compID = Convert.ToInt16(comp.ID); _TempView.AddRange(_View.Where(aa => aa.DeptID == _compID).ToList()); } _View = _TempView.ToList(); } GridViewSection.DataSource = _View.Where(aa => aa.SectionName.ToUpper().Contains(search.ToUpper())).ToList(); GridViewSection.DataBind(); }
private void BindGridViewSection(string search) { FiltersModel fm = Session["FiltersModel"] as FiltersModel; List <ViewSection> _View = new List <ViewSection>(); List <ViewSection> _TempView = new List <ViewSection>(); User LoggedInUser = Session["LoggedUser"] as User; TAS2013Entities db = new TAS2013Entities(); QueryBuilder qb = new QueryBuilder(); string query = qb.QueryForSectionRptFilters(LoggedInUser); DataTable dt = qb.GetValuesfromDB("select * from ViewSection " + query); List <ViewSection> _Viewsec = new List <ViewSection>(); List <ViewSection> _TempViewsec = new List <ViewSection>(); _View = dt.ToList <ViewSection>().AsQueryable().SortBy("SectionName").ToList(); foreach (var item in db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID && aa.LocationOrSection == "Section").ToList()) { _TempView.AddRange(_View.Where(aa => aa.SectionID == item.SectionID).ToList()); } GridViewSection.DataSource = _TempView.Where(aa => aa.SectionName.ToUpper().Contains(search.ToUpper())).ToList(); GridViewSection.DataBind(); }