protected void Sort(string sortExpression, params string[] sortExpr) { DataTable dataTable = Session["referrerinfoclinic_data"] as DataTable; if (dataTable != null) { if (Session["referrerinfoclinic_sortexpression"] == null) { Session["referrerinfoclinic_sortexpression"] = ""; } DataView dataView = new DataView(dataTable); string[] sortData = Session["referrerinfoclinic_sortexpression"].ToString().Trim().Split(' '); string newSortExpr = (sortExpr.Length == 0) ? (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" : sortExpr[0]; dataView.Sort = sortExpression + " " + newSortExpr; Session["referrerinfoclinic_sortexpression"] = sortExpression + " " + newSortExpr; GrdReferrer.DataSource = dataView; GrdReferrer.DataBind(); } }
protected void GrdReferrer_Sorting(object sender, GridViewSortEventArgs e) { // dont allow sorting if in edit mode if (GrdReferrer.EditIndex >= 0) { return; } DataTable dataTable = Session["referrerlistmultiplepopup_data"] as DataTable; if (dataTable != null) { if (Session["referrerlistmultiplepopup_sortexpression"] == null) { Session["referrerlistmultiplepopup_sortexpression"] = ""; } DataView dataView = new DataView(dataTable); string[] sortData = Session["referrerlistmultiplepopup_sortexpression"].ToString().Trim().Split(' '); string newSortExpr = (e.SortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC"; dataView.Sort = e.SortExpression + " " + newSortExpr; Session["referrerlistmultiplepopup_sortexpression"] = e.SortExpression + " " + newSortExpr; GrdReferrer.DataSource = dataView; GrdReferrer.DataBind(); } }
/* * 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 GrdReferrer protected void FillReferrerGrid() { //DataTable dt = RegisterReferrerDB.GetDataTable(false, new int[] { 191 }, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked); DataTable dt = OrganisationDB.GetDataTable(0, false, true, true, true, true, false, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked, "191"); Session["referrerorglistpopup_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerorglistpopup_sortexpression"] != null && Session["referrerorglistpopup_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerorglistpopup_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void FillGrid() { string searchName = ""; if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0) { searchName = Request.QueryString["name_search"]; txtSearchName.Text = Request.QueryString["name_search"]; } bool searchNameOnlyStartsWith = true; if (Request.QueryString["name_starts_with"] != null && Request.QueryString["name_starts_with"].Length > 0) { searchNameOnlyStartsWith = Request.QueryString["name_starts_with"] == "0" ? false : true; chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } else { chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } int orgID = 0; if (Request.QueryString["org"] != null && Regex.IsMatch(Request.QueryString["org"], @"\d{1,10}") && OrganisationDB.Exists(Convert.ToInt32(Request.QueryString["org"]))) { orgID = Convert.ToInt32(Request.QueryString["org"]); } // get count Hashtable countHash = new Hashtable(); Hashtable countDeletedHash = new Hashtable(); DataTable dt_reg_refs = RegisterReferrerDB.GetDataTable(orgID, -1, true, new int[] { 191 }, "", false, "", "", "", false); foreach (DataRow row in dt_reg_refs.Rows) { int org_id = Convert.ToInt32(row["organisation_id"]); if (!Convert.ToBoolean(row["is_deleted"])) { countHash[org_id] = (countHash[org_id] == null) ? 1 : ((int)countHash[org_id]) + 1; } else { countDeletedHash[org_id] = (countDeletedHash[org_id] == null) ? 1 : ((int)countDeletedHash[org_id]) + 1; } } DataTable dt = null; if (Request.QueryString["referrer"] == null) { dt = OrganisationDB.GetDataTable(orgID, chkShowDeleted.Checked, true, true, true, true, false, searchName, searchNameOnlyStartsWith, "191"); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]); dt.Rows[i]["count"] = countHash[org_id] == null ? 0 : (int)countHash[org_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id]; } } else { if (!Regex.IsMatch(Request.QueryString["referrer"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url referrer"); return; } Referrer referrer = ReferrerDB.GetByID(Convert.ToInt32(Request.QueryString["referrer"])); if (referrer == null) { HideTableAndSetErrorMessage("Invalid url referrer"); return; } lblHeading.Text = "Referrer Clinics of " + referrer.Person.FullnameWithoutMiddlename; dt = RegisterReferrerDB.GetDataTable_OrganisationsOf(referrer.ReferrerID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); dt.Columns.Add("is_deleted", typeof(Boolean)); dt.Columns.Add("entity_id", typeof(Int32)); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]); dt.Rows[i]["count"] = countHash[org_id] == null ? 0 : (int)countHash[org_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id]; // update these so when delete/undelete - it removes the connection, not the org dt.Rows[i]["organisation_id"] = dt.Rows[i]["register_referrer_id"]; dt.Rows[i]["is_deleted"] = dt.Rows[i]["register_referrer_is_deleted"]; dt.Rows[i]["entity_id"] = dt.Rows[i]["organisation_entity_id"]; } } // add suburb_name Hashtable entityIDsHash = new Hashtable(); for (int i = 0; i < dt.Rows.Count; i++) { entityIDsHash[Convert.ToInt32(dt.Rows[i]["entity_id"])] = 1; } int[] entityIDs = new int[entityIDsHash.Keys.Count]; entityIDsHash.Keys.CopyTo(entityIDs, 0); Hashtable emailHash = PatientsContactCacheDB.GetBullkAddress(entityIDs, -1); dt.Columns.Add("suburb_name", typeof(string)); for (int i = 0; i < dt.Rows.Count; i++) { int entityID = Convert.ToInt32(dt.Rows[i]["entity_id"]); string suburbName = GetSuburb(emailHash, entityID); dt.Rows[i]["suburb_name"] = suburbName == null ? "" : suburbName; } Session["referrerinfoclinic_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfoclinic_sortexpression"] != null && Session["referrerinfoclinic_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfoclinic_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } if (Request.QueryString["referrer"] != null) { GrdReferrer.FooterRow.Visible = false; GrdReferrer.Columns[GrdReferrer.Columns.Count - 2].Visible = false; } }
protected void FillGrid() { string searchName = ""; if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0) { searchName = Request.QueryString["name_search"]; txtSearchName.Text = Request.QueryString["name_search"]; } bool searchNameOnlyStartsWith = true; if (Request.QueryString["name_starts_with"] != null && Request.QueryString["name_starts_with"].Length > 0) { searchNameOnlyStartsWith = Request.QueryString["name_starts_with"] == "0" ? false : true; chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } else { chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } int referrerID = -1; if (Request.QueryString["referrer"] != null && Regex.IsMatch(Request.QueryString["referrer"], @"\d{1,10}") && ReferrerDB.Exists(Convert.ToInt32(Request.QueryString["referrer"]))) { referrerID = Convert.ToInt32(Request.QueryString["referrer"]); } // get the counts Hashtable countHash = new Hashtable(); Hashtable countDeletedHash = new Hashtable(); DataTable dt_reg_refs = RegisterReferrerDB.GetDataTable(0, referrerID, true, new int[] { 191 }, "", false, "", "", "", false); foreach (DataRow row in dt_reg_refs.Rows) { int referrer_id = Convert.ToInt32(row["referrer_id"]); if (!Convert.ToBoolean(row["is_deleted"])) { countHash[referrer_id] = (countHash[referrer_id] == null) ? 1 : ((int)countHash[referrer_id]) + 1; } else { countDeletedHash[referrer_id] = (countDeletedHash[referrer_id] == null) ? 1 : ((int)countDeletedHash[referrer_id]) + 1; } } DataTable dt = null; if (Request.QueryString["org"] == null) { dt = ReferrerDB.GetDataTable(referrerID, searchName, searchNameOnlyStartsWith, chkShowDeleted.Checked); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); for (int i = 0; i < dt.Rows.Count; i++) { int referrer_id = Convert.ToInt32(dt.Rows[i]["referrer_id"]); dt.Rows[i]["count"] = countHash[referrer_id] == null ? 0 : (int)countHash[referrer_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[referrer_id] == null ? 0 : (int)countDeletedHash[referrer_id]; } } else { if (!Regex.IsMatch(Request.QueryString["org"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url org"); return; } Organisation org = OrganisationDB.GetByID(Convert.ToInt32(Request.QueryString["org"])); if (org == null) { HideTableAndSetErrorMessage("Invalid url org"); return; } lblHeading.Text = "Referrers at " + org.Name; dt = RegisterReferrerDB.GetDataTable_ReferrersOf(org.OrganisationID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); dt.Columns.Add("count", typeof(Int32)); dt.Columns.Add("count_deleted", typeof(Int32)); dt.Columns.Add("is_deleted", typeof(Boolean)); for (int i = 0; i < dt.Rows.Count; i++) { int referrer_id = Convert.ToInt32(dt.Rows[i]["referrer_id"]); dt.Rows[i]["count"] = countHash[referrer_id] == null ? 0 : (int)countHash[referrer_id]; dt.Rows[i]["count_deleted"] = countDeletedHash[referrer_id] == null ? 0 : (int)countDeletedHash[referrer_id]; // update these so when delete/undelete - it removes the connection, not the referrer dt.Rows[i]["referrer_id"] = dt.Rows[i]["register_referrer_id"]; dt.Rows[i]["is_deleted"] = dt.Rows[i]["register_referrer_is_deleted"]; } } Session["referrerinfoperson_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfoperson_sortexpression"] != null && Session["referrerinfoperson_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfoperson_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } if (Request.QueryString["org"] != null) { GrdReferrer.FooterRow.Visible = false; GrdReferrer.Columns[GrdReferrer.Columns.Count - 2].Visible = false; } }
protected void FillGrid() { string searchName = ""; if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0) { searchName = Request.QueryString["name_search"]; txtSearchName.Text = Request.QueryString["name_search"]; } bool searchNameOnlyStartsWith = true; if (Request.QueryString["name_starts_with"] != null && Request.QueryString["name_starts_with"].Length > 0) { searchNameOnlyStartsWith = Request.QueryString["name_starts_with"] == "0" ? false : true; chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } else { chkSearchOnlyStartWith.Checked = searchNameOnlyStartsWith; } if (Request.QueryString["org"] == null || !Regex.IsMatch(Request.QueryString["org"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url org"); return; } if (!Regex.IsMatch(Request.QueryString["org"], @"^\d+$")) { HideTableAndSetErrorMessage("Invalid url org"); return; } Organisation org = OrganisationDB.GetByID(Convert.ToInt32(Request.QueryString["org"])); if (org == null) { HideTableAndSetErrorMessage("Invalid url org"); return; } lblHeading.Text = "Referrers at " + org.Name; DataTable dt = RegisterReferrerDB.GetDataTable_ReferrersOf(org.OrganisationID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); dt.Columns.Add("original_referrer_id", typeof(Int32)); dt.Columns.Add("is_deleted", typeof(Boolean)); for (int i = 0; i < dt.Rows.Count; i++) { // update these so when delete/undelete - it removes the connection, not the referrer dt.Rows[i]["original_referrer_id"] = dt.Rows[i]["referrer_id"]; dt.Rows[i]["referrer_id"] = dt.Rows[i]["register_referrer_id"]; dt.Rows[i]["is_deleted"] = dt.Rows[i]["register_referrer_is_deleted"]; } Session["referrerinfopersonofclinic_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfopersonofclinic_sortexpression"] != null && Session["referrerinfopersonofclinic_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfopersonofclinic_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } }
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; } string searchProviderNbr = ""; if (Request.QueryString["provider_nbr_search"] != null && Request.QueryString["provider_nbr_search"].Length > 0) { searchProviderNbr = Request.QueryString["provider_nbr_search"]; txtSearchProviderNbr.Text = Request.QueryString["provider_nbr_search"]; } bool searchProviderNbrOnlyStartsWith = true; if (Request.QueryString["provider_nbr_starts_with"] != null && Request.QueryString["provider_nbr_starts_with"].Length > 0) { searchProviderNbrOnlyStartsWith = Request.QueryString["provider_nbr_starts_with"] == "0" ? false : true; chkProviderNbrSearchOnlyStartWith.Checked = searchProviderNbrOnlyStartsWith; } else { chkProviderNbrSearchOnlyStartWith.Checked = searchProviderNbrOnlyStartsWith; } string searchPhoneNbr = ""; if (Request.QueryString["phone_nbr_search"] != null && Request.QueryString["phone_nbr_search"].Length > 0) { searchPhoneNbr = Request.QueryString["phone_nbr_search"]; txtSearchPhoneNbr.Text = Request.QueryString["phone_nbr_search"]; } bool searchPhoneNbrOnlyStartsWith = true; if (Request.QueryString["phone_nbr_starts_with"] != null && Request.QueryString["phone_nbr_starts_with"].Length > 0) { searchPhoneNbrOnlyStartsWith = Request.QueryString["phone_nbr_starts_with"] == "0" ? false : true; chkPhoneNbrSearchOnlyStartWith.Checked = searchPhoneNbrOnlyStartsWith; } else { chkPhoneNbrSearchOnlyStartWith.Checked = searchPhoneNbrOnlyStartsWith; } DataTable dt = RegisterReferrerDB.GetDataTable(0, -1, chkShowDeleted.Checked, new int[] { 191 }, searchSurname, searchSurnameOnlyStartsWith, "", "", searchProviderNbr, searchProviderNbrOnlyStartsWith, searchPhoneNbr, searchPhoneNbrOnlyStartsWith); Hashtable regRefHash = PatientReferrerDB.GetHashtableByRegRef(true, false, false); dt.Columns.Add("count", typeof(int)); for (int i = 0; i < dt.Rows.Count; i++) { int regRefID = Convert.ToInt32(dt.Rows[i]["register_referrer_id"]); dt.Rows[i]["count"] = regRefHash[regRefID] == null ? 0 : ((PatientReferrer[])regRefHash[regRefID]).Length; } // add suburb_name Hashtable entityIDsHash = new Hashtable(); for (int i = 0; i < dt.Rows.Count; i++) { entityIDsHash[Convert.ToInt32(dt.Rows[i]["organisation_entity_id"])] = 1; } int[] entityIDs = new int[entityIDsHash.Keys.Count]; entityIDsHash.Keys.CopyTo(entityIDs, 0); Hashtable emailHash = PatientsContactCacheDB.GetBullkAddress(entityIDs, -1); dt.Columns.Add("suburb_name", typeof(string)); for (int i = 0; i < dt.Rows.Count; i++) { int entityID = Convert.ToInt32(dt.Rows[i]["organisation_entity_id"]); string suburbName = GetSuburb(emailHash, entityID); dt.Rows[i]["suburb_name"] = suburbName == null ? "" : suburbName; } Session["referrerinfolist_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerinfolist_sortexpression"] != null && Session["referrerinfolist_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerinfolist_sortexpression"].ToString(); GrdReferrer.DataSource = dataView; } else { GrdReferrer.DataSource = dt; } try { GrdReferrer.DataBind(); GrdReferrer.PagerSettings.FirstPageText = "1"; GrdReferrer.PagerSettings.LastPageText = GrdReferrer.PageCount.ToString(); GrdReferrer.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdReferrer.DataSource = dt; GrdReferrer.DataBind(); int TotalColumns = GrdReferrer.Rows[0].Cells.Count; GrdReferrer.Rows[0].Cells.Clear(); GrdReferrer.Rows[0].Cells.Add(new TableCell()); GrdReferrer.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdReferrer.Rows[0].Cells[0].Text = "No Record Found"; } }