Ejemplo n.º 1
0
		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();
		}
Ejemplo n.º 2
0
		private void btnAdd_Click(object sender, EventArgs e)
		{
			int InventoryID = 0;

			BPOrderDetails bp = new BPOrderDetails();
			BPInventory bpInventory = new BPInventory();
			DSInventory = new BEInventory();

			GridItemCollection CheckedCollection = new GridItemCollection();
			CheckedCollection = dgInventory.GetCheckedItems(dgInventory.Levels[0].Columns[1]);

			// if adding an item turn off '0 item' message from submit button
			if (CheckedCollection.Count > 0)
			{
				btnSubmit.MessageEnabled = false;
			}

			if (OrderID > 0 && OrderCompleted == false)
			{
				DSOrders = bp.SelectByOrderID(OrderID);

				foreach (GridItem item in CheckedCollection)
				{
					InventoryID = Convert.ToInt32(item[0]);
					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;
						DSOrders.tbl_OrderDetails.Addtbl_OrderDetailsRow(OrderDetails);
					
						BEInventory.tbl_InventoryRow Inventory;
						DSInventory.Merge(bpInventory.SelectInventoryByID(InventoryID));
						Inventory = DSInventory.tbl_Inventory.FindByInventoryID(InventoryID);	
						Inventory.InventoryInStock = 2;
					}
				}
				bp.Update(DSOrders);
				bpInventory.Update(DSInventory);
			}

			dgInventory.UnCheckAll();

			BindDSInventory();
			BindDSOrders();
		}
Ejemplo n.º 3
0
		private void btnAdd_Click(object sender, EventArgs e)
		{
			int InventoryID = 0;

			BPOrderDetails bp = new BPOrderDetails();
			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 = bp.SelectByOrderID(OrderID);

				foreach (GridItem item in CheckedCollection)
				{
					InventoryID = Convert.ToInt32(item[0]);
					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:
								OrderDetails.BuyRentStatus = "Buy";
								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;
						Inventory.SetJobNumberNull();
					}
				}
				bp.Update(DSOrders);
				bpInventory.Update(DSInventory);
			}

			// reset or turn off warning message on submit button
			if (CheckedCollection.Count > 0)
			{
				if(bp.HasBuyRentItemsByOrderID(OrderID))
				{
					btnSubmit.Message = "ATTENTION: This order includes items for Purchase and/or Rental. Click OK to continue or CANCEL to edit the order.";
					btnSubmit.MessageEnabled = true;
				}
				else
					btnSubmit.MessageEnabled = false;
			}

			dgInventory.UnCheckAll();

			BindDSInventory();
			BindDSOrders();
		}