public static Offering GetOfferingByOrgAndOffering(int organisation_id, int offering_id) { string sql = JoinedSql_Offerings + " AND OrganisationOfferings.date_active <= GETDATE() AND OrganisationOfferings.organisation_id = " + organisation_id.ToString() + " AND OrganisationOfferings.offering_id = " + offering_id.ToString() + " ORDER BY OrganisationOfferings.date_active DESC"; DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; return((tbl.Rows.Count == 0) ? null : OfferingDB.LoadAll(tbl.Rows[0])); }
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 Tuple <Booking, PatientReferrer, bool, string, HealthCard> LoadRow(DataRow row) { Booking booking = BookingDB.Load(row, "booking_", true, false); booking.Offering = OfferingDB.Load(row, "offering_"); PatientReferrer pr = PatientReferrerDB.Load(row, "pr_"); pr.RegisterReferrer = RegisterReferrerDB.Load(row, "regref_"); pr.RegisterReferrer.Referrer = ReferrerDB.Load(row, "referrer_"); pr.RegisterReferrer.Referrer.Person = PersonDB.Load(row, "referrer_person_"); pr.RegisterReferrer.Referrer.Person.Title = IDandDescrDB.Load(row, "referrer_person_title_title_id", "referrer_person_title_descr"); if (row["organisation_organisation_id"] != DBNull.Value) { pr.RegisterReferrer.Organisation = OrganisationDB.Load(row, "organisation_"); } pr.Patient = PatientDB.Load(row, "patient_"); pr.Patient.Person = PersonDB.Load(row, "patient_person_"); pr.Patient.Person.Title = IDandDescrDB.Load(row, "patient_person_title_title_id", "patient_person_title_descr"); bool refHasEmail = Convert.ToInt32(row["ref_has_email"]) == 1; string refEmail = row["ref_email"] == DBNull.Value ? null : Convert.ToString(row["ref_email"]); HealthCard hc = HealthCardDB.Load(row, "hc_"); return(new Tuple <Booking, PatientReferrer, bool, string, HealthCard>(booking, pr, refHasEmail, refEmail, hc)); }
private void FillEditViewForm(bool isEditMode) { Offering offering = OfferingDB.GetByID(GetFormID()); if (offering == null) { HideTableAndSetErrorMessage("Invalid Offering ID"); return; } lblId.Text = offering.OfferingID.ToString(); lblOffering.Text = offering.Name; txtPopupMessage.Text = offering.PopupMessage; if (isEditMode) { } else { } if (isEditMode) { btnSubmit.Text = "Update"; } else // is view mode { btnSubmit.Visible = false; btnCancel.Text = "Close"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Utilities.SetNoCache(Response); } try { if (Session == null || Session["DB"] == null) { throw new SessionTimedOutException(); } string patient_id = Request.QueryString["patient_id"]; if (patient_id == null || !Regex.IsMatch(patient_id, @"^\d+$")) { throw new CustomMessageException(); } Patient patient = PatientDB.GetByID(Convert.ToInt32(patient_id)); if (patient == null) { throw new CustomMessageException(); } string offering_id = Request.QueryString["offering_id"]; if (offering_id == null || !Regex.IsMatch(offering_id, @"^\d+$")) { throw new CustomMessageException(); } Offering offering = OfferingDB.GetByID(Convert.ToInt32(offering_id)); if (offering == null) { throw new CustomMessageException(); } string booking_datetime = Request.QueryString["booking_datetime"]; if (booking_datetime == null || !Regex.IsMatch(booking_datetime, @"^\d{4}_\d{2}_\d{2}_\d{4}$")) { throw new CustomMessageException(); } DateTime dateTime = ConvertStringToDateTime(booking_datetime); int nbrMedicareThisServiceSoFarThisPeriod = (int)InvoiceDB.GetMedicareCountByPatientAndDateRange(patient.PatientID, dateTime.Date.AddMonths(-1 * offering.MaxNbrClaimableMonths), dateTime.Date, offering.OfferingID); // return "[done]:[limit]" Response.Write(nbrMedicareThisServiceSoFarThisPeriod + ":" + offering.MaxNbrClaimable + ":" + offering.MaxNbrClaimableMonths); } catch (SessionTimedOutException) { Utilities.UnsetSessionVariables(); Response.Write("SessionTimedOutException"); } catch (Exception ex) { Response.Write("Exception: " + (Utilities.IsDev() ? ex.ToString() : "please contact system administrator.")); } }
protected void btnUpdatePrice_Command(object sender, CommandEventArgs e) { if (e.CommandName == "UpdateMedicarePriceAll") { decimal newPrice = Convert.ToDecimal(txtNewPrice.Text); OfferingDB.UpdateAllMedicare(newPrice); FillGrid(); } }
public static Offering[] GetOfferingsByOrg(string organisation_ids) { DataTable tbl = GetDataTable_OfferingsByOrg(organisation_ids); Offering[] list = new Offering[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = OfferingDB.LoadAll(tbl.Rows[i]); } return(list); }
public static Offering[] GetOfferingsByOrg(bool only_active, string organisation_ids, string offering_invoice_type_ids = null, string offering_type_ids = null) { DataTable tbl = GetDataTable_OfferingsByOrg(only_active, organisation_ids, offering_invoice_type_ids, offering_type_ids); Offering[] list = new Offering[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = OfferingDB.LoadAll(tbl.Rows[i]); } return(list); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (GetUrlParamType() == UrlParamType.View) { Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "edit")); } else if (GetUrlParamType() == UrlParamType.Edit) { if (!IsValidFormID()) { HideTableAndSetErrorMessage(); return; } int offeringID = GetFormID(); if (!OfferingDB.Exists(offeringID)) { HideTableAndSetErrorMessage("Invalid Offering ID"); return; } OfferingDB.UpdatePopupMessage(offeringID, txtPopupMessage.Text); //close this window Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>"); } else if (GetUrlParamType() == UrlParamType.Add) { if (!IsValidFormID()) { HideTableAndSetErrorMessage(); return; } int offeringID = GetFormID(); if (!OfferingDB.Exists(offeringID)) { HideTableAndSetErrorMessage("Invalid Offering ID"); return; } OfferingDB.UpdatePopupMessage(offeringID, txtPopupMessage.Text); // close this window Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>"); } else { HideTableAndSetErrorMessage("", "Invalid URL Parameters"); } }
protected void btnUpdateGstExempt_Command(object sender, CommandEventArgs e) { if (e.CommandName == "SetAllGstExempt") { OfferingDB.UpdateAllGstExempt(true); FillGrid(); } if (e.CommandName == "SetAllGstNotExempt") { OfferingDB.UpdateAllGstExempt(false); FillGrid(); } }
public static Stock[] GetByOrg(int organisation_id) { string sql = JoinedSql + " AND s.organisation_id = " + organisation_id.ToString() + " ORDER BY o.name"; DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; Stock[] stockList = new Stock[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { stockList[i] = StockDB.Load(tbl.Rows[i], "s_"); stockList[i].Offering = OfferingDB.Load(tbl.Rows[i], "o_"); } return(stockList); }
public static Hashtable GetHashtableByOrg(Organisation organisation) { Hashtable hash = new Hashtable(); DataTable dt_offering = GetDataTableByOrg(organisation); for (int i = 0; i < dt_offering.Rows.Count; i++) { Offering offering = OfferingDB.LoadAll(dt_offering.Rows[i]); hash[offering.OfferingID] = offering; } return(hash); }
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(); } }
public static Hashtable GetColorCodes() { Hashtable offeringColourHash = new Hashtable(); Offering[] offerings = OfferingDB.GetAll(false, null); foreach (Offering offering in offerings) { if (offering.UseCustomColor) { offeringColourHash[offering.OfferingID] = offering.CustomColor; } } return(offeringColourHash); }
public static System.Collections.Hashtable GetHashByOrg(int org_id) { System.Collections.Hashtable orgOfferings = new System.Collections.Hashtable(); DataTable dt_orgOfferings = StockDB.GetDataTable_ByOrg(org_id); for (int i = 0; i < dt_orgOfferings.Rows.Count; i++) { Stock curStock = StockDB.Load(dt_orgOfferings.Rows[i], "s_"); curStock.Offering = OfferingDB.Load(dt_orgOfferings.Rows[i], "o_"); orgOfferings[curStock.Offering.OfferingID] = curStock; } return(orgOfferings); }
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 Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Utilities.SetNoCache(Response); } try { if (Session == null || Session["DB"] == null) { throw new SessionTimedOutException(); } string offering_id = Request.QueryString["offering"]; if (offering_id == null || !Regex.IsMatch(offering_id, @"^\-?\d+$")) { throw new CustomMessageException(); } Offering offering = OfferingDB.GetByID(Convert.ToInt32(offering_id)); if (offering_id == "-1" || offering == null) { throw new CustomMessageException(); } string fieldsSep = "<<sep>>"; string serialized = offering.Name + fieldsSep + offering.ServiceTimeMinutes + fieldsSep + offering.PopupMessage + fieldsSep + offering.Field.ID + fieldsSep + offering.Field.Descr + fieldsSep; Response.Write(serialized); } catch (SessionTimedOutException) { Utilities.UnsetSessionVariables(); Response.Write("SessionTimedOutException"); } catch (Exception ex) { Response.Write("Exception: " + (Utilities.IsDev() ? ex.ToString() : "please contact system administrator.")); } }
public static InvoiceLine LoadAll(DataRow row) { InvoiceLine line = Load(row); if (row["offering_id"] != DBNull.Value) { line.Offering = OfferingDB.Load(row); } if (row["patient_id"] != DBNull.Value) { line.Patient = PatientDB.Load(row, "patient_"); line.Patient.Person = PersonDB.Load(row, "patient_person_"); line.Patient.Person.Title = IDandDescrDB.Load(row, "title_patient_title_id", "title_patient_descr"); } return(line); }
private void FillEmptyAddForm() { Offering offering = OfferingDB.GetByID(GetFormID()); if (offering == null) { HideTableAndSetErrorMessage("Invalid Offering ID"); return; } lblId.Text = offering.OfferingID.ToString(); lblOffering.Text = offering.Name; txtPopupMessage.Text = offering.PopupMessage; btnSubmit.Text = "Add Popup Message"; btnCancel.Visible = true; }
public static DataTable AddIsActiveFieldToRows(DataTable dt_original) { DataTable dt = dt_original.Copy(); dt.Columns.Add("is_active", typeof(bool)); System.Collections.Hashtable offerings = new System.Collections.Hashtable(); for (int i = 0; i < dt.Rows.Count; i++) { OrganisationOfferings curOrgOffering = OrganisationOfferingsDB.Load(dt.Rows[i], "oo_"); curOrgOffering.Offering = OfferingDB.Load(dt.Rows[i], "o_"); if (curOrgOffering.DateActive.Date > DateTime.Today) // if date after today - ignore (its inactive) { continue; } if (offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)] == null) { offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)] = curOrgOffering; } else if (((OrganisationOfferings)offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)]).DateActive < curOrgOffering.DateActive) { offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)] = curOrgOffering; } else if (((OrganisationOfferings)offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)]).DateActive == curOrgOffering.DateActive && ((OrganisationOfferings)offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)]).OrganisationOfferingID > curOrgOffering.OrganisationOfferingID) { offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)] = curOrgOffering; } } for (int i = 0; i < dt.Rows.Count; i++) { OrganisationOfferings curOrgOffering = OrganisationOfferingsDB.Load(dt.Rows[i], "oo_"); curOrgOffering.Offering = OfferingDB.Load(dt.Rows[i], "o_"); OrganisationOfferings activeOrgOffering = (OrganisationOfferings)(offerings[new Hashtable2D.Key(curOrgOffering.Offering.OfferingID, curOrgOffering.Organisation.OrganisationID)]); dt.Rows[i]["is_active"] = curOrgOffering.OrganisationOfferingID == activeOrgOffering.OrganisationOfferingID; if (dt.Rows[i]["oo_date_active"] == DBNull.Value) { dt.Rows[i]["is_active"] = false; } } return(dt); }
public static StaffOfferings LoadAll(DataRow row) { StaffOfferings so = Load(row, "so_"); so.Offering = OfferingDB.Load(row, "o_"); so.Offering.OfferingType = IDandDescrDB.Load(row, "type_offering_type_id", "type_descr"); so.Offering.Field = IDandDescrDB.Load(row, "fld_field_id", "fld_descr"); so.Offering.AgedCarePatientType = IDandDescrDB.Load(row, "acpatientcat_aged_care_patient_type_id", "acpatientcat_descr"); so.Offering.OfferingInvoiceType = IDandDescrDB.Load(row, "invtype_offering_invoice_type_id", "invtype_descr"); so.Staff = StaffDB.Load(row, "staff_"); so.Staff.Person = PersonDB.Load(row, "person_"); so.Staff.Person.Title = IDandDescrDB.Load(row, "title_title_id", "title_descr"); so.Staff.Field = IDandDescrDB.Load(row, "field_field_id", "field_descr"); so.Staff.StaffPosition = StaffPositionDB.Load(row, "staff_position_"); so.Staff.CostCentre = CostCentreDB.Load(row, "cost_centre_"); return(so); }
public static System.Collections.Hashtable GetHashActiveByOrg(int org_id) { System.Collections.Hashtable activeOrgOfferings = new System.Collections.Hashtable(); DataTable dt_activeOrgOfferings = OrganisationOfferingsDB.GetDataTable_ByOrg(org_id); dt_activeOrgOfferings = OrganisationOfferingsDB.AddIsActiveFieldToRows(dt_activeOrgOfferings); for (int i = dt_activeOrgOfferings.Rows.Count - 1; i >= 0; i--) { if (Convert.ToBoolean(dt_activeOrgOfferings.Rows[i]["is_active"])) { OrganisationOfferings curOrgOffering = OrganisationOfferingsDB.Load(dt_activeOrgOfferings.Rows[i], "oo_"); curOrgOffering.Offering = OfferingDB.Load(dt_activeOrgOfferings.Rows[i], "o_"); activeOrgOfferings[curOrgOffering.Offering.OfferingID] = curOrgOffering; } } return(activeOrgOfferings); }
public static void UpdateAndCheckWarning(int organisation_id, int offering_id, int qtyUsed) { Organisation org = OrganisationDB.GetByID(organisation_id); Offering offering = OfferingDB.GetByID(offering_id); Stock[] stockList = StockDB.GetByOrg(org.OrganisationID); string warningEmail = SystemVariableDB.GetByDescr("StockWarningNotificationEmailAddress").Value; for (int i = 0; i < stockList.Length; i++) { if (offering.OfferingID == stockList[i].Offering.OfferingID && stockList[i].Quantity >= 0) { int prevQty = stockList[i].Quantity; int postQty = stockList[i].Quantity - qtyUsed; if (postQty < 0) { postQty = 0; } if (warningEmail.Length > 0 && stockList[i].WarningAmount >= 0 && qtyUsed > 0 && stockList[i].WarningAmount < prevQty && stockList[i].WarningAmount >= postQty) { try { Emailer.SimpleEmail( warningEmail, "Stock Warning Level Reached For " + stockList[i].Offering.Name + " at " + org.Name, "This is an automated email to notify you that the stock warning level of <b>" + stockList[i].WarningAmount + "</b> items that was set for <b>" + stockList[i].Offering.Name + "</b> at <b>" + org.Name + "</b> has been reached and you may need to re-stock.<br /><br />Best regards,<br />Mediclinic", true, null, null ); } catch (Exception ex) { Logger.LogException(ex, true); } } StockDB.UpdateQuantity(stockList[i].StockID, postQty); } } }
public static BookingPatientOffering LoadAll(DataRow row) { BookingPatientOffering bpo = Load(row, "bpo_"); bpo.Offering = OfferingDB.Load(row, "offering_"); bpo.Offering.Field = IDandDescrDB.Load(row, "offeringfield_field_id", "offeringfield_descr"); bpo.AddedBy = StaffDB.Load(row, "added_by_"); bpo.AddedBy.Person = PersonDB.Load(row, "added_by_person_"); bpo.AddedBy.Person.Title = IDandDescrDB.Load(row, "title_added_by_title_id", "title_added_by_descr"); if (row["deleted_by_person_person_id"] != DBNull.Value) { bpo.DeletedBy = StaffDB.Load(row, "deleted_by_"); bpo.DeletedBy.Person = PersonDB.Load(row, "deleted_by_person_"); bpo.DeletedBy.Person.Title = IDandDescrDB.Load(row, "title_deleted_by_title_id", "title_deleted_by_descr"); } return(bpo); }
public static OfferingOrder LoadAll(DataRow row) { OfferingOrder o = Load(row, "offeringorder_"); if (row["organisation_organisation_id"] != DBNull.Value) { o.Organisation = OrganisationDB.Load(row, "organisation_"); o.Organisation.OrganisationType = OrganisationTypeDB.Load(row, "org_type_"); o.Organisation.OrganisationType.OrganisationTypeGroup = IDandDescrDB.Load(row, "typegroup_organisation_type_group_id", "typegroup_descr"); } if (row["staff_staff_id"] != DBNull.Value) { o.Staff = StaffDB.Load(row, "staff_"); } if (row["staff_staff_id"] != DBNull.Value) { o.Staff.Person = PersonDB.Load(row, "person_staff_"); o.Staff.Person.Title = IDandDescrDB.Load(row, "title_staff_title_id", "title_staff_descr"); } if (row["patient_patient_id"] != DBNull.Value) { o.Patient = PatientDB.Load(row, "patient_"); } if (row["patient_patient_id"] != DBNull.Value) { o.Patient.Person = PersonDB.Load(row, "person_patient_"); o.Patient.Person.Title = IDandDescrDB.Load(row, "title_patient_title_id", "title_patient_descr"); } if (row["offering_offering_id"] != DBNull.Value) { o.Offering = OfferingDB.Load(row, "offering_"); } if (row["offeringfield_field_id"] != DBNull.Value) { o.Offering.Field = IDandDescrDB.Load(row, "offeringfield_field_id", "offeringfield_descr"); } return(o); }
protected void GrdOffering_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdOffering.Rows[e.RowIndex].FindControl("lblId"); try { OfferingDB.UpdateInactive(Convert.ToInt32(lblId.Text)); } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { SetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); }
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"; } }
protected void FillGrid() { bool isAgedCareResidentTypes = IsValidIsAgedCareResidentTypes() ? GetFormIsAgedCareResidentTypes() : false; if (isAgedCareResidentTypes) { lblHeading.Text = "Aged Care Resident Types - Specific Prices Per Facility/Wing/Unit"; } Organisation org = null; if (IsValidFormID()) { org = OrganisationDB.GetByID(GetFormID()); } DataTable dt = org == null ? dt = OrganisationOfferingsDB.GetDataTable(false, UserView.GetInstance().IsClinicView ? 5 : 6) : OrganisationOfferingsDB.GetDataTable_ByOrg(org.OrganisationID); for (int i = dt.Rows.Count - 1; i >= 0; i--) { Offering o = OfferingDB.Load(dt.Rows[i], "o_"); if ((isAgedCareResidentTypes && o.AgedCarePatientType.ID == 1) || (!isAgedCareResidentTypes && o.AgedCarePatientType.ID != 1)) { dt.Rows.RemoveAt(i); } } dt = OrganisationOfferingsDB.AddIsActiveFieldToRows(dt); Session["registerofferingtoorg_data"] = dt; if (dt.Rows.Count > 0) { if (IsPostBack && Session["registerofferingtoorg_sortexpression"] != null && Session["registerofferingtoorg_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt); dataView.Sort = Session["registerofferingtoorg_sortexpression"].ToString(); GrdRegistration.DataSource = dataView; } else { GrdRegistration.DataSource = dt; } try { GrdRegistration.DataBind(); } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdRegistration.DataSource = dt; GrdRegistration.DataBind(); int TotalColumns = GrdRegistration.Rows[0].Cells.Count; GrdRegistration.Rows[0].Cells.Clear(); GrdRegistration.Rows[0].Cells.Add(new TableCell()); GrdRegistration.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdRegistration.Rows[0].Cells[0].Text = "No Record Found"; } if (hideFotter) { GrdRegistration.FooterRow.Visible = false; } }