示例#1
0
        private void BindProducts()
        {
            ProductQuery entity = new ProductQuery();

            entity.Keywords    = productName;
            entity.ProductCode = productCode;
            entity.CategoryId  = categoryId;

            if (categoryId.HasValue)
            {
                entity.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(categoryId.Value).Path;
            }

            entity.PageSize   = pager.PageSize;
            entity.PageIndex  = pager.PageIndex;
            entity.SaleStatus = productstatus;
            entity.SortOrder  = SortAction.Desc;
            entity.SortBy     = "DisplaySequence";
            Globals.EntityCoding(entity, true);
            DbQueryResult alertProducts = SubSiteProducthelper.GetAlertProducts(entity);

            grdProducts.DataSource = alertProducts.Data;
            grdProducts.DataBind();
            pager.TotalRecords  = alertProducts.TotalRecords;
            pager1.TotalRecords = alertProducts.TotalRecords;
        }
示例#2
0
        private void btnCreateReport_Click(object sender, EventArgs e)
        {
            LoadParameters();

            ProductQuery entity = new ProductQuery();

            entity.Keywords    = productName;
            entity.ProductCode = productCode;
            entity.CategoryId  = categoryId;

            if (categoryId.HasValue)
            {
                entity.MaiCategoryPath = SubsiteCatalogHelper.GetCategory(categoryId.Value).Path;
            }
            entity.PageSize   = pager.PageSize;
            entity.PageIndex  = pager.PageIndex;
            entity.SaleStatus = productstatus;
            entity.SortOrder  = SortAction.Desc;
            entity.SortBy     = "DisplaySequence";
            Globals.EntityCoding(entity, true);
            DbQueryResult alertProducts = SubSiteProducthelper.GetAlertProducts(entity);
            DataTable     data          = new DataTable();

            if (alertProducts.Data != null)
            {
                data = (DataTable)alertProducts.Data;
            }
            string s = string.Empty + "排序号,商品名称,商家编码,库存,状态,最低零售价(元),一口价,采购价,差价\r\n";

            foreach (DataRow row in data.Rows)
            {
                s = s + (data.Rows.IndexOf(row) + 1);
                s = s + "," + row["ProductName"].ToString();
                s = s + "," + row["ProductCode"].ToString();
                s = s + "," + row["Stock"].ToString();
                s = s + "," + ShowStatus(row["SaleStatus"]);
                if (!string.IsNullOrEmpty(row["LowestSalePrice"].ToString()))
                {
                    s = s + "," + decimal.Parse(row["LowestSalePrice"].ToString()).ToString("F2");
                }
                else
                {
                    s = s + ",0.00";
                }
                if (!string.IsNullOrEmpty(row["SalePrice"].ToString()))
                {
                    s = s + "," + decimal.Parse(row["SalePrice"].ToString()).ToString("F2");
                }
                else
                {
                    s = s + ",0.00";
                }
                if (!string.IsNullOrEmpty(row["PurchasePrice"].ToString()))
                {
                    s = s + "," + decimal.Parse(row["PurchasePrice"].ToString()).ToString("F2");
                }
                else
                {
                    s = s + ",0.00";
                }
                s = s + "," + decimal.Parse(row["PurchasePrice"].ToString()).ToString("F2");
                s = s + "," + ((decimal.Parse(row["SalePrice"].ToString()) - decimal.Parse(row["PurchasePrice"].ToString()))).ToString("F2") + "\r\n";
            }
            object obj2 = s;

            s = string.Concat(new object[] { obj2, "总记录数:", alertProducts.TotalRecords, "条" });
            Page.Response.Clear();
            Page.Response.Buffer  = false;
            Page.Response.Charset = "GB2312";
            Page.Response.AppendHeader("Content-Disposition", "attachment;filename=ProductAlert.csv");
            Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
            Page.Response.ContentType     = "application/octet-stream";
            Page.EnableViewState          = false;
            Page.Response.Write(s);
            Page.Response.End();
        }