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