Beispiel #1
0
        private void exportDetail()
        {
            User   user        = (User)Session["user"];
            int    regionId    = user.ReginId.RegionId;
            string roleName    = user.RoleId.RoleName;
            string strWhere    = "";
            string groupbyType = Request["groupbyType"];
            string supplier    = Request["supplier"];
            string regionName  = Request["regionName"];

            if (groupbyType == "state" || groupbyType == null)
            {
                groupbyType = "supplier";
            }
            if (supplier != "" && supplier != null)
            {
                strWhere = "supplier='" + supplier + "'";
            }
            if (regionName != "" && regionName != null)
            {
                strWhere = "regionName='" + regionName + "'";
            }

            if (roleName != "超级管理员")
            {
                if (strWhere == "" || strWhere == null)
                {
                    strWhere = "regionId=" + regionId;
                }
                else
                {
                    strWhere += "and regionId=" + regionId;
                }
            }
            string str = "";

            if (strWhere == "" || strWhere == null)
            {
                str = groupbyType + " like'%'";
            }
            else
            {
                str = strWhere;
            }
            string    file  = "书籍库存明细导出" + DateTime.Now.ToString("yyyyMMddHHmmss");
            DataTable dt    = StockBll.bookStockDe(str, groupbyType);
            int       count = dt.Rows.Count;

            if (count > 0)
            {
                ExcelHelp.dtToExcelForXlsxByNpoi(dt, file);
            }
            else
            {
                Response.Write("<script language='javascript'>alert('查询不到数据,不能执行导出操作!')</script>");
            }
        }