Пример #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!");
        }
Пример #2
0
        private void PullOrderRow(GridViewCommandEventArgs e, GridView order, GridView inventory)
        {
            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          = row.FindControl("Buffer") as HiddenField;
                        var qty             = row.FindControl("Qty") as TextBox;
                        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.Qty    = int.Parse(qty.Text);
                            details.Price  = decimal.Parse(price.Text);
                            details.Buffer = int.Parse(buffer.Value);
                            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 price           = row.FindControl("Price") as Label;
                        var buffer          = row.FindControl("Buffer") 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 addtoinventory   = orderDetails[index];
                    var currentinventory = FromOrderToInventory(inventory);
                    currentinventory.Add(addtoinventory);
                    CurrentInventoryGridView.DataSource = currentinventory;
                    CurrentInventoryGridView.DataBind();
                    //add items to inventory details
                    orderDetails.RemoveAt(index);
                    order.DataSource = orderDetails;
                    order.DataBind();
                }
                else
                {
                    throw new Exception("Product is not in the list.");
                }
            }, "Success", "Part removed from the order");
        }