public string Create([Bind(Exclude = "Id")] LTP Model) { ApplicationDbContext db = new ApplicationDbContext(); string msg; try { if (ModelState.IsValid) { db.LTPs.Add(Model); db.SaveChanges(); msg = "Сохранено успешно"; } else { msg = "Данные не прошли проверку ввода"; } } catch (Exception ex) { msg = "Произошла ошибка:" + ex.Message; } return(msg); }
public TipoPersonal(ETP persona) { InitializeComponent(); _lTP = new LTP(); _eTP = new ETP(); BindingTipoPersonalReload(); _eTP = persona; _isEnablebinding = true; }
public TipoPersonal() { InitializeComponent(); _lTP = new LTP(); _eTP = new ETP(); _isEnablebinding = true; BindingTipoPersonal(); btnUpdateTP.Enabled = false; }
public string Delete(int Id) { ApplicationDbContext db = new ApplicationDbContext(); LTP lTPs = db.LTPs.Find(Id); db.LTPs.Remove(lTPs); db.SaveChanges(); return("Удалено успешно"); }
public string Edit(LTP Model) { ApplicationDbContext db = new ApplicationDbContext(); string msg; try { if (ModelState.IsValid) { db.Entry(Model).State = EntityState.Modified; db.SaveChanges(); msg = "Сохранено успешно"; } else { msg = "Данные не прошли проверку ввода"; } } catch (Exception ex) { msg = "Произошла ошибка:" + ex.Message; } return(msg); }