Esempio n. 1
0
        protected void GetPurchaseOrder_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                bool is_Selected = VendorDropDown.SelectedIndex > 0;

                if (is_Selected)
                {
                    //get customer summary information
                    var controller  = new PurchasingController();
                    var info        = controller.GetVendorSummary(int.Parse(VendorDropDown.SelectedValue));
                    VendorName.Text = info.Name;
                    Location.Text   = info.Location;
                    Phone.Text      = info.Phone;

                    OrderDetailsPanel.Enabled = true;
                    OrderDetailsPanel.Visible = true;


                    // Populate GridViews
                    var currentOrderDetails         = controller.GetCurrentOrder((int.Parse(VendorDropDown.SelectedValue)), EmployeeName.Text);
                    CurrentOrderGridView.DataSource = currentOrderDetails;
                    CurrentOrderGridView.DataBind();

                    var currentInventoryDetails         = controller.GenInventoryForVendor(int.Parse(VendorDropDown.SelectedValue));
                    CurrentInventoryGridView.DataSource = currentInventoryDetails;
                    CurrentInventoryGridView.DataBind();

                    //calculate Totals
                    CalculateTotals();
                }
                else
                {
                    throw new Exception("Please select a vendor");
                }
            }, "Success", "Order found!");
        }
Esempio n. 2
0
        private void PullInventoryRow(GridViewCommandEventArgs e, GridView inventory, GridView order)
        {
            MessageUserControl.TryRun(() =>
            {
                int index;
                if (int.TryParse(e.CommandArgument.ToString(), out index))
                {
                    List <CurrentOrder> inventoryDetails = new List <CurrentOrder>();
                    List <CurrentOrder> orderDetails     = new List <CurrentOrder>();

                    foreach (GridViewRow row in CurrentOrderGridView.Rows)
                    {
                        var purchaseorderid = row.FindControl("PurchaseOrderID") as HiddenField;
                        var partid          = row.FindControl("PartID") as Label;
                        var desc            = row.FindControl("Description") as Label;
                        var qoh             = row.FindControl("QOH") as Label;
                        var qoo             = row.FindControl("QOO") as Label;
                        var rol             = row.FindControl("ROL") as Label;
                        var buffer          = rol.FindControl("Buffer") as HiddenField;
                        var price           = row.FindControl("Price") as TextBox;

                        if (partid != null)
                        {
                            var details             = new CurrentOrder();
                            details.PurchaseOrderID = int.Parse(purchaseorderid.Value);
                            details.PartID          = int.Parse(partid.Text);
                            details.Description     = desc.Text;
                            if (qoh.Text == "0")
                            {
                                details.QOH = 0;
                            }
                            else
                            {
                                details.QOH = int.Parse(qoh.Text);
                            }

                            details.QOO    = int.Parse(qoo.Text);
                            details.ROL    = int.Parse(rol.Text);
                            details.Buffer = int.Parse(buffer.Value);
                            details.Price  = decimal.Parse(price.Text);

                            orderDetails.Add(details);
                        }
                    }

                    foreach (GridViewRow row in CurrentInventoryGridView.Rows)
                    {
                        var purchaseorderid = row.FindControl("PurchaseOrderID") as HiddenField;
                        var partid          = row.FindControl("PartID") as Label;
                        var desc            = row.FindControl("Description") as Label;
                        var qoh             = row.FindControl("QOH") as Label;
                        var qoo             = row.FindControl("QOO") as Label;
                        var rol             = row.FindControl("ROL") as Label;
                        var buffer          = row.FindControl("Buffer") as Label;
                        var price           = row.FindControl("Price") as Label;

                        if (partid != null)
                        {
                            var details             = new CurrentOrder();
                            details.PurchaseOrderID = int.Parse(purchaseorderid.Value);
                            details.PartID          = int.Parse(partid.Text);
                            details.Description     = desc.Text;
                            if (qoh.Text == "0")
                            {
                                details.QOH = 0;
                            }
                            else
                            {
                                details.QOH = int.Parse(qoh.Text);
                            }

                            details.QOO    = int.Parse(qoo.Text);
                            details.ROL    = int.Parse(rol.Text);
                            details.Buffer = int.Parse(buffer.Text);
                            details.Price  = decimal.Parse(price.Text);

                            inventoryDetails.Add(details);
                        }
                    }

                    var addtoorder = inventoryDetails[index];
                    var coorder    = FromInventoryToOrder(order);
                    coorder.Add(addtoorder);
                    CurrentOrderGridView.DataSource = coorder;
                    CurrentOrderGridView.DataBind();
                    //add items to inventory details
                    inventoryDetails.RemoveAt(index);
                    inventory.DataSource = inventoryDetails;
                    inventory.DataBind();
                }
                else
                {
                    throw new Exception("Product is not in the list.");
                }
            }, "Success", "Part added to the order");
        }