Esempio n. 1
0
    protected void ShoppingCartList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        ListViewDataItem row = e.Item as ListViewDataItem;

        string username = User.Identity.Name;

        int partid = int.Parse(e.CommandArgument.ToString());

        SalesController sysmgr = new SalesController();

        if (e.CommandName == "Change")
        {
            int quantity = int.Parse((row.FindControl("QuantityTextBox") as TextBox).Text.ToString());

            if (quantity < 1)
            {
                MessageUserControl.ShowInfo("Warning", "Quantity must be at least 1");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    sysmgr.Update_CartItem(username, partid, quantity);
                }, "Success", "Item quantity updated");
            }
        }
        else
        {
            MessageUserControl.TryRun(() =>
            {
                sysmgr.Remove_CartItem(username, partid);
            }, "Success", "Item removed");
        }

        ShoppingCartList.DataBind();

        TotalsGridView.DataBind();

        Page_Load(this, e);
    }
Esempio n. 2
0
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        PurchaseOrder purchaseorder = new PurchaseOrder();

        // get the vendorID from the DDL and set it into purchaseorder
        purchaseorder.VendorID = int.Parse(VendorDDL.SelectedValue);

        List <PurchaseOrderDetail> purchaseorderdetails = new List <PurchaseOrderDetail>();

        foreach (ListViewItem item in CurrentPOListView.Items)
        {
            PurchaseOrderDetail purchaseorderdetail = new PurchaseOrderDetail();

            purchaseorderdetail.PurchaseOrderDetailID = int.Parse((item.FindControl("PurchaseOrderDetailIDLabel2") as Label).Text.ToString());
            purchaseorderdetail.PartID        = int.Parse((item.FindControl("PartIDLabel2") as Label).Text.ToString());
            purchaseorderdetail.Quantity      = int.Parse((item.FindControl("QuantityTextBox2") as TextBox).Text.ToString());
            purchaseorderdetail.PurchasePrice = decimal.Parse((item.FindControl("PurchasePriceTextBox2") as TextBox).Text.ToString());

            purchaseorderdetails.Add(purchaseorderdetail);
        }

        var sysmgr = new PurchasingController();

        MessageUserControl.TryRun(() =>
        {
            sysmgr.Update_PurchaseOrder(purchaseorder, purchaseorderdetails);

            // rebind the current PO
            CurrentPOListView.DataSourceID = "CurrentPOODS";
            CurrentPOListView.DataBind();

            // rebind the totals for the current PO
            TotalsGridView.DataBind();

            // rebind the current inventory list
            CurrentInventoryListView.DataSourceID = "CurrentInventoryODS";
            CurrentInventoryListView.DataBind();
        }, "Success", "Purchase Order item(s) quantity and purchase price updated");
    }
    protected void PlaceOrderBtn_Click(object sender, EventArgs e)
    {
        string username = User.Identity.Name;

        int couponid = int.Parse(CouponListDD.SelectedValue);

        FinalTotalPOCO totals = new FinalTotalPOCO();

        totals.SubTotal = decimal.Parse(TotalsGridView.DataKeys[0].Values[0].ToString());
        totals.Discount = decimal.Parse(TotalsGridView.DataKeys[0].Values[1].ToString());
        totals.GST      = decimal.Parse(TotalsGridView.DataKeys[0].Values[2].ToString());
        totals.Total    = decimal.Parse(TotalsGridView.DataKeys[0].Values[3].ToString());

        string paymethod = PaymentMethodRB.SelectedValue;

        MessageUserControl.TryRun(() =>
        {
            SalesController sysmgr  = new SalesController();
            List <Part> backordered = sysmgr.Place_Order(username, couponid, totals, paymethod);

            if (backordered.Count > 0)
            {
                backorderalertlabel.Text = "";
                string backorderalert    = "The following items have been backordered: ";

                foreach (Part part in backordered)
                {
                    backorderalert += part.Description + " ";
                }

                backorderalertlabel.Visible = true;
                backorderalertlabel.Text    = backorderalert;
            }

            ShoppingCartList.DataBind();
            TotalsGridView.DataBind();
        }, "Success", "Your order has been processed.");
    }
