Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        id = Request.QueryString["Id"];
        if (id != null && id != "")
        {
            go = GalaOrder.GetGalaOrder(new Guid(id));
        }
        else
        {
            go = GalaOrder.NewGalaOrder();
        }

        if (!IsPostBack)
        {
            LoadForm();
            PopulateForm();
        }
    }
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();
        }
    }