示例#1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (GetUrlParamType() == UrlParamType.View)
        {
            maintable.Visible = false; // hide this so that we don't send all the page data (all suburbs, etc) to display before it redirects
            Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "edit"));
        }
        else if (GetUrlParamType() == UrlParamType.Edit)
        {
            try
            {
                UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

                if (urlParamCreditType != UrlParamCreditType.Add)
                {
                    throw new CustomMessageException("Can no edit a '" + GetUrlParamCreditType().ToString() + "'");
                }

                if (!ddlExpiryValidateAllOrNoneSet.IsValid)
                {
                    return;
                }

                Credit credit = CreditDB.GetByID(GetFormID());

                /*
                 * txtAmount.Text = txtAmount.Text.Trim();
                 * if (txtAmount.Text.StartsWith("$")) txtAmount.Text = txtAmount.Text.Substring(1);
                 * decimal amount;
                 * if (!decimal.TryParse(txtAmount.Text, out amount))
                 *  throw new CustomMessageException("Amount must be a valid amount.");
                 */

                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    CreditDB.Update(credit.CreditID, credit.CreditType.ID, credit.EntityID, credit.Amount, txtDescr.Text.Trim(), GetExpiryFromForm(), credit.VoucherCredit == null ? -1 : credit.VoucherCredit.CreditID, credit.InvoiceID, credit.TyroPaymentPendingID, Convert.ToInt32(Session["StaffID"]));
                }


                Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "view"));
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
        else if (GetUrlParamType() == UrlParamType.Add)
        {
            try
            {
                UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

                if (urlParamCreditType != UrlParamCreditType.Add)
                {
                    throw new CustomMessageException("Can no add a '" + GetUrlParamCreditType().ToString() + "'");
                }

                if (!ddlExpiryValidateAllOrNoneSet.IsValid)
                {
                    return;
                }

                int entityID = GetFormID();

                txtAmount.Text = txtAmount.Text.Trim();
                if (txtAmount.Text.StartsWith("$"))
                {
                    txtAmount.Text = txtAmount.Text.Substring(1);
                }
                decimal amount;
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    throw new CustomMessageException("Amount must be a valid amount.");
                }

                int credit_type_id = -1;
                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    credit_type_id = 1;
                }
                else if (urlParamCreditType == UrlParamCreditType.Use)
                {
                    credit_type_id = 2;
                }
                else if (urlParamCreditType == UrlParamCreditType.CashoutTyroToMC)
                {
                    credit_type_id = 3;
                }
                else if (urlParamCreditType == UrlParamCreditType.CashoutMCtoPT)
                {
                    credit_type_id = 4;
                }
                else
                {
                    throw new CustomMessageException("Invalid URL Field ct");
                }


                bool refresh_on_close = Request.QueryString["refresh_on_close"] != null && Request.QueryString["refresh_on_close"] == "1";

                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    int creditID = CreditDB.Insert_AddVoucher(entityID, amount, txtDescr.Text.Trim(), GetExpiryFromForm(), Convert.ToInt32(Session["StaffID"]));

                    // need non booking org .. to put on invoice .....
                    // so need to put it in gui .. only for adding type 1

                    Patient patient       = PatientDB.GetByEntityID(entityID);
                    int     invID         = InvoiceDB.Insert(108, -1, 0, patient.PatientID, Convert.ToInt32(ddlClinic.SelectedValue), "", "", Convert.ToInt32(Session["StaffID"]), Convert.ToInt32(Session["SiteID"]), amount, 0, false, false, false, DateTime.MinValue);
                    int     invoiceLineID = InvoiceLineDB.Insert(invID, patient.PatientID, -1, creditID, 1, amount, 0, "", "", -1);

                    System.Drawing.Size size = Receipt.GetPopupWindowAddSize();
                    size = new System.Drawing.Size(size.Width + 15, size.Height + 60);
                    Response.Redirect("~/Invoice_ReceiptAndCreditNoteAddV2.aspx?id=" + invID + "&returnValue=false&window_size=" + size.Width + "_" + size.Height + (refresh_on_close ? "&refresh_on_close=1" : ""), false);
                    return;
                }



                // close this window

                maintable.Visible = false;

                if (refresh_on_close)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.opener.location.href=window.opener.location.href;self.close();</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
                }
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
        else
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
        }
    }
