protected void GrdRegistration_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Insert"))
        {
            DropDownList ddlOrganisation = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewOrganisation");
            DropDownList ddlOffering     = (DropDownList)GrdRegistration.FooterRow.FindControl("ddlNewOffering");
            TextBox      txtPrice        = (TextBox)GrdRegistration.FooterRow.FindControl("txtNewPrice");
            TextBox      txtDateActive   = (TextBox)GrdRegistration.FooterRow.FindControl("txtNewDateActive");

            CustomValidator txtValidateDOB = (CustomValidator)GrdRegistration.FooterRow.FindControl("txtValidateNewDateActive");
            if (!txtValidateDOB.IsValid)
            {
                return;
            }

            try
            {
                DateTime dateActive = GetDate(txtDateActive.Text.Trim());
                OrganisationOfferingsDB.Insert(Convert.ToInt32(ddlOrganisation.SelectedValue), Convert.ToInt32(ddlOffering.SelectedValue), Convert.ToDecimal(txtPrice.Text), dateActive);
            }
            catch (UniqueConstraintException)
            {
                // happens when 2 forms allow adding - do nothing and let form re-update
                ;
            }
            FillGrid();
        }
    }
    protected void GrdRegistration_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label        lblId         = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");
        DropDownList ddlOffering   = (DropDownList)GrdRegistration.Rows[e.RowIndex].FindControl("ddlOffering");
        TextBox      txtPrice      = (TextBox)GrdRegistration.Rows[e.RowIndex].FindControl("txtPrice");
        TextBox      txtDateActive = (TextBox)GrdRegistration.Rows[e.RowIndex].FindControl("txtDateActive");

        CustomValidator txtValidateDateActive = (CustomValidator)GrdRegistration.Rows[e.RowIndex].FindControl("txtValidateDateActive");

        if (!txtValidateDateActive.IsValid)
        {
            return;
        }

        DateTime dateActive = GetDate(txtDateActive.Text.Trim());

        OrganisationOfferings orgOffering = OrganisationOfferingsDB.GetByID(Convert.ToInt32(lblId.Text));

        if (orgOffering != null)
        {
            OrganisationOfferingsDB.Update(Convert.ToInt32(lblId.Text), orgOffering.Organisation.OrganisationID, orgOffering.Offering.OfferingID, Convert.ToDecimal(txtPrice.Text), GetDate(txtDateActive.Text.Trim()));
        }

        GrdRegistration.EditIndex = -1;
        FillGrid();
    }
    protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label lblId = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");

        try
        {
            OrganisationOfferings orgOffering = OrganisationOfferingsDB.GetByID(Convert.ToInt32(lblId.Text));
            if (orgOffering != null)
            {
                OrganisationOfferingsDB.Delete(orgOffering.OrganisationOfferingID);
            }
        }
        catch (ForeignKeyConstraintException fkcEx)
        {
            if (Utilities.IsDev())
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
            }
            else
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this");
            }
        }

        FillGrid();
    }
コード例 #4
0
    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);
    }
コード例 #5
0
    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);
    }
    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;
        }
    }
