/// <summary> /// printReport /// PDFを出力する /// </summary> private void printReport() { // データ検索用 List <string> lstSearchItem = new List <string>(); //年月日の日付フォーマット後を入れる用 string strYMDformat = ""; //空文字判定(機関開始、期間終了) if (txtCalendarYMopen.blIsEmpty() == false || txtCalendarYMclose.blIsEmpty() == false) { // メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "項目が空です。\r\n日付を入力してください。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtCalendarYMopen.Focus(); return; } //空文字判定(得意先コード開始) if (labelSet_TokuisakiStart.CodeTxtText == "") { //メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_NULL, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); labelSet_TokuisakiStart.Focus(); return; } // 空文字判定(仕入先コード終了) if (labelSet_TokuisakiEnd.CodeTxtText == "") { // メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_NULL, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); labelSet_TokuisakiEnd.Focus(); return; } //日付フォーマット生成、およびチェック strYMDformat = txtCalendarYMopen.chkDateYMDataFormat(txtCalendarYMopen.Text); //開始年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtCalendarYMopen.Focus(); return; } else { txtCalendarYMopen.Text = strYMDformat; } //初期化 strYMDformat = ""; //日付フォーマット生成、およびチェック strYMDformat = txtCalendarYMclose.chkDateYMDataFormat(txtCalendarYMclose.Text); //終了年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtCalendarYMclose.Focus(); return; } else { txtCalendarYMclose.Text = strYMDformat; } //営業所コードのチェック if (labelSet_Eigyosho1.chkTxtEigyousho() == true) { labelSet_Eigyosho1.Focus(); return; } //グループコードのチェック if (labelSet_GroupCd1.chkTxtGroupCd() == true) { labelSet_GroupCd1.Focus(); return; } //担当者コードのチェック if (labelSet_Tantousha1.chkTxtTantosha() == true) { labelSet_Tantousha1.Focus(); return; } //受注者コードのチェック if (lsJuchusha.chkTxtTantosha() == true) { lsJuchusha.Focus(); return; } //大分類コードのチェック if (labelSet_Daibunrui1.chkTxtDaibunrui() == true) { labelSet_Daibunrui1.Focus(); return; } //中分類コードのチェック if (labelSet_Chubunrui1.chkTxtChubunrui(labelSet_Daibunrui1.CodeTxtText) == true) { labelSet_Chubunrui1.Focus(); return; } //メーカーコードのチェック if (labelSet_Maker1.chkTxtMaker() == true) { labelSet_Maker1.Focus(); return; } this.Cursor = Cursors.WaitCursor; // ビジネス層のインスタンス生成 C0490_UriageSuiiHyo_B uriagesuiihyoB = new C0490_UriageSuiiHyo_B(); try { // 検索するデータをリストに格納 lstSearchItem.Add(txtCalendarYMopen.Text); lstSearchItem.Add(txtCalendarYMclose.Text); lstSearchItem.Add(labelSet_TokuisakiStart.CodeTxtText); lstSearchItem.Add(labelSet_TokuisakiEnd.CodeTxtText); lstSearchItem.Add(labelSet_Daibunrui1.CodeTxtText); lstSearchItem.Add(labelSet_Eigyosho1.CodeTxtText); lstSearchItem.Add(labelSet_Tantousha1.CodeTxtText); lstSearchItem.Add(labelSet_Chubunrui1.CodeTxtText); lstSearchItem.Add(labelSet_GroupCd1.CodeTxtText); lstSearchItem.Add(lsJuchusha.CodeTxtText); lstSearchItem.Add(labelSet_Maker1.CodeTxtText); // 検索実行(印刷用) DataTable dtSiireSuiiList = uriagesuiihyoB.getUriageSuiiList(lstSearchItem, "print"); this.Cursor = Cursors.Default; if (dtSiireSuiiList.Rows.Count > 0) { // 印刷ダイアログ Common.Form.PrintForm pf = new Common.Form.PrintForm(this, "", CommonTeisu.SIZE_A4, CommonTeisu.YOKO); pf.ShowDialog(this); // プレビューの場合 if (this.printFlg == CommonTeisu.ACTION_PREVIEW) { this.Cursor = Cursors.WaitCursor; // PDF作成 string strFile = uriagesuiihyoB.dbToPdf(dtSiireSuiiList, lstSearchItem[0]); this.Cursor = Cursors.Default; pf.execPreview(@strFile); } // 一括印刷の場合 else if (this.printFlg == CommonTeisu.ACTION_PRINT) { this.Cursor = Cursors.WaitCursor; // PDF作成 string strFile = uriagesuiihyoB.dbToPdf(dtSiireSuiiList, lstSearchItem[0]); this.Cursor = Cursors.Default; // 用紙サイズ、印刷方向はインスタンス生成と同じ値を入れる // ダイアログ表示時は最後の引数はtrue // (ダイアログ非経由の直接印刷時は先頭引数にプリンタ名を入れ、最後の引数をfalseに) pf.execPrint(null, @strFile, CommonTeisu.SIZE_A4, CommonTeisu.YOKO, true); } pf.Dispose(); } else { this.Cursor = Cursors.Default; // メッセージボックスの処理、対象データがない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_VIEW, "対象のデータはありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_INFOMATION); basemessagebox.ShowDialog(); } } catch (Exception ex) { // エラーロギング new CommonException(ex); return; } }