public ActionResult SetCashier(int id, int value) { var entity = ExpenseVoucher.Find(id); var item = Employee.TryFind(value); if (GetSession() == null) { return(Content(Resources.InvalidCashDrawer)); } if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } if (item != null) { entity.Creator = item; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = id, value = entity.Creator.ToString() })); }
public ActionResult SetComment(int id, string value) { if (GetSession() == null) { return(Content(Resources.InvalidCashDrawer)); } var entity = ExpenseVoucher.Find(id); string val = (value ?? string.Empty).Trim(); if (entity.IsCompleted || entity.IsCancelled) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } entity.Comment = (value.Length == 0) ? null : val; entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(Json(new { id = id, value = entity.Comment })); }
public JsonResult GetSuggestions(int expensevoucher, string pattern) { var item = ExpenseVoucher.Find(expensevoucher); var query = Expense.Queryable.Where(x => x.Name.Contains(pattern) || x.Comment.Contains(pattern)); var items = query.Take(15).ToList().Select(x => new { id = x.Id, name = x.Name, comment = x.Comment }); return(Json(items, JsonRequestBehavior.AllowGet)); }
public ActionResult Print(int id) { var model = ExpenseVoucher.Find(id); if (!model.IsCancelled && model.IsCompleted) { return(PdfTicketView("Print", model)); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { ExpenseVoucher item = ExpenseVoucher.Find(id); if (item.IsCompleted || item.IsCancelled) { return(RedirectToAction("View", new { id = item.Id })); } return(View(item)); }
public ActionResult Confirm(int id) { var entity = ExpenseVoucher.Find(id); if (entity.IsCancelled || entity.IsCompleted || GetSession() == null) { return(RedirectToAction("Index")); } entity.Updater = CurrentUser.Employee; entity.ModificationTime = DateTime.Now; entity.IsCompleted = true; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } return(RedirectToAction("Index")); }
public ActionResult AddItem(int expensevoucher, int expense) { ExpenseVoucher entity = ExpenseVoucher.Find(expensevoucher); Expense item = Expense.Find(expense); if (entity.IsCancelled || entity.IsCompleted) { Response.StatusCode = 400; return(Content(Resources.ItemAlreadyCompletedOrCancelled)); } ExpenseVoucherDetail detail = new ExpenseVoucherDetail { ExpenseVoucher = entity, Expense = item, Comment = item.Comment }; using (var scope = new TransactionScope()) { detail.CreateAndFlush(); } return(Json(new { id = detail.Id }, JsonRequestBehavior.AllowGet)); }
public ActionResult Pdf(int id) { return(PdfView("Print", ExpenseVoucher.Find(id))); }
public ViewResult View(int id) { return(View(ExpenseVoucher.Find(id))); }
public ActionResult Totals(int id) { var entity = ExpenseVoucher.Find(id); return(PartialView("_Totals", entity)); }