private void buttonOrdPlaceOrder_Click(object sender, EventArgs e) { //Order Validators if (!Validator.IsEmptyComboBox(comboBoxOrdClient)) { MessageBox.Show("Order must have a valid Client.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } if (!Validator.IsEmptyComboBox(comboBoxOrdProduct)) { MessageBox.Show("Order must have a valid Product.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } if (!Validator.IsEmpty(textBoxOrdQuantity)) { MessageBox.Show("Orders must have a valid quantity.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxAutID.Clear(); textBoxAutID.Focus(); return; } int temp = 0; if ((!int.TryParse((textBoxOrdQuantity.Text), out temp))) { MessageBox.Show("Quantity of Products must be a integer number.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxOrdQuantity.Clear(); textBoxOrdQuantity.Focus(); return; } Order aOrder = createOrder(); Books aBook = BooksDA.SearchByTitle(comboBoxOrdProduct.Text); Clients aClient = ClientsDA.Search(comboBoxOrdClient.Text); aBook.QOH = aBook.QOH - aOrder.OrdQuantity; BooksDA.Update(aBook); aClient.creditLimit = aClient.creditLimit - aOrder.OrdTotal; ClientsDA.Update(aClient); OrderDA.SaveOrder(aOrder); buttonOrdList.PerformClick(); UpdateComboBoxes(); }
//Add private void buttonOrdAdd_Click(object sender, EventArgs e) { Validator checker = new Validator(); if (checker.isNotNull(comboBoxOrdClient.Text, "Client") && checker.isNotNull(comboBoxOrdISBN.Text, "Book ISBN") && checker.isNotNull(textBoxOrdBkQt.Text, "Quantity") && checker.isNotNull(comboBoxOrdMadeBy.Text, "Order made by?")) { Order aorder = createOrder(); Book abook = BookDA.SearchISBN(Convert.ToInt64(comboBoxOrdISBN.Text)); Client aclient = ClientDA.SearchName(comboBoxOrdClient.Text); abook.BkQOH = abook.BkQOH - aorder.OrdBkQuantity; BookDA.Update(abook); aclient.ClientCredit = aclient.ClientCredit - aorder.OrdCost; ClientDA.Update(aclient); OrderDA.SaveOrder(aorder); UpdateComboBoxes(); } }
protected void btnSubmitOrder_Click(object sender, EventArgs e) { List <CartItem> cartItems = (List <CartItem>)Session["items"]; if (currentCustomer != null) { currentOrder.CustomerFirst = currentCustomer.CustomerFirst; currentOrder.CustomerLast = currentCustomer.CustomerLast; currentOrder.OrderDate = DateTime.Now; currentOrder.OrderTotal = total; OrderDA.SaveOrder(currentOrder); currentOrder = OrderDA.GetCustomersLatestOrder(currentCustomer.CustomerFirst, currentCustomer.CustomerLast); foreach (CartItem item in cartItems) { int productID = item.ProductID; int orderID = currentOrder.OrderID; string productDetail = item.Description; OrderDA.SaveOrderLineItems(orderID, productID, productDetail); } Session["Receipt"] = currentOrder; } else { currentOrder.CustomerFirst = txtFirstName.Text; currentOrder.CustomerLast = txtLastName.Text; currentOrder.OrderDate = DateTime.Now; currentOrder.OrderTotal = total; OrderDA.SaveOrder(currentOrder); currentOrder = OrderDA.GetCustomersLatestOrder(currentOrder.CustomerFirst, currentOrder.CustomerLast); foreach (CartItem item in cartItems) { int productID = item.ProductID; int orderID = currentOrder.OrderID; string productDetail = item.ProductDetail; OrderDA.SaveOrderLineItems(orderID, productID, productDetail); } Session["Receipt"] = currentOrder; } Response.Redirect("OrderReciept.aspx"); }
public string SaveOrder(OrderEntity order, List <OrderGoodsEntity> orderGoods, string loginName) { OrderDA da = new OrderDA(); return(da.SaveOrder(order, orderGoods, loginName)); }