예제 #1
0
        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()
            }));
        }
예제 #2
0
        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
            }));
        }
예제 #3
0
        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));
        }
예제 #4
0
        public ActionResult Print(int id)
        {
            var model = ExpenseVoucher.Find(id);

            if (!model.IsCancelled && model.IsCompleted)
            {
                return(PdfTicketView("Print", model));
            }
            return(RedirectToAction("Index"));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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"));
        }
예제 #7
0
        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));
        }
예제 #8
0
 public ActionResult Pdf(int id)
 {
     return(PdfView("Print", ExpenseVoucher.Find(id)));
 }
예제 #9
0
 public ViewResult View(int id)
 {
     return(View(ExpenseVoucher.Find(id)));
 }
예제 #10
0
        public ActionResult Totals(int id)
        {
            var entity = ExpenseVoucher.Find(id);

            return(PartialView("_Totals", entity));
        }