Пример #1
0
        //private static Invoice receipt;

        protected void Page_Load(object sender, EventArgs e)
        {
            //Collects current method and page for error tracking
            string method = "Page_Load";

            Session["currPage"] = "PurchasesCart.aspx";
            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //checks if the user has logged in
                if (Session["currentUser"] == null)
                {
                    //Go back to Login to log in
                    Response.Redirect("LoginPage.aspx", false);
                }
                else
                {
                    Invoice receipt = new Invoice();
                    CU = (CurrentUser)Session["currentUser"];
                    if (!Page.IsPostBack)
                    {
                        if (!IM.CallReturnBolInvoiceExists(Convert.ToInt32(Request.QueryString["receipt"].ToString()), objPageDetails))
                        {
                            receipt.varInvoiceNumber       = IM.CallReturnNextReceiptNumber(CU, objPageDetails);
                            receipt.intInvoiceSubNumber    = 1;
                            receipt.customer               = CM.CallReturnCustomer(Convert.ToInt32(Request.QueryString["customer"].ToString()), objPageDetails)[0];
                            receipt.employee               = CU.employee;
                            receipt.location               = CU.location;
                            receipt.fltGovernmentTaxAmount = 0;
                            receipt.fltProvincialTaxAmount = 0;
                            receipt.intTransactionTypeID   = 5;
                            //receipt.bitChargeGST = false;
                            //receipt.bitChargePST = false;
                            IM.CallCreateInitialTotalsForTable(receipt, objPageDetails);
                        }
                        else
                        {
                            receipt = IM.CallReturnCurrentPurchaseInvoice(Convert.ToInt32(Request.QueryString["receipt"]), CU.location.intProvinceID, objPageDetails)[0];
                        }

                        //Checks if there is a Customer Number stored in the Session

                        //Set name in text box
                        txtCustomer.Text = receipt.customer.varFirstName + " " + receipt.customer.varLastName;
                        //display system time in Sales Page
                        DateTime today = DateTime.Today;
                        lblDateDisplay.Text          = today.ToString("dd/MMM/yy");
                        lblReceiptNumberDisplay.Text = receipt.varInvoiceNumber.ToString();
                        UpdateReceiptTotal();
                    }
                }
            }
            //Exception catch
            catch (ThreadAbortException) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]), method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
        //private static Invoice returnInvoice;

        protected void Page_Load(object sender, EventArgs e)
        {
            //Collects current method and page for error tracking
            string method = "Page_Load";

            Session["currPage"] = "ReturnsCart.aspx";
            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                lblInvalidQty.Visible = false;
                //checks if the user has logged in
                if (Session["currentUser"] == null)
                {
                    //Go back to Login to log in
                    Response.Redirect("LoginPage.aspx", false);
                }
                else
                {
                    CU = (CurrentUser)Session["currentUser"];
                    if (!Page.IsPostBack)
                    {
                        List <Invoice> returnInvoicesCalled = IM.CallReturnInvoice(Convert.ToInt32(Request.QueryString["invoice"]), objPageDetails);
                        Invoice        returnInvoice        = new Invoice();
                        if (returnInvoicesCalled.Count > 0)
                        {
                            returnInvoice = returnInvoicesCalled[0];
                            returnInvoice.intInvoiceSubNumber  = IM.CallCalculateNextInvoiceSubNum(returnInvoice.varInvoiceNumber, objPageDetails);
                            returnInvoice.location             = CU.location;
                            returnInvoice.employee             = CU.employee;
                            returnInvoice.intTransactionTypeID = 2;
                            returnInvoice = IM.CallCreateInitialTotalsForTable(returnInvoice, objPageDetails)[0];

                            var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                            nameValues.Set("invoice", returnInvoice.intInvoiceID.ToString());
                            Response.Redirect(Request.Url.AbsolutePath + "?" + nameValues, false);
                        }
                        else
                        {
                            returnInvoice = IM.CallReturnCurrentInvoice(Convert.ToInt32(Request.QueryString["invoice"]), CU.location.intProvinceID, objPageDetails)[0];
                        }
                        lblCustomerDisplay.Text      = returnInvoice.customer.varFirstName.ToString() + " " + returnInvoice.customer.varLastName.ToString();
                        lblInvoiceNumberDisplay.Text = returnInvoice.varInvoiceNumber + "-" + returnInvoice.intInvoiceSubNumber;
                        lblDateDisplay.Text          = returnInvoice.dtmInvoiceDate.ToString("dd/MMM/yy");
                        //binds items in cart to gridview
                        GrdInvoicedItems.DataSource = IIM.CallReturnInvoiceItemsFromProcessedSalesForReturn(returnInvoice.varInvoiceNumber.ToString(), returnInvoice.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);
                        GrdInvoicedItems.DataBind();

                        GrdReturningItems.DataSource = returnInvoice.invoiceItems;
                        GrdReturningItems.DataBind();

                        //IM.CalculateNewInvoiceReturnTotalsToUpdate(returnInvoice, objPageDetails);
                        lblReturnSubtotalDisplay.Text = "$ " + returnInvoice.fltSubTotal.ToString("#0.00");
                    }
                }
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
Пример #3
0
        //Still need to account for a duplicate item being added
        protected void Page_Load(object sender, EventArgs e)
        {
            //Collects current method and page for error tracking
            string method = "Page_Load";

            Session["currPage"] = "SalesCart.aspx";
            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //checks if the user has logged in
                if (Session["currentUser"] == null)
                {
                    //Go back to Login to log in
                    Response.Redirect("LoginPage.aspx", false);
                }
                else
                {
                    CU = (CurrentUser)Session["currentUser"];
                    lblInvalidQty.Visible = false;
                    if (!Page.IsPostBack)
                    {
                        txtSearch.Focus();
                        //Set name in text box
                        Invoice invoice = new Invoice();
                        if (Request.QueryString["invoice"].ToString() == "-10")
                        {
                            Invoice newInvoice = new Invoice
                            {
                                varInvoiceNumber       = IM.CallReturnNextInvoiceNumberForNewInvoice(CU, objPageDetails),
                                intInvoiceSubNumber    = 1,
                                customer               = CM.CallReturnCustomer(Convert.ToInt32(Request.QueryString["customer"].ToString()), objPageDetails)[0],
                                employee               = CU.employee,
                                location               = CU.location,
                                fltGovernmentTaxAmount = 0,
                                fltProvincialTaxAmount = 0,
                                fltLiquorTaxAmount     = 0,
                                bitIsShipping          = false,
                                //newInvoice.bitChargeGST = true;
                                //newInvoice.bitChargePST = true;
                                //newInvoice.bitChargeLCT = true;
                                intTransactionTypeID     = 1,
                                varAdditionalInformation = ""
                            };
                            invoice = IM.CallCreateInitialTotalsForTable(newInvoice, objPageDetails)[0];

                            var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                            nameValues.Set("customer", invoice.customer.intCustomerID.ToString());
                            nameValues.Set("invoice", invoice.intInvoiceID.ToString());
                            Response.Redirect(Request.Url.AbsolutePath + "?" + nameValues, false);
                        }
                        else
                        {
                            invoice = IM.CallReturnCurrentInvoice(Convert.ToInt32(Request.QueryString["invoice"].ToString()), objPageDetails)[0];
                        }

                        DdlShippingProvince.DataSource    = LM.CallReturnProvinceDropDown(invoice.location.intCountryID, objPageDetails);
                        DdlShippingProvince.SelectedValue = invoice.intShippingProvinceID.ToString();
                        DdlShippingProvince.DataBind();

                        txtCustomer.Text             = invoice.customer.varFirstName + " " + invoice.customer.varLastName;
                        lblDateDisplay.Text          = DateTime.Today.ToString("dd/MMM/yy");
                        lblInvoiceNumberDisplay.Text = invoice.varInvoiceNumber + "-" + invoice.intInvoiceSubNumber;
                        //change to gather the items from table
                        GrdCartItems.DataSource = invoice.invoiceItems;
                        GrdCartItems.DataBind();
                        if (invoice.bitIsShipping)
                        {
                            RdbShipping.Checked         = true;
                            DdlShippingProvince.Visible = true;
                            DdlShippingProvince.Enabled = true;
                        }
                        else
                        {
                            RdbInStorePurchase.Checked  = true;
                            DdlShippingProvince.Visible = false;
                            DdlShippingProvince.Enabled = false;
                        }
                        txtShippingAmount.Text    = invoice.fltShippingCharges.ToString();
                        lblSubtotalDisplay.Text   = invoice.fltSubTotal.ToString("C");
                        Session["currentInvoice"] = invoice;
                    }
                }
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }