public FileResult ExportExcel(MProductSearch condition) { StringBuilder where = new StringBuilder(); where.Append("select ProductNumber,ProductName,Price,States,AddTime from [Product] where 1=1 "); where.Append(MProductSearch.StrWhere(condition)); DataTable dt = ExportWay.ExcelDataTable(where.ToString()); string[] list = { "产品编号", "产品名称", "零售价", "状态", "添加时间" }; return(File(ExportWay.GetExcel(dt, list), "application/vnd.ms-excel", "产品" + DateTime.Now.ToShortTimeString() + ".xls")); }
public ActionResult GetProductPage(MProductSearch condition) { PageJsonModel <Product> page = new PageJsonModel <Product>(); page.pageIndex = condition.pageIndex; page.pageSize = condition.pageSize; page.strForm = "Product"; page.strSelect = "* "; page.strWhere = " and States='已上架'"; page.strOrder = "ProductID desc"; page.LoadList(); return(Json(page.pageResponse, JsonRequestBehavior.AllowGet)); }
private string StrWhere(MProductSearch condition) { string where = string.Empty; //产品名称 if (!string.IsNullOrWhiteSpace(condition.GoodsName)) { where += " and Product.ProductName like '%" + Common.Filter(condition.GoodsName) + "%' "; } if (!string.IsNullOrWhiteSpace(condition.States)) { where += string.Format(" and Product.States='{0}' ", Common.Filter(condition.States)); } return(where); }
public ActionResult GetProductPage(MProductSearch condition) { string where = StrWhere(condition); PageJsonModel <Product> page = new PageJsonModel <Product>(); page.pageIndex = condition.pageIndex; page.pageSize = condition.pageSize; page.strForm = " Product "; page.strSelect = " * "; page.strWhere = where; if (string.IsNullOrWhiteSpace(condition.orderby) == false) { page.strOrder = Common.FilteSQLStr(condition.orderby); } else { page.strOrder = " ProductID desc "; } page.LoadList(); return(Json(page.pageResponse, JsonRequestBehavior.AllowGet)); }