private void buttonOrderAddMan_Click(object sender, EventArgs e) { try { OrderMenu orderMenu = new OrderMenu(); // orderMenu.OrderNo = Convert.ToInt32(this.textBoxOrderNo.Text); orderMenu.ItemName = this.textBoxOdrItemNameMan_bt.Text; orderMenu.ItemQuantity = Convert.ToInt32(this.textBoxOrderQuantityMan.Text); OrderMenuRepo orderMenuRepo = new OrderMenuRepo(); if (orderMenu.ItemQuantity <= orderMenuRepo.GetQuantity(orderMenu.ItemName)) { if (orderMenuRepo.Insert(orderMenu)) { List <OrderMenu> orderMenuList = orderMenuRepo.GetAllOrderMenu(); this.dataGridViewOrderedItmManagwe2.DataSource = orderMenuList; InventoryRepo inventoryRepo = new InventoryRepo(); inventoryRepo.Update(orderMenuRepo.GetQuantity(orderMenu.ItemName) - orderMenu.ItemQuantity, orderMenu.ItemName); List <Inventory> inventoryList = inventoryRepo.GetAllInventory(); this.dataGridOrderMenuItemMan1.DataSource = inventoryList; } } else { MessageBox.Show("Quantity Limit Exceed"); } } catch { } }
private void buttonOrderDiscardMan_Click(object sender, EventArgs e) { try { OrderMenu orderMenu = new OrderMenu(); // orderMenu.OrderNo = Convert.ToInt32(this.textBoxOrderNo.Text); orderMenu.ItemName = this.textBoxOdrItemNameMan_bt.Text; orderMenu.ItemQuantity = Convert.ToInt32(this.textBoxOrderQuantityMan.Text); InventoryRepo inventoryRepo = new InventoryRepo(); OrderMenuRepo orderMenuRepo = new OrderMenuRepo(); inventoryRepo.Update(orderMenuRepo.GetQuantity(orderMenu.ItemName) + orderMenu.ItemQuantity, orderMenu.ItemName); orderMenuRepo.Delete(orderMenu.ItemName); // orderMenuRepo.Update(, orderMenu.ItemName); List <OrderMenu> orderMenuList = orderMenuRepo.GetAllOrderMenu(); this.dataGridViewOrderedItmManagwe2.DataSource = orderMenuList; List <Inventory> inventoryList = inventoryRepo.GetAllInventory(); this.dataGridOrderMenuItemMan1.DataSource = inventoryList; this.textBoxOdrItemNameMan_bt.Text = ""; this.textBoxOrderQuantityMan.Text = ""; } catch { } }