Beispiel #1
0
    public void PartCollarInfor()
    {
        DataTable       dt           = new DataTable();
        TOaPartCollarVo objItems     = new TOaPartCollarVo();
        TOaPartInfoVo   objItemParts = new TOaPartInfoVo();

        if (!String.IsNullOrEmpty(strPartCollarId))
        {
            objItems.ID = strPartCollarId;
        }
        objItems.USER_ID = strReal_Name;
        if (!String.IsNullOrEmpty(strBeginDate) || !String.IsNullOrEmpty(strEndDate))
        {
            objItems.REMARK4 = strBeginDate;
            objItems.REMARK5 = strEndDate;
        }

        if (!String.IsNullOrEmpty(strPartCode) || !String.IsNullOrEmpty(strPartName) || !String.IsNullOrEmpty(strPartId))
        {
            objItemParts.ID        = strPartId;
            objItemParts.PART_NAME = strPartName;
            objItemParts.PART_CODE = strPartCode;
        }

        dt = new TOaPartCollarLogic().SelectUnionPartByTable(objItems, objItemParts, 0, 0);

        ReportDataSource rds = new ReportDataSource("DataSet1", dt);

        this.reportViewer1.LocalReport.DataSources.Clear();
        this.reportViewer1.LocalReport.DataSources.Add(rds);
        this.reportViewer1.LocalReport.Refresh();
    }
Beispiel #2
0
    /// <summary>
    /// 获取信息
    /// </summary>
    /// <returns></returns>
    private string getInfo(string strid)
    {
        TOaPartCollarVo objT = new TOaPartCollarLogic().Details(strid);

        objT.REMARK2 = new TSysUserLogic().Details(objT.USER_ID).REAL_NAME;

        return(ToJson(objT));
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        string strPartCollarId = "";

        strPartCollarId = this.hidExportDate.Value.ToString();
        DataTable       dt           = new DataTable();
        TOaPartCollarVo objItems     = new TOaPartCollarVo();
        TOaPartInfoVo   objItemParts = new TOaPartInfoVo();

        objItems.ID = strPartCollarId.Replace(",", "','");
        if (!String.IsNullOrEmpty(strPartId))
        {
            objItemParts.ID = strPartId;
        }
        dt = new TOaPartCollarLogic().SelectUnionPartByTable(objItems, objItemParts, 0, 0);
        FileStream   file         = new FileStream(HttpContext.Current.Server.MapPath("template/PartUsedHistorySheet.xls"), FileMode.Open, FileAccess.Read);
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
        ISheet       sheet        = hssfworkbook.GetSheet("Sheet1");

        sheet.GetRow(2).GetCell(0).SetCellValue("生成日期:" + DateTime.Now.ToString("yyyy-MM-dd"));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            sheet.GetRow(i + 4).GetCell(0).SetCellValue(dt.Rows[i]["PART_NAME"].ToString());
            sheet.GetRow(i + 4).GetCell(1).SetCellValue(dt.Rows[i]["PART_CODE"].ToString());
            sheet.GetRow(i + 4).GetCell(2).SetCellValue(dt.Rows[i]["USED_QUANTITY"].ToString());
            sheet.GetRow(i + 4).GetCell(3).SetCellValue(dt.Rows[i]["LASTIN_DATE"].ToString());
            sheet.GetRow(i + 4).GetCell(4).SetCellValue(dt.Rows[i]["REAL_NAME"].ToString());
            sheet.GetRow(i + 4).GetCell(5).SetCellValue(dt.Rows[i]["REASON"].ToString());
        }
        using (MemoryStream stream = new MemoryStream())
        {
            hssfworkbook.Write(stream);
            HttpContext curContext = HttpContext.Current;
            // 设置编码和附件格式
            curContext.Response.ContentType     = "application/vnd.ms-excel";
            curContext.Response.ContentEncoding = Encoding.UTF8;
            curContext.Response.Charset         = "";
            curContext.Response.AppendHeader("Content-Disposition",
                                             "attachment;filename=" + HttpUtility.UrlEncode("物料领用历史明细表-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls", Encoding.UTF8));
            curContext.Response.BinaryWrite(stream.GetBuffer());
            curContext.Response.End();
        }
    }