コード例 #7
0
    public DataTable GetSelectedList()
    {
        DataTable dt_selected_list = Session["data_selected"] as DataTable;

        string areaTreated = string.Empty;

        if (InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance)
        {
            areaTreated = HealthCardDB.GetActiveByPatientID(Booking.Patient.PatientID).AreaTreated;
        }

        if (dt_selected_list == null)
        {
            dt_selected_list = new DataTable();
            dt_selected_list.Columns.Add(new DataColumn("offering_id"));
            dt_selected_list.Columns.Add(new DataColumn("hc_paid"));
            dt_selected_list.Columns.Add(new DataColumn("short_name"));
            dt_selected_list.Columns.Add(new DataColumn("name"));
            dt_selected_list.Columns.Add(new DataColumn("area_treated"));
            dt_selected_list.Columns.Add(new DataColumn("service_reference"));
            dt_selected_list.Columns.Add(new DataColumn("show_area_treated", typeof(Boolean)));
            dt_selected_list.Columns.Add(new DataColumn("show_service_reference", typeof(Boolean)));
            dt_selected_list.Columns.Add(new DataColumn("default_price"));
            dt_selected_list.Columns.Add(new DataColumn("pt_price"));                // added
            dt_selected_list.Columns.Add(new DataColumn("hc_price"));                // added
            dt_selected_list.Columns.Add(new DataColumn("pt_gst"));                  // added
            dt_selected_list.Columns.Add(new DataColumn("hc_gst"));                  // added
            dt_selected_list.Columns.Add(new DataColumn("quantity"));
            dt_selected_list.Columns.Add(new DataColumn("total_line_price"));
            dt_selected_list.Columns.Add(new DataColumn("total_line_gst"));
            dt_selected_list.Columns.Add(new DataColumn("total_pt_price"));          // added
            dt_selected_list.Columns.Add(new DataColumn("total_hc_price"));          // added
            dt_selected_list.Columns.Add(new DataColumn("total_pt_gst"));            // added
            dt_selected_list.Columns.Add(new DataColumn("total_hc_gst"));            // added
            dt_selected_list.Columns.Add(new DataColumn("on_order", typeof(Boolean)));


            if (this.booking != null)
            {
                Booking.InvoiceType invType = InvoiceType;

                Offering orgOffering = OrganisationOfferingsDB.GetOfferingByOrgAndOffering(this.booking.Organisation.OrganisationID, this.booking.Offering.OfferingID);
                if (orgOffering == null)
                {
                    orgOffering = this.booking.Offering;
                }

                bool    invoiceGapPayments = Convert.ToInt32(SystemVariableDB.GetByDescr("InvoiceGapPayments").Value) == 1;
                decimal GST_Percent        = Convert.ToDecimal(((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["GST_Percent"].Value);
                decimal GST_Modifier       = GST_Percent / (decimal)100;

                bool incGstOnPTInvoices = IncGstOnInvoices_Private && !orgOffering.IsGstExempt;
                bool incGstOnHCInvoices = (invType == Booking.InvoiceType.Medicare && IncGstOnInvoices_MC && !orgOffering.IsGstExempt) ||
                                          (invType == Booking.InvoiceType.DVA && IncGstOnInvoices_DVA && !orgOffering.IsGstExempt) ||
                                          (invType == Booking.InvoiceType.Insurance && IncGstOnInvoices_Insurance && !orgOffering.IsGstExempt);


                decimal pt_price = orgOffering.DefaultPrice;
                decimal hc_price = 0;
                decimal pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                decimal hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;

                if (invType == Booking.InvoiceType.Medicare)
                {
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > orgOffering.MedicareCharge ? orgOffering.DefaultPrice - orgOffering.MedicareCharge : 0;
                    hc_price = orgOffering.MedicareCharge;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }
                if (invType == Booking.InvoiceType.DVA)
                {
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > orgOffering.DvaCharge ? orgOffering.DefaultPrice - orgOffering.DvaCharge : 0;
                    hc_price = orgOffering.DvaCharge;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }
                if (invType == Booking.InvoiceType.Insurance)
                {
                    hc_price = orgOffering.TacCompanyCode.Length > 0 ? orgOffering.TacCharge : orgOffering.DefaultPrice;
                    pt_price = invoiceGapPayments && orgOffering.DefaultPrice > hc_price ? orgOffering.DefaultPrice - hc_price : 0;
                    pt_tax   = !incGstOnPTInvoices ? 0 : pt_price * GST_Modifier;
                    hc_tax   = !incGstOnHCInvoices ? 0 : hc_price * GST_Modifier;
                }


                DataRow row = dt_selected_list.NewRow();
                row["offering_id"]            = booking.Offering.OfferingID;
                row["hc_paid"]                = (this.InvoiceType == Booking.InvoiceType.DVA || this.InvoiceType == Booking.InvoiceType.Medicare);
                row["short_name"]             = booking.Offering.ShortName;
                row["name"]                   = booking.Offering.Name;
                row["area_treated"]           = areaTreated;
                row["service_reference"]      = "";
                row["show_area_treated"]      = InvoiceType == Booking.InvoiceType.DVA || InvoiceType == Booking.InvoiceType.Insurance;
                row["show_service_reference"] = InvoiceType == Booking.InvoiceType.Insurance;
                row["default_price"]          = row["total_line_price"] = orgOffering.DefaultPrice;
                row["pt_price"]               = row["total_pt_price"] = pt_price;                      // added
                row["pt_gst"]                 = row["total_pt_gst"] = pt_tax;                          // added
                row["hc_price"]               = row["total_hc_price"] = hc_price;                      // added
                row["hc_gst"]                 = row["total_hc_gst"] = hc_tax;                          // added
                row["quantity"]               = "1";
                row["on_order"]               = false;
                dt_selected_list.Rows.Add(row);
            }

            Session["data_selected"] = dt_selected_list;
        }

        if (dt_selected_list.Rows.Count == 1 && dt_selected_list.Rows[0][0] == DBNull.Value)
        {
            dt_selected_list.Rows.RemoveAt(0);
        }

        return(dt_selected_list);
    }
コード例 #8
0
    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";
        }
    }
コード例 #9
0
    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);
    }