private void btncomplete_Click(object sender, EventArgs e) { Customer customer = new Customer(); Order order = new Order(); customer.CustomerName = txtcname.Text; customer.CustomerSurname = txtcsname.Text; crepo.Add(customer); order.Customer = customer; order.CustomerID = customer.CustomerID; orepo.Add(order); foreach (Product item in ((MainMenu)Mainmenu).GetProduct()) { OrderDetail orderDetail = new OrderDetail(); orderDetail.OrderID = order.OrderID; //orderDetail.Product = item; orderDetail.ProductID = item.ProductID; orderDetail.Quantity = 1; odrepo.Add(orderDetail); prepo.Update(item); } MessageBox.Show("Your Order is Completed. Total Price : " + txtPrice.Text); }
private void btnComplete_Click(object sender, EventArgs e) { Form loginform = new Form(); loginform = Application.OpenForms["LoginForm"]; decimal total = 0; Order order = new Order(); Tour tour = new Tour(); tour = ((RequestForm)requestform).GetTour(); foreach (ListViewItem item in lstSalesOperations.Items) { total = decimal.Parse(item.SubItems[4].Text) + total; tour.Limit = tour.Limit - 1; trepo.Update(tour); } order.TotalPrice = total; order.OrderDate = DateTime.Now; order.AirPlaneStatus = ord.AirPlaneStatus; order.EmployeeID = ((LoginForm)loginform).GetEmployee().EmployeeID; orepo.Add(order); foreach (ListViewItem item in lstSalesOperations.Items) { OrderDetail od = new OrderDetail(); od.OrderID = order.OrderID; od.Customer = cus; od.TourID = tour.TourID; odrepo.Add(od); } MessageBox.Show("Your Order is Completed. Order ID : " + order.OrderID + " Total Price : " + total); }