示例#2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (GetUrlParamType() == UrlParamType.View)
        {
            maintable.Visible = false; // hide this so that we don't send all the page data (all suburbs, etc) to display before it redirects
            Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "edit"));
        }
        else if (GetUrlParamType() == UrlParamType.Edit)
        {
            try
            {
                UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

                if (urlParamCreditType != UrlParamCreditType.Add)
                {
                    throw new CustomMessageException("Can no edit a '" + GetUrlParamCreditType().ToString() + "'");
                }

                if (!ddlExpiryValidateAllOrNoneSet.IsValid)
                {
                    return;
                }

                Credit credit = CreditDB.GetByID(GetFormID());

                txtAmount.Text = txtAmount.Text.Trim();
                if (txtAmount.Text.StartsWith("$"))
                {
                    txtAmount.Text = txtAmount.Text.Substring(1);
                }
                decimal amount;
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    throw new CustomMessageException("Amount must be a valid amount.");
                }

                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    CreditDB.Update(credit.CreditID, credit.CreditType.ID, credit.EntityID, amount, txtDescr.Text.Trim(), GetExpiryFromForm(), credit.VoucherCredit == null ? -1 : credit.VoucherCredit.CreditID, credit.InvoiceID, credit.TyroPaymentPendingID, Convert.ToInt32(Session["StaffID"]));
                }


                Response.Redirect(UrlParamModifier.AddEdit(Request.RawUrl, "type", "view"));
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
        else if (GetUrlParamType() == UrlParamType.Add)
        {
            try
            {
                UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

                if (urlParamCreditType != UrlParamCreditType.Add)
                {
                    throw new CustomMessageException("Can no add a '" + GetUrlParamCreditType().ToString() + "'");
                }

                if (!ddlExpiryValidateAllOrNoneSet.IsValid)
                {
                    return;
                }

                int entityID = GetFormID();

                txtAmount.Text = txtAmount.Text.Trim();
                if (txtAmount.Text.StartsWith("$"))
                {
                    txtAmount.Text = txtAmount.Text.Substring(1);
                }
                decimal amount;
                if (!decimal.TryParse(txtAmount.Text, out amount))
                {
                    throw new CustomMessageException("Amount must be a valid amount.");
                }

                int credit_type_id = -1;
                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    credit_type_id = 1;
                }
                else if (urlParamCreditType == UrlParamCreditType.Use)
                {
                    credit_type_id = 2;
                }
                else if (urlParamCreditType == UrlParamCreditType.CashoutTyroToMC)
                {
                    credit_type_id = 3;
                }
                else if (urlParamCreditType == UrlParamCreditType.CashoutMCtoPT)
                {
                    credit_type_id = 4;
                }
                else
                {
                    throw new CustomMessageException("Invalid URL Field ct");
                }


                if (urlParamCreditType == UrlParamCreditType.Add)
                {
                    CreditDB.Insert_AddVoucher(entityID, amount, txtDescr.Text.Trim(), GetExpiryFromForm(), Convert.ToInt32(Session["StaffID"]));
                }



                // close this window

                maintable.Visible = false;

                bool refresh_on_close = Request.QueryString["refresh_on_close"] != null && Request.QueryString["refresh_on_close"] == "1";

                if (refresh_on_close)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.opener.location.href=window.opener.location.href;self.close();</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
                }
            }
            catch (Exception ex)
            {
                SetErrorMessage(ex.Message);
            }
        }
        else
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
        }
    }
