private void btnAdd_Click(object sender, EventArgs e) { int inventoryID = 0; string newUsed = ""; string jobNumber = ""; BPOrderDetails bpOrderDetails = new BPOrderDetails(); BPOrders bpOrders = new BPOrders(); BPInventory bpInventory = new BPInventory(); DSInventory = new BEInventory(); GridItemCollection CheckedCollection = new GridItemCollection(); CheckedCollection = dgInventory.GetCheckedItems(dgInventory.Levels[0].Columns[1]); if (OrderID > 0 && OrderCompleted == false) { DSOrders = bpOrderDetails.SelectByOrderID(OrderID); DSOrders.Merge(bpOrders.SelectOrdersByID(OrderID)); //for tracking JobNumber with inventory item if(DSOrders.tbl_Orders.Count > 0) { BEOrders.tbl_OrdersRow order = DSOrders.tbl_Orders[0]; jobNumber = order.IsOrderJobNumberNull() ? "" : order.OrderJobNumber; } foreach (GridItem item in CheckedCollection) { inventoryID = Convert.ToInt32(item[0]); newUsed = item[3].ToString(); DSOrders.tbl_OrderDetails.DefaultView.RowFilter = "InventoryID=" + inventoryID; if (DSOrders.tbl_OrderDetails.DefaultView.Count == 0) { BEOrders.tbl_OrderDetailsRow OrderDetails; OrderDetails = DSOrders.tbl_OrderDetails.Newtbl_OrderDetailsRow(); OrderDetails.OrderID = OrderID; OrderDetails.InventoryID = inventoryID; OrderDetails.InventoryItemReturned = false; switch ((InventoryTypes)InventoryType) { case InventoryTypes.Buy: if(newUsed.ToLower() == "new") OrderDetails.BuyRentStatus = "Buy-N"; else OrderDetails.BuyRentStatus = "Buy-U"; break; case InventoryTypes.Rental: OrderDetails.BuyRentStatus = "Rent"; break; default: OrderDetails.SetBuyRentStatusNull(); break; } DSOrders.tbl_OrderDetails.Addtbl_OrderDetailsRow(OrderDetails); BEInventory.tbl_InventoryRow Inventory; DSInventory.Merge(bpInventory.SelectInventoryByID(inventoryID)); Inventory = DSInventory.tbl_Inventory.FindByInventoryID(inventoryID); Inventory.InventoryInStock = 2; //track order's JobNumber with inventory item if(jobNumber != "") Inventory.JobNumber = jobNumber; else Inventory.SetJobNumberNull(); } } bpOrderDetails.Update(DSOrders); bpInventory.Update(DSInventory); } // reset or turn off warning message on submit button // if (CheckedCollection.Count > 0) // { // SetSubmitButtonWarningMessage(OrderID); // } dgInventory.UnCheckAll(); BindDSInventory(); BindDSOrders(); }
private void DeleteOrder(int someOrderID) { if (someOrderID > 0) { BPOrders bp = new BPOrders(); BPOrderDetails bpOD = new BPOrderDetails(); BEOrders.tbl_OrdersRow Order; DSOrders = bp.SelectOrdersByID(someOrderID); Order = DSOrders.tbl_Orders.FindByOrderID(someOrderID); if (!Order.OrderCompleted) ChangeInventoryStatus(someOrderID, Convert.ToInt32(!Order.IsTransfer)); Order.Delete(); DSOrders.Merge(bpOD.SelectOrderDetailsWithInventoryByOrderID(someOrderID)); foreach (BEOrders.tbl_OrderDetailsRow row in DSOrders.tbl_OrderDetails.Rows) { row.Delete(); } bp.Update(DSOrders); bpOD.Update(DSOrders); } }
private void DeleteOrder(int someOrderID) { if (someOrderID > 0) { UpdateOrderItemJobNumbers(someOrderID, string.Empty ); BPOrders bp = new BPOrders(); BPOrderDetails bpOD = new BPOrderDetails(); BEOrders.tbl_OrdersRow Order; DSOrders = bp.SelectOrdersByID(someOrderID); Order = DSOrders.tbl_Orders.FindByOrderID(someOrderID); if (!Order.OrderCompleted) ChangeInventoryStatus(someOrderID, 0); Order.Delete(); DSOrders.Merge(bpOD.SelectOrderDetailsWithInventoryByOrderID(someOrderID)); foreach (BEOrders.tbl_OrderDetailsRow row in DSOrders.tbl_OrderDetails.Rows) { row.Delete(); } bp.Update(DSOrders); bpOD.Update(DSOrders); } }