Exemple #1
0
 public void Update(DS_Orders Orders)
 {
     using (var ct = new DS_OrdersDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Orders.Attach(Orders, true);
         ct.SubmitChanges();
     }
 }
Exemple #2
0
 public void Add(DS_Orders Orders)
 {
     using (var ct = new DS_OrdersDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Orders.InsertOnSubmit(Orders);
         ct.SubmitChanges();
     }
 }
Exemple #3
0
 public void Delete(int ID)
 {
     using (var ct = new DS_OrdersDataContext(DbHelperSQL.Connection))
     {
         DS_Orders st = ct.DS_Orders.Single(a => a.ID == ID);
         ct.DS_Orders.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }
Exemple #4
0
        public void Add(DS_Orders Order, List <DS_OrderDetail> OrderDetail)
        {
            using (var con = DbHelperSQL.GetConnection()) {
                var tran = con.BeginTransaction();
                var ct   = new DS_OrdersDataContext(con);
                ct.Transaction = tran;
                var ct2 = new DS_OrderDetailDataContext(con);
                ct2.Transaction = tran;
                ct.DS_Orders.InsertOnSubmit(Order);
                ct.SubmitChanges();
                foreach (var odd in OrderDetail)
                {
                    odd.OrderID = Order.ID;
                }
                ct2.DS_OrderDetail.InsertAllOnSubmit(OrderDetail);
                ct2.SubmitChanges();

                tran.Commit();
            }
        }