private void buttonAdd_Click(object sender, EventArgs e) { Order anOrder = new Order(); anOrder.OrderId = Convert.ToInt32(textBoxOrderID.Text); Ordered ordered = new Ordered(); ordered.ProductId = Convert.ToInt32(textBoxProductID.Text); ordered.Quantity = Convert.ToInt32(textBoxQuantity.Text); anOrder.Ordered = ordered; anOrder.OrderDate = Convert.ToDateTime(dateTimePickerOrderDate.Text); anOrder.ShipDate = Convert.ToDateTime(dateTimePickerShipDate.Text); anOrder.SalesClerkId = LoggedIn.EmpId; foreach (Book element in (ProductDA.GetBook())) { if (element.Isbn == anOrder.Ordered.ProductId) { if ((element.Qoh - anOrder.Ordered.Quantity) >= 0) { element.Qoh = element.Qoh - anOrder.Ordered.Quantity; ProductDA.UpdateBook(element); OrderDA.SetOrder(anOrder); RefreshList(); } else { MessageBox.Show("Not enough stock to complete order.\nAsk Inventory to add more stock before completing order.", "Error!"); } } } }
private void buttonUpdate_Click(object sender, EventArgs e) { if (comboBoxProduct.Text == "Book") { Book aBook = new Book(); aBook.Isbn = Convert.ToInt32(textBoxISBN.Text); aBook.Name = textBoxName.Text; aBook.Price = Convert.ToDouble(textBoxPrice.Text); aBook.Year = Convert.ToInt32(textBoxYear.Text); aBook.Qoh = Convert.ToInt32(textBoxQOH.Text); aBook.Category = textBoxCategoryVersion.Text; ProductDA.UpdateBook(aBook); } else { if (comboBoxProduct.Text == "Software") { Software aSoftware = new Software(); aSoftware.Name = textBoxName.Text; aSoftware.Price = Convert.ToDouble(textBoxPrice.Text); aSoftware.Year = Convert.ToInt32(textBoxYear.Text); aSoftware.Qoh = Convert.ToInt32(textBoxQOH.Text); aSoftware.Version = textBoxCategoryVersion.Text; ProductDA.UpdateSoftware(aSoftware); } } RefreshList(); }