public ActionResult Create([Bind(Include = "ID_PaymentLog,FK_Employer,Amount_of_work,Sum_of_Bonus,Salary,Total_Payment,BuyStock_Amount,Manufacture_Amount,Sales_Amount,PaymentDate,Additional_Pay")] Payment_Logs payment_Logs) { if (ModelState.IsValid) { try { db.Payment_Logs.Add(payment_Logs); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbUpdateException ex) // ловим исключение в случае если триггер не позволит добавить запись { var sqlexception = ex.GetBaseException() as SqlException; // определяем SqlException if (sqlexception != null) { if (sqlexception.Errors.Count > 0) { if (sqlexception.Errors[0].Class == 15) // В случае если состояние RAISERROR в триггере = 15, то получаем следующее сообщение { ViewBag.message = "Вы не можете выдать сотруднику зарплату за один месяц два раза!"; } else if (sqlexception.Errors[0].Class == 16) // В случае если состояние RAISERROR в триггере 16, то получаем следующее сообщение { ViewBag.message = "В бюджете недостаточно средств, для выдачи зарплаты!"; } } } ViewBag.FK_Employer = new SelectList(db.Employers, "ID_Employers", "Name_of_Emp", payment_Logs.FK_Employer); return(View(payment_Logs)); } } ViewBag.FK_Employer = new SelectList(db.Employers, "ID_Employers", "Name_of_Emp", payment_Logs.FK_Employer); return(View(payment_Logs)); }
public ActionResult DeleteConfirmed(int id) { Payment_Logs payment_Logs = db.Payment_Logs.Find(id); db.Payment_Logs.Remove(payment_Logs); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_PaymentLog,FK_Employer,Amount_of_work,Sum_of_Bonus,Salary,Total_Payment,BuyStock_Amount,Manufacture_Amount,Sales_Amount,PaymentDate,Additional_Pay")] Payment_Logs payment_Logs) { if (ModelState.IsValid) { db.Entry(payment_Logs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FK_Employer = new SelectList(db.Employers, "ID_Employers", "Name_of_Emp", payment_Logs.FK_Employer); return(View(payment_Logs)); }
// GET: Payment_Logs/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Payment_Logs payment_Logs = db.Payment_Logs.Find(id); if (payment_Logs == null) { return(HttpNotFound()); } return(View(payment_Logs)); }
// GET: Payment_Logs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Payment_Logs payment_Logs = db.Payment_Logs.Find(id); if (payment_Logs == null) { return(HttpNotFound()); } ViewBag.FK_Employer = new SelectList(db.Employers, "ID_Employers", "Name_of_Emp", payment_Logs.FK_Employer); return(View(payment_Logs)); }