示例#3
0
    private void FillEmptyAddForm()
    {
        UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

        if (urlParamCreditType != UrlParamCreditType.Add)
        {
            throw new CustomMessageException("Can no add a '" + GetUrlParamCreditType().ToString() + "'");
        }


        ddlClinic.Items.Clear();
        ddlClinic.Items.Add(new ListItem("--Select--", "0"));
        foreach (Organisation org in OrganisationDB.GetAll(false, true, false, true, true, true))
        {
            ddlClinic.Items.Add(new ListItem(org.Name, org.OrganisationID.ToString()));
        }

        string heading = "";

        if (urlParamCreditType == UrlParamCreditType.Add)
        {
            heading = "Voucher";
        }
        if (urlParamCreditType == UrlParamCreditType.Use)
        {
            heading = "Use Of Voucher";
        }
        if (urlParamCreditType == UrlParamCreditType.CashoutTyroToMC)
        {
            heading = "Cashout - Tyro To Mediclinic";
        }
        if (urlParamCreditType == UrlParamCreditType.CashoutMCtoPT)
        {
            heading = "Cashout - Mediclinic To Patient";
        }
        lblHeading.Text = "Add " + heading;

        lblAmount.Visible = false;
        lblDescr.Visible  = false;
        lblExpiry.Visible = false;

        idRow.Visible               = false;
        typeRow.Visible             = false;
        amountUsedRow.Visible       = false;
        amountRemainingRow.Visible  = false;
        addedbyRow.Visible          = false;
        dateAddedRow.Visible        = false;
        modifiedbyRow.Visible       = false;
        dateModifiedRow.Visible     = false;
        deletedSpaceRow.Visible     = false;
        deletedbyRow.Visible        = false;
        dateDeletedRow.Visible      = false;
        preDeletedAmountRow.Visible = false;

        invoiceListSpaceRow.Visible = false;
        invoiceListRow.Visible      = false;


        if (urlParamCreditType != UrlParamCreditType.Add)
        {
            clinicRow.Visible = false;
            descrRow.Visible  = false;
            expiryRow.Visible = false;
        }
        if (urlParamCreditType != UrlParamCreditType.Use)
        {
            voucherUsedRow.Visible = false;
            invoiceRow.Visible     = false;
        }

        btnSubmit.Text    = "Add " + heading;
        btnCancel.Visible = true;
    }
示例#4
0
    private void FillEmptyAddForm()
    {
        UrlParamCreditType urlParamCreditType = GetUrlParamCreditType();

        if (urlParamCreditType != UrlParamCreditType.Add)
        {
            throw new CustomMessageException("Can no add a '" + GetUrlParamCreditType().ToString() + "'");
        }


        string heading = "";

        if (urlParamCreditType == UrlParamCreditType.Add)
        {
            heading = "Voucher";
        }
        if (urlParamCreditType == UrlParamCreditType.Use)
        {
            heading = "Use Of Voucher";
        }
        if (urlParamCreditType == UrlParamCreditType.CashoutTyroToMC)
        {
            heading = "Cashout - Tyro To Mediclinic";
        }
        if (urlParamCreditType == UrlParamCreditType.CashoutMCtoPT)
        {
            heading = "Cashout - Mediclinic To Patient";
        }
        lblHeading.Text = "Add " + heading;

        lblAmount.Visible = false;
        lblDescr.Visible  = false;
        lblExpiry.Visible = false;

        idRow.Visible               = false;
        typeRow.Visible             = false;
        amountUsedRow.Visible       = false;
        amountRemainingRow.Visible  = false;
        addedbyRow.Visible          = false;
        dateAddedRow.Visible        = false;
        modifiedbyRow.Visible       = false;
        dateModifiedRow.Visible     = false;
        deletedSpaceRow.Visible     = false;
        deletedbyRow.Visible        = false;
        dateDeletedRow.Visible      = false;
        preDeletedAmountRow.Visible = false;

        invoiceListSpaceRow.Visible = false;
        invoiceListRow.Visible      = false;


        if (urlParamCreditType != UrlParamCreditType.Add)
        {
            descrRow.Visible  = false;
            expiryRow.Visible = false;
        }
        if (urlParamCreditType != UrlParamCreditType.Use)
        {
            voucherUsedRow.Visible = false;
            invoiceRow.Visible     = false;
        }

        btnSubmit.Text    = "Add " + urlParamCreditType;
        btnCancel.Visible = true;
    }