Exemplo n.º 1
0
        protected void BtnAddPurchase_Click(object sender, EventArgs e)
        {
            //Collects current method error tracking
            string method = "BtnAddPurchase_Click";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                Invoice      receipt       = IM.CallReturnCurrentPurchaseInvoice(Convert.ToInt32(Request.QueryString["receipt"]), CU.location.intProvinceID, objPageDetails)[0];
                string[]     inventoryInfo = ItM.CallReserveTradeInSKU(CU, objPageDetails);
                InvoiceItems purchItem     = new InvoiceItems
                {
                    intInventoryID       = Convert.ToInt32(inventoryInfo[1]),
                    varSku               = inventoryInfo[0].ToString(),
                    intItemQuantity      = 1,
                    varItemDescription   = "",
                    fltItemCost          = 0.00,
                    intInvoiceID         = receipt.intInvoiceID,
                    fltItemDiscount      = 0,
                    fltItemRefund        = 0,
                    fltItemPrice         = 0,
                    bitIsDiscountPercent = false,
                    bitIsClubTradeIn     = false,
                    intItemTypeID        = 1
                };

                IIM.CallInsertItemIntoSalesCart(purchItem, receipt.intTransactionTypeID, receipt.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);
                //Bind items in cart to grid view
                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);
            }
        }
Exemplo n.º 2
0
        //Finalizing the trade-in item
        protected void BtnAddTradeIN_Click(object sender, EventArgs e)
        {
            string method = "BtnAddTradeIN_Click";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                CU = (CurrentUser)Session["currentUser"];
                //Creating a new club
                Clubs tradeIN = new Clubs
                {
                    intInventoryID           = inventoryID,
                    varSku                   = lblSKUDisplay.Text,
                    fltCost                  = Convert.ToDouble(txtCost.Text),
                    fltPrice                 = Convert.ToDouble(txtPrice.Text),
                    fltPremiumCharge         = 0,
                    intItemTypeID            = 1,
                    intBrandID               = Convert.ToInt32(ddlBrand.SelectedValue),
                    intModelID               = Convert.ToInt32(ddlModel.SelectedValue),
                    intQuantity              = Convert.ToInt32(txtQuantity.Text),
                    varTypeOfClub            = txtClubType.Text,
                    varShaftType             = txtShaft.Text,
                    varClubSpecification     = txtClubSpec.Text,
                    varShaftFlexability      = txtShaftFlex.Text,
                    varNumberOfClubs         = txtNumberofClubs.Text,
                    varShaftSpecification    = txtShaftSpec.Text,
                    varClubDexterity         = txtDexterity.Text,
                    varAdditionalInformation = txtComments.Text,
                    bitIsUsedProduct         = true,
                    intLocationID            = CU.location.intLocationID
                };

                //this adds to the temp tradeIncart
                ItM.CallAddTradeInItemToTempTable(tradeIN, objPageDetails);

                //change cost and price for cart
                InvoiceItemsManager IIM             = new InvoiceItemsManager();
                InvoiceItems        selectedTradeIn = new InvoiceItems
                {
                    intInvoiceID       = invoice.intInvoiceID,
                    intInventoryID     = tradeIN.intInventoryID,
                    varSku             = tradeIN.varSku,
                    intItemQuantity    = tradeIN.intQuantity,
                    varItemDescription = ItM.CallReturnBrandlNameFromBrandID(tradeIN.intBrandID, objPageDetails) + " "
                                         + ItM.CallReturnModelNameFromModelID(tradeIN.intModelID, objPageDetails) + " " + tradeIN.varClubSpecification + " "
                                         + tradeIN.varTypeOfClub + " " + tradeIN.varShaftSpecification + " " + tradeIN.varShaftFlexability + " "
                                         + tradeIN.varClubDexterity,
                    fltItemCost          = 0,
                    fltItemPrice         = tradeIN.fltCost * (-1),
                    fltItemDiscount      = 0,
                    fltItemRefund        = 0,
                    bitIsDiscountPercent = false,
                    bitIsClubTradeIn     = true,
                    intItemTypeID        = 1
                };

                IIM.CallInsertItemIntoSalesCart(selectedTradeIn, invoice.intTransactionTypeID, invoice.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);

                //IIM.NewTradeInChangeChargeTaxToFalse(selectedTradeIn, invoice.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);

                //Closing the trade in information window
                string redirect = "<script>window.close('TradeINEntry.aspx');</script>";
                Response.Write(redirect);
            }
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
        protected void GrdInvoicedItems_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //Collects current method for error tracking
            string method = "GrdInvoicedItems_RowDeleting";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                Invoice returnInvoice = IM.CallReturnCurrentInvoice(Convert.ToInt32(Request.QueryString["invoice"]), CU.location.intProvinceID, objPageDetails)[0];
                lblInvalidQty.Visible = false;
                //Stores the info about the item in that index
                InvoiceItems selectedSku = IIM.CallReturnInvoiceItemForReturnProcess(Convert.ToInt32(((Label)GrdInvoicedItems.Rows[e.RowIndex].Cells[0].FindControl("lblInvoiceItemID")).Text), objPageDetails);

                //if (selectedSku.bitIsDiscountPercent)
                //{
                //    selectedSku.fltItemPrice -= ((selectedSku.fltItemDiscount / 100) * selectedSku.fltItemPrice);
                //}
                //else
                //{
                //    selectedSku.fltItemPrice -= selectedSku.fltItemDiscount;
                //}

                selectedSku.intInvoiceID = Convert.ToInt32(returnInvoice.intInvoiceID);
                if (!IIM.CallItemAlreadyInCart(selectedSku, objPageDetails))
                {
                    int    currentQTY        = selectedSku.intItemQuantity;
                    string quantityForReturn = ((TextBox)GrdInvoicedItems.Rows[e.RowIndex].Cells[2].FindControl("quantityToReturn")).Text;
                    int    quantitySold      = Convert.ToInt32(((Label)GrdInvoicedItems.Rows[e.RowIndex].Cells[2].FindControl("quantitySold")).Text);
                    int    returnQuantity    = 1;
                    if (quantityForReturn != "")
                    {
                        if (int.TryParse(quantityForReturn, out returnQuantity))
                        {
                            returnQuantity = Convert.ToInt32(quantityForReturn);
                        }
                    }
                    if (returnQuantity > quantitySold || returnQuantity < 1)
                    {
                        lblInvalidQty.Visible = true;
                    }
                    else
                    {
                        double returnDollars = 0;
                        string returnAmount  = ((TextBox)GrdInvoicedItems.Rows[e.RowIndex].Cells[7].FindControl("txtReturnAmount")).Text;
                        if (returnAmount != "")
                        {
                            if (double.TryParse(returnAmount, out returnDollars))
                            {
                                returnDollars = Convert.ToDouble(returnAmount);
                            }
                        }
                        IIM.CallRemoveQTYFromInventoryWithSKU(selectedSku.intInventoryID, selectedSku.intItemTypeID, (currentQTY + returnQuantity), objPageDetails);
                        selectedSku.intItemQuantity = returnQuantity;
                        selectedSku.fltItemRefund   = -1 * returnDollars;
                        selectedSku.fltItemCost    *= -1;
                        IIM.CallInsertItemIntoSalesCart(selectedSku, returnInvoice.intTransactionTypeID, returnInvoice.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);
                        //deselect the indexed item
                        GrdInvoicedItems.EditIndex = -1;
                        //store items available for return in session
                        GrdInvoicedItems.DataSource = IIM.CallReturnInvoiceItemsFromProcessedSalesForReturn(returnInvoice.varInvoiceNumber.ToString(), returnInvoice.dtmInvoiceDate, CU.location.intProvinceID, objPageDetails);
                        GrdInvoicedItems.DataBind();

                        IM.CalculateNewInvoiceReturnTotalsToUpdate(IM.CallReturnCurrentInvoice(returnInvoice.intInvoiceID, CU.location.intProvinceID, objPageDetails)[0], objPageDetails);
                        returnInvoice = IM.CallReturnCurrentInvoice(returnInvoice.intInvoiceID, CU.location.intProvinceID, objPageDetails)[0];

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

                        //recalculate the return total
                        lblReturnSubtotalDisplay.Text = "$ " + returnInvoice.fltSubTotal.ToString("#0.00");
                    }
                }
                else
                {
                    MessageBoxCustom.ShowMessage("Same item cannot be returned for a different amount. "
                                                 + "Either cancel item to set both at new return amount or process a second return.", this);
                }
            }
            //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);
            }
        }
