protected void GridView_Sorting(object sender, GridViewSortEventArgs e) { // dont allow sorting if in edit mode if (GrdStaff.EditIndex >= 0) { return; } DataTable dataTable = Session["externalstaffinfo_data"] as DataTable; if (dataTable != null) { if (Session["externalstaffinfo_sortexpression"] == null) { Session["externalstaffinfo_sortexpression"] = ""; } DataView dataView = new DataView(dataTable); string[] sortData = Session["externalstaffinfo_sortexpression"].ToString().Trim().Split(' '); string newSortExpr = (e.SortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC"; dataView.Sort = e.SortExpression + " " + newSortExpr; Session["externalstaffinfo_sortexpression"] = e.SortExpression + " " + newSortExpr; GrdStaff.DataSource = dataView; GrdStaff.DataBind(); } }
//Bind Staff Grid Data #region [Bind Staff Grid Data] private void BindStaffGridData() { try { EWA_Common objEWA = new EWA_Common(); BL_Common objBL = new BL_Common(); objEWA.OrgId = Convert.ToString(Session["OrgId"]); objEWA.CourseId = ddlCourse.SelectedValue; //objEWA.DesignationId = ddlDesignation.SelectedItem.ToString(); // objEWA.DepartmentId = ddlDepartment.SelectedItem.ToString(); DataSet ds = objBL.BindStaffList_BL(objEWA); if (ds.Tables[0].Rows.Count > 0) { GrdStaff.DataSource = ds; GrdStaff.DataBind(); btnDownload.Visible = true; } else { GrdStaff.DataSource = null; GrdStaff.DataBind(); btnDownload.Visible = false; } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
protected void FillGrid() { string searchSurname = ""; if (Request.QueryString["surname_search"] != null && Request.QueryString["surname_search"].Length > 0) { searchSurname = Request.QueryString["surname_search"]; txtSearchSurname.Text = Request.QueryString["surname_search"]; } bool searchSurnameOnlyStartsWith = true; if (Request.QueryString["surname_starts_with"] != null && Request.QueryString["surname_starts_with"].Length > 0) { searchSurnameOnlyStartsWith = Request.QueryString["surname_starts_with"] == "0" ? false : true; chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith; } else { chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith; } DataTable dt = StaffDB.GetDataTable_StaffInfo(Convert.ToBoolean(Session["IsStakeholder"]), chkShowFired.Checked, true, true, searchSurname, searchSurnameOnlyStartsWith); // remove "Call Center" staff member for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (((int)dt.Rows[i]["staff_id"]) == -5) { dt.Rows.RemoveAt(i); } } dt.DefaultView.Sort = "firstname, surname, middlename"; dt = dt.DefaultView.ToTable(); Session["externalstaffinfo_data"] = dt; this.GrdStaff.AllowPaging = false; /* * if (!IsPostBack) * chkUsePaging.Checked = dt.Rows.Count > 50; * this.GrdStaff.AllowPaging = chkUsePaging.Checked; */ if (dt.Rows.Count > 0) { if (IsPostBack && Session["externalstaffinfo_sortexpression"] != null && Session["externalstaffinfo_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["externalstaffinfo_sortexpression"].ToString(); GrdStaff.DataSource = dataView; } else { GrdStaff.DataSource = dt; } try { GrdStaff.DataBind(); GrdStaff.PagerSettings.FirstPageText = "1"; GrdStaff.PagerSettings.LastPageText = GrdStaff.PageCount.ToString(); GrdStaff.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdStaff.DataSource = dt; GrdStaff.DataBind(); int TotalColumns = GrdStaff.Rows[0].Cells.Count; GrdStaff.Rows[0].Cells.Clear(); GrdStaff.Rows[0].Cells.Add(new TableCell()); GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdStaff.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void FillGrid() { lblNbrProviders.Text = StaffDB.GetCountOfProviders().ToString(); string searchSurname = ""; if (Request.QueryString["surname_search"] != null && Request.QueryString["surname_search"].Length > 0) { searchSurname = Request.QueryString["surname_search"]; txtSearchSurname.Text = Request.QueryString["surname_search"]; } bool searchSurnameOnlyStartsWith = true; if (Request.QueryString["surname_starts_with"] != null && Request.QueryString["surname_starts_with"].Length > 0) { searchSurnameOnlyStartsWith = Request.QueryString["surname_starts_with"] == "0" ? false : true; chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith; } else { chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith; } DataTable dt = StaffDB.GetDataTable_StaffInfo(Convert.ToBoolean(Session["IsStakeholder"]), chkShowFired.Checked, false, false, searchSurname, searchSurnameOnlyStartsWith); // remove "Patient Login" staff member and Call Centre staff memebers for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (((int)dt.Rows[i]["staff_id"]) == -6 || ((int)dt.Rows[i]["staff_id"]) == -7 || ((int)dt.Rows[i]["staff_id"]) == -8) { dt.Rows.RemoveAt(i); } } // hide higher privleiged users from lower priveliged users UserView userView = UserView.GetInstance(); for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (!userView.IsStakeholder && Convert.ToBoolean(dt.Rows[i]["is_stakeholder"])) { dt.Rows.RemoveAt(i); continue; } if (!userView.IsStakeholder && !userView.IsMasterAdmin && Convert.ToBoolean(dt.Rows[i]["is_master_admin"])) { dt.Rows.RemoveAt(i); continue; } } dt.DefaultView.Sort = "firstname, surname, middlename"; dt = dt.DefaultView.ToTable(); Session["staffinfo_data"] = dt; this.GrdStaff.AllowPaging = false; /* * if (!IsPostBack) * chkUsePaging.Checked = dt.Rows.Count > 50; * this.GrdStaff.AllowPaging = chkUsePaging.Checked; */ if (dt.Rows.Count > 0) { if (IsPostBack && Session["staffinfo_sortexpression"] != null && Session["staffinfo_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["staffinfo_sortexpression"].ToString(); GrdStaff.DataSource = dataView; } else { GrdStaff.DataSource = dt; } try { GrdStaff.DataBind(); GrdStaff.PagerSettings.FirstPageText = "1"; GrdStaff.PagerSettings.LastPageText = GrdStaff.PageCount.ToString(); GrdStaff.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdStaff.DataSource = dt; GrdStaff.DataBind(); int TotalColumns = GrdStaff.Rows[0].Cells.Count; GrdStaff.Rows[0].Cells.Clear(); GrdStaff.Rows[0].Cells.Add(new TableCell()); GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdStaff.Rows[0].Cells[0].Text = "No Record Found"; } }
/* * protected bool IsValidFormOrg() * { * string orgID = Request.QueryString["org"]; * return orgID != null && Regex.IsMatch(orgID, @"^\d+$") && OrganisationDB.Exists(Convert.ToInt32(orgID)); * } * protected int GetFormOrg(bool checkIsValid = true) * { * if (checkIsValid && !IsValidFormOrg()) * throw new Exception("Invalid url org"); * return Convert.ToInt32(Request.QueryString["org"]); * } * * protected bool IsValidFormOrgs() * { * string orgIDs = Request.QueryString["orgs"]; * return orgIDs != null && Regex.IsMatch(orgIDs, @"^[\d,]+$") && OrganisationDB.Exists(orgIDs); * } * protected string GetFormOrgs(bool checkIsValid = true) * { * if (checkIsValid && !IsValidFormOrgs()) * throw new Exception("Invalid url orgs"); * return Request.QueryString["orgs"]; * } */ #endregion #region GrdStaff protected void FillStaffGrid() { DataTable dt = StaffDB.GetDataTable_StaffInfo(false, false, false, false, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked); bool onlyProviders = IsValidFormOnlyProviders() ? GetFormOnlyProviders(false) : false; if (onlyProviders) { lblHeading.Text = "Providers"; for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (!StaffDB.Load(dt.Rows[i]).IsProvider) { dt.Rows.RemoveAt(i); } } } Session["staff_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["staff_sortExpression"] != null && Session["staff_sortExpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["staff_sortExpression"].ToString(); GrdStaff.DataSource = dataView; } else { GrdStaff.DataSource = dt; } try { GrdStaff.DataBind(); // don't need paging -- already have scrolling -- and there won't be too many staff to send in one page GrdStaff.PagerSettings.FirstPageText = "1"; GrdStaff.PagerSettings.LastPageText = GrdStaff.PageCount.ToString(); GrdStaff.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdStaff.DataSource = dt; GrdStaff.DataBind(); int TotalColumns = GrdStaff.Rows[0].Cells.Count; GrdStaff.Rows[0].Cells.Clear(); GrdStaff.Rows[0].Cells.Add(new TableCell()); GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdStaff.Rows[0].Cells[0].Text = "No Record Found"; } }