public static BHXH.Data.ListChiBo New(string MaChiBo, string TenChiBo) { if (MaChiBo == "" || TenChiBo == "") { return(null); } if (IsExisted(MaChiBo, TenChiBo) != null) { return(IsExisted(MaChiBo, TenChiBo)); } BHXH.Data.BHXHEntities ctx = new Data.BHXHEntities(); BHXH.Data.ListChiBo n = new Data.ListChiBo(); n.MaChiBo = MaChiBo; n.TenChiBo = TenChiBo; ctx.ListChiBo.Add(n); try { ctx.SaveChanges(); ctx.Dispose(); return(n); } catch (Exception) { return(null); } finally { } }
public static void Delete(string MaChiBo) { BHXH.Data.BHXHEntities ctx = new Data.BHXHEntities(); var obj = new Data.ListChiBo { MaChiBo = MaChiBo }; ctx.ListChiBo.Attach(obj); ctx.ListChiBo.Remove(obj); ctx.SaveChanges(); }