public ChiTietHoaDonDaiLy(CHITIETHOADONDAILY chitiet)
 {
     MaSoSach = chitiet.masosach;
     MaSoHoaDon = chitiet.masohoadon;
     SoLuong = chitiet.soluong;
     DonGia = chitiet.dongia;
     TrangThai = chitiet.trangthai;
 }
		private void detach_CHITIETHOADONDAILies(CHITIETHOADONDAILY entity)
		{
			this.SendPropertyChanging();
			entity.SACH = null;
		}
 partial void DeleteCHITIETHOADONDAILY(CHITIETHOADONDAILY instance);
 partial void UpdateCHITIETHOADONDAILY(CHITIETHOADONDAILY instance);
 partial void InsertCHITIETHOADONDAILY(CHITIETHOADONDAILY instance);
		private void attach_CHITIETHOADONDAILies(CHITIETHOADONDAILY entity)
		{
			this.SendPropertyChanging();
			entity.HOADONDAILY = this;
		}
 public ChiTietHoaDonDaiLy(CHITIETHOADONDAILY chitiet, SACH sach)
     : this(chitiet)
 {
     Sach = new Sach(sach);
 }
 public static bool add(ChiTietHoaDonDaiLy chitiet, int masohoadon)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETHOADONDAILY ct;
             ct = (from c in db.CHITIETHOADONDAILies
                   where c.masohoadon.Equals(masohoadon)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct != null) return false;
             ct = new CHITIETHOADONDAILY
             {
                 masohoadon = masohoadon,
                 masosach = chitiet.MaSoSach,
                 soluong = chitiet.SoLuong,
                 dongia = chitiet.DonGia,
                 trangthai = chitiet.TrangThai == null ? 0 : 1
             };
             db.CHITIETHOADONDAILies.InsertOnSubmit(ct);
             db.SubmitChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }