public ChiTietHoaDonNXB(CHITIETHOADONNXB chitiet)
 {
     MaSoSach = chitiet.masosach;
     SoLuong = chitiet.soluong;
     DonGia = chitiet.dongia;
     MaSoHoaDon = chitiet.masohoadon;
     TrangThai = chitiet.trangthai;
 }
		private void detach_CHITIETHOADONNXBs(CHITIETHOADONNXB entity)
		{
			this.SendPropertyChanging();
			entity.SACH = null;
		}
 partial void DeleteCHITIETHOADONNXB(CHITIETHOADONNXB instance);
 partial void UpdateCHITIETHOADONNXB(CHITIETHOADONNXB instance);
 partial void InsertCHITIETHOADONNXB(CHITIETHOADONNXB instance);
		private void attach_CHITIETHOADONNXBs(CHITIETHOADONNXB entity)
		{
			this.SendPropertyChanging();
			entity.HOADONNXB = this;
		}
 public ChiTietHoaDonNXB(CHITIETHOADONNXB chitiet, SACH sach)
     : this(chitiet)
 {
     Sach = new Sach(sach);
 }
 public static bool add(ChiTietHoaDonNXB chitiet, int masohoadon)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CHITIETHOADONNXB ct;
             ct = (from c in db.CHITIETHOADONNXBs
                   where c.masohoadon.Equals(masohoadon)
                   && c.masosach.Equals(chitiet.MaSoSach)
                   select c).SingleOrDefault();
             if (ct != null) return false;
             ct = new CHITIETHOADONNXB
             {
                 masohoadon = masohoadon,
                 masosach = chitiet.MaSoSach,
                 soluong = chitiet.SoLuong,
                 dongia = chitiet.DonGia,
                 trangthai = chitiet.TrangThai == null ? 0 : 1
             };
             db.CHITIETHOADONNXBs.InsertOnSubmit(ct);
             db.SubmitChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }