public ActionResult Create([Bind(Include = "Id, Employee, Amount, Issuer, ReferenceNumber, Date, PeriodInMonths, ExceptionalPayment, IsActive, Notes, IssueDescription, Installment")] Debt debt) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { DebtServices.Insert(CurrentUser.Id, debt, db); TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed"); return(RedirectToAction("Index")); } catch (CfException cfex) { TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage; } catch (Exception ex) { TempData["Failure"] = ex.Message; } } ViewBag.IssuerList = new SelectList(IssuerServices.List(db), "Id", "Name"); ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName"); return(View(debt)); }
public ActionResult Create([Bind(Include = "Id, Debt, Employee, IsActive, Notes")] Warrant warrant) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { WarrantServices.Insert(CurrentUser.Id, warrant, db); TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed"); return(RedirectToAction("Index")); } catch (CfException cfex) { TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage; } catch (Exception ex) { TempData["Failure"] = ex.Message; } } ViewBag.DebtList = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber"); ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName"); return(View(warrant)); }
public ActionResult Create() { Db db = new Db(DbServices.ConnectionString); ViewBag.DebtList = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber"); ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName"); return(View()); }
public JsonResult CreateDeb(Debt debt) { Db db = new Db(DbServices.ConnectionString); if (ModelState.IsValid) { try { EmployeeVw employee = EmployeeVwServices.Get(debt.Employee); if (employee == null) { return(Json(new { status = false, message = "الرقم الذاتي غير صحيح" }, JsonRequestBehavior.AllowGet)); } if (debt.Date == null) { debt.Date = System.DateTime.Now; } debt = DebtServices.Insert(CurrentUser.Id, debt, db); TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed"); } catch (CfException cfex) { TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage; } catch (Exception ex) { TempData["Failure"] = ex.Message; } } else { string errorMsg = ""; foreach (ModelState item in ModelState.Values) { if (item.Errors.Count == 0) { continue; } else { for (int i = 0; i < item.Errors.Count; i++) { errorMsg += item.Errors[i].ErrorMessage + "\n"; } } } return(Json(new { status = false, message = errorMsg, }, JsonRequestBehavior.AllowGet)); } return(Json(new { status = true, Data = debt.Id }, JsonRequestBehavior.AllowGet)); }
// GET: Debt/Delete/5 public ActionResult Delete(Nullable <int> id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Db db = new Db(DbServices.ConnectionString); Debt debt = DebtServices.Get(id.Value, db); if (debt == null) { return(HttpNotFound()); } return(View(debt)); }
// GET: Warrant/Edit/5 public ActionResult Edit(Nullable <int> id) { Db db = new Db(DbServices.ConnectionString); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Warrant warrant = WarrantServices.Get(id.Value, db); if (warrant == null) { return(HttpNotFound()); } ViewBag.DebtList = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber", warrant.Debt); ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName", warrant.Employee); return(View(warrant)); }
// GET: Debt/Edit/5 public ActionResult Edit(Nullable <int> id) { Db db = new Db(DbServices.ConnectionString); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Debt debt = DebtServices.Get(id.Value, db); if (debt == null) { return(HttpNotFound()); } ViewBag.IssuerList = new SelectList(IssuerServices.List(db), "Id", "Name", debt.Issuer); ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName", debt.Employee); return(View(debt)); }
public ActionResult DeleteConfirmed(int id) { try { Db db = new Db(DbServices.ConnectionString); DebtServices.Delete(CurrentUser.Id, id, db); TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "DeleteConfirmed"); // return RedirectToAction("Index"); } catch (CfException cfex) { TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage; } catch (Exception ex) { TempData["Failure"] = ex.Message; } // return View(debt); return(RedirectToAction("Index")); }
public ActionResult CreateWarrant(WarrantVwViewModel model) { WarrantVwViewModel Model = new WarrantVwViewModel(); try { EmployeeVw employee = EmployeeVwServices.Get(model.Instance.DebtEmployeeId); if (employee == null) { TempData["Failure"] = "الرقم الذاتي غير صحيح"; Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db); return(PartialView("_WarrantsList", Model)); } // check if this employee is not the debt employee Debt d = DebtServices.Get(model.Instance.DebtId, db); if (d != null) { if (d.Employee == model.Instance.DebtEmployeeId) { TempData["Failure"] = "لا يمكن أن يكفل الموظف نفسه"; Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db); return(PartialView("_WarrantsList", Model)); } } // check if this employee has been added as a garantaur Warrant ewarrant = WarrantServices.GetByDebt_EmployeeFirstOrNull(model.Instance.DebtId, model.Instance.DebtEmployeeId); if (ewarrant != null) { TempData["Failure"] = "هذا الموظف هو كفيل حالياً لهذه المديونية"; } else { Warrant w = new Warrant() { Debt = model.Instance.DebtId, Employee = model.Instance.DebtEmployeeId, IsActive = model.Instance.IsActive, Notes = model.Instance.Notes }; w = WarrantServices.Insert(CurrentUserId, w, db); } Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db); return(PartialView("_WarrantsList", Model)); } catch (CfException cfex) { TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage; //return Json(new { status = false, message = cfex.ErrorDefinition.LocalizedMessage }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { TempData["Failure"] = ex.Message; //return Json(new { status = false, message = ex.Message }, JsonRequestBehavior.AllowGet); } Model.List = WarrantVwServices.GetByDebtId(model.Instance.DebtId, db); return(PartialView("_WarrantsList", Model)); }