Example #1
0
        public PQGridData GetSalesReport()
        {
            PQGridData data = new PQGridData();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            ReportFactory reportManager = new ReportFactory(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            long stime = 0;
            long etime = 0;
            int page = 1;
            int pageSize = 50;
            int totalProducts = 0;
            string[] product_id = null;
            bool paging = false;
            long.TryParse(request["stime"], out stime);
            long.TryParse(request["etime"], out etime);
            int.TryParse(request["page"],out page);
            int.TryParse(request["pageSize"],out pageSize);

            if (!string.IsNullOrEmpty(request["products"]))
            {
                product_id = request["products"].Split(',');
            }

            if (page <= 0)
            {
                page = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 50;
            }
            if (!string.IsNullOrEmpty(request["paging"]) && request["paging"] == "1")
            {
                paging = true;
            }
            else
            {
                paging = false;
            }
            try
            {
                string json = reportManager.GetSalesReport(stime, etime, product_id, page, pageSize, out totalProducts, paging, false);
                data.totalRecords = totalProducts;
                if (!string.IsNullOrEmpty(json))
                {
                    data.data = JArray.Parse(json);
                }
                data.curPage = page;
            }
            catch (Exception ex)
            {
            }
            finally
            {

            }
            return data;
        }
Example #2
0
        public ApiMessage GetExcelSaleReport()
        {
            ApiMessage message = new ApiMessage() { Status = "ok" };
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            ReportFactory reportManager = new ReportFactory(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            long stime = 0;
            long etime = 0;

            int totalProducts = 0;
            string[] product_id = null;

            long.TryParse(request["stime"], out stime);
            long.TryParse(request["etime"], out etime);

            if (!string.IsNullOrEmpty(request["products"]))
            {
                product_id = request["products"].Split(',');
            }

            try
            {
                string json = reportManager.GetSalesReport(stime, etime, product_id, 0, 0, out totalProducts, false, false);
                if (!string.IsNullOrEmpty(json))
                {
                    SaleExcelReport excel = new SaleExcelReport();
                    excel.Export(json);
                    message.Item = "http://" + request.Url.Authority + "/Content/reports/tmp/" + excel.ReportFileName;
                }
                else
                {
                    message.Status = "failed";
                    message.Message = "没有搜索到符合要求的销售数据";
                }
            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = "没有搜索到符合要求的销售数据";
            }
            finally
            {

            }
            return message;
        }