Exemple #1
0
        public ActionResult Save(OutcomeInfo 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 = OutcomeInfo.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));
            }
        }
Exemple #2
0
        public ActionResult Update(int id)
        {
            var model = OutcomeInfo.Get(UserID, Employee.ID, id);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.SavePartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Save, model));
        }
Exemple #3
0
        public ActionResult List()
        {
            var data = OutcomeInfo.Find(UserID, Employee.ID, Employee.BussinessID);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, data)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, data));
        }
Exemple #4
0
        public ActionResult Detail(int id)
        {
            var data = OutcomeInfo.Get(UserID, Employee.ID, id, true);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.DetailPartial, data)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Detail, data));
        }
Exemple #5
0
        public ActionResult Remove(int id)
        {
            OutcomeInfo.Remove(UserID, Employee.ID, id);
            var model = OutcomeInfo.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));
        }
Exemple #6
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));
        }
Exemple #7
0
        public ActionResult Download(OutcomeFilter filter)
        {
            var result = false;

            try
            {
                var data = OutcomeInfo.Find(UserID, Employee.ID, Employee.BussinessID, "", filter, true, null);
                if (data != null)
                {
                    var fileName = String.Format("Outcomes_{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));
        }