Beispiel #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateForm())
        {
            Guid goId = new Guid(hldOrderId.Value);
            go = GalaOrder.GetGalaOrder(goId);

            // save the amount to the first entry or this default entry
            //go.AmountReceived += decimal.Parse(txtAmountRecieved.Text);
            //go.Save();

            go.DatePaidString = dpDateReceived.DateInput.SelectedDate.ToString();
            go.RemarksPayment = txtRemarks.Text;

            // paid?
            bool isPaid = false;
            //Guid paymentGroupId = entry.PayGroupId;
            //EntryList list = EntryList.GetEntryList(paymentGroupId, Guid.Empty, "");
            //foreach (Entry ent in list)
            //{
            string paidstatus_org = go.PayStatus;

            // make the change only if the status has changed.
            // if not do not change it
            if (chkPaid.Checked && paidstatus_org == StatusPaymentEntry.NotPaid)
            {
                go.PayStatus = StatusPaymentEntry.Paid;
                isPaid       = true;
            }
            if (!chkPaid.Checked && paidstatus_org == StatusPaymentEntry.Paid)
            {
                go.PayStatus = StatusPaymentEntry.NotPaid;
            }
            go.Save();
            //}


            //// send email?
            //if (chkSendPaidEmail.Checked)
            //{
            //    if (go.PaymentMethod == PaymentType.PayPal) // there shouldnt be any PP, its disabled on the list, it can never come here
            //        GeneralFunction.CompleteNewGalaOrderPayPal(go.Id);
            //    else
            //        GeneralFunction.CompleteNewGalaOrderOthers(go.Id);
            //}


            // Always send email if paid
            if (isPaid)
            {
                GeneralFunction.CompleteNewGalaOrderOthers(go.Id);
            }



            //// history
            //AmountReceived amt = AmountReceived.NewAmountReceived();
            //amt.Amount = decimal.Parse(txtAmountRecieved.Text);
            //amt.DateReceivedString = dpDateReceived.DateInput.SelectedDate.ToString();
            //amt.PaygroupId = entry.PayGroupId;
            //amt.Invoice = "";
            //amt.Remarks = txtRemarks.Text;
            //amt.IsSetPaid = isPaid;
            //amt.DateCreatedString = DateTime.Now.ToString();
            //amt.Save();



            if (Save_Clicked != null)
            {
                Save_Clicked(this, EventArgs.Empty);
            }
        }
    }
Beispiel #2
0
    private void SaveForm()
    {
        if (go.IsNew)
        {
            go = GalaOrder.NewGalaOrder();
        }

        go.TableCount = 0;
        go.SeatCount  = 0;

        if (ddlTableCount.SelectedValue != "")
        {
            go.TableCount = int.Parse(ddlTableCount.SelectedValue);
        }
        if (ddlSingleCount.SelectedValue != "")
        {
            go.SeatCount = int.Parse(ddlSingleCount.SelectedValue);
        }
        go.Shipping = rblShipping.SelectedValue;

        go.PayFirstname = txtFirstname.Text.Trim();
        go.PayLastname  = txtLastname.Text.Trim();
        go.PayContact   = GeneralFunction.CreateContact(txtContactCountryCode.Text.Trim(), txtContactAreaCode.Text.Trim(), txtContactNumber.Text.Trim());
        go.PayEmail     = txtEmail.Text.Trim();

        go.PayCompany  = txtCompany.Text.Trim();
        go.PayAddress1 = txtAddress1.Text.Trim();
        go.PayAddress2 = txtAddress2.Text.Trim();
        go.PayCity     = txtCity.Text.Trim();
        go.PayPostal   = txtPostal.Text.Trim();
        go.PayCountry  = ddlCountry.SelectedValue;

        go.PaymentMethod = rblPayment.SelectedValue;


        // Calculation
        go.Amount = (go.TableCount * 4000) + (go.SeatCount * 450);
        go.Fee    = 0;
        if (go.Shipping == "courier")
        {
            go.FeeShipping = 15;
        }
        if (rblPayment.SelectedValue == PaymentType.BankTransfer)
        {
            go.Fee = GeneralFunction.CalculateBankTransferFees();
        }
        if (rblPayment.SelectedValue == PaymentType.PayPal)
        {
            go.Fee = GeneralFunction.CalculateCreditFees(go.Amount + go.FeeShipping);
        }

        // Gst
        go.Tax = 0;
        if (ddlCountry.SelectedValue.ToLower() == "singapore")
        {
            go.Tax = GeneralFunction.CalculateTax(go.Amount + go.Fee + go.FeeShipping);
        }


        // Misc
        go.Status            = StatusGalaOrder.Confirm; //StatusGalaOrder.Draft;
        go.PayStatus         = StatuspaymentGalaOrder.NotPaid;
        go.IsReminded        = 0;
        go.DateCreatedString = DateTime.Now.ToString();


        if (go.IsValid)
        {
            go = go.Save();
        }
        else
        {
            lbError.Text  = go.BrokenRulesCollection.ToString();
            lbError2.Text = go.BrokenRulesCollection.ToString();
        }
    }