Exemplo n.º 1
0
        public ActionResult StockBillList()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string localName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string localType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            int pageIndex = WebUtil.GetFormValue<int>("pageIndex", 0);
            int pageSize = WebUtil.GetFormValue<int>("pageSize", 0);
            string storageNum = this.DefaultStore;

            LocalProductProvider provider = new LocalProductProvider();
            LocalProductEntity entity = new LocalProductEntity();

            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            if (!localName.IsEmpty())
            {
                entity.Where("LocalName", ECondition.Like, "%" + localName + "%");
                entity.Or("LocalNum", ECondition.Like, "%" + localName + "%");
            }
            if (!searchKey.IsEmpty())
            {
                entity.Begin<LocalProductEntity>()
                 .Where<LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<LocalProductEntity>();
            }
            PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
            List<LocalProductEntity> listResult = provider.GetList(entity, ref pageInfo);
            int allNum = provider.GetAllNum(localName, localType, searchKey, storageNum);
            double allTotalPrice = provider.GetAllTotalPrice(localName, localType, searchKey, storageNum);
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice = a.Num * a.AvgPrice;
                });
            }
            string json = ConvertJson.ListToJson<LocalProductEntity>(listResult, "List");
            this.ReturnJson.AddProperty("Data", new JsonObject(json));
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            this.ReturnJson.AddProperty("AllNum", allNum);
            this.ReturnJson.AddProperty("AllTotalPrice", allTotalPrice);
            return Content(this.ReturnJson.ToString());
        }
Exemplo n.º 2
0
        public ActionResult ToStockBilReportExcel()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string localName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string localType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            string storageNum = this.DefaultStore;

            LocalProductProvider provider = new LocalProductProvider();
            LocalProductEntity entity = new LocalProductEntity();
            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            if (!localName.IsEmpty())
            {
                entity.Where("LocalName", ECondition.Like, "%" + localName + "%");
            }
            if (!searchKey.IsEmpty())
            {
                entity.Begin<LocalProductEntity>()
                 .Where<LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<LocalProductEntity>();
            }

            PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            List<LocalProductEntity> listResult = provider.GetList(entity, ref pageInfo);
            int allNum = provider.GetAllNum(localName, localType, searchKey, storageNum);
            double allTotalPrice = provider.GetAllTotalPrice(localName, localType, searchKey, storageNum);
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice = a.Num * a.AvgPrice;
                });
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("库位 "));
                dt.Columns.Add(new DataColumn("库位类型"));
                dt.Columns.Add(new DataColumn("产品编号"));
                dt.Columns.Add(new DataColumn("产品条码"));
                dt.Columns.Add(new DataColumn("产品名称"));
                dt.Columns.Add(new DataColumn("类别名称"));
                dt.Columns.Add(new DataColumn("规格"));
                dt.Columns.Add(new DataColumn("预警值下限"));
                dt.Columns.Add(new DataColumn("预警值上限"));
                dt.Columns.Add(new DataColumn("库存数"));
                dt.Columns.Add(new DataColumn("价格"));
                dt.Columns.Add(new DataColumn("总价"));

                int count = 1;
                foreach (LocalProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.LocalName;
                    row[2] = EnumHelper.GetEnumDesc<ELocalType>(t.LocalType);
                    row[3] = t.ProductNum;
                    row[4] = t.BarCode;
                    row[5] = t.ProductName;
                    row[6] = t.CateName;
                    row[7] = t.Size;
                    row[8] = t.MinNum;
                    row[9] = t.MaxNum;
                    row[10] = t.Num;
                    row[11] = t.AvgPrice;
                    row[12] = t.TotalPrice;
                    dt.Rows.Add(row);
                    count++;
                }
                DataRow rowTemp = dt.NewRow();
                rowTemp[0] = count;
                rowTemp[1] = "";
                rowTemp[2] = "";
                rowTemp[3] = "";
                rowTemp[4] = "";
                rowTemp[5] = "";
                rowTemp[6] = "";
                rowTemp[7] = "";
                rowTemp[8] = "";
                rowTemp[9] = "总计";
                rowTemp[10] = allNum;
                rowTemp[11] = "";
                rowTemp[12] = allTotalPrice;
                dt.Rows.Add(rowTemp);
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("库存清单报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                AsposeExcel excel = new AsposeExcel(System.IO.Path.Combine(filePath, filename), "");
                excel.DatatableToExcel(dt, "库存清单报表", "库存清单报表");
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }
Exemplo n.º 3
0
 public ActionResult GetOrderDetail()
 {
     string orderNum = WebUtil.GetFormValue<string>("orderNum", string.Empty);
     Bill<OrdersEntity, OrderDetailEntity> bill = new OrderBill();
     if (!orderNum.IsEmpty())
     {
         OrderDetailEntity detail = new OrderDetailEntity();
         detail.OrderNum = orderNum;
         List<OrderDetailEntity> listResult = bill.GetOrderDetail(detail);
         if (!listResult.IsNullOrEmpty())
         {
             listResult.Remove(a => a.Num == 0);
             LocalProductProvider provider = new LocalProductProvider();
             string storageNum = this.DefaultStore;
             foreach (OrderDetailEntity item in listResult)
             {
                 item.LocalNum = provider.GetLocalNum(storageNum, item.ProductNum);
             }
             string json = ConvertJson.ListToJson<OrderDetailEntity>(listResult, "List");
             JsonObject jsonObject = new JsonObject(json);
             this.ReturnJson.AddProperty("Data", jsonObject);
         }
     }
     return Content(this.ReturnJson.ToString());
 }
Exemplo n.º 4
0
 public ActionResult GetLocalNum()
 {
     string storageNum = this.DefaultStore;
     string productNum = WebUtil.GetFormValue<string>("productNum", string.Empty);
     LocalProductProvider provider = new LocalProductProvider();
     double sum = provider.GetLocalNum(storageNum, productNum);
     this.ReturnJson.AddProperty("Sum", sum);
     return Content(this.ReturnJson.ToString());
 }
Exemplo n.º 5
0
 public ActionResult GetLocalProductList()
 {
     string BarCode = WebUtil.GetFormValue<string>("BarCode", string.Empty);
     LocalProductProvider provider = new LocalProductProvider();
     List<LocalProductEntity> listResult = provider.GetList(BarCode);
     listResult = listResult.IsNull() ? new List<LocalProductEntity>() : listResult;
     string json = ConvertJson.ListToJson<LocalProductEntity>(listResult, "List");
     this.ReturnJson.AddProperty("Data", new JsonObject(json));
     return Content(this.ReturnJson.ToString());
 }