///<summary> ///addCyubunrui ///テキストボックス内のデータをDBに登録 ///作成者:大河内 ///作成日:2017/3/9 ///更新者:大河内 ///更新日:2017/4/6 ///カラム論理名 ///</summary> private void addChubunrui() { //データ渡し用 List <string> lstString = new List <string>(); //文字判定 if (txtDaibunrui.blIsEmpty() == false || txtChubunrui.blIsEmpty() == false) { MessageBox.Show("項目が空です。文字を入力してください。", "入力項目", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //データ渡し用 lstString.Add(txtDaibunrui.Text); lstString.Add(txtChubunrui.Text); lstString.Add(txtElem.Text); lstString.Add(SystemInformation.UserName); //処理部に移動 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); chubunB.addChubunrui(lstString); txtChubunrui.Text = ""; txtElem.Text = ""; lblDsp.Text = ""; txtChubunrui.Focus(); }
///<summary> ///delCtyubunrui ///テキストボックス内のデータをDBから削除 ///作成者:大河内 ///作成日:2017/3/2 ///更新者:大河内 ///更新日:2017/3/29 ///カラム論理名 ///</summary> public void delChubunrui() { //データ渡し用 List <string> lstString = new List <string>(); bool blDelFinish = false; //文字判定 if (txtDaibunrui.blIsEmpty() == false || txtChubunrui.blIsEmpty() == false) { return; } //データ渡し用 lstString.Add(txtDaibunrui.Text); lstString.Add(txtChubunrui.Text); lstString.Add(txtElem.Text); lstString.Add(SystemInformation.UserName); //処理部に移動 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); blDelFinish = chubunB.delChubunrui(lstString); if (blDelFinish == true) { //大分類コード以外白紙にする txtChubunrui.Text = ""; txtElem.Text = ""; lblDsp.Text = ""; txtDaibunrui.Focus(); } }
///<summary> ///printChubun ///印刷ダイアログ ///</summary> private void printChubun() { //SQL実行時に取り出したデータを入れる用 DataTable dtSetCd_B = new DataTable(); //PDF作成後の入れ物 string strFile = ""; //ビジネス層のインスタンス生成 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); try { dtSetCd_B = chubunB.getPrintData(); //取得したデータがない場合 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; } //初期値 Common.Form.PrintForm pf = new Common.Form.PrintForm(this, "", CommonTeisu.SIZE_A4, TATE); pf.ShowDialog(this); //プレビューの場合 if (this.printFlg == CommonTeisu.ACTION_PREVIEW) { //結果セットをレコードセットに strFile = chubunB.dbToPdf(dtSetCd_B); // プレビュー pf.execPreview(strFile); } // 一括印刷の場合 else if (this.printFlg == CommonTeisu.ACTION_PRINT) { // PDF作成 strFile = chubunB.dbToPdf(dtSetCd_B); // 一括印刷 pf.execPrint(null, strFile, CommonTeisu.SIZE_A4, CommonTeisu.TATE, true); } } catch (Exception ex) { //データロギング 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> ///judtxtChubunruiLeave ///code入力箇所からフォーカスが外れた時(中分類) ///作成者:大河内 ///作成日:2017/3/3 ///更新者:大河内 ///更新日:2017/4/6 ///カラム論理名 ///</summary> public void judtxtChubunruiLeave(object sender, EventArgs e) { //データ渡し用 List <string> lstString = new List <string>(); DataTable DtSetcode; if (txtChubunrui.Text == "" || String.IsNullOrWhiteSpace(txtChubunrui.Text).Equals(true)) { return; } //前後の空白を取り除く txtChubunrui.Text = txtChubunrui.Text.Trim(); if (txtChubunrui.TextLength == 1) { txtChubunrui.Text = txtChubunrui.Text.ToString().PadLeft(2, '0'); } //データ渡し用 lstString.Add(txtDaibunrui.Text); lstString.Add(txtChubunrui.Text); //処理部に移動 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); //戻り値のDatatableを取り込む DtSetcode = chubunB.judTxtChubunruiLeave(lstString); if (DtSetcode.Rows.Count == 0) { } else { txtDaibunrui.Text = DtSetcode.Rows[0]["大分類コード"].ToString(); txtChubunrui.Text = DtSetcode.Rows[0]["中分類コード"].ToString(); txtElem.Text = DtSetcode.Rows[0]["中分類名"].ToString(); } }
///<summary> /// F10:Excel出力 ///</summary> private void excelChubun() { //SQL実行時に取り出したデータを入れる用 DataTable dtSetCd_B = new DataTable(); //ビジネス層のインスタンス生成 M1110_Chubunrui_B daibunB = new M1110_Chubunrui_B(); try { dtSetCd_B = daibunB.getPrintData(); BaseMessageBox basemessagebox; //取得したデータがない場合 if (dtSetCd_B == null || dtSetCd_B.Rows.Count == 0) { //例外発生メッセージ(OK) basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_ERROR, "対象のデータはありません", CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); return; } // SaveFileDialogクラスのインスタンスを作成 SaveFileDialog sfd = new SaveFileDialog(); // ファイル名の指定 sfd.FileName = "中分類マスタ_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xlsx"; // デフォルトパス取得(デスクトップ) string Init_dir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //はじめに表示されるフォルダを指定する sfd.InitialDirectory = Init_dir; // ファイルフィルタの設定 sfd.Filter = "すべてのファイル(*.*)|*.*"; //ダイアログを表示する if (sfd.ShowDialog() == DialogResult.OK) { CreatePdf cpdf = new CreatePdf(); //Linqで必要なデータをselect var outDataAll = dtSetCd_B.AsEnumerable() .Select(dat => new { daibunCd = (String)dat["大分類コード"], daibunName = dat["大分類名"], chubunCd = (String)dat["中分類コード"], chubunName = dat["中分類名"], chubunSubName = dat["補助名称"], }).ToList(); //リストをデータテーブルに変換 DataTable dtChkList = cpdf.ConvertToDataTable(outDataAll); string[] header = { "コード", "大分類名", "コード", "中分類名", "補助名称", }; string outFile = sfd.FileName; // Excel作成処理 cpdf.DtToXls(dtSetCd_B, "中分類マスタリスト", outFile, 3, 1, header); // メッセージボックスの処理、Excel作成完了の場合のウィンドウ(OK) basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_VIEW, "Excelファイルを作成しました。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_INFOMATION); basemessagebox.ShowDialog(); } } catch (Exception ex) { //データロギング 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> ///setTxtChubunrui ///code入力箇所からフォーカスが外れた時(中分類) ///</summary> public void setTxtChubunrui() { //データ渡し用 List <string> lstString = new List <string>(); //検索時のデータ取り出し先 DataTable dtSetCd; //前後の空白を取り除く txtChubunrui.Text = txtChubunrui.Text.Trim(); //空文字判定(中分類コード) if (StringUtl.blIsEmpty(txtChubunrui.Text) == false) { return; } // 値チェック(中分類コード) if (chkChubunrui() == true) { return; } //データの存在確認を検索する情報を入れる lstString.Add(lblSetDaibun.CodeTxtText); lstString.Add(txtChubunrui.Text); //ビジネス層のインスタンス生成 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); try { //戻り値のDatatableを取り込む dtSetCd = chubunB.getTxtChubunruiLeave(lblSetDaibun.CodeTxtText, txtChubunrui.Text); //Datatable内のデータが存在する場合 if (dtSetCd.Rows.Count != 0) { lblSetDaibun.CodeTxtText = dtSetCd.Rows[0]["大分類コード"].ToString(); txtChubunrui.Text = dtSetCd.Rows[0]["中分類コード"].ToString(); txtElem.Text = dtSetCd.Rows[0]["中分類名"].ToString(); txtSubName.Text = dtSetCd.Rows[0]["補助名称"].ToString(); btnF01.Enabled = true; btnF03.Enabled = true; btnF04.Enabled = true; } else { txtElem.Text = ""; txtSubName.Text = ""; btnF01.Enabled = true; btnF03.Enabled = false; btnF04.Enabled = true; } } catch (Exception ex) { //データロギング 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> ///delCtyubunrui ///テキストボックス内のデータをDBから削除 ///</summary> public void delChubunrui() { //記入情報削除用 List <string> lstChubunrui = new List <string>(); //検索時のデータ取り出し先 DataTable dtSetCd; //空文字判定(大部類コード、中分類コード) if (StringUtl.blIsEmpty(lblSetDaibun.CodeTxtText) == false || txtChubunrui.blIsEmpty() == false) { return; } // 値チェック(大分類コード) if (lblSetDaibun.chkTxtDaibunrui()) { return; } //ビジネス層のインスタンス生成 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); try { //戻り値のDatatableを取り込む dtSetCd = chubunB.getTxtChubunruiLeave(lblSetDaibun.CodeTxtText, txtChubunrui.Text); //取消メソッド起動前に、残す項目を確保用 string strTokuiSub = ""; //検索結果にデータが存在しなければ終了 if (dtSetCd.Rows.Count == 0) { return; } //メッセージボックスの処理、削除するか否かのウィンドウ(YES,NO) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_DEL, CommonTeisu.LABEL_DEL_BEFORE, CommonTeisu.BTN_YESNO, CommonTeisu.DIAG_QUESTION); //YESが押された場合 if (basemessagebox.ShowDialog() == DialogResult.No) { return; } //削除情報を入れる(大分類コード、中分類コード、中分類名、ユーザー名) lstChubunrui.Add(dtSetCd.Rows[0]["大分類コード"].ToString()); lstChubunrui.Add(dtSetCd.Rows[0]["中分類コード"].ToString()); lstChubunrui.Add(dtSetCd.Rows[0]["中分類名"].ToString()); lstChubunrui.Add(dtSetCd.Rows[0]["補助名称"].ToString()); lstChubunrui.Add(SystemInformation.UserName); //ビジネス層、削除ロジックに移動 chubunB.delChubunrui(lstChubunrui); //メッセージボックスの処理、削除完了のウィンドウ(OK) basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_DEL, CommonTeisu.LABEL_DEL_AFTER, CommonTeisu.BTN_OK, CommonTeisu.DIAG_INFOMATION); basemessagebox.ShowDialog(); //取消メソッド起動前に、残す項目を確保 strTokuiSub = lblSetDaibun.CodeTxtText; //テキストボックスを白紙にする DipDelChubunrui(); } catch (Exception ex) { //データロギング 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> ///addChubunrui ///テキストボックス内のデータをDBに登録 ///</summary> private void addChubunrui() { //記入情報登録用 List <string> lstChubunrui = new List <string>(); //取消メソッド起動前に、残す項目を確保用 string strTokuiSub = ""; //文字判定(大分類コード) if (StringUtl.blIsEmpty(lblSetDaibun.CodeTxtText) == false) { //メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_NULL, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); lblSetDaibun.Focus(); return; } // 値チェック(大分類コード) if (lblSetDaibun.chkTxtDaibunrui()) { return; } //文字判定(中分類コード) if (txtChubunrui.blIsEmpty() == false) { //メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_NULL, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtChubunrui.Focus(); return; } //文字判定(中分類名) if (txtElem.blIsEmpty() == false) { //メッセージボックスの処理、項目が空の場合のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_NULL, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR); basemessagebox.ShowDialog(); txtElem.Focus(); return; } //登録情報を入れる(大分類コード、中分類コード、中分類名、ユーザー名) lstChubunrui.Add(lblSetDaibun.CodeTxtText); lstChubunrui.Add(txtChubunrui.Text); lstChubunrui.Add(txtElem.Text); lstChubunrui.Add(txtSubName.Text); lstChubunrui.Add(SystemInformation.UserName); //ビジネス層のインスタンス生成 M1110_Chubunrui_B chubunB = new M1110_Chubunrui_B(); try { //登録 chubunB.addChubunrui(lstChubunrui); //メッセージボックスの処理、登録完了のウィンドウ(OK) BaseMessageBox basemessagebox = new BaseMessageBox(this, CommonTeisu.TEXT_TOUROKU, CommonTeisu.LABEL_TOUROKU, CommonTeisu.BTN_OK, CommonTeisu.DIAG_INFOMATION); basemessagebox.ShowDialog(); //取消メソッド起動前に、残す項目を確保 strTokuiSub = lblSetDaibun.CodeTxtText; //テキストボックスを白紙にする DipDelChubunrui(); } catch (Exception ex) { //データロギング 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; } }