示例#1
0
        /// <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.Equals(""))
            {
                // メッセージボックスの処理、項目が空の場合のウィンドウ(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.Equals(""))
            {
                // メッセージボックスの処理、項目が空の場合のウィンドウ(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_Eigyosho.chkTxtEigyousho() == true)
            {
                labelSet_Eigyosho.Focus();

                return;
            }

            //グループコードのチェック
            if (labelSet_GroupCd.chkTxtGroupCd() == true)
            {
                labelSet_GroupCd.Focus();

                return;
            }

            //受注者コードのチェック
            if (labelSet_Juchusha.chkTxtTantosha() == true)
            {
                labelSet_Juchusha.Focus();

                return;
            }

            //大分類コードのチェック
            if (labelSet_Daibunrui.chkTxtDaibunrui() == true)
            {
                labelSet_Daibunrui.Focus();

                return;
            }

            //中分類コードのチェック
            if (labelSet_Chubunrui.chkTxtChubunrui(labelSet_Daibunrui.CodeTxtText) == true)
            {
                labelSet_Chubunrui.Focus();

                return;
            }

            //メーカーコードのチェック
            if (labelSet_Maker.chkTxtMaker() == true)
            {
                labelSet_Maker.Focus();

                return;
            }

            this.Cursor = Cursors.WaitCursor;

            // ビジネス層のインスタンス生成
            C0480_SiireSuiiHyo_B siiresuiihyoB = new C0480_SiireSuiiHyo_B();

            try
            {
                // 検索するデータをリストに格納
                lstSearchItem.Add(txtCalendarYMopen.Text);
                lstSearchItem.Add(txtCalendarYMclose.Text);
                lstSearchItem.Add(labelSet_Eigyosho.CodeTxtText);
                lstSearchItem.Add(labelSet_GroupCd.CodeTxtText);
                lstSearchItem.Add(labelSet_TokuisakiStart.CodeTxtText);
                lstSearchItem.Add(labelSet_TokuisakiEnd.CodeTxtText);
                lstSearchItem.Add(labelSet_Juchusha.CodeTxtText);
                lstSearchItem.Add(labelSet_Daibunrui.CodeTxtText);
                lstSearchItem.Add(labelSet_Chubunrui.CodeTxtText);
                lstSearchItem.Add(labelSet_Maker.CodeTxtText);

                // 検索実行(印刷用)
                DataTable dtSiireSuiiList = siiresuiihyoB.getSiireSuiiList(lstSearchItem, "print");

                this.Cursor = Cursors.Default;

                if (dtSiireSuiiList.Rows.Count > 0)
                {
                    // 印刷ダイアログ
                    Common.Form.PrintForm pf = new Common.Form.PrintForm(this, "", CommonTeisu.SIZE_B4, CommonTeisu.YOKO);
                    pf.ShowDialog(this);

                    // プレビューの場合
                    if (this.printFlg == CommonTeisu.ACTION_PREVIEW)
                    {
                        this.Cursor = Cursors.WaitCursor;

                        // PDF作成
                        String strFile = siiresuiihyoB.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 = siiresuiihyoB.dbToPdf(dtSiireSuiiList, lstSearchItem[0]);

                        this.Cursor = Cursors.Default;

                        // 一括印刷
                        pf.execPrint(null, strFile, CommonTeisu.SIZE_B4, CommonTeisu.YOKO, true);
                    }

                    this.Cursor = Cursors.Default;

                    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);

                // メッセージボックスの処理、PDF作成失敗の場合のウィンドウ(OK)
                BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_VIEW, "印刷が失敗しました。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                basemessagebox.ShowDialog();

                return;
            }
        }
示例#2
0
        /// <summary>
        /// setSiireSuiiHyo
        /// データグリッドビューにデータを表示
        /// </summary>
        private void setSiireSuiiHyo()
        {
            // 金額1~金額12、金額合計の合計用
            decimal[] decGoukei = new decimal[13];

            // データ検索用
            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.Equals(""))
            {
                // メッセージボックスの処理、項目が空の場合のウィンドウ(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.Equals(""))
            {
                // メッセージボックスの処理、項目が空の場合のウィンドウ(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_Eigyosho.chkTxtEigyousho() == true)
            {
                labelSet_Eigyosho.Focus();

                return;
            }

            //グループコードのチェック
            if (labelSet_GroupCd.chkTxtGroupCd() == true)
            {
                labelSet_GroupCd.Focus();

                return;
            }

            //受注者コードのチェック
            if (labelSet_Juchusha.chkTxtTantosha() == true)
            {
                labelSet_Juchusha.Focus();

                return;
            }

            //大分類コードのチェック
            if (labelSet_Daibunrui.chkTxtDaibunrui() == true)
            {
                labelSet_Daibunrui.Focus();

                return;
            }

            //中分類コードのチェック
            if (labelSet_Chubunrui.chkTxtChubunrui(labelSet_Daibunrui.CodeTxtText) == true)
            {
                labelSet_Chubunrui.Focus();

                return;
            }

            //メーカーコードのチェック
            if (labelSet_Maker.chkTxtMaker() == true)
            {
                labelSet_Maker.Focus();

                return;
            }

            // ビジネス層のインスタンス生成
            C0480_SiireSuiiHyo_B siiresuiihyoB = new C0480_SiireSuiiHyo_B();

            try
            {
                // 検索するデータをリストに格納
                lstSearchItem.Add(txtCalendarYMopen.Text);
                lstSearchItem.Add(txtCalendarYMclose.Text);
                lstSearchItem.Add(labelSet_Eigyosho.CodeTxtText);
                lstSearchItem.Add(labelSet_GroupCd.CodeTxtText);
                lstSearchItem.Add(labelSet_TokuisakiStart.CodeTxtText);
                lstSearchItem.Add(labelSet_TokuisakiEnd.CodeTxtText);
                lstSearchItem.Add(labelSet_Juchusha.CodeTxtText);
                lstSearchItem.Add(labelSet_Daibunrui.CodeTxtText);
                lstSearchItem.Add(labelSet_Chubunrui.CodeTxtText);
                lstSearchItem.Add(labelSet_Maker.CodeTxtText);

                // 検索実行(表示用)
                DataTable dtSiireSuiiList = siiresuiihyoB.getSiireSuiiList(lstSearchItem, "disp");

                DataRow drGoukei = dtSiireSuiiList.NewRow();
                int     rowsCnt  = dtSiireSuiiList.Rows.Count;

                // 検索データがある場合
                if (dtSiireSuiiList != null && rowsCnt > 0)
                {
                    // 金額1~金額12、金額合計の計算
                    for (int cnt = 0; cnt < rowsCnt; cnt++)
                    {
                        decGoukei[0]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額1"].ToString()));
                        decGoukei[1]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額2"].ToString()));
                        decGoukei[2]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額3"].ToString()));
                        decGoukei[3]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額4"].ToString()));
                        decGoukei[4]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額5"].ToString()));
                        decGoukei[5]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額6"].ToString()));
                        decGoukei[6]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額7"].ToString()));
                        decGoukei[7]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額8"].ToString()));
                        decGoukei[8]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額9"].ToString()));
                        decGoukei[9]  += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額10"].ToString()));
                        decGoukei[10] += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額11"].ToString()));
                        decGoukei[11] += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額12"].ToString()));
                        decGoukei[12] += decimal.ToInt32(Decimal.Parse(dtSiireSuiiList.Rows[cnt]["金額合計"].ToString()));
                    }
                }

                // 合計行へ値をセット
                drGoukei["仕入先名"] = "【合計】";
                drGoukei["金額1"]  = decGoukei[0];
                drGoukei["金額2"]  = decGoukei[1];
                drGoukei["金額3"]  = decGoukei[2];
                drGoukei["金額4"]  = decGoukei[3];
                drGoukei["金額5"]  = decGoukei[4];
                drGoukei["金額6"]  = decGoukei[5];
                drGoukei["金額7"]  = decGoukei[6];
                drGoukei["金額8"]  = decGoukei[7];
                drGoukei["金額9"]  = decGoukei[8];
                drGoukei["金額10"] = decGoukei[9];
                drGoukei["金額11"] = decGoukei[10];
                drGoukei["金額12"] = decGoukei[11];
                drGoukei["金額合計"] = decGoukei[12];

                // 合計行を追加
                dtSiireSuiiList.Rows.Add(drGoukei);

                // データテーブルからデータグリッドへセット
                gridSiireSuii.DataSource = dtSiireSuiiList;

                String strName = "";

                // 配列の前後で名前が重複している場合は名前を削除
                for (int cnt = 0; cnt < gridSiireSuii.RowCount; cnt++)
                {
                    // 配列の前後を比較、同じ名前だった場合
                    if (gridSiireSuii[0, cnt].Value.ToString().Equals(strName))
                    {
                        // 名前を削除
                        gridSiireSuii[0, cnt].Value = null;
                    }
                    else
                    {
                        strName = gridSiireSuii[0, cnt].Value.ToString();
                    }
                }

                gridSiireSuii.Visible = true;

                Control cNow = this.ActiveControl;
                cNow.Focus();
            }
            catch (Exception ex)
            {
                // エラーロギング
                new CommonException(ex);
                return;
            }
            return;
        }