Ejemplo n.º 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 == "")
            {
                //メッセージボックスの処理、項目が空の場合のウィンドウ(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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// setUriageSuiiHyo
        /// データグリッドビューにデータを表示
        /// </summary>
        private void setUriageSuiiHyo()
        {
            //データ検索用
            List <string> lstUriageSuiiLoad = new List <string>();

            //検索時のデータ取り出し先
            DataTable dtSetView;

            //年月日の日付フォーマット後を入れる用
            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;
            }


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

            try
            {
                //データの存在確認を検索する情報を入れる
                /*[0]開始期間*/ lstUriageSuiiLoad.Add(txtCalendarYMopen.Text);
                /*[1]終了期間*/ lstUriageSuiiLoad.Add(txtCalendarYMclose.Text);
                /*[2]開始得意先コード*/ lstUriageSuiiLoad.Add(labelSet_TokuisakiStart.CodeTxtText);
                /*[3]終了得意先コード*/ lstUriageSuiiLoad.Add(labelSet_TokuisakiEnd.CodeTxtText);
                /*[4]大分類コード*/ lstUriageSuiiLoad.Add(labelSet_Daibunrui1.CodeTxtText);
                /*[5]営業所コード*/ lstUriageSuiiLoad.Add(labelSet_Eigyosho1.CodeTxtText);
                /*[6]担当者コード*/ lstUriageSuiiLoad.Add(labelSet_Tantousha1.CodeTxtText);
                /*[7]中分類コード*/ lstUriageSuiiLoad.Add(labelSet_Chubunrui1.CodeTxtText);
                /*[8]グループコード*/ lstUriageSuiiLoad.Add(labelSet_GroupCd1.CodeTxtText);
                /*[9]受注者コード*/ lstUriageSuiiLoad.Add(lsJuchusha.CodeTxtText);
                /*[10]メーカーコード*/ lstUriageSuiiLoad.Add(labelSet_Maker1.CodeTxtText);

                //ビジネス層、データグリッドビュー表示用ロジックに移動
                dtSetView = uriagesuiihyoB.getUriageSuiiList(lstUriageSuiiLoad, "disp");

                //データを配置(datagridview)
                gridUriageSuii.DataSource = dtSetView;

                //合計額計算処理
                int    i;
                int    j;
                String pre;
                pre = "";
                decimal[] suM = new decimal[14];

                for (i = 0; i < 13; i++)
                {
                    suM[i] = 0;
                }

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

                    for (j = 0; j < 13; j++)
                    {
                        suM[j] = suM[j] + decimal.Parse(gridUriageSuii[j + 2, i].Value.ToString());
                    }
                }

                DataRow datarow = dtSetView.NewRow();

                datarow["得意先名"] = "【合計】";
                datarow["金額1"]  = suM[0];
                datarow["金額2"]  = suM[1];
                datarow["金額3"]  = suM[2];
                datarow["金額4"]  = suM[3];
                datarow["金額5"]  = suM[4];
                datarow["金額6"]  = suM[5];
                datarow["金額7"]  = suM[6];
                datarow["金額8"]  = suM[7];
                datarow["金額9"]  = suM[8];
                datarow["金額10"] = suM[9];
                datarow["金額11"] = suM[10];
                datarow["金額12"] = suM[11];
                datarow["金額合計"] = suM[12];

                dtSetView.Rows.Add(datarow);

                //データに合計を追加したものを配置(datagridview)
                gridUriageSuii.DataSource = dtSetView;

                gridUriageSuii.Visible = true;
            }
            catch (Exception ex)
            {
                //エラーロギング
                gridUriageSuii.Visible = true;
                new CommonException(ex);
                return;
            }
        }