public ActionResult GetList() { string ProductName = WebUtil.GetFormValue <string>("ProductName", string.Empty); int pageIndex = WebUtil.GetFormValue <int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue <int>("pageSize", 0); string CateNum = WebUtil.GetFormValue <string>("CateNum", string.Empty); ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); if (!ProductName.IsEmpty()) { entity.Begin <ProductEntity>() .Where <ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%") .Or <ProductEntity>("SnNum", ECondition.Like, "%" + ProductName + "%") .Or <ProductEntity>("BarCode", ECondition.Like, "%" + ProductName + "%") .End <ProductEntity>(); } if (!CateNum.IsEmpty()) { entity.Where <ProductEntity>("CateNum", ECondition.Eth, CateNum); } PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List <ProductEntity> listResult = provider.GetList(entity, ref pageInfo); string json = ConvertJson.ListToJson <ProductEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 查询产品列表 /// </summary> /// <returns></returns> public ActionResult GetList() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); ProductProvider provider = new ProductProvider(CompanyID); List <ProductEntity> list = provider.GetList(); DataListResult <ProductEntity> result = new DataListResult <ProductEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = list }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 查询分页 /// </summary> /// <returns></returns> public ActionResult GetPage() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int PageSize = WebUtil.GetFormValue <int>("PageSize", 10); string BarCode = WebUtil.GetFormValue <string>("BarCode"); string ProductName = WebUtil.GetFormValue <string>("ProductName"); string FactoryNum = WebUtil.GetFormValue <string>("FactoryNum"); string InCode = WebUtil.GetFormValue <string>("InCode"); string UnitNum = WebUtil.GetFormValue <string>("UnitNum"); string CateNum = WebUtil.GetFormValue <string>("CateNum"); string Size = WebUtil.GetFormValue <string>("Size"); int IsSingle = WebUtil.GetFormValue <int>("IsSingle", 0); ProductEntity entity = new ProductEntity(); entity.BarCode = BarCode; entity.ProductName = ProductName; entity.FactoryNum = FactoryNum; entity.InCode = InCode; entity.UnitNum = UnitNum; entity.CateNum = CateNum; entity.Size = Size; entity.IsSingle = IsSingle; PageInfo pageInfo = new PageInfo(); pageInfo.PageIndex = PageIndex; pageInfo.PageSize = PageSize; ProductProvider provider = new ProductProvider(CompanyID); List <ProductEntity> list = provider.GetList(entity, ref pageInfo); DataListResult <ProductEntity> result = new DataListResult <ProductEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo }; return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult ToExcel() { PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; string ProductName = WebUtil.GetFormValue <string>("ProductName", string.Empty); int pageIndex = WebUtil.GetFormValue <int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue <int>("pageSize", 0); string CateNum = WebUtil.GetFormValue <string>("CateNum", string.Empty); ProductProvider provider = new ProductProvider(); ProductEntity entity = new ProductEntity(); if (!ProductName.IsEmpty()) { entity.Where <ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%"); } if (!CateNum.IsEmpty()) { entity.Where <ProductEntity>("CateNum", ECondition.Eth, CateNum); } List <ProductEntity> listResult = provider.GetList(entity, ref pageInfo); listResult = listResult.IsNull() ? new List <ProductEntity>() : listResult; if (listResult.IsNotNull()) { 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("净重")); dt.Columns.Add(new DataColumn("毛重")); dt.Columns.Add(new DataColumn("备注")); int count = 1; foreach (ProductEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.SnNum; row[2] = t.BarCode; row[3] = t.ProductName; row[4] = t.CateName; row[5] = t.Num; row[6] = t.MinNum; row[7] = t.MaxNum; row[8] = t.UnitName; row[9] = t.AvgPrice; row[10] = t.InPrice; row[11] = t.OutPrice; row[12] = t.NetWeight.ToString(); row[13] = t.GrossWeight.ToString(); row[14] = t.Remark; dt.Rows.Add(row); count++; } 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")); NPOIExcel excel = new NPOIExcel("产品管理", "产品", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return(Content(this.ReturnJson.ToString())); }