public static int add(TheKho thekho)
 {
     try
     {
         using(EntitiesDataContext db = new EntitiesDataContext())
         {
             THEKHO tk;
             tk = (from s in db.THEKHOs
                   where s.masosach.Equals(thekho.MaSoSach)
                     && s.ngayghi.Equals(thekho.NgayGhi)
                   select s).SingleOrDefault();
             if(tk != null)
             {
                 tk.soluong = thekho.SoLuong;
                 db.SubmitChanges();
                 return 1;
             }
             else
             {
                 tk = new THEKHO()
                 {
                     masosach = thekho.MaSoSach,
                     soluong = thekho.SoLuong,
                     ngayghi = thekho.NgayGhi
                 };
                 db.THEKHOs.InsertOnSubmit(tk);
                 db.SubmitChanges();
                 return 1;
             }
         }
     }
     catch
     {
         return 0;
     }
 }
		private void detach_THEKHOs(THEKHO entity)
		{
			this.SendPropertyChanging();
			entity.SACH = null;
		}
		private void attach_THEKHOs(THEKHO entity)
		{
			this.SendPropertyChanging();
			entity.SACH = this;
		}
 partial void DeleteTHEKHO(THEKHO instance);
 partial void UpdateTHEKHO(THEKHO instance);
 partial void InsertTHEKHO(THEKHO instance);
Esempio n. 7
0
 public TheKho(THEKHO thekho,SACH sach)
     : this(thekho)
 {
     Sach = new Sach(sach);
 }
Esempio n. 8
0
 public TheKho(THEKHO thekho)
 {
     MaSoSach = thekho.masosach;
     SoLuong = thekho.soluong;
     NgayGhi = thekho.ngayghi;
 }