Esempio n. 4
0
    protected void GetCreatePO_Click(object sender, EventArgs e)
    {
        if (VendorDDL.SelectedValue == "0")
        {
            MessageUserControl.ShowInfo("You must first select a vendor from the list.");
        }
        else
        {
            // only show the GridViews, Listviews and buttons on click
            showAll();

            // set the current active order ODS to the listview
            CurrentPOListView.DataSourceID = "CurrentPOODS";
            CurrentPOListView.DataBind();

            if (CurrentPOListView.Items.Count == 0) // then create the suggested putchase order
            {
                // set the suggested order ODS to the listview and bind it
                CurrentPOListView.DataSourceID = "SuggestedPOODS";
                CurrentPOListView.DataBind();

                PurchaseOrder purchaseorder = new PurchaseOrder();

                // get the vendorID from the DDL and set it into purchaseorder
                purchaseorder.VendorID = int.Parse(VendorDDL.SelectedValue);

                var usersysmgr = new UserManager();

                int employeeId = usersysmgr.Get_EmployeeId(User.Identity.Name);

                // create new list to store the purchase order details
                List <PurchaseOrderDetail> purchaseorderdetails = new List <PurchaseOrderDetail>();

                // go through the needed rows of the listview to get the data needed for suggested order and add it to the purchaseorderdetails list
                foreach (ListViewItem item in CurrentPOListView.Items)
                {
                    PurchaseOrderDetail purchaseorderdetail = new PurchaseOrderDetail();

                    purchaseorderdetail.PartID        = int.Parse((item.FindControl("PartIDLabel2") as Label).Text.ToString());
                    purchaseorderdetail.Quantity      = int.Parse((item.FindControl("QuantityTextBox2") as TextBox).Text.ToString());
                    purchaseorderdetail.PurchasePrice = decimal.Parse((item.FindControl("PurchasePriceTextBox2") as TextBox).Text.ToString());

                    purchaseorderdetails.Add(purchaseorderdetail);
                }


                // pass the data to the controller to create the suggested order
                var sysmgr = new PurchasingController();
                MessageUserControl.TryRun(() =>
                {
                    sysmgr.NewSuggestedOrder(purchaseorder, purchaseorderdetails, employeeId);
                }, "Success", "Suggested purchase order created.");

                TotalsGridView.DataBind();

                PurchaseOrder purchaseordertotals = new PurchaseOrder();

                // pass the subtotal, taxamount to purchaseorder here
                purchaseordertotals.SubTotal  = Math.Round(decimal.Parse(TotalsGridView.DataKeys[0].Values[0].ToString()), 2);
                purchaseordertotals.TaxAmount = Math.Round(decimal.Parse(TotalsGridView.DataKeys[0].Values[1].ToString()), 2);

                // pass the totals to the controller to update the suggested order
                var newsysmgr = new PurchasingController();
                MessageUserControl.TryRun(() =>
                {
                    newsysmgr.UpdateTotalsSuggestedOrder(purchaseorder, purchaseordertotals);
                }, "Success", "Suggested purchase order totals updated.");

                // Bind the new current inventory for the suggested order
                CurrentInventoryListView.DataSourceID = "CurrentInventoryODS";
                CurrentInventoryListView.DataBind();

                // this is for if the vendor has no parts available to be automatically put on the suggested purchase order
                if (CurrentPOListView.Items.Count == 0)
                {
                    MessageUserControl.ShowInfo("Information", "No active purchase order found. A suggested purchase order has been created, however, no parts from this vendor are eligible for the suggested purchase order.");
                }
                else // else, the suggested parts will be shown on the suggested order
                {
                    MessageUserControl.ShowInfo("Information", "No active purchase order found. A suggested purchase order has been created.");
                }
            }
            else
            {
                // Bind the new current inventory for the current active order
                CurrentInventoryListView.DataSourceID = "CurrentInventoryODS";
                CurrentInventoryListView.DataBind();

                MessageUserControl.ShowInfo("Information", "Current active order found.");
            }
        }
    }