protected void GetSuggestedOrder_Click(object sender, EventArgs e) { int purchaseOrder; string stringOrder = VendorDropdown.SelectedItem.Text; string cutString = stringOrder.Substring(stringOrder.Length - 3); if (VendorDropdown.SelectedIndex != 0) { if (int.TryParse(cutString, out purchaseOrder)) { PurchaseOrderDisplay.Text = purchaseOrder.ToString(); PurchasingController sysmgr = new PurchasingController(); List <SuggestedOrderItems> list = sysmgr.GetSuggestedOrders(purchaseOrder); SuggestedItems.DataSource = list; SuggestedItems.DataBind(); List <NonSuggestedOrderItems> list2 = sysmgr.GetNonSuggestedItems(int.Parse(VendorDropdown.SelectedValue), purchaseOrder); NonSuggestedItems.DataSource = list2; NonSuggestedItems.DataBind(); UpdateOrderLink.Text = "Update Order"; DeleteOrderLink.Enabled = true; PlaceOrderLink.Enabled = true; } else { PurchaseOrderDisplay.Text = purchaseOrder.ToString(); PurchasingController sysmgr = new PurchasingController(); List <SuggestedOrderItems> list = sysmgr.ReviewSuggestedOrder(int.Parse(VendorDropdown.SelectedValue)); SuggestedItems.DataSource = list; SuggestedItems.DataBind(); foreach (GridViewRow gvr in SuggestedItems.Rows) { (gvr.FindControl("RemoveItem") as Button).Visible = true; (gvr.FindControl("RemoveItem") as Button).Enabled = false; } List <NonSuggestedOrderItems> list2 = sysmgr.GetNonSuggestedOrderItems(int.Parse(VendorDropdown.SelectedValue)); foreach (GridViewRow gvr in NonSuggestedItems.Rows) { (gvr.FindControl("AddToOrder") as Button).Enabled = false; (gvr.FindControl("AddToOrder") as Button).Visible = true; } NonSuggestedItems.DataSource = list2; NonSuggestedItems.DataBind(); DeleteOrderLink.Enabled = true; PlaceOrderLink.Enabled = true; } GetVendorInfo(); } else { MessageUserControl.ShowInfo("You need a select a vendor before you can make the transaction"); } }
protected void DeleteOrderLink_Click(object sender, EventArgs e) { string purchaseOrderIDString = PurchaseOrderDisplay.Text; string vendorID = VendorDropdown.Text; if (purchaseOrderIDString == "" || purchaseOrderIDString == "0") { MessageUserControl.ShowInfo("You must have purchase order first"); } else if (vendorID == "") { MessageUserControl.ShowInfo("You must have a vendor."); } else if (SuggestedItems.Rows.Count == 0) { MessageUserControl.ShowInfo("You must have at least one item in order to delete the purchase order."); } else { MessageUserControl.TryRun(() => { int PurchaseOrderID = int.Parse(purchaseOrderIDString); var stockItemID = int.Parse(purchaseOrderIDString); var stockItems = new List <SuggestedOrderItems>(); foreach (GridViewRow gvr in SuggestedItems.Rows) { SuggestedOrderItems item = new SuggestedOrderItems(); item.ID = int.Parse(SuggestedItems.Rows[gvr.RowIndex].Cells[0].Text); stockItems.Add(item); } PurchasingController sysmgr = new PurchasingController(); sysmgr.DeleteOrder(PurchaseOrderID, stockItems); SuggestedItems.DataSource = null; SuggestedItems.DataBind(); NonSuggestedItems.DataBind(); GetSuggestedOrder.Text = ""; VendorName.Text = ""; VendorPhone.Text = ""; UpdateOrderLink.Text = ""; RefreshVendorList("0"); subtotalAmount.Text = ""; gstAmount.Text = ""; totalAmount.Text = ""; }, "Purchase Order Deleted", "All purchase order details removed as well from that order"); } }
protected void SuggestedItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (PurchaseOrderDisplay.Text != "") { if (e.CommandName.Equals("RemoveOrder")) { MessageUserControl.TryRun(() => { int purchaseorderid = int.Parse(PurchaseOrderDisplay.Text); int stockitemid = int.Parse(e.CommandArgument.ToString()); PurchasingController po = new PurchasingController(); po.RemoveFromOrder(purchaseorderid, stockitemid); SuggestedItems.DataBind(); NonSuggestedItems.DataBind(); }, "Item Removed", "Item has been removed from purchase order"); } } }
protected void NonSuggestedItems_RowCommand(object sender, GridViewCommandEventArgs e) { int vendorID = int.Parse(VendorDropdown.SelectedValue); int purchaseOrderID = int.Parse(PurchaseOrderDisplay.Text); if (purchaseOrderID == 0) { MessageUserControl.ShowInfo("The Purchase Order ID doesn't exist."); } else if (vendorID == 0) { MessageUserControl.ShowInfo("The Vendor has not been selected. Pick a vendor."); } else if (e.CommandName.Equals("AddToOrder")) { MessageUserControl.TryRun(() => { purchaseOrderID = int.Parse(PurchaseOrderDisplay.Text); int stockItemID = int.Parse(e.CommandArgument.ToString()); int POQTY = 1; //int POQTY = int.Parse((SuggestedItems.FindControl("PurchaseOrderQuantity") as TextBox).Text); PurchaseOrderDetail addpod = new PurchaseOrderDetail(); addpod.PurchaseOrderID = purchaseOrderID; addpod.StockItemID = stockItemID; addpod.Quantity = POQTY; PurchasingController sysmgr = new PurchasingController(); sysmgr.AddToOrder(addpod); SuggestedItems.DataSource = sysmgr.GetOrder(addpod.PurchaseOrderID); SuggestedItems.DataBind(); NonSuggestedItems.DataSource = sysmgr.GetNonSuggestedItems(addpod.PurchaseOrderID, vendorID); NonSuggestedItems.DataBind(); }, "Item Added", "Item has been added to the current purchase order."); } }