Example #1
0
    protected void btn_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandArgument == "Add Voucher")
        {
            try
            {
                decimal amount;
                if (!decimal.TryParse(txtAddAmount.Text, out amount))
                {
                    throw new CustomMessageException("Not a valid amount");
                }
                CreditDB.Insert_AddVoucher(224413, amount, txtAddDescr.Text, DateTime.MinValue, Convert.ToInt32(Session["StaffID"]));
                FillCreditGrid();
                FillPayments();
            }
            catch (Exception ex)
            {
                lblErrorMessage.Text = ex.Message;
            }
        }
        if (e.CommandArgument == "Tyro Cashout")
        {
            try
            {
                decimal amount;
                if (!decimal.TryParse(txtCashAmount.Text, out amount))
                {
                    throw new CustomMessageException("Not a valid amount");
                }

                int tyro_payment_pending_id = 6;
                CreditDB.Insert_Cashout(amount, tyro_payment_pending_id, Convert.ToInt32(Session["StaffID"]));
                FillCreditGrid();
                FillPayments();
            }
            catch (Exception ex)
            {
                lblErrorMessage.Text = ex.Message;
            }
        }
    }
Example #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, 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");
        }
    }
Example #3
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");
        }
    }