///<summary> ///printDenpyoCount ///印刷ダイアログ ///</summary> private void printDenpyoCount() { //SQL実行時に取り出したデータを入れる用 DataTable dtSetCd_B = new DataTable(); //PDF作成後の入れ物 string strFile = ""; //検索開始日確保 DateTime dateOpen; //検索終了日確保 DateTime dateClose; //各取り出しデータ int intJuchu = 0; int intHachu = 0; int intShire = 0; int intUriage = 0; int intNyuko = 0; int intShuko = 0; int intTanto = 0; //合計データ用 List <string> lstKei = new List <string>(); //ビジネス層のインスタンス生成 C6000_TantoshabetuDenpyoCount_B denpyocountB = new C6000_TantoshabetuDenpyoCount_B(); try { //初期値 Common.Form.PrintForm pf = new Common.Form.PrintForm(this, "", CommonTeisu.SIZE_A4, YOKO); pf.ShowDialog(this); pf.intPrintCnt = int.Parse(txtPrintCount.Text); //入力項目の記入に漏れがある場合 if (txtDenpyoOpen.blIsEmpty() == false || txtDenpyoClose.blIsEmpty() == false || txtTantoshaCdOpen.codeTxt.blIsEmpty() == false || txtTantoshaCdClose.codeTxt.blIsEmpty() == false) { //例外発生メッセージ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, "対象のデータはありません", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); return; } //データの取得 dtSetCd_B = denpyocountB.getData(txtDenpyoOpen.Text, txtDenpyoClose.Text, txtTantoshaCdOpen.CodeTxtText, txtTantoshaCdClose.CodeTxtText); //取得したデータがない場合 if (dtSetCd_B.Rows.Count == 0 || dtSetCd_B == null) { //例外発生メッセージ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, "対象のデータはありません", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); return; } //datagridviewの行数分ループ for (int intRcnt = 0; intRcnt < dtSetCd_B.Rows.Count; intRcnt++) { intJuchu = intJuchu + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["受注計"].ToString())); intHachu = intHachu + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["発注計"].ToString())); intShire = intShire + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["仕入計"].ToString())); intUriage = intUriage + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["売上計"].ToString())); intNyuko = intNyuko + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["入庫計"].ToString())); intShuko = intShuko + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["出庫計"].ToString())); intTanto = intTanto + (int)Math.Floor(double.Parse(dtSetCd_B.Rows[intRcnt]["担当計"].ToString())); } //合計データをまとめる lstKei.Add(intJuchu.ToString()); lstKei.Add(intHachu.ToString()); lstKei.Add(intShire.ToString()); lstKei.Add(intUriage.ToString()); lstKei.Add(intNyuko.ToString()); lstKei.Add(intShuko.ToString()); lstKei.Add(intTanto.ToString()); //表示する年月日の取得、編集 dateOpen = DateTime.Parse(txtDenpyoOpen.Text); dateClose = DateTime.Parse(txtDenpyoClose.Text); //プレビューの場合 if (this.printFlg == CommonTeisu.ACTION_PREVIEW) { // カーソルを待機状態にする this.Cursor = Cursors.WaitCursor; //結果セットをレコードセットに strFile = denpyocountB.dbToPdf(dtSetCd_B, dateOpen, dateClose, txtTantoshaCdOpen.CodeTxtText, txtTantoshaCdClose.CodeTxtText, lstKei); // プレビュー pf.execPreview(strFile); } // 一括印刷の場合 else if (this.printFlg == CommonTeisu.ACTION_PRINT) { // カーソルを待機状態にする this.Cursor = Cursors.WaitCursor; // PDF作成 strFile = denpyocountB.dbToPdf(dtSetCd_B, dateOpen, dateClose, txtTantoshaCdOpen.CodeTxtText, txtTantoshaCdClose.CodeTxtText, lstKei); // 一括印刷 pf.execPrint(null, strFile, CommonTeisu.SIZE_A4, CommonTeisu.YOKO, true); } pf.Dispose(); // カーソルの状態を元に戻す this.Cursor = Cursors.Default; } catch (Exception ex) { // カーソルの状態を元に戻す this.Cursor = Cursors.Default; //データロギング new CommonException(ex); //例外発生メッセージ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); return; } }
/// <summary> /// setDataView /// データグリッドビューにデータを表示 /// </summary> private void setDataView() { //データ検索用 List <string> lstUriageSuiiLoad = new List <string>(); //検索時のデータ取り出し先 DataTable dtSetView; // 空文字判定(開始年月日) if (txtDenpyoOpen.blIsEmpty() == false) { // メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "項目が空です。\r\n日付を入力してください。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtDenpyoOpen.Focus(); return; } // 空文字判定(終了年月日) if (txtDenpyoOpen.blIsEmpty() == false) { // メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "項目が空です。\r\n日付を入力してください。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtDenpyoOpen.Focus(); return; } //年月日の日付フォーマット後を入れる用 string strYMDformat = ""; //日付フォーマット生成、およびチェック strYMDformat = txtDenpyoOpen.chkDateDataFormat(txtDenpyoOpen.Text); //開始年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtDenpyoOpen.Focus(); return; } else { txtDenpyoOpen.Text = strYMDformat; } //初期化 strYMDformat = ""; //日付フォーマット生成、およびチェック strYMDformat = txtDenpyoClose.chkDateDataFormat(txtDenpyoClose.Text); //終了年月日の日付チェック if (strYMDformat == "") { // メッセージボックスの処理、項目が日付でない場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, "入力された日付が正しくありません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtDenpyoClose.Focus(); return; } else { txtDenpyoClose.Text = strYMDformat; } //開始担当者コードのチェック if (txtTantoshaCdOpen.chkTxtTantosha() == true) { txtTantoshaCdOpen.Focus(); return; } //終了担当者コードのチェック if (txtTantoshaCdClose.chkTxtTantosha() == true) { txtTantoshaCdClose.Focus(); return; } //各取り出しデータ int intJuchu = 0; int intHachu = 0; int intShire = 0; int intUriage = 0; int intNyuko = 0; int intShuko = 0; int intTanto = 0; C6000_TantoshabetuDenpyoCount_B denpyocountB = new C6000_TantoshabetuDenpyoCount_B(); try { // カーソルを待機状態にする this.Cursor = Cursors.WaitCursor; dtSetView = denpyocountB.getData(txtDenpyoOpen.Text, txtDenpyoClose.Text, txtTantoshaCdOpen.CodeTxtText, txtTantoshaCdClose.CodeTxtText); // 各合計を計算 foreach (DataRow row in dtSetView.Rows) { intJuchu += (int)Math.Floor(double.Parse(row["受注計"].ToString())); intHachu += (int)Math.Floor(double.Parse(row["発注計"].ToString())); intShire += (int)Math.Floor(double.Parse(row["仕入計"].ToString())); intUriage += (int)Math.Floor(double.Parse(row["売上計"].ToString())); intNyuko += (int)Math.Floor(double.Parse(row["入庫計"].ToString())); intShuko += (int)Math.Floor(double.Parse(row["出庫計"].ToString())); intTanto += (int)Math.Floor(double.Parse(row["担当計"].ToString())); } // 検索結果をグリッドに反映 gridViewData.DataSource = dtSetView; // 各合計をテキストボックスに反映 txtJuchuKei.Text = string.Format("{0:#,0}", intJuchu); // 受注計の合計 txtHachu.Text = string.Format("{0:#,0}", intHachu); // 発注計の合計 txtShire.Text = string.Format("{0:#,0}", intShire); // 仕入計の合計 txtUriage.Text = string.Format("{0:#,0}", intUriage); // 売上計の合計 txtNyuko.Text = string.Format("{0:#,0}", intNyuko); // 入庫計の合計 txtShuko.Text = string.Format("{0:#,0}", intShuko); // 出庫計の合計 txtTanto.Text = string.Format("{0:#,0}", intTanto); // 担当計の合計 // カーソルの状態を元に戻す this.Cursor = Cursors.Default; } catch (Exception ex) { // カーソルの状態を元に戻す this.Cursor = Cursors.Default; //データロギング new CommonException(ex); //例外発生メッセージ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); return; } }