public int Create(RPT_Company data) { using (ReportEntities db = new ReportEntities()) { db.RPT_Company.Add(data); return(db.SaveChanges()); } }
public int Update(RPT_Company data) { using (ReportEntities db = new ReportEntities()) { var exsit = db.RPT_Company.FirstOrDefault(p => p.CompanyCode == data.CompanyCode); if (exsit != null) { int id = exsit.ID; exsit.CopyFrom(data); exsit.ID = id; } return(db.SaveChanges()); } }