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