Exemplo n.º 1
0
        public ActionResult Save(IncomeInfo info)
        {
            var    result = info.Save(ModelState, UserID, Employee.ID, Employee.BussinessID);
            var    isAjaxRequest = Request.IsAjaxRequest();
            string view; object model;

            if (result)
            {
                view  = isAjaxRequest ? Views.ListPartial : Views.List;
                model = IncomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "Luu thông tin thành công");
            }
            else
            {
                view  = isAjaxRequest ? Views.SavePartial : Views.Save;
                model = info;
            }
            if (isAjaxRequest)
            {
                return(Json(new
                {
                    result = result,
                    html = RenderPartialViewToString(view, model),
                },
                            JsonRequestBehavior.DenyGet));
            }
            else
            {
                return(View(view, model));
            }
        }
Exemplo n.º 2
0
        public ActionResult List()
        {
            var data = IncomeInfo.Find(UserID, Employee.ID, Employee.BussinessID);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, data)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, data));
        }
Exemplo n.º 3
0
        public ActionResult Remove(int id)
        {
            IncomeInfo.Remove(UserID, Employee.ID, id);
            var model = IncomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "Xóa thông tin thành công");

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, model));
        }
Exemplo n.º 4
0
        public ActionResult GetTransactions()
        {
            var now      = DateTime.Now;
            var startDay = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            var endDay   = startDay.AddDays(1);
            var model    = new TransactionSummary()
            {
                Transactions = Transaction.Find(UserID, new TransactionClass[] { TransactionClass.Order, TransactionClass.Repair, TransactionClass.Warranty }, startDay, endDay),
                Incomes      = IncomeInfo.Find(UserID, Employee.BussinessID, new IncomeFilter()
                {
                    From = startDay, To = endDay
                }, null),
                Outcomes = OutcomeInfo.Find(UserID, Employee.BussinessID, new OutcomeFilter()
                {
                    From = startDay, To = endDay
                }, null)
            };

            return(Json(new
            {
                html = RenderPartialViewToString("OrderSummary", model)
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult Download(IncomeFilter filter)
        {
            var result = false;

            try
            {
                var data = IncomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true, null);
                if (data != null)
                {
                    var fileName = String.Format("Incomes_{0}.xls", DateTime.Now.ToString("ddMMyyyyHHmmss"));
                    var file     = String.Format("{0}/Content/Download/{1}", SiteConfiguration.ApplicationPath, fileName);
                    Functions.CheckDirectory(String.Format("{0}/Content/Download/", SiteConfiguration.ApplicationPath));
                    SaveDownload(file, data.Data);
                    Session[SessionKey.Download] = fileName;
                    result = true;
                }
            }
            catch { }
            return(Json(new
            {
                result = result
            }, JsonRequestBehavior.DenyGet));
        }