public static int add(HoaDonDaiLy hoadon)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             var hd = new HOADONDAILY
             {
                 masodaily = hoadon.MaSoDaiLy,
                 ngaylap = hoadon.NgayLap,
                 tongtien = hoadon.ChiTiet.Sum(ct => ct.SoLuong * ct.DonGia),
                 trangthai = 0
             };
             db.HOADONDAILies.InsertOnSubmit(hd);
             db.SubmitChanges();
             foreach (ChiTietHoaDonDaiLy ct in hoadon.ChiTiet)
             {
                 ChiTiet.add(ct, hd.masohoadon);
             }
             return hd.masohoadon;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 0;
     }
 }
예제 #2
0
 public HoaDonDaiLy(HOADONDAILY hoadon)
 {
     MaSoHoaDon = hoadon.masohoadon;
     MaSoDaiLy = hoadon.masodaily;
     NgayLap = hoadon.ngaylap;
     TongTien = hoadon.tongtien;
     TrangThai = hoadon.trangthai;
 }
 partial void DeleteHOADONDAILY(HOADONDAILY instance);
 partial void UpdateHOADONDAILY(HOADONDAILY instance);
 partial void InsertHOADONDAILY(HOADONDAILY instance);
		private void detach_HOADONDAILies(HOADONDAILY entity)
		{
			this.SendPropertyChanging();
			entity.DAILY = null;
		}
		private void attach_HOADONDAILies(HOADONDAILY entity)
		{
			this.SendPropertyChanging();
			entity.DAILY = this;
		}
예제 #8
0
 public HoaDonDaiLy(HOADONDAILY hoadon, DAILY daily)
     : this(hoadon)
 {
     DaiLy = new DaiLy(daily);
 }