Exemplo n.º 1
0
        ///<summary>
        ///updTxtTokuisakiLeave
        ///code入力箇所からフォーカスが外れた時
        ///</summary>
        public void updTxtTokuisakiLeave(object sender, EventArgs e)
        {
            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetCd;

            string strSQLName = null;

            Boolean blnGood;

            if (this.CodeTxtText == "" || String.IsNullOrWhiteSpace(this.CodeTxtText).Equals(true))
            {
                this.valueTextText   = "";
                this.AppendLabelText = "";
                return;
            }

            //禁止文字チェック
            blnGood = StringUtl.JudBanChr(this.CodeTxtText);
            //数字のみを許可する
            blnGood = StringUtl.JudBanSelect(this.CodeTxtText, CommonTeisu.NUMBER_ONLY);

            if (blnGood == false)
            {
                this.valueTextText = "";

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent.Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                    return;
                }
                else
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                    return;
                }
            }

            //前後の空白を取り除く
            this.CodeTxtText = this.CodeTxtText.Trim();

            if (this.CodeTxtText.Length < 4)
            {
                this.CodeTxtText = this.CodeTxtText.ToString().PadLeft(4, '0');
            }

            // 存在チェックを行い
            if (SearchOn == false)
            {
                return;
            }

            strSQLName = "C_LIST_Torihikisaki_SELECT_LEAVE";

            //データ渡し用
            lstStringSQL.Add("Common");
            lstStringSQL.Add(strSQLName);

            OpenSQL opensql = new OpenSQL();

            try
            {
                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                if (strSQLInput == "")
                {
                    return;
                }

                //配列設定
                string[] aryStr = { this.CodeTxtText };

                strSQLInput = string.Format(strSQLInput, aryStr);

                //SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetCd = dbconnective.ReadSql(strSQLInput);

                if (dtSetCd.Rows.Count != 0)
                {
                    string strZeikubun = "";

                    if (dtSetCd.Rows[0]["消費税計算区分"].ToString() == "0" || dtSetCd.Rows[0]["消費税計算区分"].ToString() == "2")
                    {
                        strZeikubun = "外税";
                    }
                    else if (dtSetCd.Rows[0]["消費税計算区分"].ToString() == "1")
                    {
                        strZeikubun = "内税";
                    }

                    this.CodeTxtText     = dtSetCd.Rows[0]["取引先コード"].ToString();
                    this.valueTextText   = dtSetCd.Rows[0]["取引先名称"].ToString();
                    this.AppendLabelText = strZeikubun;
                }
                else
                {
                    this.valueTextText = "";

                    //グループボックスかパネル内にいる場合
                    if (this.Parent is GroupBox || this.Parent is Panel)
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_VIEW, CommonTeisu.LABEL_NOTDATA, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();
                        return;
                    }
                    else
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_VIEW, CommonTeisu.LABEL_NOTDATA, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();
                        return;
                    }
                }
                return;
            }
            catch (Exception ex)
            {
                //データロギング
                new CommonException(ex);

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
                else
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
            }
        }
