Esempio n. 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            i++;
            var list = (from customer2 in MyDataContext.CustomerTable where customer2.CustomerID == "CustomerID" + i select customer2).ToList();

            if (list.Count > 0)
            {
                MessageBox.Show("数据已经存在");
                return;
            }


            Customer customer = new Customer { CustomerID = "CustomerID" + i, ID = i, Name = "CustomerName" + i };
            MyDataContext.CustomerTable.InsertOnSubmit(customer);

            Order order1 = new Order { Customer = customer, Name = "order1_" + i, OrderID = i, CustomerID = "CustomerID1" + i, Desc ="desc"};
            MyDataContext.OrderTable.InsertOnSubmit(order1);
            Order order2 = new Order { Customer = customer, Name = "order2_" + i, OrderID = i, CustomerID = "CustomerID2" + i, Desc = "desc" };
            MyDataContext.OrderTable.InsertOnSubmit(order2);

            MyDataContext.SubmitChanges();
            MessageBox.Show("成功插入");
        }
Esempio n. 2
0
 private void removed(Order order)
 {
     order.Customer = null;
 }
Esempio n. 3
0
 private void add(Order order)
 {
     order.Customer = this;
 }