protected void SetUpGUI() { ddlNewStaff.Items.Clear(); ddlNewStaff.Items.Add(new ListItem("All Staff", "-1")); DataTable dtStaff = StaffDB.GetDataTable(); for (int i = 0; i < dtStaff.Rows.Count; i++) { if (!Convert.ToBoolean(dtStaff.Rows[i]["staff_is_fired"]) && Convert.ToBoolean(dtStaff.Rows[i]["staff_is_provider"])) { ddlNewStaff.Items.Add(new ListItem(dtStaff.Rows[i]["person_firstname"].ToString() + " " + dtStaff.Rows[i]["person_surname"].ToString(), dtStaff.Rows[i]["staff_staff_id"].ToString())); } } ddlNewOffering.Style["max-width"] = "250px"; ddlNewOffering.Items.Clear(); ddlNewOffering.Items.Add(new ListItem("All Offerings", "-1")); DataTable dtOfferings = OfferingDB.GetDataTable(false, "1,3", "63,89"); for (int i = 0; i < dtOfferings.Rows.Count; i++) { if (!Convert.ToBoolean(dtOfferings.Rows[i]["o_is_deleted"])) { ddlNewOffering.Items.Add(new ListItem(dtOfferings.Rows[i]["o_name"].ToString(), dtOfferings.Rows[i]["o_offering_id"].ToString())); } } txtNewActiveDate.Text = DateTime.Today.ToString("dd-MM-yyyy"); }
protected void GrdStaffOfferings_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable dt = Session["staff_offerings_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("so_staff_offering_id=" + lblId.Text); DataRow thisRow = foundRows[0]; Utilities.AddConfirmationBox(e); if ((e.Row.RowState & DataControlRowState.Edit) > 0) { Utilities.SetEditRowBackColour(e, System.Drawing.Color.LightGoldenrodYellow); } } if (e.Row.RowType == DataControlRowType.Footer) { DropDownList ddlStaff = (DropDownList)e.Row.FindControl("ddlNewStaff"); DataTable staff = StaffDB.GetDataTable(); DataView dataView = new DataView(staff); dataView.Sort = "person_firstname, person_surname"; staff = dataView.ToTable(); for (int i = 0; i < staff.Rows.Count; i++) { Staff s = StaffDB.LoadAll(staff.Rows[i]); ddlStaff.Items.Add(new ListItem(s.Person.FullnameWithoutMiddlename, s.StaffID.ToString())); } DropDownList ddlOffering = (DropDownList)e.Row.FindControl("ddlNewOffering"); string offering_invoice_type_id = null; if (UserView.GetInstance().IsAgedCareView) { offering_invoice_type_id = "3,4"; // 4 = AC } else // if (!UserView.GetInstance().IsAgedCareView) { offering_invoice_type_id = "1,3"; // 4 = Clinic } DataTable offerings = OfferingDB.GetDataTable(false, offering_invoice_type_id); ddlOffering.DataSource = offerings; ddlOffering.DataTextField = "o_name"; ddlOffering.DataValueField = "o_offering_id"; ddlOffering.DataBind(); } }
protected void FillOfferingGrid() { UserView userView = UserView.GetInstance(); DataTable dt = OfferingDB.GetDataTable(false, userView.IsAgedCareView ? "3,4" : "1,3", "63,89", false, txtSearchOffering.Text.Trim(), chkOfferingSearchOnlyStartWith.Checked); Session["offeringlist_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["offeringlist_sortexpression"] != null && Session["offeringlist_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["offeringlist_sortexpression"].ToString(); GrdOffering.DataSource = dataView; } else { GrdOffering.DataSource = dt; } try { GrdOffering.DataBind(); GrdOffering.PagerSettings.FirstPageText = "1"; GrdOffering.PagerSettings.LastPageText = GrdOffering.PageCount.ToString(); GrdOffering.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt.Rows.Add(dt.NewRow()); GrdOffering.DataSource = dt; GrdOffering.DataBind(); int TotalColumns = GrdOffering.Rows[0].Cells.Count; GrdOffering.Rows[0].Cells.Clear(); GrdOffering.Rows[0].Cells.Add(new TableCell()); GrdOffering.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdOffering.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void SetUpGUI() { ddlStaff.Items.Clear(); ddlStaff.Items.Add(new ListItem("All Providers", "-1")); DataTable dtStaff = StaffDB.GetDataTable(); for (int i = 0; i < dtStaff.Rows.Count; i++) { if (!Convert.ToBoolean(dtStaff.Rows[i]["staff_is_fired"]) && Convert.ToBoolean(dtStaff.Rows[i]["staff_is_provider"])) { ddlStaff.Items.Add(new ListItem(dtStaff.Rows[i]["person_firstname"].ToString() + " " + dtStaff.Rows[i]["person_surname"].ToString(), dtStaff.Rows[i]["staff_staff_id"].ToString())); } } ddlOfferings.Style["max-width"] = "375px"; ddlOfferings.Items.Clear(); ddlOfferings.Items.Add(new ListItem("All Offerings", "-1")); DataTable dtOfferings = OfferingDB.GetDataTable(false, "1,3", "63,89"); for (int i = 0; i < dtOfferings.Rows.Count; i++) { if (!Convert.ToBoolean(dtOfferings.Rows[i]["o_is_deleted"])) { ddlOfferings.Items.Add(new ListItem(dtOfferings.Rows[i]["o_name"].ToString(), dtOfferings.Rows[i]["o_offering_id"].ToString())); } } if (IsValidFormStaffID()) { ddlStaff.SelectedValue = StaffDB.GetByID(GetFormStaffID()).StaffID.ToString(); } if (IsValidFormOfferingID()) { ddlOfferings.SelectedValue = OfferingDB.GetByID(GetFormOfferingID()).OfferingID.ToString(); } }
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; } } } }
public void FillOfferingGrid() { Booking.InvoiceType invType = InvoiceType; decimal GST_Percent = Convert.ToDecimal(((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["GST_Percent"].Value); decimal GST_Modifier = GST_Percent / (decimal)100; bool hasGstItems_HC = false; bool hasGstItems_PT = false; DataTable dt_offering; DataTable dt_org_offering = null; // just to get the prices if there is a specific price for this clinic try { if (this.booking == null) { dt_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, 0); // get empty datatable } else { if (booking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 5) // clinics { dt_offering = OfferingDB.GetDataTable(false, "1,3", "63"); dt_org_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, booking.Organisation.OrganisationID, "1,3", "63,89"); // dt_offering = OfferingDB.GetDataTable(1); } else if (booking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 6) // aged care { dt_offering = OfferingDB.GetDataTable(false, "3,4", "63"); dt_org_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, booking.Organisation.OrganisationID, "3,4", "63,89"); // dt_offering = OfferingDB.GetDataTable(4); } else { throw new Exception("Unknown booking screen type"); } // If row exists in org-offering table, then use that price for (int i = 0; i < dt_org_offering.Rows.Count; i++) { for (int j = 0; j < dt_offering.Rows.Count; j++) { if (Convert.ToInt32(dt_offering.Rows[j]["o_offering_id"]) == Convert.ToInt32(dt_org_offering.Rows[i]["o_offering_id"])) { dt_offering.Rows[j]["o_default_price"] = dt_org_offering.Rows[i]["o_default_price"]; } } } } for (int i = dt_offering.Rows.Count - 1; i >= 0; i--) { // remove service they are here for if (booking.Offering.OfferingID == Convert.ToInt32(dt_offering.Rows[i]["o_offering_id"])) { dt_offering.Rows.RemoveAt(i); } else { // if pt pays invoice, use default price for all (so no change) // if medicare invoice, use default price for all offerings OTHER than the service they are here for (so no change) // if dva invoice, use dva price for all // Remove this ... and show pt price and hc price on the screen and use that on the data tables // //if (invType == Booking.InvoiceType.DVA) // dt_offering.Rows[i]["o_default_price"] = dt_offering.Rows[i]["o_dva_charge"]; } } // add all products (by invoice type id 1 or 4, and offering_type_ids for only products : "89") DataTable dt_products = null; if (this.booking == null) { dt_products = OfferingDB.GetDataTable(false, UserView.GetInstance().IsAgedCareView ? "3,4" : "1,3", "89"); } else { if (booking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 5) { dt_products = OfferingDB.GetDataTable(false, "1,3", "89"); } else if (booking.Organisation.OrganisationType.OrganisationTypeGroup.ID == 6) { dt_products = OfferingDB.GetDataTable(false, "3,4", "89"); } else { throw new Exception("Unknown booking screen type"); } // // If row exists in org-offering table, then use that price // if (dt_org_offering != null) { for (int i = 0; i < dt_org_offering.Rows.Count; i++) { for (int j = 0; j < dt_products.Rows.Count; j++) { if (Convert.ToInt32(dt_products.Rows[j]["o_offering_id"]) == Convert.ToInt32(dt_org_offering.Rows[i]["o_offering_id"])) { dt_products.Rows[j]["o_default_price"] = dt_org_offering.Rows[i]["o_default_price"]; } } } } } for (int i = 0; i < dt_products.Rows.Count; i++) { dt_offering.ImportRow(dt_products.Rows[i]); } bool invoiceGapPayments = Convert.ToInt32(SystemVariableDB.GetByDescr("InvoiceGapPayments").Value) == 1; dt_offering.Columns.Add("hc_paid"); dt_offering.Columns.Add("pt_price", typeof(decimal)); dt_offering.Columns.Add("hc_price", typeof(decimal)); dt_offering.Columns.Add("pt_gst", typeof(decimal)); dt_offering.Columns.Add("hc_gst", typeof(decimal)); for (int i = 0; i < dt_offering.Rows.Count; i++) { bool isGstExempt = Convert.ToBoolean(dt_offering.Rows[i]["o_is_gst_exempt"]); string medicare_company_code = dt_offering.Rows[i]["o_medicare_company_code"].ToString(); string dva_company_code = dt_offering.Rows[i]["o_dva_company_code"].ToString(); string tac_company_code = dt_offering.Rows[i]["o_tac_company_code"].ToString(); bool incGstOnPTInvoices = IncGstOnInvoices_Private && !isGstExempt; bool incGstOnHCInvoices = (invType == Booking.InvoiceType.Medicare && IncGstOnInvoices_MC && !isGstExempt) || (invType == Booking.InvoiceType.DVA && IncGstOnInvoices_DVA && !isGstExempt) || (invType == Booking.InvoiceType.Insurance && IncGstOnInvoices_Insurance && !isGstExempt); dt_offering.Rows[i]["pt_price"] = Convert.ToDecimal(dt_offering.Rows[i]["o_default_price"]); dt_offering.Rows[i]["hc_price"] = 0; dt_offering.Rows[i]["pt_gst"] = !incGstOnPTInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["pt_price"]) * GST_Modifier; dt_offering.Rows[i]["hc_gst"] = !incGstOnHCInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["hc_price"]) * GST_Modifier; if (invType == Booking.InvoiceType.DVA) { dt_offering.Rows[i]["hc_paid"] = dva_company_code.Length > 0; if (dva_company_code.Length > 0) { decimal default_price = Convert.ToDecimal(dt_offering.Rows[i]["o_default_price"]); decimal dva_price = Convert.ToDecimal(dt_offering.Rows[i]["o_dva_charge"]); dt_offering.Rows[i]["pt_price"] = (invoiceGapPayments && default_price > dva_price) ? default_price - dva_price : 0; dt_offering.Rows[i]["hc_price"] = dva_price; dt_offering.Rows[i]["pt_gst"] = !incGstOnPTInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["pt_price"]) * GST_Modifier; dt_offering.Rows[i]["hc_gst"] = !incGstOnHCInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["hc_price"]) * GST_Modifier; } } if (invType == Booking.InvoiceType.Insurance) { dt_offering.Rows[i]["hc_paid"] = tac_company_code.Length > 0; //if (tac_company_code.Length > 0) //{ decimal default_price = Convert.ToDecimal(dt_offering.Rows[i]["o_default_price"]); decimal tac_price = (tac_company_code.Length > 0) ? Convert.ToDecimal(dt_offering.Rows[i]["o_tac_charge"]) : default_price; dt_offering.Rows[i]["pt_price"] = (invoiceGapPayments && default_price > tac_price) ? default_price - tac_price : 0; dt_offering.Rows[i]["hc_price"] = tac_price; dt_offering.Rows[i]["pt_gst"] = !incGstOnPTInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["pt_price"]) * GST_Modifier; dt_offering.Rows[i]["hc_gst"] = !incGstOnHCInvoices ? 0 : Convert.ToDecimal(dt_offering.Rows[i]["hc_price"]) * GST_Modifier; //} } else if (InvoiceType == Booking.InvoiceType.Medicare) { dt_offering.Rows[i]["hc_paid"] = false; // medicare invoice - all items to add beyond booking offering are privately invoiced } else { dt_offering.Rows[i]["hc_paid"] = false; } if (!isGstExempt && Convert.ToDecimal(dt_offering.Rows[i]["hc_gst"]) > 0) { hasGstItems_HC = true; } if (!isGstExempt && Convert.ToDecimal(dt_offering.Rows[i]["pt_gst"]) > 0) { hasGstItems_PT = true; } } } catch (Exception ex) { SetErrorMessage("", ex.ToString()); //return; throw; } Session["data_offering"] = dt_offering; if (!hasGstItems_HC && !hasGstItems_PT) { GrdOffering.Columns[7].Visible = false; GrdOffering.Columns[5].Visible = false; } if (dt_offering.Rows.Count > 0) { if (IsPostBack && Session["sortExpression_Offering"] != null && Session["sortExpression_Offering"].ToString().Length > 0) { DataView dataView = new DataView(dt_offering); dataView.Sort = Session["sortExpression_Offering"].ToString(); GrdOffering.DataSource = dataView; } else { GrdOffering.DataSource = dt_offering; } try { GrdOffering.DataBind(); // add items for javascript live search so can have // dropdown that when chosing an item, it clicks the right button string fieldsSep = "[[fieldsSep]]"; string itemSep = "[[itemSep]]"; string output = string.Empty; for (int i = 0; i < GrdOffering.Rows.Count; i++) { Label lblShortName = (Label)GrdOffering.Rows[i].FindControl("lblShortName"); Button btnAdd = (Button)GrdOffering.Rows[i].FindControl("btnAdd"); output += (i == 0 ? "" : itemSep) + lblShortName.Text + fieldsSep + btnAdd.ClientID; } hiddenItemList.Value = output; // end live search data } catch (Exception) { //SetErrorMessage("", ex.ToString()); // already should be showing in page containing this control this.HideElementsForError(); throw; } } else { dt_offering.Rows.Add(dt_offering.NewRow()); GrdOffering.DataSource = dt_offering; GrdOffering.DataBind(); int TotalColumns = GrdOffering.Rows[0].Cells.Count; GrdOffering.Rows[0].Cells.Clear(); GrdOffering.Rows[0].Cells.Add(new TableCell()); GrdOffering.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdOffering.Rows[0].Cells[0].Text = "No Items Found"; } }
public static DataTable GetDataTableByOrg(Organisation organisation) { DataTable dt_offering = null; DataTable dt_org_offering = null; if (organisation == null) { dt_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, 0); // get empty datatable } else { if (organisation.OrganisationType.OrganisationTypeGroup.ID == 5) // clinics { dt_offering = OfferingDB.GetDataTable(false, "1,2,3", "63"); dt_org_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, organisation.OrganisationID, "1,2,3", "63,89"); // dt_offering = OfferingDB.GetDataTable(1); } else if (organisation.OrganisationType.OrganisationTypeGroup.ID == 6) // aged care { dt_offering = OfferingDB.GetDataTable(false, "1,2,3,4", "63"); DataTable dt_offering2 = OfferingDB.GetDataTable(true, "1,2,3,4", "63"); dt_offering.Merge(dt_offering2); dt_org_offering = OrganisationOfferingsDB.GetDataTable_OfferingsByOrg(true, organisation.OrganisationID, "1,2,3,4", "63,89"); // dt_offering = OfferingDB.GetDataTable(4); } else { throw new Exception("Unknown org type group"); } // // If row exists in org-offering table, then use that price // for (int i = 0; i < dt_org_offering.Rows.Count; i++) { for (int j = 0; j < dt_offering.Rows.Count; j++) { if (Convert.ToInt32(dt_offering.Rows[j]["o_offering_id"]) == Convert.ToInt32(dt_org_offering.Rows[i]["o_offering_id"])) { dt_offering.Rows[j]["o_default_price"] = dt_org_offering.Rows[i]["o_default_price"]; } } } } // add all products (by invoice type id 1 or 4, and offering_type_ids for only products : "89") DataTable dt_products = null; if (organisation == null) { dt_products = OfferingDB.GetDataTable(false, -1, "89"); } else { if (organisation.OrganisationType.OrganisationTypeGroup.ID == 5) { dt_products = OfferingDB.GetDataTable(false, "1,2,3", "89"); } else if (organisation.OrganisationType.OrganisationTypeGroup.ID == 6) { dt_products = OfferingDB.GetDataTable(false, "1,2,3,4", "89"); } else { throw new Exception("Unknown booking screen type"); } // // If row exists in org-offering table, then use that price // if (dt_org_offering != null) { for (int i = 0; i < dt_org_offering.Rows.Count; i++) { for (int j = 0; j < dt_products.Rows.Count; j++) { if (Convert.ToInt32(dt_products.Rows[j]["o_offering_id"]) == Convert.ToInt32(dt_org_offering.Rows[i]["o_offering_id"])) { dt_products.Rows[j]["o_default_price"] = dt_org_offering.Rows[i]["o_default_price"]; } } } } } for (int i = 0; i < dt_products.Rows.Count; i++) { dt_offering.ImportRow(dt_products.Rows[i]); } return(dt_offering); }
protected void FillGrid() { bool isAgedCareResidentTypes = IsValidIsAgedCareResidentTypes() ? GetFormIsAgedCareResidentTypes() : false; if (isAgedCareResidentTypes) { lblHeading.Text = "Aged Care Resident Types"; } 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; } DataTable dt = OfferingDB.GetDataTable(isAgedCareResidentTypes, "1,3,4", null, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith); Session["offeringinfo_data"] = dt; this.GrdOffering.AllowPaging = false; if (!IsPostBack) { chkUsePaging.Checked = dt.Rows.Count > 50; } this.GrdOffering.AllowPaging = chkUsePaging.Checked; if (dt.Rows.Count > 0) { if (IsPostBack && Session["offeringinfo_sortexpression"] != null && Session["offeringinfo_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["offeringinfo_sortexpression"].ToString(); GrdOffering.DataSource = dataView; } else { GrdOffering.DataSource = dt; } try { GrdOffering.DataBind(); GrdOffering.PagerSettings.FirstPageText = "1"; GrdOffering.PagerSettings.LastPageText = GrdOffering.PageCount.ToString(); GrdOffering.DataBind(); } catch (Exception ex) { HideTableAndSetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdOffering.DataSource = dt; GrdOffering.DataBind(); int TotalColumns = GrdOffering.Rows[0].Cells.Count; GrdOffering.Rows[0].Cells.Clear(); GrdOffering.Rows[0].Cells.Add(new TableCell()); GrdOffering.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdOffering.Rows[0].Cells[0].Text = "No Record Found"; } }