예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //lblDelete.Visible = false;
                txtSearch.Focus();
                if (Session["key"] != null)
                {
                    int custNum;
                    custNum = (int)(Convert.ToInt32(Session["key"].ToString()));

                    Customer c = ssm.GetCustomerbyCustomerNumber(custNum);
                    txtCustomer.Text = c.firstName + " " + c.lastName;
                }
                //display system time in Sales Page
                DateTime today = DateTime.Today;
                lblDate.Text = today.ToString("yyyy-MM-dd");
                if (Session["ItemsInCart"] != null)
                {
                    grdCartItems.DataSource = Session["ItemsInCart"];
                    grdCartItems.DataBind();
                    lblSubtotalDisplay.Text = "$ " + ssm.returnSubtotalAmount((List <Cart>)Session["ItemsInCart"]).ToString();
                }
            }
            else if (Convert.ToBoolean(Session["UpdateTheCart"]))
            {
                grdCartItems.DataSource = Session["ItemsInCart"];
                grdCartItems.DataBind();
                Session["UpdateTheCart"] = null;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int      custNum = (int)(Convert.ToInt32(Session["key"].ToString()));
            Customer c       = ssm.GetCustomerbyCustomerNumber(custNum);

            lblCustomerName.Text  = c.firstName.ToString() + " " + c.lastName.ToString();
            lblStreetAddress.Text = c.primaryAddress.ToString();
            lblPostalAddress.Text = c.city.ToString() + ", " + lm.provinceName(c.province) + " " + c.postalCode.ToString();
            lblPhone.Text         = c.primaryPhoneNumber.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["key"] != null)
            {
                if (!IsPostBack)
                {
                    int      custNum = (int)(Convert.ToInt32(Session["key"].ToString()));
                    Customer c       = ssm.GetCustomerbyCustomerNumber(custNum);

                    lblFirstNameDisplay.Text            = c.firstName.ToString();
                    lblLastNameDisplay.Text             = c.lastName.ToString();
                    lblPrimaryAddressDisplay.Text       = c.primaryAddress.ToString();
                    lblBillingAddressDisplay.Text       = c.billingAddress.ToString();
                    lblSecondaryAddressDisplay.Text     = c.secondaryAddress.ToString();
                    lblPrimaryPhoneNumberDisplay.Text   = c.primaryPhoneNumber.ToString();
                    lblSecondaryPhoneNumberDisplay.Text = c.secondaryPhoneNumber.ToString();
                    lblEmailDisplay.Text      = c.email.ToString();
                    lblCityDisplay.Text       = c.city.ToString();
                    lblProvinceDisplay.Text   = lm.provinceName(c.province);
                    lblCountryDisplay.Text    = lm.countryName(c.country);
                    lblPostalCodeDisplay.Text = c.postalCode.ToString();
                }
            }
            else
            {
                txtFirstName.Visible        = true;
                lblFirstNameDisplay.Visible = false;

                txtLastName.Visible        = true;
                lblLastNameDisplay.Visible = false;

                txtPrimaryAddress.Visible        = true;
                lblPrimaryAddressDisplay.Visible = false;

                txtBillingAddress.Visible        = true;
                lblBillingAddressDisplay.Visible = false;

                txtSecondaryAddress.Visible        = true;
                lblSecondaryAddressDisplay.Visible = false;

                txtPrimaryPhoneNumber.Visible        = true;
                lblPrimaryPhoneNumberDisplay.Visible = false;

                txtSecondaryPhoneNumber.Visible        = true;
                lblSecondaryPhoneNumberDisplay.Visible = false;

                txtEmail.Visible        = true;
                lblEmailDisplay.Visible = false;

                txtCity.Visible        = true;
                lblCityDisplay.Visible = false;

                ddlProvince.Visible        = true;
                lblProvinceDisplay.Visible = false;

                ddlCountry.Visible        = true;
                lblCountryDisplay.Visible = false;

                txtPostalCode.Visible        = true;
                lblPostalCodeDisplay.Visible = false;

                btnSaveCustomer.Visible        = false;
                btnAddCustomer.Visible         = true;
                pnlDefaultButton.DefaultButton = "btnAddCustomer";
                btnEditCustomer.Visible        = false;
                btnCancel.Visible       = false;
                btnBackToSearch.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List <Tax>         t    = new List <Tax>();
                List <Cart>        cart = new List <Cart>();
                CalculationManager cm   = new CalculationManager();


                if (Session["MethodsofPayment"] == null)
                {
                    double dblShippingAmount = Convert.ToDouble(Session["ShippingAmount".ToString()]);
                    bool   bolShipping       = Convert.ToBoolean(Session["shipping"]);
                    if (bolShipping)
                    {
                        int      custNum = (int)Convert.ToInt32(Session["key"].ToString());
                        Customer c       = ssm.GetCustomerbyCustomerNumber(custNum);
                        t = ssm.getTaxes(c.province);
                        lblShipping.Visible       = true;
                        lblShippingAmount.Visible = true;
                    }
                    else
                    {
                        //**Will need to be enabled not shipping
                        //t = ssm.getTaxes(Convert.ToInt(Session["location"].ToString());
                        lblShipping.Visible       = false;
                        lblShippingAmount.Visible = false;
                    }
                    ckm = new CheckoutManager(cm.returnTotalAmount(cart), cm.returnDiscount(cart), cm.returnTradeInAmount(cart), dblShippingAmount, true, true, 0, 0, 0, cm.returnSubtotalAmount(cart));
                    foreach (var T in t)
                    {
                        switch (T.taxName)
                        {
                        case "GST":
                            lblGovernment.Visible    = true;
                            ckm.dblGst               = cm.returnGSTAmount(T.taxRate, ckm.dblSubTotal);
                            lblGovernmentAmount.Text = "$ " + ckm.dblGst.ToString("#0.00");
                            btnRemoveGov.Visible     = true;
                            break;

                        case "PST":
                            lblProvincial.Visible = true;
                            pst = Math.Round((T.taxRate * subtotal), 2);
                            lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                            btnRemoveProv.Visible    = true;
                            break;

                        case "HST":
                            lblProvincial.Visible = false;
                            lblGovernment.Text    = "HST";
                            gst = Math.Round((T.taxRate * subtotal), 2);
                            lblGovernmentAmount.Text = "$ " + gst.ToString("#0.00");
                            btnRemoveProv.Visible    = false;
                            btnRemoveGov.Text        = "HST";
                            break;

                        case "RST":
                            lblProvincial.Visible = true;
                            lblProvincial.Text    = "RST";
                            pst = Math.Round((T.taxRate * subtotal), 2);
                            lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                            btnRemoveProv.Visible    = true;
                            btnRemoveProv.Text       = "RST";
                            break;

                        case "QST":
                            lblProvincial.Visible = true;
                            lblProvincial.Text    = "QST";
                            pst = Math.Round((T.taxRate * subtotal), 2);
                            lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                            btnRemoveProv.Visible    = true;
                            btnRemoveProv.Text       = "QST";
                            break;
                        }
                    }
                }
                else
                {
                    ckm     = (CheckoutManager)Session["CheckOutTotals"];
                    mopList = (List <Checkout>)Session["MethodsofPayment"];
                    foreach (var mop in mopList)
                    {
                        dblAmountPaid += mop.amountPaid;
                    }
                    gvCurrentMOPs.DataSource = mopList;
                    gvCurrentMOPs.DataBind();
                    ckm.dblAmountPaid       = dblAmountPaid;
                    ckm.dblRemainingBalance = ckm.dblSubTotal - ckm.dblAmountPaid;
                }
                Session["CheckOutTotals"] = ckm;

                //***Assign each item to its Label.

                //    //Assigning session brought from the cart to variables
                //    int custNum = (int)(Convert.ToInt32(Session["key"].ToString()));
                //    bool shipping = Convert.ToBoolean(Session["shipping"]);
                //    cart = (List<Cart>)Session["ItemsInCart"];
                //    double dblShippingAmount = Convert.ToDouble(Session["ShippingAmount"].ToString());
                //    Customer c = ssm.GetCustomerbyCustomerNumber(custNum);
                //    //End of assigning

                //    if (shipping == false)
                //    {
                //        //**Need to change to location for taxes
                //        t = ssm.getTaxes(c.province);
                //        lblShipping.Visible = false;
                //        lblShippingAmount.Visible = false;
                //        //txtShippingAmount.Visible = false;
                //    }
                //    else if (shipping == true)
                //    {
                //        t = ssm.getTaxes(c.province);
                //        lblShipping.Visible = true;
                //        lblShippingAmount.Visible = true;
                //        //txtShippingAmount.Visible = true;
                //    }

                //    lblTotalInCartAmount.Text = "$ " + cm.returnTotalAmount(cart).ToString("#0.00");
                //    lblTotalInDiscountsAmount.Text = "$ " + cm.returnDiscount(cart).ToString("#0.00");
                //    lblTradeInsAmount.Text = "$ " + cm.returnTradeInAmount(cart).ToString("#0.00");
                //    subtotal = cm.returnSubtotalAmount(cart);
                //    lblSubTotalAmount.Text = "$ " + subtotal.ToString("#0.00");
                //    lblShippingAmount.Text = "$ " + dblShippingAmount.ToString("#0.00");

                //    foreach (var T in t)
                //    {
                //        switch (T.taxName)
                //        {
                //            case "GST":
                //                lblGovernment.Visible = true;
                //                gst = cm.returnGSTAmount(T.taxRate, cart);
                //                lblGovernmentAmount.Text = "$ " + gst.ToString("#0.00");
                //                btnRemoveGov.Visible = true;
                //                break;
                //            case "PST":
                //                lblProvincial.Visible = true;
                //                pst = Math.Round((T.taxRate * subtotal), 2);
                //                lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                //                btnRemoveProv.Visible = true;
                //                break;
                //            case "HST":
                //                lblProvincial.Visible = false;
                //                lblGovernment.Text = "HST";
                //                gst = Math.Round((T.taxRate * subtotal), 2);
                //                lblGovernmentAmount.Text = "$ " + gst.ToString("#0.00");
                //                btnRemoveProv.Visible = false;
                //                btnRemoveGov.Text = "HST";
                //                break;
                //            case "RST":
                //                lblProvincial.Visible = true;
                //                lblProvincial.Text = "RST";
                //                pst = Math.Round((T.taxRate * subtotal), 2);
                //                lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                //                btnRemoveProv.Visible = true;
                //                btnRemoveProv.Text = "RST";
                //                break;
                //            case "QST":
                //                lblProvincial.Visible = true;
                //                lblProvincial.Text = "QST";
                //                pst = Math.Round((T.taxRate * subtotal), 2);
                //                lblProvincialAmount.Text = "$ " + pst.ToString("#0.00");
                //                btnRemoveProv.Visible = true;
                //                btnRemoveProv.Text = "QST";
                //                break;
                //        }
                //    }
                //    dblAmountPaid = 0;
                //    //Checking if there are MOP's
                //    if (Session["MethodsofPayment"] != null)
                //    {
                //        ck = (List<Checkout>)Session["MethodsofPayment"];
                //        foreach (var mop in ck)
                //        {
                //            dblAmountPaid += mop.amountPaid;
                //        }
                //        gvCurrentMOPs.DataSource = ck;
                //        gvCurrentMOPs.DataBind();
                //    }
                //    //End of checking MOP's

                //    ckm = new CheckoutManager(cm.returnTotalAmount(cart), cm.returnDiscount(cart), cm.returnTradeInAmount(cart), dblShippingAmount, noGST, noPST, gst, pst,(cm.returnSubtotalAmount(cart)-dblAmountPaid));
                //    balancedue = ckm.dblGst + ckm.dblPst + ckm.dblShipping + ckm.dblTotal - (ckm.dblDiscounts + ckm.dblTradeIn);
                //    lblBalanceAmount.Text = "$ " + balancedue.ToString("#0.00");
                //    lblRemainingBalanceDueDisplay.Text = "$ " + balancedue.ToString("#0.00");
                //    Session["CheckOutTotals"] = ckm;
                //}
                //if (txtShippingAmount.Text == null || txtShippingAmount.Text == "")
                //{
                //    txtShippingAmount.Text = "0";
                //}
                //shippingCost = Convert.ToDouble(txtShippingAmount.Text);
                //ckm = (CheckoutManager)Session["CheckOutTotals"];
                //ckm.dblShipping = shippingCost;
                //balancedue = ckm.dblGst + ckm.dblPst + ckm.dblShipping + ckm.dblTotal - (ckm.dblDiscounts + ckm.dblTradeIn);
                //lblBalanceAmount.Text = "$ " + balancedue.ToString("#0.00");
                //Session["CheckOutTotals"] = ckm;
                //if (Session["MethodsofPayment"] == null)
                //{
                //    lblRemainingBalanceDueDisplay.Text = "$ " + balancedue.ToString("#0.00");
                //}
                //else
                //{
                //    ck = (List<Checkout>)Session["MethodsofPayment"];
                //    gvCurrentMOPs.DataSource = ck;
                //    gvCurrentMOPs.DataBind();
                //    foreach (var mop in ck)
                //    {
                //        dblAmountPaid += mop.amountPaid;
                //    }
                //    if (!ckm.blGst)
                //    {
                //        dblRemaining += ckm.dblGst;
                //    }
                //    if (!ckm.blPst)
                //    {
                //        dblRemaining += ckm.dblPst;
                //    }
                //    dblRemaining += ckm.dblTotal + ckm.dblShipping - (ckm.dblDiscounts + ckm.dblTradeIn);
                //    lblRemainingBalanceDueDisplay.Text = "$ " + (dblRemaining - dblAmountPaid).ToString("#0.00");
            }
        }