protected void FillOrganisationGrid() { UserView userView = UserView.GetInstance(); lblHeading.Text = !userView.IsAgedCareView ? "Facilitys" : "Clinics"; int patientID = IsValidFormPatient() ? GetFormPatient(false) : -1; DataTable dt = patientID == -1 ? OrganisationDB.GetDataTable(0, false, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked) : RegisterPatientDB.GetDataTable_OrganisationsOf(patientID, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked); Session["organisationlist_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["organisationlist_sortexpression"] != null && Session["organisationlist_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["organisationlist_sortexpression"].ToString(); GrdOrganisation.DataSource = dataView; } else { GrdOrganisation.DataSource = dt; } try { GrdOrganisation.DataBind(); GrdOrganisation.PagerSettings.FirstPageText = "1"; GrdOrganisation.PagerSettings.LastPageText = GrdOrganisation.PageCount.ToString(); GrdOrganisation.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdOrganisation.DataSource = dt; GrdOrganisation.DataBind(); int TotalColumns = GrdOrganisation.Rows[0].Cells.Count; GrdOrganisation.Rows[0].Cells.Clear(); GrdOrganisation.Rows[0].Cells.Add(new TableCell()); GrdOrganisation.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdOrganisation.Rows[0].Cells[0].Text = "No Record Found"; } }
public static Organisation[] GetTree(DataTable dt = null, bool showDeleted = false, int organisationID = 0, bool onlyLowerBranches = false, string org_type_ids = "") { if (dt == null) { dt = OrganisationDB.GetDataTable(0, showDeleted, true, false, false, true, true, "", false, org_type_ids); } dt.Columns.Add("tree_level", typeof(Int32)); Organisation[] tree = GetChildren(ref dt, "parent_organisation_id is NULL", 0); for (int i = 0; i < tree.Length; i++) { SetParents(ref tree[i]); } if (organisationID != 0) { for (int i = 0; i < tree.Length; i++) { if (tree[i].OrganisationID == organisationID || Contains(tree[i].TreeChildren, organisationID)) { if (!onlyLowerBranches) { tree = new Organisation[] { tree[i] } } ; else { tree = new Organisation[] { GetNode(new Organisation[] { tree[i] }, organisationID) } }; } } } if (onlyLowerBranches && tree.Length > 0) // if taking only sub-tree, then reset the level to zero for the base node(s) { int levelAdjustment = tree[0].TreeLevel; for (int i = 0; i < tree.Length; i++) { AdjustLevel(ref tree[i], levelAdjustment); } } return(tree); }
/* * 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"; } }
public static DataTable GetFlattenedTree_DataTable(DataTable dt = null, bool showDeleted = false, int organisationID = 0, bool onlyLowerBranches = false, string org_type_ids = "") { if (dt == null) { dt = OrganisationDB.GetDataTable(0, showDeleted, true, false, false, true, true, "", false, org_type_ids); } dt.Columns.Add("tree_level", typeof(Int32)); Organisation[] tree = GetChildren(ref dt, "parent_organisation_id is NULL", 0); if (organisationID != 0) { for (int i = 0; i < tree.Length; i++) { if (tree[i].OrganisationID == organisationID || Contains(tree[i].TreeChildren, organisationID)) { if (!onlyLowerBranches) { tree = new Organisation[] { tree[i] } } ; else { tree = new Organisation[] { GetNode(new Organisation[] { tree[i] }, organisationID) } }; } } } DataTable newTable = dt.Clone(); Flatten(tree, ref newTable); if (onlyLowerBranches && newTable.Rows.Count > 0) // if taking only sub-tree, then reset the level to zero for the base node(s) { int levelAdjustment = Convert.ToInt32(newTable.Rows[0]["tree_level"]); for (int i = 0; i < newTable.Rows.Count; i++) { newTable.Rows[i]["tree_level"] = Convert.ToInt32(newTable.Rows[i]["tree_level"]) - levelAdjustment; } } return(newTable); }
protected DataTable GetOrgsDaTatable(UrlParamType urlParamType, bool showDeleted, string searchName = "", bool searchNameOnlyStartsWith = false) { DataTable dt = null; switch (GetUrlParamType()) { case UrlParamType.Clinic: dt = OrganisationDB.GetDataTable_Clinics(chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); break; case UrlParamType.AgedCare: dt = OrganisationDB.GetDataTable_AgedCareFacs(chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); break; case UrlParamType.Insurance: dt = OrganisationDB.GetDataTable_Insurance(chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); break; case UrlParamType.External: if (IsValidFormOrgTypeIDs()) { dt = OrganisationDB.GetDataTable_External(chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith, true, GetFormOrgTypeIDs()); } else { dt = OrganisationDB.GetDataTable_External(chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); } break; default: dt = OrganisationDB.GetDataTable(0, chkShowDeleted.Checked, true, false, false, true, false, searchName, searchNameOnlyStartsWith); break; } return(dt); }
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 GrdRegistration_RowDataBound(object sender, GridViewRowEventArgs e) { UserView userView = UserView.GetInstance(); Organisation org = null; if (IsValidFormID()) { org = OrganisationDB.GetByID(GetFormID()); } DataTable dt = Session["registerofferingtoorg_data"] as DataTable; bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value); if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow) { Label lblId = (Label)e.Row.FindControl("lblId"); DataRow[] foundRows = dt.Select("oo_organisation_offering_id=" + lblId.Text); DataRow thisRow = foundRows[0]; DropDownList ddlOffering = (DropDownList)e.Row.FindControl("ddlOffering"); if (ddlOffering != null) { //Offering[] incList_orig = OrganisationOfferingsDB.GetOfferingsByOrg(false, Convert.ToInt32(thisRow["organisation_organisation_id"])); //Offering[] incList = Offering.RemoveByID(incList_orig, Convert.ToInt32(thisRow["o_offering_id"])); //DataTable offering = OfferingDB.GetDataTable_AllNotInc(incList); //DataTable offering = OfferingDB.GetDataTable_AllNotInc(incList); string offering_invoice_type_ids = "-1"; if (userView.IsAgedCareView) { offering_invoice_type_ids = "3,4"; // 4 = AC } else if (userView.IsClinicView) { offering_invoice_type_ids = "1,3"; // 1 = Clinic } else { throw new Exception("Logged in to neither clinic nor aged care"); } bool isAgedCareResidentTypes = IsValidIsAgedCareResidentTypes() ? GetFormIsAgedCareResidentTypes() : false; DataTable offering = OfferingDB.GetDataTable(isAgedCareResidentTypes, offering_invoice_type_ids); offering.DefaultView.Sort = "o_name ASC"; foreach (DataRowView row in offering.DefaultView) { ddlOffering.Items.Add(new ListItem(row["o_name"].ToString(), row["o_offering_id"].ToString())); } ddlOffering.SelectedValue = thisRow["o_offering_id"].ToString(); } Utilities.AddConfirmationBox(e); if ((e.Row.RowState & DataControlRowState.Edit) > 0) { Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow); } } if (e.Row.RowType == DataControlRowType.Footer) { Label lblOrganisation = (Label)e.Row.FindControl("lblNewOrganisation"); if (lblOrganisation != null) { lblOrganisation.Text = org.Name; } DropDownList ddlOffering = (DropDownList)e.Row.FindControl("ddlNewOffering"); if (ddlOffering != null) { DropDownList ddlOrganisation = (DropDownList)e.Row.FindControl("ddlNewOrganisation"); DataTable organisation = OrganisationDB.GetDataTable(0, false, true, !userView.IsClinicView, !userView.IsAgedCareView, true, true); DataView dataView = new DataView(organisation); dataView.Sort = "name"; organisation = dataView.ToTable(); for (int i = 0; i < organisation.Rows.Count; i++) { Organisation o = OrganisationDB.Load(organisation.Rows[i]); ddlOrganisation.Items.Add(new ListItem(o.Name, o.OrganisationID.ToString())); } if (org != null) { ddlOrganisation.SelectedValue = org.OrganisationID.ToString(); } //Offering[] incList = OrganisationOfferingsDB.GetOfferingsByOrg(false, org.OrganisationID); //DataTable offering = OfferingDB.GetDataTable_AllNotInc(incList); string offering_invoice_type_ids = "-1"; if (userView.IsAgedCareView) { offering_invoice_type_ids = "1,2,3,4"; // 4 = AC } else if (userView.IsClinicView) { offering_invoice_type_ids = "1,2,3"; // 1 = Clinic } else { throw new Exception("Logged in to neither clinic nor aged care"); } bool isAgedCareResidentTypes = IsValidIsAgedCareResidentTypes() ? GetFormIsAgedCareResidentTypes() : false; DataTable offering = OfferingDB.GetDataTable(isAgedCareResidentTypes, offering_invoice_type_ids); DataView dv = new DataView(offering); dv.Sort = "o_name ASC"; offering = dv.ToTable(); foreach (DataRow row in offering.Rows) { ddlOffering.Items.Add(new ListItem(row["o_name"].ToString(), row["o_offering_id"].ToString())); } if (offering.Rows.Count == 0 || organisation.Rows.Count == 0) { hideFotter = true; } } } }
protected void GrdReferrer_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable dt = Session["referrerinfoclinicofref_data"] as DataTable; bool tblEmpty = (dt.Rows.Count == 1 && dt.Rows[0][0] == DBNull.Value); if (!tblEmpty && e.Row.RowType == DataControlRowType.DataRow) { Label lblId = (Label)e.Row.FindControl("lblId"); DataRow[] foundRows = dt.Select("organisation_id=" + lblId.Text); DataRow thisRow = foundRows[0]; DropDownList ddlOrgs = (DropDownList)e.Row.FindControl("ddlOrgs"); if (ddlOrgs != null) { string s = thisRow["original_organisation_id"].ToString(); DataTable dt_orgs = OrganisationDB.GetDataTable(0, chkShowDeleted.Checked, true, true, true, true, false, "", false, "191"); // check for deleted org DataRow[] foundRows_orgs = dt_orgs.Select("organisation_id=" + thisRow["original_organisation_id"].ToString()); if (!chkShowDeleted.Checked && foundRows_orgs.Length == 0) { DataTable dt_deleted_orgs = OrganisationDB.GetDataTable(0, true, true, true, true, true, false, "", false, "191"); foundRows_orgs = dt_deleted_orgs.Select("organisation_id=" + thisRow["original_organisation_id"].ToString()); if (foundRows_orgs.Length == 1) { dt_orgs.Rows.Add(foundRows_orgs[0].ItemArray); } } ddlOrgs.DataSource = dt_orgs; ddlOrgs.DataBind(); ddlOrgs.SelectedValue = thisRow["original_organisation_id"].ToString(); } HyperLink lnkContactInfo = (HyperLink)e.Row.FindControl("lnkContactInfo"); if (lnkContactInfo != null) { int entity_id = Convert.ToInt32(thisRow["entity_id"]); string addEditContactListPage; if (Utilities.GetAddressType().ToString() == "Contact") { addEditContactListPage = "AddEditContactList.aspx"; } else if (Utilities.GetAddressType().ToString() == "ContactAus") { addEditContactListPage = "ContactAusListV2.aspx"; } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } string allFeatures = "dialogWidth:525px;dialogHeight:430px;center:yes;resizable:no; scroll:no"; string js = "javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + entity_id.ToString() + "', '', '" + allFeatures + "');return false;"; lnkContactInfo.Visible = true; lnkContactInfo.NavigateUrl = " "; lnkContactInfo.Text = "Clinic Contact"; lnkContactInfo.Attributes.Add("onclick", js); } ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete"); if (btnDelete != null) { bool is_deleted = Convert.ToBoolean(thisRow["is_deleted"]); if (is_deleted) { btnDelete.CommandName = "_UnDelete"; btnDelete.ImageUrl = "~/images/tick-24.png"; btnDelete.AlternateText = "UnDelete"; btnDelete.ToolTip = "UnDelete"; } } Utilities.AddConfirmationBox(e); if ((e.Row.RowState & DataControlRowState.Edit) > 0) { Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow); } } if (e.Row.RowType == DataControlRowType.Footer) { DropDownList ddlNewOrgs = (DropDownList)e.Row.FindControl("ddlNewOrgs"); DataTable dt_orgs = OrganisationDB.GetDataTable(0, chkShowDeleted.Checked, true, true, true, true, false, "", false, "191"); ddlNewOrgs.DataSource = dt_orgs; ddlNewOrgs.DataBind(); } }
protected void FillOrganisationGrid() { UserView userView = UserView.GetInstance(); int patientID = IsValidFormPatient() ? GetFormPatient(false) : -1; //DataTable dt = patientID == -1 ? // OrganisationDB.GetDataTable(false, true, !incClinics, !incAgedCare, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked) : // RegisterPatientDB.GetDataTable_OrganisationsOf(patientID, true, !incClinics, !incAgedCare, true, txtSearchOrganisation.Text.Trim(), chkOrganisationSearchOnlyStartWith.Checked); //DataTable dt = patientID == -1 ? // OrganisationDB.GetDataTable(false, true, !incClinics, !incAgedCare, true, "", false) : // RegisterPatientDB.GetDataTable_OrganisationsOf(patientID, true, !incClinics, !incAgedCare, true, "", false); DataTable dt = OrganisationDB.GetDataTable(0, false, true, !userView.IsClinicView && !userView.IsGPView, !userView.IsAgedCareView, true, true, "", false); if (dt.Rows.Count == 1) { Response.Redirect("~/BookingsV2.aspx?orgs=" + dt.Rows[0]["organisation_id"] + (Request.QueryString["patient"] != null ? "&patient=" + Request.QueryString["patient"] : "")); return; } Session["selectorganisation_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["selectorganisation_sortexpression"] != null && Session["selectorganisation_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["selectorganisation_sortexpression"].ToString(); GrdOrganisation.DataSource = dataView; } else { GrdOrganisation.DataSource = dt; } try { GrdOrganisation.DataBind(); GrdOrganisation.PagerSettings.FirstPageText = "1"; GrdOrganisation.PagerSettings.LastPageText = GrdOrganisation.PageCount.ToString(); GrdOrganisation.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdOrganisation.DataSource = dt; GrdOrganisation.DataBind(); int TotalColumns = GrdOrganisation.Rows[0].Cells.Count; GrdOrganisation.Rows[0].Cells.Clear(); GrdOrganisation.Rows[0].Cells.Add(new TableCell()); GrdOrganisation.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdOrganisation.Rows[0].Cells[0].Text = "No Record Found"; } }
public static Organisation[] GetFlattenedTree(DataTable dt = null, bool showDeleted = false, int organisationID = 0, bool onlyLowerBranches = false, string org_type_ids = "") { if (dt == null) { dt = OrganisationDB.GetDataTable(0, showDeleted, true, false, false, true, true, "", false, org_type_ids); } dt.Columns.Add("tree_level", typeof(Int32)); Organisation[] tree = GetChildren(ref dt, "parent_organisation_id is NULL", 0); if (organisationID != 0) { for (int i = 0; i < tree.Length; i++) { if (tree[i].OrganisationID == organisationID || Contains(tree[i].TreeChildren, organisationID)) { if (!onlyLowerBranches) { tree = new Organisation[] { tree[i] } } ; else { tree = new Organisation[] { GetNode(new Organisation[] { tree[i] }, organisationID) } }; } } } DataTable newTable = dt.Clone(); Flatten(tree, ref newTable); if (onlyLowerBranches && newTable.Rows.Count > 0) // if taking only sub-tree, then reset the level to zero for the base node(s) { int levelAdjustment = Convert.ToInt32(newTable.Rows[0]["tree_level"]); for (int i = 0; i < newTable.Rows.Count; i++) { newTable.Rows[i]["tree_level"] = Convert.ToInt32(newTable.Rows[i]["tree_level"]) - levelAdjustment; } } ArrayList newList = new ArrayList(); Hashtable orgHash = new Hashtable(); for (int i = 0; i < newTable.Rows.Count; i++) { Organisation org = OrganisationDB.LoadAll(newTable.Rows[i]); org.TreeLevel = Convert.ToInt32(newTable.Rows[i]["tree_level"]); orgHash[org.OrganisationID] = org; newList.Add(org); } Organisation[] list = (Organisation[])newList.ToArray(typeof(Organisation)); for (int i = 0; i < list.Length; i++) { if (list[i].ParentOrganisation != null) { list[i].ParentOrganisation = (Organisation)orgHash[list[i].ParentOrganisation.OrganisationID]; } } return(list); }