Exemplo n.º 2
0
        ///<summary>
        ///setSelectItem
        ///各画面へのデータ渡し
        ///作成者:大河内
        ///作成日:2017/3/23
        ///更新者:大河内
        ///更新日:2017/3/23
        ///カラム論理名
        ///</summary>
        public void setSelectItem(int intFrmKind, string strSelectid)
        {
            DataTable dtSelectData;

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            switch (intFrmKind)
            {
            //大分類
            case 1:
                MessageBox.Show("移動前のウィンドウが違います。(大分類)", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            //中分類
            case 2:
                MessageBox.Show("移動前のウィンドウが違います。(大分類)", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            //メーカー
            case 3:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT メーカーコード, メーカー名 FROM メーカー WHERE 削除 = 'N' AND メーカーコード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "M_Maker")
                    {
                        //データを連れてくるため、newをしないこと
                        M_Maker maker = (M_Maker)frm;
                        maker.setMakerCode(dtSelectData);
                        break;
                    }
                }
                break;

            case 5:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT メーカーコード, メーカー名 FROM メーカー WHERE 削除 = 'N' AND メーカーコード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "TanaorosiInput")
                    {
                        //データを連れてくるため、newをしないこと
                        TanaorosiInput tanaorosinput = (TanaorosiInput)frm;
                        tanaorosinput.setMakerCode(dtSelectData);
                        break;
                    }
                }
                break;

            case 6:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT メーカーコード, メーカー名 FROM メーカー WHERE 削除 = 'N' AND メーカーコード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "TanaorosiInput")
                    {
                        //データを連れてくるため、newをしないこと
                        TanaorosiInput tanaorosinput = (TanaorosiInput)frm;
                        tanaorosinput.setMakerEdit(dtSelectData);
                        break;
                    }
                }
                break;

            case 7:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT メーカーコード, メーカー名 FROM メーカー WHERE 削除 = 'N' AND メーカーコード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "ShouhinList")
                    {
                        //データを連れてくるため、newをしないこと
                        ShouhinList shouhinlist = (ShouhinList)frm;
                        shouhinlist.setMakerCode(dtSelectData);
                        break;
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
        // 登録
        public void addShiire(List <string[]> lsInput)
        {
            DBConnective dbconnective = new DBConnective();

            try
            {
                // トランザクション開始
                dbconnective.BeginTrans();

                for (int cnt = 0; cnt < lsInput.Count; cnt++)
                {
                    string[] strs = lsInput[cnt];
                    // 支払消去_PROCを実行
                    dbconnective.ReadSql("支払消去2_PROC '" + strs[0] + "', '" + strs[1] + "', '" + strs[10] + "'");

                    string strProc = "支払追加2_PROC '" + strs[0] + "', '" + strs[1] + "', '" +
                                     strs[2] + "', '" + strs[3] + "', '" + strs[4] + "', '" +
                                     strs[5] + "', ";

                    // 支払期日がない場合
                    if (strs[6].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[6] + "', ";
                    }

                    // 備考がない場合
                    if (strs[7].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[7] + "', ";
                    }

                    if (strs[8].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[8] + "', ";
                    }

                    if (strs[9].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[9] + "', ";
                    }



                    if (strs[10].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[10] + "', ";
                    }

                    if (strs[11].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[11] + "', ";
                    }

                    if (strs[12].Equals(""))
                    {
                        strProc += "NULL, ";
                    }
                    else
                    {
                        strProc += "'" + strs[12] + "', ";
                    }

                    strProc += "'" + strs[13] + "',";

                    strProc += "'" + strs[14] + "'";

                    // 支払追加_PROCを実行
                    dbconnective.ReadSql(strProc);
                }
                // コミット
                dbconnective.Commit();
            }
            catch (Exception ex)
            {
                // ロールバック処理
                dbconnective.Rollback();
                //new CommonException(ex);
                throw;
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 4
0
        ///<summary>
        ///setMOshoki
        ///データの数確認とMOデータの初期更新
        ///</summary>
        public void setMOshoki(List <string> lstString)
        {
            //SQLファイルのパスとファイル名を入れる用
            List <string> lstSQL = new List <string>();

            //SQLファイルのパス用(フォーマット後)
            string strSQLInput = "";

            //SQLファイルのパスとファイル名を追加
            lstSQL.Add("B0250_MOnyuryoku");
            lstSQL.Add("MOnyuryoku_SELECT_GetDataCnt");

            //SQL実行時に取り出したデータを入れる用
            DataTable dtSetCd_B = new DataTable();

            //SQL接続
            OpenSQL opensql = new OpenSQL();

            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                //SQLファイルのパス取得
                strSQLInput = opensql.setOpenSQL(lstSQL);

                //パスがなければ返す
                if (strSQLInput == "")
                {
                    return;
                }

                //SQLファイルと該当コードでフォーマット
                strSQLInput = string.Format(strSQLInput, lstString[1], lstString[3], lstString[4], lstString[5]);

                //SQL接続後、該当データを取得
                dtSetCd_B = dbconnective.ReadSql(strSQLInput);

                //既にデータがある場合
                if (dtSetCd_B.Rows[0][0].ToString() == "0")
                {
                    return;
                }

                List <string> lstTableName = new List <string>();
                lstTableName.Add("@在庫年月日");
                lstTableName.Add("@年月");
                lstTableName.Add("@月数");
                lstTableName.Add("@メーカーコード");
                lstTableName.Add("@大分類コード");
                lstTableName.Add("@中分類コード");
                lstTableName.Add("@仕入先コード");
                lstTableName.Add("@ユーザー名");

                List <string> lstDataName = new List <string>();
                lstDataName.Add(lstString[0]);
                lstDataName.Add(lstString[1]);
                lstDataName.Add(lstString[2]);
                lstDataName.Add(lstString[3]);
                lstDataName.Add(lstString[4]);
                lstDataName.Add(lstString[5]);
                lstDataName.Add(lstString[6]);
                lstDataName.Add(lstString[7]);

                //中分類が空の場合
                if (lstDataName[5].Trim() == "")
                {
                    string strSQL = "MOデータ初期更新_PROC '" + lstDataName[0] +
                                    "','" + lstDataName[1] +
                                    "','" + lstDataName[2] +
                                    "','" + lstDataName[3] +
                                    "','" + lstDataName[4] +
                                    "', NULL" +
                                    ",'" + lstDataName[6] +
                                    "','" + lstDataName[7] + "'";
                    dbconnective.RunSql(strSQL);
                }
                else
                {
                    //MOデータ初期更新_PROCを実行
                    dbconnective.RunSqlRe("MOデータ初期更新_PROC", CommandType.StoredProcedure, lstDataName, lstTableName);
                }


                //コミット
                dbconnective.Commit();
            }
            catch
            {
                //ロールバック開始
                dbconnective.Rollback();
                throw;
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 5
0
        ///<summary>
        ///delDaibunrui
        ///テキストボックス内のデータをDBから削除
        ///作成者:大河内
        ///作成日:2017/3/21
        ///更新者:大河内
        ///更新日:2017/4/7
        ///カラム論理名
        ///</summary>
        public bool delDaibunrui(List <string> lstString)
        {
            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            bool blDelFinish = false;

            string strSQLName = null;

            //接続用クラスのインスタンス作成
            DBConnective dbConnective = new DBConnective();

            //トランザクション開始
            dbConnective.BeginTrans();

            strSQLName = "M1010_Daibun_SELECT_Kaburi_DEL";

            //データ渡し用
            lstStringSQL.Add("M1010_Daibunrui");
            lstStringSQL.Add(strSQLName);

            OpenSQL opensql     = new OpenSQL();
            string  strSQLInput = opensql.setOpenSQL(lstStringSQL);

            //配列設定
            string[] strArray = { lstString[0] };

            strSQLInput = string.Format(strSQLInput, strArray);

            lstStringSQL.Clear();

            //検索件数を表示
            int CoverCnt = int.Parse(dbConnective.ReadSql(strSQLInput).Rows[0][0].ToString());

            if (CoverCnt == 0)
            {
                //該当するものが無い、ボタンの機能がない場合
                return(blDelFinish);
            }
            else if (CoverCnt == 1)
            {
                try
                {
                    if (DialogResult.OK == MessageBox.Show("表示中のレコードを削除します。よろしいですか。",
                                                           "削除", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                    {
                        strSQLName = "M1010_Daibun_UPDATE_DELETE";

                        //データ渡し用
                        lstStringSQL.Add("M1010_Daibunrui");
                        lstStringSQL.Add(strSQLName);

                        opensql     = new OpenSQL();
                        strSQLInput = opensql.setOpenSQL(lstStringSQL);

                        //配列初期化、再設定
                        strArray = new string[] { lstString[0], DateTime.Now.ToString(), lstString[1] };

                        strSQLInput = string.Format(strSQLInput, strArray);

                        dbConnective.RunSql(strSQLInput);

                        //コミット開始
                        dbConnective.Commit();

                        MessageBox.Show("正常に削除されました。", "削除", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch
                {
                    //ロールバック開始
                    dbConnective.Rollback();
                }
                finally
                {
                    //closeが入る
                }
            }
            return(blDelFinish);
        }
Exemplo n.º 6
0
        ///<summary>
        ///getShohinView
        ///検索データを記入
        ///</summary>
        public DataTable getShohinView(List <int> lstInt, List <string> lstString, List <Boolean> lstBoolean, Boolean blnZaikoKensaku)
        {
            //SQLファイルのパスとファイル名を入れる用
            List <string> lstSQL = new List <string>();

            //SQLファイルのパス用(フォーマット後)
            string strSQLInput = "";

            //分岐WHERE分用
            string strWhere = "";

            //仮商品かどうかの判定(更新ユーザー名表示時の"見"表示用)
            Boolean blKari = false;

            //本登録データの場合
            if (lstBoolean[2] == true)
            {
                //大分類あり
                if (lstString[0] != "")
                {
                    strWhere = strWhere + " AND 商品.大分類コード = '" + lstString[0] + "'";
                }

                //大分類と中分類共に記入されている場合
                if (lstString[0] != "" && lstString[1] != "")
                {
                    strWhere = strWhere + " AND 商品.中分類コード = '" + lstString[1] + "'";
                }

                //メーカーと大分類あり
                if (lstString[2] != "")
                {
                    strWhere = strWhere + " AND 商品.メーカーコード = '" + lstString[2] + "'";
                }

                //検索文字列と大分類またはメーカーがあり、部分検索の場合
                if (lstString[3] != "" && lstBoolean[1] == true)
                {
                    strWhere = strWhere + " AND REPLACE( ISNULL(商品.C1,''),' ' ,'') LIKE '%" + lstString[3] + "%'";
                }
                //検索文字列と大分類またはメーカーがあり、完全一致検索の場合
                else if (lstString[3] != "" && lstBoolean[1] == false)
                {
                    strWhere = strWhere + " AND REPLACE( ISNULL(商品.C1,''),' ' ,'') LIKE '" + lstString[3] + "'";
                }
                else
                {
                    strWhere = strWhere + "";
                }

                //副番と大分類またはメーカーがあり、部分検索の場合
                if (lstString[4] != "" && lstBoolean[1] == true)
                {
                    strWhere = strWhere + " AND REPLACE((ISNULL(商品.C2, '') + ISNULL(商品.C3, '') + ISNULL(商品.C4, '') + ISNULL(商品.C5, '') + ISNULL(商品.C6, '') ),' ' ,'') LIKE '%" + lstString[4] + "%'";
                }
                //副番と大分類またはメーカーがあり、完全一致検索の場合
                else if (lstString[4] != "" && lstBoolean[1] == false)
                {
                    strWhere = strWhere + " AND REPLACE((ISNULL(商品.C2, '') + ISNULL(商品.C3, '') + ISNULL(商品.C4, '') + ISNULL(商品.C5, '') + ISNULL(商品.C6, '') ),' ' ,'') LIKE '" + lstString[4] + "'";
                }
                else
                {
                    strWhere = strWhere + "";
                }

                //未登録棚の場合
                if (lstBoolean[0] == true)
                {
                    strWhere = strWhere + "AND  (";
                    strWhere = strWhere + " ((SELECT 棚番名 FROM 棚番 WHERE 商品.棚番本社=棚番.棚番)  IS NULL)";
                    strWhere = strWhere + " OR ((SELECT 棚番名 FROM 棚番 WHERE 商品.棚番岐阜=棚番.棚番)  IS NULL)";
                    strWhere = strWhere + " )";
                }

                //SQLファイルのパスとファイル名を追加
                lstSQL.Add("Common");
                lstSQL.Add("CommonForm");
                lstSQL.Add("ShohinList_View");

                blKari = false;
            }
            //仮登録データの場合
            else
            {
                //大分類あり
                if (lstString[0] != "")
                {
                    strWhere = strWhere + " AND 仮商品.大分類コード = '" + lstString[0] + "'";
                }

                //大分類と中分類共に記入されている場合
                if (lstString[0] != "" && lstString[1] != "")
                {
                    strWhere = strWhere + " AND 仮商品.中分類コード = '" + lstString[1] + "'";
                }

                //メーカーと大分類あり
                if (lstString[2] != "")
                {
                    strWhere = strWhere + " AND 仮商品.メーカーコード = '" + lstString[2] + "'";
                }

                //検索文字列と大分類またはメーカーがあり、部分検索の場合
                if (lstString[3] != "" && lstBoolean[1] == true)
                {
                    strWhere = strWhere + " AND REPLACE( ISNULL(仮商品.C1,''),' ' ,'') LIKE '%" + lstString[3] + "%'";
                }
                //検索文字列と大分類またはメーカーがあり、完全一致検索の場合
                else if (lstString[3] != "" && lstBoolean[1] == false)
                {
                    strWhere = strWhere + " AND REPLACE( ISNULL(仮商品.C1,''),' ' ,'') LIKE '" + lstString[3] + "'";
                }
                else
                {
                    strWhere = strWhere + "";
                }

                //副番と大分類またはメーカーがあり、部分検索の場合
                if (lstString[4] != "" && lstBoolean[1] == true)
                {
                    strWhere = strWhere + " AND REPLACE((ISNULL(仮商品.C2, '') + ISNULL(仮商品.C3, '') + ISNULL(仮商品.C4, '') + ISNULL(仮商品.C5, '') + ISNULL(仮商品.C6, '') ),' ' ,'') LIKE '%" + lstString[4].Replace(" ", "") + "%'";
                }
                //副番と大分類またはメーカーがあり、完全一致検索の場合
                else if (lstString[4] != "" && lstBoolean[1] == false)
                {
                    strWhere = strWhere + " AND REPLACE((ISNULL(仮商品.C2, '') + ISNULL(仮商品.C3, '') + ISNULL(仮商品.C4, '') + ISNULL(仮商品.C5, '') + ISNULL(仮商品.C6, '') ),' ' ,'') LIKE '" + lstString[4].Replace(" ", "") + "'";
                }
                else
                {
                    strWhere = strWhere + "";
                }

                //未登録棚の場合
                if (lstBoolean[0] == true)
                {
                    strWhere = strWhere + "AND  (";
                    strWhere = strWhere + " ((SELECT 棚番名 FROM 棚番 WHERE 商品.棚番本社=棚番.棚番)  IS NULL)";
                    strWhere = strWhere + " OR ((SELECT 棚番名 FROM 棚番 WHERE 商品.棚番岐阜=棚番.棚番)  IS NULL)";
                    strWhere = strWhere + " )";
                }

                strWhere += " ORDER BY 見積, 仮商品.商品コード, 仮商品.登録日時";

                //SQLファイルのパスとファイル名を追加
                lstSQL.Add("Common");
                lstSQL.Add("CommonForm");
                lstSQL.Add("ShohinList_View_Kari");

                blKari = true;
            }

            //SQL接続
            OpenSQL opensql = new OpenSQL();

            //SQL用に移動
            DBConnective dbConnective = new DBConnective();

            //商品テーブルから取り出すデータ
            DataTable dtShohin = new DataTable();

            try
            {
                //SQLファイルのパス取得
                strSQLInput = opensql.setOpenSQL(lstSQL);

                //パスがなければ返す
                if (strSQLInput == "")
                {
                    return(dtShohin);
                }

                //SQLファイルと該当コードでフォーマット
                strSQLInput = string.Format(strSQLInput, strWhere, lstString[4]);

                //SQL発行
                dtShohin = dbConnective.ReadSql(strSQLInput);

                //データがあった場合
                if (dtShohin.Rows.Count > 0)
                {
                    //掛け率のカラム追加
                    dtShohin.Columns.Add("掛率", Type.GetType("System.String"));
                    DataRow drInsert = dtShohin.NewRow();
                    drInsert["掛率"] = "";

                    for (int intShohinCnt = 0; intShohinCnt < dtShohin.Rows.Count; intShohinCnt++)
                    {
                        //本社在庫が空でない時
                        if (dtShohin.Rows[intShohinCnt]["本社在庫"].ToString() != "")
                        {
                            //本社在庫が0の時
                            if (decimal.Parse(dtShohin.Rows[intShohinCnt]["本社在庫"].ToString()) == 0)
                            {
                                dtShohin.Rows[intShohinCnt]["本社在庫"] = DBNull.Value;
                            }
                        }

                        //本社フリーが空でない時
                        if (dtShohin.Rows[intShohinCnt]["本社フリー"].ToString() != "")
                        {
                            //本社フリーが0の時
                            if (decimal.Parse(dtShohin.Rows[intShohinCnt]["本社フリー"].ToString()) == 0)
                            {
                                dtShohin.Rows[intShohinCnt]["本社フリー"] = DBNull.Value;
                            }
                        }

                        //岐阜在庫が空でない時
                        if (dtShohin.Rows[intShohinCnt]["岐阜在庫"].ToString() != "")
                        {
                            //岐阜在庫が0の時
                            if (decimal.Parse(dtShohin.Rows[intShohinCnt]["岐阜在庫"].ToString()) == 0)
                            {
                                dtShohin.Rows[intShohinCnt]["岐阜在庫"] = DBNull.Value;
                            }
                        }

                        //岐阜フリーが空でない時
                        if (dtShohin.Rows[intShohinCnt]["岐阜フリー"].ToString() != "")
                        {
                            //岐阜フリーが0の時
                            if (decimal.Parse(dtShohin.Rows[intShohinCnt]["岐阜フリー"].ToString()) == 0)
                            {
                                dtShohin.Rows[intShohinCnt]["岐阜フリー"] = DBNull.Value;
                            }
                        }

                        //定価を取り出す
                        string strTeika = string.Format("{0:#,0}", decimal.Parse(dtShohin.Rows[intShohinCnt]["定価"].ToString()));
                        //仕入単価を取り出す
                        string strShireTanka = string.Format("{0:#,0.00}", decimal.Parse(dtShohin.Rows[intShohinCnt]["仕入単価"].ToString()));

                        //仕入単価と定価が同じになる場合
                        if (strShireTanka == "0.00" || strTeika == "0")
                        {
                            //掛率を挿入
                            dtShohin.Rows[intShohinCnt]["掛率"] = "0";
                        }
                        else
                        {
                            //掛率を挿入
                            dtShohin.Rows[intShohinCnt]["掛率"] = ((decimal)(decimal.Parse(strShireTanka) / decimal.Parse(strTeika)) * 100).ToString("#.0");
                        }

                        //定価を挿入
                        dtShohin.Rows[intShohinCnt]["定価"] = strTeika;

                        //仕入単価を挿入
                        dtShohin.Rows[intShohinCnt]["仕入単価"] = strShireTanka;

                        //仮登録データの場合
                        if (blKari == true)
                        {
                            //棚番本社に記載がない場合(見積もり入力からの仮商品登録)
                            if (dtShohin.Rows[intShohinCnt]["棚番本社"].ToString().Trim() == "")
                            {
                                dtShohin.Rows[intShohinCnt]["メモ"] = "見 " + dtShohin.Rows[intShohinCnt]["メモ"].ToString();
                            }
                            else
                            {
                                dtShohin.Rows[intShohinCnt]["メモ"] = "   " + dtShohin.Rows[intShohinCnt]["メモ"].ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                new CommonException(ex);
                throw (ex);
            }
            return(dtShohin);
        }
Exemplo n.º 7
0
        ///<summary>
        ///setGridKataban2
        ///下段グリッドビューの表示
        ///</summary>
        public DataTable setGridKataban2(List <string> lstStringViewData)
        {
            //SQL実行時に取り出したデータを入れる用(グリッドデータ取り出しに必要なデータ用)
            DataTable dtChuban = new DataTable();

            //SQL実行時に取り出したデータを入れる用(グリッド取り出し用)
            DataTable dtKataban = new DataTable();

            //SQLファイルのパスとファイル名を入れる用(グリッドデータ取り出しに必要なデータ用)
            List <string> lstSQLChuban = new List <string>();

            //SQLファイルのパスとファイル名を入れる用(グリッドデータ取り出し用)
            List <string> lstSQLKataban2 = new List <string>();

            //中分類コード用SQL
            string strSQLChubun = "";

            //中分類コードがある場合
            if (!string.IsNullOrWhiteSpace(lstStringViewData[3].ToString().Trim()))
            {
                strSQLChubun = "AND MO.中分類コード= '" + lstStringViewData[3] + "'";
            }

            //マイナスの型番にチェックされている場合
            if (lstStringViewData[4].Equals("Minus"))
            {
                //lstStringViewData[6]
                lstStringViewData.Add(" AND (現在在庫数 + 発注残数量 - (売上数量 * " + lstStringViewData[5] + ")) < 0");
            }
            else
            {
                lstStringViewData.Add("");
            }

            //SQLファイルのパス用(フォーマット後)
            string strSQLInputChuban = "";
            string strSQLInputKata2  = "";

            //SQLファイルのパスとファイル名を追加
            lstSQLChuban.Add("B0250_MOnyuryoku");
            lstSQLChuban.Add("MOnyuryoku_SELECT_Chuban");

            lstSQLKataban2.Add("B0250_MOnyuryoku");
            lstSQLKataban2.Add("MOnyuryoku_SELECT_GetDataKataban2");

            //SQL発行
            OpenSQL opensql = new OpenSQL();

            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                //SQLファイルのパス取得
                strSQLInputChuban = opensql.setOpenSQL(lstSQLChuban);

                //パスがなければ返す
                if (strSQLInputChuban == "")
                {
                    return(dtKataban);
                }

                //データ取得(ここから取得)
                dtChuban = dbconnective.ReadSql(strSQLInputChuban);

                //取り出しデータが空白込みでデータがある場合
                if (dtChuban.Rows.Count > 0)
                {
                    //データが空白の場合
                    if (dtChuban.Rows[0]["注番文字"].ToString() == "")
                    {
                        return(dtKataban);
                    }
                }

                //SQLファイルのパス取得
                strSQLInputKata2 = opensql.setOpenSQL(lstSQLKataban2);

                //パスがなければ返す
                if (strSQLInputKata2 == "")
                {
                    return(dtKataban);
                }

                //SQLファイルと該当コードでフォーマット
                strSQLInputKata2 = string.Format(strSQLInputKata2,
                                                 lstStringViewData[0],               //年月度
                                                 lstStringViewData[1],               //メーカーコード
                                                 lstStringViewData[2],               //大分類コード
                                                 strSQLChubun,                       //中分類コード
                                                 lstStringViewData[6],               //マイナス型番にチェックされてる場合の追加WHERE
                                                 dtChuban.Rows[0]["注番文字"].ToString() //注番文字
                                                 );

                //データ取得(ここから取得)
                dtKataban = dbconnective.ReadSql(strSQLInputKata2);
            }
            catch (Exception ex)
            {
                //ロールバック開始
                dbconnective.Rollback();
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
            return(dtKataban);
        }
Exemplo n.º 8
0
        ///<summary>
        ///getDataKaburi
        ///商品テーブルから同じ品名・型番のデータを取得
        ///</summary>
        public DataTable getDataKaburi(List <string> lstString)
        {
            //SQL実行時に取り出したデータを入れる用
            DataTable dtKataban = new DataTable();

            //SQLファイルのパスとファイル名を入れる用
            List <string> lstSQLShohin = new List <string>();

            //SQLファイルのパス用(フォーマット後)
            string strSQLInput = "";
            string strSQLOther = "";

            strSQLOther = strSQLOther + "AND C1 = '" + lstString[4] + "'";

            //C2がある場合
            if (StringUtl.blIsEmpty(lstString[5].ToString()))
            {
                strSQLOther = strSQLOther + "AND C2 = '" + lstString[5] + "'";
            }

            //C3がある場合
            if (StringUtl.blIsEmpty(lstString[6].ToString()))
            {
                strSQLOther = strSQLOther + "AND C3 = '" + lstString[6] + "'";
            }

            //C4がある場合
            if (StringUtl.blIsEmpty(lstString[7].ToString()))
            {
                strSQLOther = strSQLOther + "AND C4 = '" + lstString[7] + "'";
            }

            //C5がある場合
            if (StringUtl.blIsEmpty(lstString[8].ToString()))
            {
                strSQLOther = strSQLOther + "AND C5 = '" + lstString[8] + "'";
            }

            //C6がある場合
            if (StringUtl.blIsEmpty(lstString[9].ToString()))
            {
                strSQLOther = strSQLOther + "AND C6 = '" + lstString[9] + "'";
            }

            //メーカーコードがある場合
            if (StringUtl.blIsEmpty(lstString[1].ToString()))
            {
                strSQLOther = strSQLOther + "AND メーカーコード = '" + lstString[1] + "'";
            }

            //SQLファイルのパスとファイル名を追加
            lstSQLShohin.Add("M1030_Shohin");
            lstSQLShohin.Add("Shohin_Data_Kaburi_SELECT");

            //SQL発行
            OpenSQL opensql = new OpenSQL();

            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                //SQLファイルのパス取得(商品テーブル)
                strSQLInput = opensql.setOpenSQL(lstSQLShohin);

                //パスがなければ返す
                if (strSQLInput == "")
                {
                    return(dtKataban);
                }

                //SQLファイルと該当コードでフォーマット
                strSQLInput = string.Format(strSQLInput,
                                            strSQLOther
                                            );

                //データ取得(ここから取得)
                dtKataban = dbconnective.ReadSql(strSQLInput);

                return(dtKataban);
            }
            catch (Exception ex)
            {
                //ロールバック開始
                dbconnective.Rollback();
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
        }
        /// <summary>
        /// getRiekiritsuList
        /// 商品分類別利益率を取得
        /// </summary>
        public DataTable getRiekiritsuList(List <string> lstSearchItem, List <string> lstSerachOrder)
        {
            string    strSql;
            DataTable dtGetTableGrid = new DataTable();

            strSql  = "SELECT d.得意先コード,";
            strSql += "dbo.f_get取引先名称(d.得意先コード) AS 得意先名,";
            strSql += "RTRIM(dbo.f_get大分類名(d.大分類コード)) AS 大分類,";
            strSql += "RTRIM(dbo.f_get中分類名(d.大分類コード,d.中分類コード)) AS 中分類,";
            strSql += "RTRIM(dbo.f_getメーカー名(d.メーカーコード)) AS メーカー,";
            strSql += "d.利益率 ,";
            strSql += "d.掛率 ,";
            strSql += "'  ' + d.設定 AS 設定,";
            strSql += "d.大分類コード,";
            strSql += "d.中分類コード,";
            strSql += "d.メーカーコード,";
            strSql += "d.ID";

            strSql += " FROM 商品分類別利益率 d ";
            strSql += " WHERE ";

            strSql += " d.削除='N' ";

            // 得意先コードがある場合
            if (!lstSearchItem[0].Equals(""))
            {
                strSql += " AND d.得意先コード='" + lstSearchItem[0] + "'";
            }

            // 担当者コードがある場合
            if (!lstSearchItem[1].Equals(""))
            {
                strSql += " AND dbo.f_get担当者コード(d.得意先コード)='" + lstSearchItem[1] + "'";
            }

            // 大分類コードがある場合
            if (!lstSearchItem[2].Equals(""))
            {
                strSql += " AND d.大分類コード='" + lstSearchItem[2] + "'";
            }

            // 中分類コードがある場合
            if (!lstSearchItem[3].Equals(""))
            {
                strSql += " AND d.中分類コード='" + lstSearchItem[3] + "'";
            }

            // メーカーがある場合
            if (!lstSearchItem[4].Equals(""))
            {
                strSql += " AND d.メーカーコード='" + lstSearchItem[4] + "'";
            }

            DBConnective dbconnective = new DBConnective();

            try
            {
                // 検索データをテーブルへ格納
                dtGetTableGrid = dbconnective.ReadSql(strSql);

                return(dtGetTableGrid);
            }
            catch
            {
                throw;
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 10
0
        ///<summary>
        ///addShohin
        ///テキストボックス内のデータをDBに登録
        ///</summary>
        public void addShohin(List <string> lstString, Boolean blnKanri)
        {
            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            //トランザクション開始
            dbconnective.BeginTrans();
            try
            {
                string[] aryStr = new string[] {
                    lstString[0],                    //商品コード
                    lstString[1],                    //メーカーコード
                    lstString[2],                    //大分類コード
                    lstString[3],                    //中分類コード
                    lstString[4],                    //C1
                    lstString[5],                    //C2
                    lstString[6],                    //C3
                    lstString[7],                    //C4
                    lstString[8],                    //C5
                    lstString[9],                    //C6
                    "",                              //発注区分
                    lstString[10],                   //標準売価
                    lstString[11],                   //仕入単価
                    lstString[12],                   //在庫管理区分
                    lstString[13],                   //棚番本社
                    lstString[14],                   //棚番岐阜
                    lstString[15],                   //メモ
                    lstString[16],                   //評価単価
                    lstString[17],                   //定価
                    lstString[18],                   //箱入数
                    lstString[19],                   //建値仕入単価
                    lstString[20],                   //コメント
                    "N",                             //削除
                    DateTime.Now.ToString(),         //登録日時
                    lstString[21],                   //登録ユーザー名
                    DateTime.Now.ToString(),         //更新日時
                    lstString[21]                    //更新ユーザー名
                };

                //マスタ権限の場合
                if (blnKanri == true)
                {
                    dbconnective.RunSqlCommon(CommonTeisu.C_SQL_SHOHIN_UPD, aryStr);

                    //SQL実行時に取り出したデータを入れる用
                    DataTable dtTantoshaCd = new DataTable();

                    //SQLファイルのパスとファイル名を入れる用
                    List <string> lstSQLKariSelect = new List <string>();
                    List <string> lstSQLKariUpdate = new List <string>();

                    //SQLファイルのパス用(フォーマット後)
                    string strSQLInput = "";

                    //SQLファイルのパスとファイル名を追加
                    lstSQLKariSelect.Add("M1030_Shohin");
                    lstSQLKariSelect.Add("Shohin_DataKari_ShohinCd_SELECT");

                    //SQLファイルのパスとファイル名を追加
                    lstSQLKariUpdate.Add("M1030_Shohin");
                    lstSQLKariUpdate.Add("Shohin_KariToroku_UPDATE");

                    //SQL発行
                    OpenSQL opensql = new OpenSQL();

                    //SQLファイルのパス取得
                    strSQLInput = opensql.setOpenSQL(lstSQLKariSelect);

                    //パスがなければ返す
                    if (strSQLInput == "")
                    {
                        return;
                    }

                    //SQLファイルと該当コードでフォーマット
                    strSQLInput = string.Format(strSQLInput,
                                                lstString[22]   //テキスト商品コード
                                                );

                    //仮商品データの存在確認
                    dtTantoshaCd = dbconnective.ReadSql(strSQLInput);

                    //データの存在確認
                    if (dtTantoshaCd.Rows.Count > 0)
                    {
                        //SQLファイルのパス取得
                        strSQLInput = opensql.setOpenSQL(lstSQLKariUpdate);

                        //パスがなければ返す
                        if (strSQLInput == "")
                        {
                            return;
                        }

                        //SQLファイルと該当コードでフォーマット
                        strSQLInput = string.Format(strSQLInput,
                                                    dtTantoshaCd.Rows[0][0]   //仮商品の商品コード
                                                    );

                        //仮商品データ更新(削除フラグを立てる)
                        dbconnective.RunSql(strSQLInput);
                    }
                }
                else
                {
                    dbconnective.RunSqlCommon(CommonTeisu.C_SQL_SHOHIN_KARI_UPD, aryStr);
                }

                dbconnective.Commit();
            }
            catch (Exception ex)
            {
                //ロールバック開始
                dbconnective.Rollback();

                new CommonException(ex);
                throw (ex);
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 11
0
        ///<summary>
        ///getNewShohinNo
        ///商品番号の取得
        ///</summary>
        public string getNewShohinNo(Boolean blnKanri)
        {
            //出力する伝票番号
            string strGetDenpyo = "";

            //伝票番号取得用のPROC用
            object objDummy     = 0;
            object objReturnval = "";

            //新規商品コードを入れる用
            string strCdHEAD  = "";
            string strCdHEAD2 = "";
            //新規伝票番号を入れる用
            string strDenNo  = "";
            string strDenNo2 = "";

            //伝票番号PROCより確保した頭文字以外の伝票番号
            int intGetNo = 0;

            //SQLファイルのパスとファイル名を入れる用
            List <string> lstSQL = new List <string>();

            //SQLファイルのパス用(フォーマット後)
            string strSQLInput = "";

            //SQL実行時に取り出したデータを入れる用
            DataTable dtSetCd_B = new DataTable();

            //SQL接続
            OpenSQL opensql = new OpenSQL();

            //商品マスターの場合
            if (blnKanri == true)
            {
                //SQLファイルのパスとファイル名を追加
                lstSQL.Add("M1030_Shohin");
                lstSQL.Add("Shohin_CdMAX_SELECT");


                //伝票番号取得用(名前)
                List <String> lstGetDenpyoNoName = new List <string>();

                //伝票番号取得用(データ)
                List <string> lstSearchData = new List <string>();

                lstGetDenpyoNoName.Add("@テーブル名");

                //SQL用に移動
                DBConnective dbconnective = new DBConnective();
                try
                {
                    //SQLファイルのパス取得
                    strSQLInput = opensql.setOpenSQL(lstSQL);

                    //パスがなければ返す
                    if (strSQLInput == "")
                    {
                        return(strGetDenpyo);
                    }

                    //SQL接続後、該当データを取得
                    dtSetCd_B = dbconnective.ReadSql(strSQLInput);

                    //データの中身がない場合
                    if (dtSetCd_B.Rows[0][0].ToString() == "")
                    {
                        return(strGetDenpyo);
                    }

                    strCdHEAD = dtSetCd_B.Rows[0][0].ToString().Substring(0, 1);

                    //頭文字によって動作を変える
                    switch (strCdHEAD)
                    {
                    case "A":
                        strCdHEAD2 = "B";
                        strDenNo   = "商品コード2";
                        strDenNo2  = "商品コード3";
                        break;

                    case "B":
                        strCdHEAD2 = "C";
                        strDenNo   = "商品コード3";
                        strDenNo2  = "商品コード4";
                        break;

                    case "C":
                        strCdHEAD2 = "D";
                        strDenNo   = "商品コード4";
                        strDenNo2  = "商品コード5";
                        break;

                    case "D":
                        strCdHEAD2 = "E";
                        strDenNo   = "商品コード5";
                        strDenNo2  = "商品コード6";
                        break;

                    case "E":
                        strCdHEAD2 = "F";
                        strDenNo   = "商品コード6";
                        strDenNo2  = "商品コード7";
                        break;

                    case "F":
                        strCdHEAD2 = "G";
                        strDenNo   = "商品コード7";
                        strDenNo2  = "商品コード8";
                        break;

                    case "G":
                        strCdHEAD2 = "H";
                        strDenNo   = "商品コード8";
                        strDenNo2  = "商品コード9";
                        break;

                    case "H":
                        strCdHEAD2 = "I";
                        strDenNo   = "商品コード9";
                        strDenNo2  = "商品コード10";
                        break;

                    case "I":
                        strCdHEAD2 = "J";
                        strDenNo   = "商品コード10";
                        strDenNo2  = "商品コード11";
                        break;

                    case "J":
                        strCdHEAD2 = "K";
                        strDenNo   = "商品コード11";
                        strDenNo2  = "商品コード12";
                        break;

                    case "K":
                        strCdHEAD2 = "L";
                        strDenNo   = "商品コード12";
                        strDenNo2  = "商品コード13";
                        break;

                    case "L":
                        strCdHEAD2 = "M";
                        strDenNo   = "商品コード13";
                        strDenNo2  = "商品コード14";
                        break;

                    case "M":
                        strCdHEAD2 = "N";
                        strDenNo   = "商品コード14";
                        strDenNo2  = "商品コード15";
                        break;

                    case "N":
                        strCdHEAD2 = "O";
                        strDenNo   = "商品コード15";
                        strDenNo2  = "商品コード16";
                        break;

                    case "O":
                        strCdHEAD2 = "P";
                        strDenNo   = "商品コード16";
                        strDenNo2  = "商品コード17";
                        break;

                    case "P":
                        strCdHEAD2 = "Q";
                        strDenNo   = "商品コード17";
                        strDenNo2  = "商品コード18";
                        break;

                    case "Q":
                        strCdHEAD2 = "R";
                        strDenNo   = "商品コード18";
                        strDenNo2  = "商品コード19";
                        break;

                    case "R":
                        strCdHEAD2 = "S";
                        strDenNo   = "商品コード19";
                        strDenNo2  = "商品コード20";
                        break;

                    case "S":
                        strCdHEAD2 = "T";
                        strDenNo   = "商品コード20";
                        strDenNo2  = "商品コード21";
                        break;

                    case "T":
                        strCdHEAD2 = "U";
                        strDenNo   = "商品コード21";
                        strDenNo2  = "商品コード22";
                        break;

                    case "U":
                        strCdHEAD2 = "V";
                        strDenNo   = "商品コード22";
                        strDenNo2  = "商品コード23";
                        break;

                    case "V":
                        strCdHEAD2 = "W";
                        strDenNo   = "商品コード23";
                        strDenNo2  = "商品コード24";
                        break;

                    case "W":
                        strCdHEAD2 = "X";
                        strDenNo   = "商品コード24";
                        strDenNo2  = "商品コード25";
                        break;

                    case "X":
                        strCdHEAD2 = "B";
                        strDenNo   = "商品コード25";
                        strDenNo2  = "商品コード26";
                        break;

                    case "Y":
                        strCdHEAD2 = "B";
                        strDenNo   = "商品コード26";
                        strDenNo2  = "商品コード27";
                        break;

                    case "Z":
                        strGetDenpyo = "0";
                        break;
                    }

                    //頭文字がZの場合
                    if (strGetDenpyo == "0")
                    {
                        return(strGetDenpyo);
                    }

                    DataTable dt = dbconnective.ReadSql("select 最終番号 FROM 伝票番号 where テーブル名 = '" + strDenNo + "'");

                    if (dt == null || dt.Rows.Count == 0)
                    {
                        return(strGetDenpyo);
                    }
                    int num = int.Parse(dtSetCd_B.Rows[0][0].ToString().Substring(1));
                    num = int.Parse(dt.Rows[0][0].ToString());

                    //頭文字以降の数値が9999以上の場合
                    //if (int.Parse(dtSetCd_B.Rows[0][0].ToString().Substring(1)) >= 9999)
                    if (num >= 9999)
                    {
                        strCdHEAD = strCdHEAD2;
                        strDenNo  = strDenNo2;
                    }

                    lstSearchData.Add(strDenNo);

                    //伝票番号の最新を取得
                    intGetNo = int.Parse(dbconnective.RunSqlRe("get伝票番号_PROC", CommandType.StoredProcedure, lstSearchData, lstGetDenpyoNoName, "@番号"));

                    //0パディングと頭文字を追加
                    strGetDenpyo = strCdHEAD + string.Format("{0:0000}", intGetNo);
                }
                catch (Exception ex)
                {
                    new CommonException(ex);
                    throw (ex);
                }
                finally
                {
                    dbconnective.DB_Disconnect();
                }
            }
            //商品マスタではない場合
            else
            {
                //伝票番号取得用(名前)
                List <String> lstGetDenpyoNoName = new List <string>();

                //伝票番号取得用(データ)
                List <string> lstSearchData = new List <string>();

                lstGetDenpyoNoName.Add("@テーブル名");

                //SQL用に移動
                DBConnective dbconnective = new DBConnective();
                try
                {
                    lstSearchData.Add("仮商品コード");

                    //伝票番号の最新を取得
                    intGetNo = int.Parse(dbconnective.RunSqlRe("get伝票番号_PROC", CommandType.StoredProcedure, lstSearchData, lstGetDenpyoNoName, "@番号"));

                    //0パディングと頭文字を追加
                    strGetDenpyo = string.Format("{0:00000000}", intGetNo);
                }
                catch (Exception ex)
                {
                    new CommonException(ex);
                    throw (ex);
                }
                finally
                {
                    dbconnective.DB_Disconnect();
                }
            }

            return(strGetDenpyo);
        }
Exemplo n.º 12
0
        ///<summary>
        ///setViewGrid
        ///Gridを表示させる
        ///作成者:大河内
        ///作成日:2017/3/28
        ///更新者:大河内
        ///更新日:2017/4/10
        ///カラム論理名
        ///</summary>
        public DataTable setViewGrid(List <string> lstString)
        {
            DataTable dtView = new DataTable();

            string strSQLInput = null;

            //初期化
            strSQLInput = "";

            string strSQLName = null;

            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            strSQLName = "Tanaorosi_SELECT_SetDataGridView";

            //データ渡し用
            lstStringSQL.Add(strSQLName);

            OpenSQL opensql = new OpenSQL();

            strSQLInput = opensql.setOpenSQL(lstStringSQL);

            if (lstString[3] != "")
            {
                strSQLInput = strSQLInput + " AND 中分類コード='" + lstString[2] + "'";
            }
            if (lstString[4] != "")
            {
                strSQLInput = strSQLInput + " AND 棚番='" + lstString[3] + "'";
            }
            if (lstString[5] != "")
            {
                strSQLInput = strSQLInput + " AND メーカーコード='" + lstString[4] + "'";
            }
            if (lstString[6] == "1")
            {
                strSQLInput = strSQLInput + " ORDER BY 品名型番";
            }
            if (lstString[6] == "2")
            {
                strSQLInput = strSQLInput + " ORDER BY メーカー名,品名型番";
            }
            if (lstString[6] == "3")
            {
                strSQLInput = strSQLInput + " ORDER BY 棚番,メーカー名,品名型番";
            }
            if (lstString[6] == "4")
            {
                strSQLInput = strSQLInput + " ORDER BY 棚番,品名型番";
            }

            //配列設定
            string[] strArray = { lstString[0], lstString[1], lstString[2], lstString[3], lstString[4], lstString[5] };

            strSQLInput = string.Format(strSQLInput, strArray);

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            dtView = dbconnective.ReadSql(strSQLInput);

            return(dtView);
        }
Exemplo n.º 13
0
        ///<summary>
        ///txtGridViewLieave
        ///code入力箇所からフォーカスが外れた時(Grid表示関係)
        ///作成者:大河内
        ///作成日:2017/3/14
        ///更新者:大河内
        ///更新日:2017/4/10
        ///カラム論理名
        ///</summary>
        public DataTable txtGridViewLieave(int intDBjud, List <string> lstString)
        {
            //テキストボックスのデータを確保
            string strTextCase = "";

            string strSQLName = null;

            string strSQLInput = null;

            string[] strArray = new string[] { };

            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetcode_B = new DataTable();

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            //どこのDBを参照するか
            switch (intDBjud)
            {
            case 1:    //営業所
                if (lstString[0] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[0].Length <= 3)
                {
                    strTextCase = lstString[0].ToString().PadLeft(4, '0');
                }
                else
                {
                    strTextCase = lstString[0];
                }

                strSQLName = "EigyoushoList_SELECT_DataView";

                //データ渡し用
                lstStringSQL.Add(strSQLName);

                OpenSQL opensql = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            case 2:    //大分類

                if (lstString[1] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[1].Length == 1)
                {
                    strTextCase = lstString[1].ToString().PadLeft(2, '0');
                }
                else
                {
                    strTextCase = lstString[1];
                }

                strSQLName = "M1010_Daibun_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("M1010_Daibunrui");
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            case 3:    //中分類
                if (lstString[2] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[2].Length == 1)
                {
                    strTextCase = lstString[2].ToString().PadLeft(2, '0');
                }
                else
                {
                    strTextCase = lstString[2];
                }

                strSQLName = "M1110_Chubun_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("M1110_Chubunrui");
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { lstString[1], strTextCase };
                break;

            case 4:    //メーカー
                if (lstString[3] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[3].Length <= 2)
                {
                    strTextCase = lstString[3].ToString().PadLeft(3, '0');
                }
                else
                {
                    strTextCase = lstString[3];
                }

                strSQLName = "M1020_Maker_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("M1020_Maker");
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            case 5:    //棚番
                if (lstString[4] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[4].Length <= 5)
                {
                    //blnBtnMove = true;
                    return(dtSetcode_B);
                }
                else
                {
                    strTextCase = lstString[4];
                }
                strSQLName = "Tanaban_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            case 6:    //編集中分類
                if (lstString[5] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[5].Length == 1)
                {
                    strTextCase = lstString[5].ToString().PadLeft(2, '0');
                }
                else
                {
                    strTextCase = lstString[5];
                }
                strSQLName = "M1110_Chubun_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("M1110_Chubunrui");
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { lstString[1], strTextCase };
                break;

            case 7:    //編集メーカー
                if (lstString[6] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[6].Length <= 2)
                {
                    strTextCase = lstString[6].ToString().PadLeft(3, '0');
                }
                else
                {
                    strTextCase = lstString[6];
                }
                strSQLName = "M1020_Maker_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("M1020_Maker");
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            case 8:    //編集棚番
                if (lstString[7] == "")
                {
                    return(dtSetcode_B);
                }
                else if (lstString[7].Length <= 5)
                {
                    return(dtSetcode_B);
                }
                else
                {
                    strTextCase = lstString[7];
                }
                strSQLName = "Tanaban_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add(strSQLName);

                opensql     = new OpenSQL();
                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                strArray = new string[] { strTextCase };
                break;

            default:
                return(dtSetcode_B);
            }

            strSQLInput = string.Format(strSQLInput, strArray);

            //SQL文を直書き(+戻り値を受け取る)
            dtSetcode_B = dbconnective.ReadSql(strSQLInput);

            return(dtSetcode_B);
        }
Exemplo n.º 14
0
        ///<summary>
        /// chkTxtShiresaki
        /// ファンクション機能の仕入先コードエラーチェック処理
        /// 引数 :なし
        /// 戻り値:エラー発生【true】
        ///</summary>
        public bool chkTxtShiresaki()
        {
            // データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetCd;

            Boolean blnGood;

            if (this.CodeTxtText == "" || String.IsNullOrWhiteSpace(this.CodeTxtText).Equals(true))
            {
                this.ValueLabelText  = "";
                this.AppendLabelText = "";
                return(false);
            }

            // 前後の空白を取り除く
            this.CodeTxtText = this.CodeTxtText.Trim();

            // 禁止文字チェック
            if (StringUtl.JudBanSQL(this.CodeTxtText) == false)
            {
                // メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                BaseMessageBox basemessagebox = new BaseMessageBox(Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                basemessagebox.ShowDialog();

                this.ValueLabelText  = "";
                this.AppendLabelText = "";
                this.CodeTxtText     = "";

                return(true);
            }


            // 全角数字を半角数字に変換
            this.CodeTxtText = StringUtl.JudZenToHanNum(this.CodeTxtText);

            // 数値チェック
            if (StringUtl.JudBanSelect(this.CodeTxtText, CommonTeisu.NUMBER_ONLY) == true)
            {
                // 4文字以下の場合0パティング
                if (this.CodeTxtText.Length < 4)
                {
                    this.CodeTxtText = this.CodeTxtText.ToString().PadLeft(4, '0');
                }
            }

            // データ渡し用
            lstStringSQL.Add("Common");
            lstStringSQL.Add("C_LIST_ShiresakiAS400_SELECT_LEAVE");

            OpenSQL opensql = new OpenSQL();

            try
            {
                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                if (strSQLInput == "")
                {
                    return(false);
                }

                strSQLInput = string.Format(strSQLInput, this.CodeTxtText);

                // SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                // SQL文を直書き(+戻り値を受け取る)
                dtSetCd = dbconnective.ReadSql(strSQLInput);

                if (dtSetCd.Rows.Count != 0)
                {
                    this.CodeTxtText    = dtSetCd.Rows[0]["仕入先コード"].ToString();
                    this.ValueLabelText = dtSetCd.Rows[0]["仕入先名"].ToString();
                }
                else
                {
                    // メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_VIEW, CommonTeisu.LABEL_NOTDATA, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();

                    this.ValueLabelText  = "";
                    this.AppendLabelText = "";
                    this.CodeTxtText     = "";

                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                // データロギング
                new CommonException(ex);

                // 例外発生メッセージ(OK)
                BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                basemessagebox.ShowDialog();

                return(true);
            }
        }
        /// <summary>
        /// getUriage
        /// 売上データを取得
        /// </summary>
        public DataTable getUriage(List <string> lstItem)
        {
            DataTable dtUriage = new DataTable();
            string    strSql;
            string    strDate;
            string    strZennenDate;
            DateTime  dt = new DateTime(int.Parse(lstItem[0]), 5, 1);

            string tantoF = "";
            string tantoT = "";

            if (!string.IsNullOrWhiteSpace(lstItem[1]))
            {
                tantoF = lstItem[1];
            }
            if (!string.IsNullOrWhiteSpace(lstItem[2]))
            {
                tantoT = lstItem[2];
            }


            strSql = "SELECT グループコード, グループ名, 担当者コード, 担当者名,";

            for (int cnt = 1; cnt <= 12; cnt++)
            {
                strSql += " 売上額" + cnt.ToString() + ", 粗利額" + cnt.ToString() + ", ";
                strSql += " 前年売上額" + cnt.ToString() + ", 前年粗利額" + cnt.ToString() + ", ";
                strSql += " CASE WHEN 前年粗利額" + cnt.ToString() + " = 0 THEN 0";
                strSql += " ELSE 粗利額" + cnt.ToString() + " / 前年粗利額" + cnt.ToString();
                strSql += " END AS 前年比率" + cnt.ToString() + ",";
            }

            strSql += " 上期売上額, 上期粗利額, 上期前年売上額, 上期前年粗利額,";
            strSql += " CASE WHEN 上期前年粗利額 = 0 THEN 0";
            strSql += " ELSE 上期粗利額 / 上期前年粗利額";
            strSql += " END AS 上期前年比率,";

            strSql += " 下期売上額, 下期粗利額, 下期前年売上額, 下期前年粗利額,";
            strSql += " CASE WHEN 下期前年粗利額 = 0 THEN 0";
            strSql += " ELSE 下期粗利額 / 下期前年粗利額";
            strSql += " END AS 下期前年比率";

            strSql += " FROM";
            strSql += " (SELECT グループコード,";
            strSql += " dbo.f_getグループ名(グループコード) AS グループ名,";
            strSql += " 担当者コード,";
            strSql += " 担当者名,";

            // 5月~12月、翌年の1月~4月
            for (int intMonth = 0; intMonth < 12; intMonth++)
            {
                strDate       = dt.AddMonths(intMonth).ToString("yyyy/MM/dd");
                strZennenDate = dt.AddYears(-1).AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 売上額" + (intMonth + 1).ToString() + ",";
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 前年売上額" + (intMonth + 1).ToString() + ",";
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 粗利額" + (intMonth + 1).ToString() + ",";
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 前年粗利額" + (intMonth + 1).ToString() + ",";
            }

            // 上期売上額合計(5月~10月)
            for (int intMonth = 0; intMonth < 5; intMonth++)
            {
                strDate = dt.AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) +";
            }
            strDate = dt.AddMonths(5).ToString("yyyy/MM/dd");
            strSql += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 上期売上額,";

            // 上期前年売上額合計(5月~10月)
            for (int intMonth = 0; intMonth < 5; intMonth++)
            {
                strZennenDate = dt.AddYears(-1).AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) +";
            }
            strZennenDate = dt.AddYears(-1).AddMonths(5).ToString("yyyy/MM/dd");
            strSql       += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 上期前年売上額,";

            // 上期粗利額合計(5月~10月)
            for (int intMonth = 0; intMonth < 5; intMonth++)
            {
                strDate = dt.AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) +";
            }
            strDate = dt.AddMonths(5).ToString("yyyy/MM/dd");
            strSql += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 上期粗利額,";

            // 上期前年粗利額合計(5月~10月)
            for (int intMonth = 0; intMonth < 5; intMonth++)
            {
                strZennenDate = dt.AddYears(-1).AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) +";
            }
            strZennenDate = dt.AddYears(-1).AddMonths(5).ToString("yyyy/MM/dd");
            strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 上期前年粗利額,";

            // 下期売上額合計(11月~12月、翌年の1月~4月)
            for (int intMonth = 6; intMonth < 11; intMonth++)
            {
                strDate = dt.AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) +";
            }
            strDate = dt.AddMonths(11).ToString("yyyy/MM/dd");
            strSql += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 下期売上額,";

            // 下期前年売上額合計(11月~12月、翌年の1月~4月)
            for (int intMonth = 6; intMonth < 11; intMonth++)
            {
                strDate = dt.AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) +";
            }
            strZennenDate = dt.AddYears(-1).AddMonths(11).ToString("yyyy/MM/dd");
            strSql       += " ROUND(dbo.f_get担当者別売上管理表_売上高_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 下期前年売上額,";

            // 下期粗利額合計(11月~12月、翌年の1月~4月)
            for (int intMonth = 6; intMonth < 11; intMonth++)
            {
                strZennenDate = dt.AddYears(-1).AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) +";
            }
            strDate = dt.AddMonths(11).ToString("yyyy/MM/dd");
            strSql += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strDate + "'), dbo.f_月末日('" + strDate + "')) / 1000, 0) AS 下期粗利額,";

            // 下期前年粗利額合計(11月~12月、翌年の1月~4月)
            for (int intMonth = 6; intMonth < 11; intMonth++)
            {
                strZennenDate = dt.AddYears(-1).AddMonths(intMonth).ToString("yyyy/MM/dd");
                strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) +";
            }
            strZennenDate = dt.AddYears(-1).AddMonths(11).ToString("yyyy/MM/dd");
            strSql       += " ROUND(dbo.f_get担当者別売上管理表_粗利額_売上ヘッダ(担当者コード, dbo.f_月初日('" + strZennenDate + "'), dbo.f_月末日('" + strZennenDate + "')) / 1000, 0) AS 下期前年粗利額";

            strSql += " FROM 担当者";
            strSql += " WHERE 削除 = 'N'";

            if (!string.IsNullOrWhiteSpace(tantoF))
            {
                strSql += " AND 担当者コード >= '" + tantoF + "'";
            }
            if (!string.IsNullOrWhiteSpace(tantoT))
            {
                strSql += " AND 担当者コード <= '" + tantoT + "'";
            }


            strSql += " ) AS Z";
            strSql += " ORDER BY グループコード, 担当者コード";

            DBConnective dbconnective = new DBConnective();

            try
            {
                // 検索データをテーブルへ格納
                dtUriage = dbconnective.ReadSql(strSql);

                return(dtUriage);
            }
            catch
            {
                throw;
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 16
0
        ///<summary>
        ///setSelectItem
        ///各画面へのデータ渡し
        ///作成者:大河内
        ///作成日:2017/3/23
        ///更新者:大河内
        ///更新日:2017/3/23
        ///カラム論理名
        ///</summary>
        public void setSelectItem(int intFrmKind, string strTxtCD, string strSelectid)
        {
            DataTable dtSelectData;

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            //SQL文を直書き(+戻り値を受け取る)
            dtSelectData = dbconnective.ReadSql("SELECT 中分類コード, 中分類名 FROM 中分類 WHERE 削除 = 'N' AND 大分類コード = '" + strTxtCD + "' AND 中分類コード = '" + strSelectid + "'");

            switch (intFrmKind)
            {
            //大分類
            case 1:
                MessageBox.Show("移動前のウィンドウが違います。(大分類)", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            //中分類
            case 2:
                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "M_Chubunrui")
                    {
                        //データを連れてくるため、newをしないこと
                        M_Chubunrui chubunrui = (M_Chubunrui)frm;
                        chubunrui.setChubunrui(dtSelectData);
                        break;
                    }
                }
                break;

            case 5:
                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "TanaorosiInput")
                    {
                        //データを連れてくるため、newをしないこと
                        TanaorosiInput tanaorosinput = (TanaorosiInput)frm;
                        tanaorosinput.setCyubunrui(dtSelectData);
                        break;
                    }
                }
                break;

            case 6:
                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "TanaorosiInput")
                    {
                        //データを連れてくるため、newをしないこと
                        TanaorosiInput tanaorosinput = (TanaorosiInput)frm;
                        tanaorosinput.setChubunEdit(dtSelectData);
                        break;
                    }
                }
                break;

            case 7:
                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name == "ShouhinList")
                    {
                        //データを連れてくるため、newをしないこと
                        ShouhinList shouhinlist = (ShouhinList)frm;
                        shouhinlist.setCyubunrui(dtSelectData);
                        break;
                    }
                }
                break;

            default:
                return;
            }
        }
Exemplo n.º 17
0
        ///<summary>
        ///getLabel
        ///textboxのデータをlabelに記入
        ///</summary>
        public DataTable getLabel(List <string> lstString, List <int> lstint)
        {
            //SQL出力後のデータテーブル
            DataTable dtSetData = null;

            //テキストボックスのデータを確保
            string strTextCase = "";

            //データ渡し用
            List <string> lstStringSQL = new List <string>();
            OpenSQL       opensql      = new OpenSQL();

            //どこのDBを参照するか
            switch (lstint[0])
            {
            case CommonTeisu.FRM_DAIBUNRUI:    //大分類

                if (lstString[0] == "")
                {
                    lstString[0] = "";
                    return(dtSetData);
                }
                else if (lstString[0].Length == 1)
                {
                    lstString[0] = lstString[0].ToString().PadLeft(2, '0');
                }
                else
                {
                    strTextCase = lstString[0];
                }

                strSQLName = "C_LIST_Daibun_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("Common");
                lstStringSQL.Add(strSQLName);

                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                string[] aryStr = { lstString[0] };

                strSQLInput = string.Format(strSQLInput, aryStr);

                //SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetData = dbconnective.ReadSql(strSQLInput);
                break;

            case CommonTeisu.FRM_CHUBUNRUI:    //中分類
                if (lstString[1] == "")
                {
                    lstString[1] = "";
                    return(dtSetData);
                }
                else if (lstString[1].Length == 1)
                {
                    strTextCase = lstString[1].ToString().PadLeft(2, '0');
                }
                else
                {
                    strTextCase = lstString[1];
                }

                strSQLName = "C_LIST_Chubun_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("Common");
                lstStringSQL.Add(strSQLName);

                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                aryStr = new string[] { lstString[0], strTextCase };

                strSQLInput = string.Format(strSQLInput, aryStr);

                //SQLのインスタンス作成
                dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetData = dbconnective.ReadSql(strSQLInput);
                break;

            case CommonTeisu.FRM_MAKER:    //メーカー
                if (lstString[2] == "")
                {
                    lstString[2] = "";
                    return(dtSetData);
                }
                else if (lstString[2].Length <= 2)
                {
                    strTextCase = lstString[2].ToString().PadLeft(3, '0');
                }
                else
                {
                    strTextCase = lstString[2];
                }

                strSQLName = "M1020_Maker_SELECT_LEAVE";

                //データ渡し用
                lstStringSQL.Add("Common");
                lstStringSQL.Add(strSQLName);

                strSQLInput = opensql.setOpenSQL(lstStringSQL);

                //配列設定
                aryStr = new string[] { strTextCase };

                strSQLInput = string.Format(strSQLInput, aryStr);

                //SQLのインスタンス作成
                dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetData = dbconnective.ReadSql(strSQLInput);
                break;

            default:
                return(dtSetData);
            }
            return(dtSetData);
        }
Exemplo n.º 18
0
        /// <summary>
        /// gridに表示する取引先データ取得</summary>
        /// <param name="lstSelectData">
        ///     検索文字列用List</param>
        /// <returns>
        ///     検索結果をDataTableで返す</returns>
        public DataTable getTorihikisaki(List <string> lstSelectData)
        {
            DataTable dt = new DataTable();

            // AND条件用変数
            string andSql = "";

            // DBコネクションのインスタンス生成
            DBConnective dbConnective = new DBConnective();

            try
            {
                // フリガナが入力されている場合
                if (lstSelectData[0] != "")
                {
                    string kana = lstSelectData[0];

                    // 文字列"kana"に含まれる文字がすべて"ひらがな"か調べる
                    // すべてひらがな(true)なら変換
                    if (Regex.IsMatch(kana, @"^[\p{IsHiragana}\u30FC\u30A0]+$"))
                    {
                        // "ひらがな"を"カタカナ"に
                        kana = Strings.StrConv(kana, VbStrConv.Katakana, 0x411);
                    }
                    // 文字列"kana"に含まれる文字がすべて"カタカナ"か調べる
                    // すべてカタカナ(true)なら変換
                    //  通常の全角カタカナの他に、カタカナフリガナ拡張、
                    //  濁点と半濁点、半角カタカナもカタカナとする
                    if (Regex.IsMatch(kana, @"^[\p{IsKatakana}\u31F0-\u31FF\u3099-\u309C\uFF65-\uFF9F]+$"))
                    {
                        // 全角を半角に
                        kana = Strings.StrConv(kana, VbStrConv.Narrow, 0x411);
                    }

                    andSql += " AND カナ LIKE '%" + kana + "%'";
                }

                // 取引先名称が入力されている場合
                if (lstSelectData[1] != "")
                {
                    andSql += " AND 取引先名称 LIKE '%" + lstSelectData[1] + "%'";
                }

                // SQLのパス指定用List
                List <string> listSqlPath = new List <string>();
                listSqlPath.Add("Common");
                listSqlPath.Add("C_LIST_Torihikisaki_SELECT");

                OpenSQL opensql = new OpenSQL();
                // sqlファイルからSQL文を取得
                string strSqltxt = opensql.setOpenSQL(listSqlPath);
                string sql       = string.Format(strSqltxt, andSql);

                // SQL実行
                dt = dbConnective.ReadSql(sql);

                return(dt);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbConnective.DB_Disconnect();
            }
        }
Exemplo n.º 19
0
        ///<summary>
        ///getSelectItem
        ///商品データの取得
        ///</summary>
        public DataTable getSelectItem(string strSelectShohinCD, bool blHontorokuData)
        {
            DataTable dtShohin = new DataTable();

            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            //商品の処理
            lstStringSQL = new List <string>();

            lstStringSQL.Add("Common");

            //本登録データ登録の場合
            if (blHontorokuData)
            {
                lstStringSQL.Add("C_LIST_Shohin_SELECT_LEAVE");
            }
            else
            {
                lstStringSQL.Add("C_LIST_Shohin_Kari_SELECT_LEAVE");
            }

            OpenSQL opensql     = new OpenSQL();
            string  strSQLInput = opensql.setOpenSQL(lstStringSQL);

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                strSQLInput = opensql.setOpenSQL(lstStringSQL);
                strSQLInput = string.Format(strSQLInput, strSelectShohinCD); //商品コード

                dtShohin = dbconnective.ReadSql(strSQLInput);

                //加工
                //指定日在庫、棚卸数量の小数点切りすて
                for (int cnt = 0; cnt < dtShohin.Rows.Count; cnt++)
                {
                    decimal decTyoubosuu = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["標準売価"].ToString()));
                    dtShohin.Rows[cnt]["標準売価"] = decTyoubosuu.ToString();
                    decimal decTanasuu = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["仕入単価"].ToString()));
                    dtShohin.Rows[cnt]["仕入単価"] = decTanasuu.ToString();
                    decimal decHyoka = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["評価単価"].ToString()));
                    dtShohin.Rows[cnt]["評価単価"] = decHyoka.ToString();
                    decimal decTeka = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["定価"].ToString()));
                    dtShohin.Rows[cnt]["定価"] = decTeka.ToString();
                    decimal decHako = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["箱入数"].ToString()));
                    dtShohin.Rows[cnt]["箱入数"] = decHako.ToString();
                    decimal decTatene = Math.Floor(decimal.Parse(dtShohin.Rows[cnt]["建値仕入単価"].ToString()));
                    dtShohin.Rows[cnt]["建値仕入単価"] = decTatene.ToString();
                }

                return(dtShohin);
            }
            catch (Exception ex)
            {
                new CommonException(ex);
                throw (ex);
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 20
0
        ///<summary>
        ///getSelectItem
        ///データグリッドビュー内のデータ選択後の処理
        ///</summary>
        public void getSelectItem(int intFrmKind, string strSelectId)
        {
            //検索データの受け取り用
            DataTable dtSelectData;

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                //SQLファイルのパスとファイル名を入れる用
                List <string> lstSQL = new List <string>();

                //SQLファイルのパスとファイル名を追加
                lstSQL.Add("Common");
                lstSQL.Add("C_LIST_Torihikisaki_SELECT_LEAVE");

                //SQL発行
                OpenSQL opensql = new OpenSQL();

                //SQLファイルのパス取得
                string strSQLInput = opensql.setOpenSQL(lstSQL);

                //SQLファイルと該当コードでフォーマット
                strSQLInput = string.Format(strSQLInput, strSelectId);

                //パスがなければ返す
                if (strSQLInput == "")
                {
                    return;
                }

                //SQL接続後、該当データを取得
                dtSelectData = dbconnective.ReadSql(strSQLInput);

                //移動元フォームの検索
                switch (intFrmKind)
                {
                //取引先
                case CommonTeisu.FRM_TORIHIKISAKI:
                    //全てのフォームの中から
                    foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                    {
                        //目的のフォームを探す
                        if (frm.Name.Equals("M1070_Torihikisaki"))
                        {
                            //データを連れてくるため、newをしないこと
                            M1070_Torihikisaki torihikisaki = (M1070_Torihikisaki)frm;
                            torihikisaki.setTorihikisaki(dtSelectData);
                            break;
                        }
                    }
                    break;

                //仕入入力
                case CommonTeisu.FRM_SHIREINPUT:
                    //全てのフォームの中から
                    foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                    {
                        //目的のフォームを探す
                        if (frm.Name.Equals("A0030_ShireInput"))
                        {
                            //データを連れてくるため、newをしないこと
                            A0030_ShireInput shireinput = (A0030_ShireInput)frm;
                            shireinput.setTorihikisaki(dtSelectData);
                            break;
                        }
                    }
                    break;

                //取引先情報
                case CommonTeisu.FRM_TORIHIKISAKI_INFO:
                    //全てのフォームの中から
                    foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                    {
                        //目的のフォームを探す
                        if (frm.Name.Equals("M1071_TorihikisakiInfo"))
                        {
                            //データを連れてくるため、newをしないこと
                            M1071_TorihikisakiInfo torihikisaki = (M1071_TorihikisakiInfo)frm;
                            torihikisaki.setTorihikisaki(dtSelectData);
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 21
0
        ///<summary>
        ///setGridKataban1
        ///上段グリッドビューの表示
        ///</summary>
        public DataTable setGridKataban1(List <string> lstStringViewData)
        {
            //SQL実行時に取り出したデータを入れる用
            DataTable dtKataban = new DataTable();

            //SQLファイルのパスとファイル名を入れる用
            List <string> lstSQL = new List <string>();

            //SQLファイルのパス用(フォーマット後)
            string strSQLInput = "";

            //SQLファイルのパスとファイル名を追加
            lstSQL.Add("B0250_MOnyuryoku");
            lstSQL.Add("MOnyuryoku_SELECT_GetDataKataban");

            //中分類コード用SQL
            string strSQLChubun = "";

            //中分類コードがある場合
            if (lstStringViewData[3].ToString().Trim() != "")
            {
                strSQLChubun = "AND 中分類コード= '" + lstStringViewData[3] + "'";
            }

            //SQL発行
            OpenSQL opensql = new OpenSQL();

            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                //SQLファイルのパス取得
                strSQLInput = opensql.setOpenSQL(lstSQL);

                //パスがなければ返す
                if (strSQLInput == "")
                {
                    return(dtKataban);
                }

                //SQLファイルと該当コードでフォーマット
                strSQLInput = string.Format(strSQLInput,
                                            lstStringViewData[0], //年月度
                                            lstStringViewData[1], //メーカーコード
                                            lstStringViewData[2], //大分類コード
                                            strSQLChubun          //中分類コード
                                            );

                //データ取得(ここから取得)
                dtKataban = dbconnective.ReadSql(strSQLInput);
            }
            catch (Exception ex)
            {
                //ロールバック開始
                dbconnective.Rollback();
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
            return(dtKataban);
        }
Exemplo n.º 22
0
        ///<summary>
        ///setData
        ///code入力箇所からフォーカスが外れた時の処理
        ///</summary>
        private void setData()
        {
            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetCd;

            Boolean blnGood;

            //空白、文字数4以上の場合
            if (this.CodeTxtText == "" || String.IsNullOrWhiteSpace(this.CodeTxtText).Equals(true) || this.CodeTxtText.Length > 3)
            {
                this.ValueLabelText  = "";
                this.AppendLabelText = "";
                return;
            }

            //前後の空白を取り除く
            this.CodeTxtText = this.CodeTxtText.Trim();

            //禁止文字チェック
            if (StringUtl.JudBanSQL(this.CodeTxtText) == false ||
                StringUtl.JudBanSelect(this.CodeTxtText, CommonTeisu.NUMBER_ONLY) == false)
            {
                this.ValueLabelText = "";

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent.Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                }
                else
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                }

                //エラーメッセージを表示された
                blMessageOn = true;

                CodeTxtText = "0";
                return;
            }

            //データ渡し用
            lstStringSQL.Add("Common");
            lstStringSQL.Add("C_LIST_Menu_SELECT_LEAVE");

            OpenSQL opensql = new OpenSQL();

            try
            {
                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                if (strSQLInput == "")
                {
                    return;
                }

                strSQLInput = string.Format(strSQLInput, this.CodeTxtText);

                //SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetCd = dbconnective.ReadSql(strSQLInput);

                //データがある場合
                if (dtSetCd.Rows.Count != 0)
                {
                    //PG番号が0の場合
                    if (dtSetCd.Rows[0]["PG番号"].ToString() == "0")
                    {
                        this.CodeTxtText    = "0";
                        this.ValueLabelText = "";
                    }
                    else
                    {
                        this.CodeTxtText    = dtSetCd.Rows[0]["PG番号"].ToString();
                        this.ValueLabelText = dtSetCd.Rows[0]["PG名"].ToString();
                    }
                    blMessageOn = false;
                }
                else
                {
                    //初期化
                    this.CodeTxtText    = "0";
                    this.ValueLabelText = "0";

                    //グループボックスかパネル内にいる場合
                    if (this.Parent is TabPage)
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent.Parent, "入力", "指定されたPgNo.は登録されていません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_EXCLAMATION);
                        basemessagebox.ShowDialog();
                    }
                    else if (this.Parent is GroupBox || this.Parent is Panel)
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, "入力", "指定されたPgNo.は登録されていません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_EXCLAMATION);
                        basemessagebox.ShowDialog();
                    }
                    else
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, "入力", "指定されたPgNo.は登録されていません。", CommonTeisu.BTN_OK, CommonTeisu.DIAG_EXCLAMATION);
                        basemessagebox.ShowDialog();
                    }

                    //エラーメッセージを表示された
                    blMessageOn = true;
                }
                return;
            }
            catch (Exception ex)
            {
                //データロギング
                new CommonException(ex);

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel || this.Parent is TabPage)
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
                else
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
            }
        }
