private void btnConfirmOrder_Click(object sender, EventArgs e) { OrderAppDataContext context = new OrderAppDataContext(); if (cmbCustomer.SelectedItem == null || cmbEmployee.SelectedItem == null || cmbShipVia.SelectedItem == null) return; Order new_order = new Order(); new_order.ShippedDate = DateTime.Now; new_order.CustomerID = cmbCustomer.SelectedValue.ToString(); new_order.EmployeeID = (int)cmbEmployee.SelectedValue; new_order.ShipVia = (int)cmbShipVia.SelectedValue; context.Orders.InsertOnSubmit(new_order); context.SubmitChanges(); foreach (ListViewItem item in listView1.Items) { Order_Detail detail = new Order_Detail(); detail.OrderID = new_order.OrderID; detail.ProductID = (int)item.Tag; detail.UnitPrice = decimal.Parse(item.SubItems[1].Text); detail.Quantity = short.Parse(item.SubItems[2].Text); detail.Discount = float.Parse(item.SubItems[3].Text) / 100; context.Order_Details.InsertOnSubmit(detail); context.SubmitChanges(); } listView1.Items.Clear(); cmbCustomer.SelectedIndex = cmbShipVia.SelectedIndex = -1; }
partial void DeleteOrder_Detail(Order_Detail instance);
partial void UpdateOrder_Detail(Order_Detail instance);
partial void InsertOrder_Detail(Order_Detail instance);
private void detach_Order_Details(Order_Detail entity) { this.SendPropertyChanging(); entity.Product = null; }
private void attach_Order_Details(Order_Detail entity) { this.SendPropertyChanging(); entity.Order = this; }