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