Exemplo n.º 23
0
        ///<summary>
        ///delTorihiki
        ///テキストボックス内のデータをDBから削除
        ///</summary>
        public void delTorihiki(List <string> lstString)
        {
            //接続用クラスのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            //トランザクション開始
            dbconnective.BeginTrans();
            try
            {
                string[] aryStr = new string[] {
                    lstString[0],
                    lstString[1],
                    lstString[2],
                    lstString[3],
                    lstString[4],
                    lstString[5],
                    lstString[6],
                    lstString[7],
                    lstString[8],
                    lstString[9],
                    lstString[10],
                    lstString[11],
                    lstString[12],
                    lstString[13],
                    lstString[14],
                    lstString[15],
                    lstString[16],
                    lstString[17],
                    lstString[18],
                    lstString[19],
                    lstString[20],
                    lstString[21],
                    lstString[22],
                    lstString[23],
                    lstString[24],
                    lstString[25],
                    lstString[26],
                    lstString[27],
                    lstString[28],
                    lstString[29],
                    lstString[30],
                    lstString[31],
                    lstString[32],
                    lstString[33],
                    lstString[34],
                    lstString[35],
                    lstString[36],
                    lstString[37],
                    lstString[38],
                    lstString[39],
                    lstString[40],
                    lstString[41],
                    lstString[42],
                    lstString[43],
                    lstString[44],
                    lstString[45],
                    lstString[46],
                    lstString[47],
                    lstString[48],
                    lstString[49],
                    lstString[50],
                    lstString[51],
                    lstString[52],
                    lstString[53],
                    lstString[54],
                    lstString[55],
                    lstString[56],
                    lstString[57],
                    lstString[58],
                    lstString[59],
                    lstString[60],
                    lstString[61],
                    lstString[62],
                    lstString[63],
                    lstString[64],
                    lstString[65],
                    lstString[66],
                    lstString[67],
                    lstString[68],
                    lstString[69],
                    lstString[70],
                    lstString[71],
                    lstString[72],
                    lstString[73],
                    lstString[75],
                    "Y",
                    DateTime.Now.ToString(),
                    lstString[76],
                    DateTime.Now.ToString(),
                    lstString[76],
                    lstString[77],
                    lstString[78]
                };

                ////SQL接続、削除
                //dbconnective.RunSqlCommon(CommonTeisu.C_SQL_TORIHIKISAKI_UPD, aryStr);

                dbconnective.ReadSql("update 取引先 set 削除 = 'Y', 更新日時 = '" + DateTime.Now.ToString() + "' where 取引先コード = '" + lstString[0] + "'");

                //コミット開始
                dbconnective.Commit();
            }
            catch (Exception ex)
            {
                //ロールバック開始
                dbconnective.Rollback();
                new CommonException(ex);
                throw (ex);
            }
            finally
            {
                //トランザクション終了
                dbconnective.DB_Disconnect();
            }
        }
        ///<summary>
        ///DISP1 大分類を指定
        ///分類コードを入力かつ中分類コードが空欄の場合
        ///</summary>
        public DataTable DISP1(List <string> lstString)
        {
            DataTable dtGetTableGrid = new DataTable();

            System.DateTime dateStartYMD;
            System.DateTime dateEndYMD;
            System.DateTime dateGetumatuYMD;

            dateStartYMD = DateTime.Parse(lstString[0] + "/01");

            dateEndYMD = DateTime.Parse(lstString[1] + "/01");

            dateGetumatuYMD = dateStartYMD.AddMonths(1);
            dateGetumatuYMD = dateGetumatuYMD.AddDays(-1);    //月末

            string strSQLInput = "";

            //データ渡し用
            List <string> lstStringSQL = new List <string>();


            //SQL文 DISP1

            strSQLInput = strSQLInput + " SELECT z.得意先コード, dbo.f_get取引先名称(z.得意先コード) AS 得意先名, 1 AS 区分, z.大分類コード, z.中分類コード, NULL AS メーカーコード, dbo.f_get中分類名(z.大分類コード, z.中分類コード) AS 分類名 ";

            //金額1~12の作成
            for (int count = 0; count <= 11; count++)
            {
                //全角数字用配列
                List <string> lstZenkakuNum = new List <string>()
                {
                    "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
                };
                strSQLInput = strSQLInput + " , ROUND(dbo.f_分類別売上推移表_売上高_中分類(z.得意先コード, z.大分類コード, z.中分類コード,'" + dateStartYMD.AddMonths(count) + "', '" + dateGetumatuYMD.AddMonths(count) + "') / 1000, 0, 0) AS 金額" + lstZenkakuNum[count].ToString();
            }

            //金額合計の作成
            strSQLInput = strSQLInput + ",";
            for (int count = 0; count <= 11; count++)
            {
                //カウント0以外には先頭に+を付与する
                if (count == 0)
                {
                    strSQLInput = strSQLInput + " ROUND(dbo.f_分類別売上推移表_売上高_中分類(z.得意先コード, z.大分類コード, z.中分類コード,'" + dateStartYMD.AddMonths(count) + "', '" + dateGetumatuYMD.AddMonths(count) + "') / 1000, 0, 0)";
                }
                else
                {
                    strSQLInput = strSQLInput + "+ ROUND(dbo.f_分類別売上推移表_売上高_中分類(z.得意先コード, z.大分類コード, z.中分類コード,'" + dateStartYMD.AddMonths(count) + "', '" + dateGetumatuYMD.AddMonths(count) + "') / 1000, 0, 0)";
                }
            }
            strSQLInput = strSQLInput + " AS 金額合計";

            strSQLInput = strSQLInput + " FROM (SELECT DISTINCT a.得意先コード, b.大分類コード, b.中分類コード FROM 売上ヘッダ a, 売上明細 b ";
            strSQLInput = strSQLInput + " WHERE a.削除 = 'N' AND a.伝票番号 = b.伝票番号 AND a.伝票年月日 >= '" + dateStartYMD + "' AND a.伝票年月日 <= '" + dateEndYMD + "' AND a.得意先コード >= '" + lstString[2] + "' AND a.得意先コード <= '" + lstString[3] + "' AND b.大分類コード ='" + lstString[4] + "' ";

            strSQLInput = strSQLInput + " ) z ORDER BY z.得意先コード, z.大分類コード, z.中分類コード ";

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            try
            {
                dtGetTableGrid = dbconnective.ReadSql(strSQLInput);
            }
            catch (Exception ex)
            {
                new CommonException(ex);
                throw (ex);
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
            return(dtGetTableGrid);
        }
Exemplo n.º 25
0
        ///<summary>
        ///addDaibunrui
        ///テキストボックス内のデータをDBに登録
        ///作成者:大河内
        ///作成日:2017/3/21
        ///更新者:大河内
        ///更新日:2017/4/7
        ///カラム論理名
        ///</summary>
        public void addDaibunrui(List <string> lstString)
        {
            //
            //共通化されるので修正しないでください
            //

            string strSQLName = null;

            //接続用クラスのインスタンス作成
            DBConnective dbConnective = new DBConnective();

            //トランザクション開始
            dbConnective.BeginTrans();

            try
            {
                //データ渡し用
                List <string> lstStringSQL = new List <string>();

                strSQLName = "M1010_Daibun_SELECT_Kaburi_ADD";

                //データ渡し用
                lstStringSQL.Add("M1010_Daibun");
                lstStringSQL.Add(strSQLName);

                OpenSQL opensql     = new OpenSQL();
                string  strSQLInput = opensql.setOpenSQL(lstString);

                //配列設定
                string[] strArray = { lstString[0] };

                strSQLInput = string.Format(strSQLInput, strArray);

                lstStringSQL.Clear();

                //検索件数を表示
                int CoverCnt = int.Parse(dbConnective.ReadSql(strSQLInput).Rows[0][0].ToString());

                if (CoverCnt == 0)
                {
                    strSQLName = "M1010_Daibun_INSERT";

                    //データ渡し用
                    lstStringSQL.Add("M1010_Daibun");
                    lstStringSQL.Add(strSQLName);

                    opensql     = new OpenSQL();
                    strSQLInput = opensql.setOpenSQL(lstString);

                    //配列初期化、再設定
                    strArray = new string[] { lstString[0], lstString[1], lstString[2], lstString[3], lstString[4], lstString[5], lstString[6], lstString[7], "N", DateTime.Now.ToString(), lstString[8], DateTime.Now.ToString(), lstString[8] };
                }
                else if (CoverCnt == 1)
                {
                    strSQLName = "M1010_Daibun_UPDATE";

                    //データ渡し用
                    lstStringSQL.Add("M1010_Daibun");
                    lstStringSQL.Add(strSQLName);

                    opensql     = new OpenSQL();
                    strSQLInput = opensql.setOpenSQL(lstStringSQL);

                    //配列初期化、再設定
                    strArray = new string[] { lstString[1], lstString[2], lstString[3], lstString[4], lstString[5], lstString[6], lstString[7], "N", DateTime.Now.ToString(), lstString[8], lstString[0] };
                }

                strSQLInput = string.Format(strSQLInput, strArray);

                dbConnective.RunSql(strSQLInput);

                //コミット開始
                dbConnective.Commit();

                MessageBox.Show("正常に登録されました。", "登録", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch
            {
                //ロールバック開始
                dbConnective.Rollback();
                //throwを入れる
            }
            //finally
            //{
            //    //closeが入る
            //}
        }
Exemplo n.º 26
0
        ///<summary>
        ///codeTxt_TextChanged
        ///入力項目に変更があった場合
        ///</summary>
        private void codeTxt_TextChanged(object sender, EventArgs e)
        {
            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetCd;

            string strSQLName = null;

            if (this.CodeTxtText == "" || String.IsNullOrWhiteSpace(this.CodeTxtText).Equals(true))
            {
                this.ValueLabelText = "";
                return;
            }

            //前後の空白を取り除く
            this.CodeTxtText = this.CodeTxtText.Trim();

            strSQLName = "C_LIST_Maker_SELECT_LEAVE";

            //データ渡し用
            lstStringSQL.Add("Common");
            lstStringSQL.Add(strSQLName);

            OpenSQL opensql = new OpenSQL();

            try
            {
                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                if (strSQLInput == "")
                {
                    return;
                }

                //配列設定
                string[] aryStr = { this.CodeTxtText };

                strSQLInput = string.Format(strSQLInput, aryStr);

                //SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetCd = dbconnective.ReadSql(strSQLInput);

                if (dtSetCd.Rows.Count != 0)
                {
                    this.CodeTxtText    = dtSetCd.Rows[0]["メーカーコード"].ToString();
                    this.ValueLabelText = dtSetCd.Rows[0]["メーカー名"].ToString();
                }
                return;
            }
            catch (Exception ex)
            {
                //データロギング
                new CommonException(ex);

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
                else
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    return;
                }
            }
        }
Exemplo n.º 27
0
        ///<summary>
        ///setGridTokusaiki
        ///得意先グリッドのデータ取得
        ///</summary>
        public DataTable getShiharaiList(List <string> lstItem)
        {
            string    strSql = "";
            DataTable dtShiharaiCheakList = new DataTable();

            string fromfrom = DateTime.Parse(lstItem[0]).AddYears(-1).ToString("yyyy/MM/dd");

            strSql += "SELECT TOP 5000 S3.伝票年月日, ";
            strSql += "S3.行番号, ";
            strSql += "sz.締切日, ";
            strSql += "sz.仕入先コード, ";
            strSql += "sz.仕入先名,";
            strSql += "sz.支払予定日, ";
            strSql += "sz.支払日, ";
            strSql += "S3.伝票番号, ";
            strSql += "S3.取引区分コード, ";
            strSql += "dbo.f_get取引区分名(S3.取引区分コード) AS 取引区分名, ";
            strSql += "CASE WHEN Rtrim(ISNULL(S3.口座,'')) = '' THEN '当' ELSE S3.口座 END AS 口座,";
            strSql += "CASE WHEN Rtrim(ISNULL(S3.金融機関名,'')) = '' THEN '第三銀行' ELSE S3.金融機関名 END AS 金融機関名,";
            strSql += "CASE WHEN Rtrim(ISNULL(S3.支店名,'')) = '' THEN '中川' ELSE S3.支店名 END AS 支店名,";
            strSql += "CONVERT(CHAR, ROUND(sz.支払予定額, 0), 126) AS 支払予定額,";
            strSql += "CONVERT(CHAR, ROUND(S3.支払額, 0), 126) AS 支払額, ";
            strSql += "S3.手形期日, ";
            strSql += "sz.支払月数,";
            strSql += "sz.支払条件,";
            strSql += "sz.集金区分,";
            strSql += "sz.消費税端数計算区分,";
            strSql += "S3.廻し先,";
            strSql += "S3.廻し先日付,";
            strSql += "sz.仕入手形期日,";
            strSql += "S3.備考, ";
            strSql += "S3.額, ";
            strSql += "S3.登録日時";


            strSql += "  from";
            strSql += "       (SELECT S2.仕入先コード,";
            strSql += "               S2.支払予定日,";
            strSql += "               SUM(S2.税込合計金額) AS 支払予定額,";
            strSql += "               S2.締切日, ";
            strSql += "               S2.仕入先名,";
            strSql += "               S2.支払日, ";
            strSql += "               S2.支払月数, ";
            strSql += "               S2.支払条件, ";
            strSql += "               S2.集金区分, ";
            strSql += "               S2.消費税端数計算区分, ";
            strSql += "               S2.仕入手形期日";
            strSql += "          FROM";
            strSql += "               (select S.仕入先コード,";
            strSql += "                       CASE WHEN RIGHT(CONVERT(VARCHAR, DATEADD(month, T.支払月数, S.伝票年月日), 111), 2) <= RIGHT('00' + LTRIM(STR(T.支払日, 2)), 2)";
            strSql += "                            THEN";
            strSql += "                                CASE WHEN RIGHT('00' + LTRIM(STR(T.支払日, 2)), 2) > RIGHT(CONVERT(VARCHAR, dbo.f_月末日(DATEADD(month, T.支払月数, S.伝票年月日)), 111), 2)";
            strSql += "                                     THEN dbo.f_月末日(DATEADD(month, T.支払月数, S.伝票年月日))";
            strSql += "                                     ELSE LEFT(CONVERT(CHAR, DATEADD(month, T.支払月数, S.伝票年月日), 111), 8) + RIGHT('00' + LTRIM(STR(T.支払日, 2)), 2)";
            strSql += "                                END";
            strSql += "                            ELSE";
            strSql += "                                CASE WHEN RIGHT('00' + LTRIM(STR(T.支払日, 2)), 2) > RIGHT(CONVERT(VARCHAR, dbo.f_月末日(DATEADD(month, T.支払月数 + 1, S.伝票年月日)), 111), 2)";
            strSql += "                                     THEN dbo.f_月末日(DATEADD(month, T.支払月数 + 1, S.伝票年月日))";
            strSql += "                                     ELSE LEFT(CONVERT(CHAR, DATEADD(month, T.支払月数 + 1, S.伝票年月日), 111), 8) + RIGHT('00' + LTRIM(STR(T.支払日, 2)), 2)";
            strSql += "                                END";
            strSql += "                            END 支払予定日,";
            strSql += "                       S.税込合計金額,";

            strSql += "                       T.締切日, ";
            strSql += "                       T.取引先名称 AS 仕入先名,";
            strSql += "                       T.支払日, ";
            strSql += "                       T.支払月数 AS 支払月数,";
            strSql += "                       T.支払条件 AS 支払条件,";
            strSql += "                       T.集金区分 AS 集金区分,";
            strSql += "                       T.消費税端数計算区分,";
            strSql += "                       CASE WHEN Rtrim(ISNULL(T.仕入手形期日,'')) = '' THEN CONVERT(CHAR, ROUND(T.支払日, 0), 126) ELSE T.仕入手形期日 END AS 仕入手形期日";

            strSql += "                  from 仕入ヘッダ S,";
            strSql += "                       取引先 T";
            strSql += "                 where S.削除 = 'N'";
            strSql += "                   and S.伝票年月日 >= '" + fromfrom + "'";
            strSql += "                   and T.削除 = 'N'";
            strSql += "                   and S.仕入先コード = T.取引先コード) AS S2";
            strSql += "         WHERE S2.支払予定日 >= '" + lstItem[0] + "'";
            strSql += "           AND S2.支払予定日 <= '" + lstItem[1] + "'";
            strSql += "         group by S2.仕入先コード, S2.支払予定日, S2.仕入先名, S2.締切日, S2.支払日, S2.支払月数, S2.支払条件, S2.集金区分, S2.消費税端数計算区分, S2.仕入手形期日) as sz";

            strSql += "  left join";
            strSql += "(SELECT Sf.支払年月日 AS 伝票年月日, ";
            strSql += "Sf.行番号, ";
            //strSql += "T.締切日, ";
            strSql += "Sf.仕入先コード, ";
            //strSql += "T.取引先名称 AS 仕入先名,";
            //strSql += "Sf.手形期日 AS 支払予定日, ";
            //strSql += "T.支払日, ";
            strSql += "Sf.伝票番号, ";
            strSql += "Sf.取引区分コード, ";
            strSql += "dbo.f_get取引区分名(Sf.取引区分コード) AS 取引区分名, ";
            strSql += "CASE WHEN Rtrim(ISNULL(Sf.口座,'')) = '' THEN '当' ELSE Sf.口座 END AS 口座,";
            strSql += "CASE WHEN Rtrim(ISNULL(Sf.金融機関名,'')) = '' THEN '第三銀行' ELSE Sf.金融機関名 END AS 金融機関名,";
            strSql += "CASE WHEN Rtrim(ISNULL(Sf.支店名,'')) = '' THEN '中川' ELSE Sf.支店名 END AS 支店名,";
            //strSql += "CONVERT(CHAR, ROUND(Sf.支払額, 0), 126) AS 支払予定額,";
            strSql += "Sf.支払額,";
            strSql += "Sf.手形期日, ";
            //strSql += "T.支払月数 AS 支払月数,";
            //strSql += "T.支払条件 AS 支払条件,";
            //strSql += "T.集金区分 AS 集金区分,";
            //strSql += "T.消費税端数計算区分,";
            strSql += "Sf.廻し先,";
            strSql += "Sf.廻し先日付,";
            //strSql += "CASE WHEN Rtrim(ISNULL(T.仕入手形期日,'')) = '' THEN CONVERT(CHAR, ROUND(T.支払日, 0), 126) ELSE T.仕入手形期日 END AS 仕入手形期日,";
            strSql += "Sf.備考, ";
            strSql += "Sf.支払額 AS 額, ";
            strSql += "Sf.登録日時 ";
            //strSql += " FROM 支払 S, 取引先 T";
            strSql += " FROM 支払 Sf";
            strSql += " WHERE Sf.削除 ='N' ";
            //strSql += "   AND T.削除 ='N' ";
            //strSql += "   AND S.仕入先コード = T.取引先コード ";

            #region 追加検索条件
            // 入力年月日(開始)がある場合
            if (!lstItem[0].Equals(""))
            {
                strSql += " AND CONVERT(VARCHAR(10),Sf.更新日時,111) >='" + lstItem[0] + "'";
                strSql += " AND CONVERT(VARCHAR(10),Sf.更新日時,111) <='" + lstItem[1] + "'";
            }

            // 伝票年月日(開始)がある場合
            if (!lstItem[2].Equals(""))
            {
                strSql += " AND Sf.支払年月日 >='" + lstItem[2] + "'";
                strSql += " AND Sf.支払年月日 <='" + lstItem[3] + "'";
            }

            // ユーザーIDがある場合
            if (!lstItem[4].Equals(""))
            {
                strSql += " AND Sf.更新ユーザー名='" + lstItem[4] + "'";
            }

            // 仕入先コードがある場合
            if (!lstItem[5].Equals("") && !lstItem[6].Equals(""))
            {
                strSql += " AND Sf.仕入先コード >='" + lstItem[5] + "'";
                strSql += " AND Sf.仕入先コード <='" + lstItem[6] + "'";
            }

            if (!lstItem[7].Equals(""))
            {
                strSql += " AND Sf.取引区分コード IN (" + lstItem[7] + ")";
            }

            if (!lstItem[8].Equals(""))
            {
                strSql += " AND Sf.手形期日 >='" + lstItem[8] + "'";
            }

            if (!lstItem[9].Equals(""))
            {
                strSql += " AND Sf.手形期日 <='" + lstItem[9] + "'";
            }

            if (!lstItem[12].Equals(""))
            {
                strSql += " AND Sf.金融機関名 like '%" + lstItem[12] + "%'";
            }

            if (!lstItem[13].Equals(""))
            {
                strSql += " AND Sf.支店名 like '%" + lstItem[13] + "%'";
            }

            if (!lstItem[14].Equals(""))
            {
                strSql += " AND Sf.口座 like '%" + lstItem[14] + "%'";
            }
            #endregion

            strSql += ") AS S3 ";
            strSql += "  on sz.仕入先コード = S3.仕入先コード";
            strSql += "   AND S3.伝票年月日 >= DATEADD(month, sz.支払月数 * -1, sz.支払予定日)";
            strSql += "   AND S3.伝票年月日 <= sz.支払予定日";


            //strSql += " ORDER BY 支払年月日, 伝票番号, 行番号";



            DBConnective dbconnective = new DBConnective();
            try
            {
                // 検索データをテーブルへ格納
                dtShiharaiCheakList = dbconnective.ReadSql(strSql);

                return(dtShiharaiCheakList);
            }
            catch
            {
                throw;
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 28
0
        ///<summary>
        ///setTxtMakerLeave
        ///code入力箇所からフォーカスが外れた時の処理
        ///</summary>
        public void setTxtMakerLeave()
        {
            //データ渡し用
            List <string> lstStringSQL = new List <string>();

            DataTable dtSetCd;

            if (this.CodeTxtText == "" || String.IsNullOrWhiteSpace(this.CodeTxtText).Equals(true))
            {
                this.ValueLabelText  = "";
                this.AppendLabelText = "";
                return;
            }

            //前後の空白を取り除く
            this.CodeTxtText = this.CodeTxtText.Trim();

            //禁止文字チェック
            if (StringUtl.JudBanSQL(this.CodeTxtText) == false)
            {
                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent.Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                }
                else
                {
                    //メッセージボックスの処理、項目が該当する禁止文字を含む場合のウィンドウ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(Parent, CommonTeisu.TEXT_INPUT, CommonTeisu.LABEL_MISS, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                }

                this.ValueLabelText  = "";
                this.CodeTxtText     = "";
                this.AppendLabelText = "";

                //エラーメッセージを表示された
                blMessageOn = true;
                return;
            }


            // 全角数字を半角数字に変換
            this.CodeTxtText = StringUtl.JudZenToHanNum(this.CodeTxtText);

            // 数値チェック
            if (StringUtl.JudBanSelect(this.CodeTxtText, CommonTeisu.NUMBER_ONLY) == true)
            {
                if (this.CodeTxtText.Length <= 3)
                {
                    this.CodeTxtText = this.CodeTxtText.ToString().PadLeft(4, '0');
                }
            }

            //データ渡し用
            lstStringSQL.Add("Common");
            lstStringSQL.Add("C_LIST_Maker_SELECT_LEAVE");

            OpenSQL opensql = new OpenSQL();

            try
            {
                string strSQLInput = opensql.setOpenSQL(lstStringSQL);

                if (strSQLInput == "")
                {
                    return;
                }

                strSQLInput = string.Format(strSQLInput, this.CodeTxtText);

                //SQLのインスタンス作成
                DBConnective dbconnective = new DBConnective();

                //SQL文を直書き(+戻り値を受け取る)
                dtSetCd = dbconnective.ReadSql(strSQLInput);

                if (dtSetCd.Rows.Count != 0)
                {
                    this.CodeTxtText    = dtSetCd.Rows[0]["メーカーコード"].ToString();
                    this.ValueLabelText = dtSetCd.Rows[0]["メーカー名"].ToString();

                    blMessageOn = false;
                }
                else
                {
                    //グループボックスかパネル内にいる場合
                    if (this.Parent is GroupBox || this.Parent is Panel)
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_VIEW, CommonTeisu.LABEL_NOTDATA, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();
                        SendKeys.Send("+{TAB}");
                    }
                    else
                    {
                        //メッセージボックスの処理、項目のデータがない場合のウィンドウ(OK)
                        BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_VIEW, CommonTeisu.LABEL_NOTDATA, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                        basemessagebox.ShowDialog();
                        SendKeys.Send("+{TAB}");
                    }

                    this.ValueLabelText  = "";
                    this.CodeTxtText     = "";
                    this.AppendLabelText = "";

                    blMessageOn = true;
                    return;
                }
                return;
            }
            catch (Exception ex)
            {
                //データロギング
                new CommonException(ex);

                //グループボックスかパネル内にいる場合
                if (this.Parent is GroupBox || this.Parent is Panel)
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                    return;
                }
                else
                {
                    //例外発生メッセージ(OK)
                    BaseMessageBox basemessagebox = new BaseMessageBox(this.Parent, CommonTeisu.TEXT_ERROR, CommonTeisu.LABEL_ERROR_MESSAGE, CommonTeisu.BTN_OK, CommonTeisu.DIAG_ERROR);
                    basemessagebox.ShowDialog();
                    SendKeys.Send("+{TAB}");
                    return;
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// getShiharaiCheakList
        /// 支払チェックリストを取得
        /// </summary>
        public DataTable getShiharaiCheakList(List <string> lstItem)
        {
            string    strSql;
            DataTable dtShiharaiCheakList = new DataTable();

            strSql  = "SELECT S.支払年月日 AS 伝票年月日, ";
            strSql += "       S.伝票番号, ";
            strSql += "       S.行番号, ";
            strSql += "       S.仕入先コード, ";
            strSql += "       T.取引先名称 AS 仕入先名, ";
            strSql += "       S.取引区分コード, ";
            strSql += "       dbo.f_get取引区分名(S.取引区分コード) AS 取引区分名, ";
            strSql += "       CASE WHEN Rtrim(ISNULL(S.口座,'')) = '' THEN '当' ELSE S.口座 END AS 口座,";
            strSql += "       CASE WHEN Rtrim(ISNULL(S.金融機関名,'')) = '' THEN '第三銀行' ELSE S.金融機関名 END AS 金融機関名,";
            strSql += "       CASE WHEN Rtrim(ISNULL(S.支店名,'')) = '' THEN '中川' ELSE S.支店名 END AS 支店名,";
            strSql += "       S.支払額, ";
            strSql += "       S.手形期日, ";
            strSql += "       S.備考 ";
            strSql += "  FROM 支払 S,";
            strSql += "       取引先 T";
            strSql += " WHERE S.削除 ='N' ";
            strSql += "   AND T.削除 ='N' ";
            strSql += "   AND S.仕入先コード = T.取引先コード ";

            // 入力年月日(開始)がある場合
            if (!lstItem[0].Equals(""))
            {
                strSql += " AND CONVERT(VARCHAR(10),S.更新日時,111) >='" + lstItem[0] + "'";
                strSql += " AND CONVERT(VARCHAR(10),S.更新日時,111) <='" + lstItem[1] + "'";
            }

            // 伝票年月日(開始)がある場合
            if (!lstItem[2].Equals(""))
            {
                strSql += " AND S.支払年月日 >='" + lstItem[2] + "'";
                strSql += " AND S.支払年月日 <='" + lstItem[3] + "'";
            }

            // ユーザーIDがある場合
            if (!lstItem[4].Equals(""))
            {
                strSql += " AND S.更新ユーザー名='" + lstItem[4] + "'";
            }

            // 仕入先コードがある場合
            if (!lstItem[5].Equals("") && !lstItem[6].Equals(""))
            {
                strSql += " AND S.仕入先コード >='" + lstItem[5] + "'";
                strSql += " AND S.仕入先コード <='" + lstItem[6] + "'";
            }

            strSql += " ORDER BY S.支払年月日,S.伝票番号,S.行番号";

            DBConnective dbconnective = new DBConnective();

            try
            {
                // 検索データをテーブルへ格納
                dtShiharaiCheakList = dbconnective.ReadSql(strSql);

                return(dtShiharaiCheakList);
            }
            catch
            {
                throw;
            }
            finally
            {
                dbconnective.DB_Disconnect();
            }
        }
Exemplo n.º 30
0
        ///<summary>
        ///setdgvSeihinDoubleClick
        ///データグリッドビュー内のデータ選択後の処理
        ///作成者:大河内
        ///作成日:2017/3/23
        ///更新者:大河内
        ///更新日:2017/3/23
        ///カラム論理名
        ///</summary>
        public void setSelectItem(int intFrmKind, string strSelectid)
        {
            DataTable dtSelectData;

            //SQLのインスタンス作成
            DBConnective dbconnective = new DBConnective();

            switch (intFrmKind)
            {
            //大分類
            case 1:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT 大分類コード, 大分類名,ラベル名1,ラベル名2,ラベル名3,ラベル名4,ラベル名5,ラベル名6 FROM 大分類 WHERE 大分類コード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name.Equals("M_Daibunrui"))
                    {
                        //データを連れてくるため、newをしないこと
                        M_Daibunrui daibunrui = (M_Daibunrui)frm;
                        daibunrui.setDaibunrui(dtSelectData);
                        break;
                    }
                }
                break;

            //中分類
            case 2:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT 大分類コード, 大分類名 FROM 大分類 WHERE 大分類コード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name.Equals("M_Chubunrui"))
                    {
                        //データを連れてくるため、newをしないこと
                        M_Chubunrui daibunrui = (M_Chubunrui)frm;
                        daibunrui.setDaibunrui(dtSelectData);
                        break;
                    }
                }
                break;

            //棚番
            case 5:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT 大分類コード, 大分類名 FROM 大分類 WHERE 大分類コード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name.Equals("TanaorosiInput"))
                    {
                        //データを連れてくるため、newをしないこと
                        TanaorosiInput tanaorosinput = (TanaorosiInput)frm;
                        tanaorosinput.setDaibunrui(dtSelectData);
                        break;
                    }
                }
                break;

            //商品リスト
            case 7:
                //SQL文を直書き(+戻り値を受け取る)
                dtSelectData = dbconnective.ReadSql("SELECT 大分類コード, 大分類名 FROM 大分類 WHERE 大分類コード = '" + strSelectid + "'");

                //全てのフォームの中から
                foreach (System.Windows.Forms.Form frm in Application.OpenForms)
                {
                    //目的のフォームを探す
                    if (frm.Name.Equals("ShouhinList"))
                    {
                        //データを連れてくるため、newをしないこと
                        ShouhinList shouhinlist = (ShouhinList)frm;
                        shouhinlist.setDaibunrui(dtSelectData);
                        break;
                    }
                }
                break;
            }
        }