protected void cmdPrint_Click(object sender, EventArgs e) { // // 製造指示表リスト発行 // ComLibrary com = new ComLibrary(); Message msg = new Message(g_user_id, g_lang); MfgBom mbom = new MfgBom(g_user_id, g_lang); DataTable dt = (DataTable)(ViewState["gdvDetail"]); if (dt == null) { return; } bool print_flag = false; //int seqno = 0; //Print Data DataTable prtDt = new DataTable(); //SubReport Data //DataTable prtDtTotal = new DataTable(); // 対象の行を探す for (int i = 0; i < dt.Rows.Count; i++) { if (com.IntToBool(com.StringToInt(dt.Rows[i]["SELECT"].ToString()))) { //印刷マーク print_flag = true; //seqno++; // Testing prtDt.Columns.Add(new DataColumn("FE_CRANK_ONLINE_NO")); prtDt.Columns.Add(new DataColumn("PRODUCTION_DATE")); prtDt.Columns.Add(new DataColumn("SHIFT")); prtDt.Columns.Add(new DataColumn("MODEL")); prtDt.Columns.Add(new DataColumn("LOTNO_ZOZAI")); prtDt.Columns.Add(new DataColumn("DIE_NO")); prtDt.Columns.Add(new DataColumn("ONLINE_DATE")); prtDt.Columns.Add(new DataColumn("ONLINE_STAMPING")); prtDt.Columns.Add(new DataColumn("REMARK")); DataRow dr = prtDt.NewRow(); dr["FE_CRANK_ONLINE_NO"] = "CRON-20180101-0001"; dr["PRODUCTION_DATE"] = "2018-04-23 00:00:00.000"; dr["SHIFT"] = "X"; dr["MODEL"] = "55A"; dr["LOTNO_ZOZAI"] = "P50203N7"; dr["DIE_NO"] = "99"; dr["ONLINE_DATE"] = "100"; dr["ONLINE_STAMPING"] = "H-0746"; dr["REMARK"] = ""; prtDt.Rows.Add(dr); // Actual Codes // データ検索 //WIPJo jo = new WIPJo(g_user_id, g_lang); //jo.job_order_no = dt.Rows[i]["Online_No"].ToString(); //jo.item_no = dt.Rows[i]["Part_No"].ToString(); //DataSet ds = jo.Get_OnRptDetail(); //if (ds == null) //{ // lblMsg.Text = jo.strErr; // lblMsg.ForeColor = Color.Red; // return; //} //prtDt = ds.Tables[0]; } } if (print_flag == false) { lblMsg.Text = msg.GetMessage("PRINT_DATA_NOT_EXIST_ERR"); lblMsg.ForeColor = Color.Red; return; } ReportClass Rpt = null; Rpt = new HondaTraceabilitySystem.Common.Report.FeOnline(); string ReportName = "MfgJOList"; try { //Rpt.Subreports["SubReport"].SetDataSource(prtDtTotal); Rpt.SetDataSource(prtDt); Rpt.SetParameterValue("H_TITLE", "INSPECTION SHEET(SEMICONDUCTOR"); PdfRtfWordFormatOptions pdfFormatOpts = new PdfRtfWordFormatOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); // exportOpts; ExportOptions exportOpts = Rpt.ExportOptions; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; exportOpts.FormatOptions = pdfFormatOpts; string tmpFilenm = ReportName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; diskOpts.DiskFileName = Server.MapPath(WebConfigurationManager.ConnectionStrings["ReportOutDir"].ConnectionString + tmpFilenm); exportOpts.DestinationOptions = diskOpts; //print Rpt.Export(); Type cstype = this.GetType(); this.Page.ClientScript.RegisterClientScriptBlock(cstype, "a", @"<script>window.open('" + WebConfigurationManager.ConnectionStrings["ReportOutDir"].ConnectionString + tmpFilenm + "', '" + ReportName + "', 'status,resizable=yes');</script>"); } catch (Exception ex) { string strErr = ex.ToString(); lblMsg.Text = ex.ToString(); return; } lblMsg.Text = msg.GetMessage("NORMAL_PRINT"); lblMsg.ForeColor = Color.Blue; }
protected void cmdPrint_Click(object sender, EventArgs e) { // // 製造指示表リスト発行 // ComLibrary com = new ComLibrary(); Message msg = new Message(g_user_id, g_lang); //MfgBom mbom = new MfgBom(g_user_id, g_lang); String h_period_from = "PERIOD FROM : "; String h_period_to = " TO : "; DataTable dt = (DataTable)(ViewState["gdvDetail"]); if (dt == null) { return; } bool print_flag = false; int seqno = 0; //Print Data DataTable prtDt = new DataTable(); //SubReport Data //DataTable prtDtTotal = new DataTable(); prtDt.Columns.Add(new DataColumn("FE_CRANK_ONLINE_NO")); prtDt.Columns.Add(new DataColumn("PRODUCTION_DATE")); prtDt.Columns.Add(new DataColumn("SHIFT")); prtDt.Columns.Add(new DataColumn("MODEL")); prtDt.Columns.Add(new DataColumn("LOTNO_ZOZAI")); prtDt.Columns.Add(new DataColumn("DIE_NO")); prtDt.Columns.Add(new DataColumn("RECEIVE_QTY")); prtDt.Columns.Add(new DataColumn("ONLINE_STAMPING")); prtDt.Columns.Add(new DataColumn("REMARK")); // 対象の行を探す for (int i = 0; i < dt.Rows.Count; i++) { if (com.IntToBool(com.StringToInt(dt.Rows[i]["SELECT"].ToString()))) { //印刷マーク print_flag = true; if (seqno == 0) { h_period_from = "PERIOD FROM : " + dt.Rows[i]["ONLINE_DATE"].ToString(); } seqno++; DataRow dr = prtDt.NewRow(); dr["FE_CRANK_ONLINE_NO"] = dt.Rows[i]["ONLINE_NO"].ToString(); dr["PRODUCTION_DATE"] = dt.Rows[i]["ONLINE_DATE"]; dr["SHIFT"] = dt.Rows[i]["SHIFT"].ToString(); dr["MODEL"] = dt.Rows[i]["MODEL"].ToString(); dr["LOTNO_ZOZAI"] = dt.Rows[i]["LOTNO_ZOZAI"].ToString(); dr["DIE_NO"] = dt.Rows[i]["DIE_NO"].ToString(); dr["RECEIVE_QTY"] = dt.Rows[i]["RECEIVE_QTY"]; dr["ONLINE_STAMPING"] = dt.Rows[i]["ONLINE_STAMPING"].ToString(); dr["REMARK"] = dt.Rows[i]["REMARK"].ToString(); prtDt.Rows.Add(dr); h_period_to = " TO : " + dt.Rows[i]["ONLINE_DATE"].ToString(); } } if (print_flag == false) { lblMsg.Text = msg.GetMessage("PRINT_DATA_NOT_EXIST_ERR"); lblMsg.ForeColor = Color.Red; return; } ReportClass Rpt = null; Rpt = new HondaTraceabilitySystem.Common.Report.FeOnline(); string ReportName = "FeOnProd"; try { //Rpt.Subreports["SubReport"].SetDataSource(prtDtTotal); Rpt.SetDataSource(prtDt); Rpt.SetParameterValue("H_TITLE", "HATC-M P-EGD Production Sheet Control"); Rpt.SetParameterValue("H_DATA_TYPE", "DATA TYPE : ON LINE"); Rpt.SetParameterValue("H_TYPE", "TYPE :"); Rpt.SetParameterValue("H_DEPT", "DEPT. : FE-P"); if (ddlPROCESS.SelectedValue == "Crank Shaft") { Rpt.SetParameterValue("H_PART_NAME", "PART NAME : CRANK ZOZAI"); Rpt.SetParameterValue("H_LINE", "LINE : CRANK LINE"); } else { Rpt.SetParameterValue("H_PART_NAME", "PART NAME : CONNROD ZOZAI"); Rpt.SetParameterValue("H_LINE", "LINE : CONNROD LINE"); } Rpt.SetParameterValue("H_PERIOD_FROM", h_period_from); Rpt.SetParameterValue("H_PERIOD_TO", h_period_to); PdfRtfWordFormatOptions pdfFormatOpts = new PdfRtfWordFormatOptions(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); // exportOpts; ExportOptions exportOpts = Rpt.ExportOptions; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; exportOpts.FormatOptions = pdfFormatOpts; string tmpFilenm = ReportName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; diskOpts.DiskFileName = Server.MapPath(WebConfigurationManager.ConnectionStrings["ReportOutDir"].ConnectionString + tmpFilenm); exportOpts.DestinationOptions = diskOpts; //print Rpt.Export(); Type cstype = this.GetType(); this.Page.ClientScript.RegisterClientScriptBlock(cstype, "a", @"<script>window.open('" + WebConfigurationManager.ConnectionStrings["ReportOutDir"].ConnectionString + tmpFilenm + "', '" + ReportName + "', 'status,resizable=yes');</script>"); } catch (Exception ex) { string strErr = ex.ToString(); lblMsg.Text = ex.ToString(); return; } lblMsg.Text = msg.GetMessage("NORMAL_PRINT"); lblMsg.ForeColor = Color.Blue; }