Exemplo n.º 4
0
        protected void GrdInventorySearched_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //Collects current method for error tracking
            string method = "GrdInventorySearched_RowCommand";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                Invoice invoice = IM.CallReturnCurrentInvoice(Convert.ToInt32(Request.QueryString["invoice"].ToString()), objPageDetails)[0];
                lblInvalidQty.Visible = false;
                int    index    = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                int    quantity = 1;
                string qty      = ((TextBox)GrdInventorySearched.Rows[index].Cells[2].FindControl("quantityToAdd")).Text;
                if (qty != "")
                {
                    if (int.TryParse(qty, out quantity))
                    {
                        quantity = Convert.ToInt32(qty);
                    }
                }
                int currentQty = Convert.ToInt32(((Label)GrdInventorySearched.Rows[index].Cells[2].FindControl("QuantityInOrder")).Text);
                if (quantity > currentQty || quantity < 1)
                {
                    lblInvalidQty.Visible = true;
                }
                else
                {
#pragma warning disable IDE0017 // Simplify object initialization
                    InvoiceItems selectedSku = new InvoiceItems();
#pragma warning restore IDE0017 // Simplify object initialization
                    selectedSku.intInventoryID = Convert.ToInt32(e.CommandArgument);
                    selectedSku.intInvoiceID   = invoice.intInvoiceID;
                    if (!IIM.CallItemAlreadyInCart(selectedSku, objPageDetails))
                    {
                        double discount       = 0;
                        string discountAmount = ((TextBox)GrdInventorySearched.Rows[index].Cells[5].FindControl("txtAmountDiscount")).Text;
                        if (discountAmount != "")
                        {
                            if (double.TryParse(discountAmount, out discount))
                            {
                                discount = Convert.ToDouble(discountAmount);
                            }
                        }
                        selectedSku.fltItemDiscount      = discount;
                        selectedSku.varItemDescription   = ((Label)GrdInventorySearched.Rows[index].Cells[3].FindControl("Description")).Text;
                        selectedSku.fltItemRefund        = 0;
                        selectedSku.fltItemPrice         = double.Parse(((Label)GrdInventorySearched.Rows[index].Cells[4].FindControl("rollPrice")).Text, NumberStyles.Currency);
                        selectedSku.fltItemCost          = double.Parse(((Label)GrdInventorySearched.Rows[index].Cells[4].FindControl("rollCost")).Text, NumberStyles.Currency);
                        selectedSku.bitIsDiscountPercent = ((CheckBox)GrdInventorySearched.Rows[index].Cells[5].FindControl("chkDiscountPercent")).Checked;
                        selectedSku.bitIsClubTradeIn     = ((CheckBox)GrdInventorySearched.Rows[index].Cells[6].FindControl("chkTradeInSearch")).Checked;
                        selectedSku.intItemTypeID        = Convert.ToInt32(((Label)GrdInventorySearched.Rows[index].Cells[7].FindControl("lblTypeIDSearch")).Text);
                        selectedSku.intItemQuantity      = quantity;

                        //add item to table and remove the added qty from current inventory
                        IIM.CallInsertItemIntoSalesCart(selectedSku, invoice.intTransactionTypeID, invoice.dtmInvoiceDate, Convert.ToInt32(DdlShippingProvince.SelectedValue), objPageDetails);
                        IIM.CallRemoveQTYFromInventoryWithSKU(selectedSku.intInventoryID, selectedSku.intItemTypeID, (currentQty - quantity), objPageDetails);

                        invoice = IM.CallReturnCurrentInvoice(invoice.intInvoiceID, objPageDetails)[0];
                        //Set an empty variable to bind to the searched items grid view so it is empty
                        GrdInventorySearched.DataSource = null;
                        GrdInventorySearched.DataBind();
                        Session["currentInvoice"] = invoice;
                        //Recalculate the new subtotal
                        UpdateInvoiceTotals();
                    }
                    else
                    {
                        MessageBoxCustom.ShowMessage("Item is already in the cart. Please update item in cart or process a second sale.", this);
                    }
                }
            }
            //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);
            }
        }