protected void UpdateOrgsFromJavascriptChanges() { string referrerIDs = hiddenReferrerIDsList.Value; // comma seperated Hashtable referrerIDsHash = new Hashtable(); if (referrerIDs.Length > 0) { foreach (string referrerID in referrerIDs.Split(',')) { referrerIDsHash[Convert.ToInt32(referrerID)] = 1; } } DataTable referrers = RegisterReferrerDB.GetDataTable(0, -1, true); RegisterReferrer[] regRefs = new RegisterReferrer[referrers.Rows.Count]; for (int i = 0; i < referrers.Rows.Count; i++) { regRefs[i] = RegisterReferrerDB.LoadAll(referrers.Rows[i]); } ArrayList referrersAdded = new ArrayList(); lstReferrers.Items.Clear(); for (int i = 0; i < regRefs.Length; i++) { if (referrerIDsHash[regRefs[i].RegisterReferrerID] != null) { string text = regRefs[i].Referrer.Person.FullnameWithoutMiddlename + " [" + regRefs[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, regRefs[i].RegisterReferrerID.ToString())); referrersAdded.Add(regRefs[i]); } } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( (RegisterReferrer[])referrersAdded.ToArray(typeof(RegisterReferrer)), ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); }
protected void AddAllReferrers() { // clear and re-set all (in alphabetical order) ArrayList newList = new ArrayList(); DataTable referrers = RegisterReferrerDB.GetDataTable(); for (int i = 0; i < referrers.Rows.Count; i++) { newList.Add(RegisterReferrerDB.LoadAll(referrers.Rows[i])); } RegisterReferrer[] allReferrers = (RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer)); lstReferrers.Items.Clear(); string items = string.Empty; for (int i = 0; i < allReferrers.Length; i++) { string text = allReferrers[i].Referrer.Person.FullnameWithoutMiddlename + " [" + allReferrers[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, allReferrers[i].RegisterReferrerID.ToString())); // add to hidden list items += (items.Length == 0 ? "" : ",") + allReferrers[i].RegisterReferrerID.ToString(); } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( allReferrers, ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); hiddenReferrerIDsList.Value = items; }
/* * 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(0, -1, false, new int[] { 191 }, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked, txtSearchSuburb.Text, txtSearchPostcode.Text); Session["referrerlistmultiplepopup_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["referrerlistmultiplepopup_sortexpression"] != null && Session["referrerlistmultiplepopup_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["referrerlistmultiplepopup_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 btnChangeToAddMode_Click(object sender, EventArgs e) { displayNoReferrerRow.Visible = false; addRow.Visible = true; newReferrersLinkRow.Visible = true; int nItems = ddlNewReferrer.Items.Count; for (int i = 0; i < nItems; i++) { ddlNewReferrer.Items.RemoveAt(0); } DataTable rr = RegisterReferrerDB.GetDataTable(0, -1, false, new int[] { 191 }); foreach (DataRowView row in rr.DefaultView) { ddlNewReferrer.Items.Add(new ListItem(row["surname"].ToString() + ", " + row["firstname"].ToString() + " [" + row["name"].ToString() + "]", row["register_referrer_id"].ToString())); } }
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 btnUpdateReferrersFromClinic_Click(object sender, EventArgs e) { int orgID = Convert.ToInt32(hiddenUpdateReferrersFromClinic_OrgID.Value); Organisation org = OrganisationDB.GetByID(orgID); if (org != null) { string referrerIDs = hiddenReferrerIDsList.Value; // comma seperated Hashtable referrerIDsHash = new Hashtable(); if (referrerIDs.Length > 0) { foreach (string referrerID in referrerIDs.Split(',')) { referrerIDsHash[Convert.ToInt32(referrerID)] = 1; } } // add all new ones (not including those already in there) RegisterReferrer[] refs = RegisterReferrerDB.GetAllActiveRegRefByPatientsOfInternalOrg(orgID); for (int i = 0; i < refs.Length; i++) { if (referrerIDsHash[refs[i].RegisterReferrerID] == null) { hiddenReferrerIDsList.Value += (hiddenReferrerIDsList.Value.Length == 0 ? "" : ",") + refs[i].RegisterReferrerID; // add to hiddenfield list of id's referrerIDsHash[refs[i].RegisterReferrerID] = 1; // add to hash } } // clear and re-set all (in alphabetical order) ArrayList newList = new ArrayList(); DataTable referrers = RegisterReferrerDB.GetDataTable(); for (int i = 0; i < referrers.Rows.Count; i++) { newList.Add(RegisterReferrerDB.LoadAll(referrers.Rows[i])); } RegisterReferrer[] allReferrers = (RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer)); ArrayList referrersAdded = new ArrayList(); lstReferrers.Items.Clear(); for (int i = 0; i < allReferrers.Length; i++) { if (referrerIDsHash[allReferrers[i].RegisterReferrerID] != null) { string text = allReferrers[i].Referrer.Person.FullnameWithoutMiddlename + " [" + allReferrers[i].Organisation.Name + "]"; lstReferrers.Items.Add(new ListItem(text, allReferrers[i].RegisterReferrerID.ToString())); referrersAdded.Add(allReferrers[i]); } } int hasBothMobileEmail = 0; int hasMobileNoEmail = 0; int hasEmailNoMobile = 0; int hasNeitherMobileEmail = 0; RegisterReferrerDB.GetCountsByEmailMobile( (RegisterReferrer[])referrersAdded.ToArray(typeof(RegisterReferrer)), ref hasBothMobileEmail, ref hasMobileNoEmail, ref hasEmailNoMobile, ref hasNeitherMobileEmail); lblReferrersWithMobileAndEmailTotal.Text = hasBothMobileEmail.ToString(); lblReferrersWithMobileNoEmailTotal.Text = hasMobileNoEmail.ToString(); lblReferrersWithEmailNoMobileTotal.Text = hasEmailNoMobile.ToString(); lblReferrersWithNeitherMobileOrEmailTotal.Text = hasNeitherMobileEmail.ToString(); lblReferrerCount.Text = lstReferrers.Items.Count.ToString(); // ----------------------------------------------- } hiddenUpdateReferrersFromClinic_OrgID.Value = string.Empty; }
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 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"; } }
protected void setReferrersList(PatientReferrer currentPatRegReferrer = null) { if (currentPatRegReferrer == null) { PatientReferrer[] patientReferrer = PatientReferrerDB.GetEPCPatientReferrersOf(this.PatientID); if (patientReferrer.Length > 0) { currentPatRegReferrer = patientReferrer[patientReferrer.Length - 1]; } } int nItems = ddlReferrer.Items.Count; for (int i = 0; i < nItems; i++) { ddlReferrer.Items.RemoveAt(0); } DataTable rr = RegisterReferrerDB.GetDataTable(0, -1, false, new int[] { 191 }); if (currentPatRegReferrer != null) { // if refererrer set as inactive (ie user set as deleted, but is still in system) // then it will show the referrer as his referrer, but when hitting update, the list will not contain it, and throws an error // so if set as inactive (deleted), then add to the list bool isDeletedReferrer = rr.Select("register_referrer_id=" + currentPatRegReferrer.RegisterReferrer.RegisterReferrerID).Length == 0; if (isDeletedReferrer) { DataRow newRow = rr.NewRow(); newRow["surname"] = currentPatRegReferrer.RegisterReferrer.Referrer.Person.Surname; newRow["firstname"] = currentPatRegReferrer.RegisterReferrer.Referrer.Person.Firstname; newRow["middlename"] = currentPatRegReferrer.RegisterReferrer.Referrer.Person.Middlename; newRow["name"] = currentPatRegReferrer.RegisterReferrer.Organisation.Name; newRow["register_referrer_id"] = currentPatRegReferrer.RegisterReferrer.RegisterReferrerID; bool inserted = false; for (int i = rr.Rows.Count - 1; i >= 0; i--) { if (currentPatRegReferrer.RegisterReferrer.Referrer.Person.Surname.CompareTo(rr.Rows[i]["surname"].ToString()) < 0) { continue; } if (currentPatRegReferrer.RegisterReferrer.Referrer.Person.Surname.CompareTo(rr.Rows[i]["surname"].ToString()) == 0) { if (currentPatRegReferrer.RegisterReferrer.Referrer.Person.Firstname.CompareTo(rr.Rows[i]["firstname"].ToString()) < 0) { continue; } if (currentPatRegReferrer.RegisterReferrer.Referrer.Person.Middlename.CompareTo(rr.Rows[i]["surname"].ToString()) == 0) { if (currentPatRegReferrer.RegisterReferrer.Referrer.Person.Firstname.CompareTo(rr.Rows[i]["middlename"].ToString()) < 0) { continue; } } } // now insert before this one if (i == rr.Rows.Count) { rr.Rows.Add(newRow); } else { rr.Rows.InsertAt(newRow, i + 1); } inserted = true; break; } if (!inserted) { if (rr.Rows.Count == 0) { rr.Rows.Add(newRow); } else { rr.Rows.InsertAt(newRow, 0); } } } } foreach (DataRowView row in rr.DefaultView) { ddlReferrer.Items.Add(new ListItem(row["surname"].ToString() + ", " + row["firstname"].ToString() + " [" + row["name"].ToString() + "]", row["register_referrer_id"].ToString())); } if (currentPatRegReferrer != null) { ddlReferrer.SelectedValue = currentPatRegReferrer.RegisterReferrer.RegisterReferrerID.ToString(); } }