コード例 #1
0
ファイル: frmTown.cs プロジェクト: ymgw0867/posting
        private void button3_Click(object sender, EventArgs e)
        {
            string          cName;
            string          sqlSTR;
            OleDbDataReader dR;

            Control.FreeSql fCon = new Control.FreeSql();

            dR = fCon.free_dsReader("select * from 市区町村 order by ID");

            while (dR.Read())
            {
                cName = dR["市区町村"].ToString();
                Control.FreeSql fCon2 = new Control.FreeSql();

                sqlSTR  = "";
                sqlSTR += "update 町名 ";
                sqlSTR += "set 町名.市区町村コード = " + dR["ID"].ToString();
                sqlSTR += "where (町名.名称 like '" + cName + "%') and ";
                sqlSTR += "(町名.市区町村コード = 0)";

                fCon2.Execute(sqlSTR);

                fCon2.Close();
            }

            dR.Close();

            fCon.Close();
        }
コード例 #2
0
            public static void ShowData(DataGridView tempDGV)
            {
                string sqlSTRING = "";
                int    iX;

                try
                {
                    tempDGV.RowCount = 0;

                    //データリーダーを取得する
                    OleDbDataReader dR;

                    sqlSTRING  = "";
                    sqlSTRING += "select * from 市区町村 ";
                    sqlSTRING += "order by ID";

                    //市区町村データのデータリーダーを取得する
                    Control.FreeSql cArea = new Control.FreeSql();
                    dR = cArea.free_dsReader(sqlSTRING);

                    //グリッドビューに表示する
                    iX = 0;

                    while (dR.Read())
                    {
                        try
                        {
                            tempDGV.Rows.Add();

                            tempDGV[0, iX].Value = int.Parse(dR["ID"].ToString());
                            tempDGV[1, iX].Value = dR["都道府県"].ToString();
                            tempDGV[2, iX].Value = dR["市区町村"].ToString();

                            iX++;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }

                    dR.Close();
                    cArea.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
コード例 #3
0
        private void ShowPosting(DataGridView tempDGV, DateTime tempDate, DateTime tempDateE, long tempID)
        {
            string          mySql = "";
            OleDbDataReader dR;
            int             iX = 0;

            mySql += "select 配布指示.配布日,町名.名称,配布エリア.枝番記入,配布エリア.予定枚数 ";
            mySql += "from (配布エリア inner join 配布指示 ";
            mySql += "on 配布エリア.配布指示ID = 配布指示.ID) left join 町名 ";
            mySql += "on 配布エリア.町名ID = 町名.ID ";
            mySql += "where ";
            mySql += "(配布エリア.受注ID = " + tempID.ToString() + ") and ";
            mySql += "(配布エリア.完了区分 = 1) and ";
            mySql += "(配布指示.配布日 >= '" + tempDate.ToShortDateString() + "') and ";
            mySql += "(配布指示.配布日 <= '" + tempDateE.ToShortDateString() + "') ";
            mySql += "order by 配布指示.配布日,町名ID";

            Control.FreeSql fCon = new Control.FreeSql();
            dR = fCon.free_dsReader(mySql);

            tempDGV.RowCount = 0;

            while (dR.Read())
            {
                tempDGV.Rows.Add();
                tempDGV[0, iX].Value = dR["配布日"];
                tempDGV[1, iX].Value = dR["名称"].ToString() + " " + dR["枝番記入"].ToString() + "";
                tempDGV[2, iX].Value = int.Parse(dR["予定枚数"].ToString());

                iX++;
            }

            //if (tempDGV.RowCount <= 27)
            //{
            //    tempDGV.Columns[1].Width = 200;
            //}
            //else
            //{
            //    tempDGV.Columns[1].Width = 183;
            //}

            tempDGV.CurrentCell = null;

            dR.Close();
            fCon.Close();
        }
コード例 #4
0
        /// <summary>
        /// 配布エリアデータのステータスを初期状態に戻す
        /// </summary>
        /// <param name="tempID">配布エリアID</param>
        private void HaihuStatusUpdate(int tempID, int tempStatus)
        {
            Control.FreeSql cUp = new Control.FreeSql();

            string sqlStr = "";

            sqlStr += "update 配布エリア ";
            sqlStr += "set ";
            sqlStr += "配布指示ID = 0,";
            sqlStr += "ステータス = " + tempStatus.ToString() + ",";
            sqlStr += "変更年月日 = '" + DateTime.Today + "' ";
            sqlStr += "where 配布エリア.ID = " + tempID.ToString();

            if (cUp.Execute(sqlStr) == false)
            {
                MessageBox.Show("配布エリアデータのステータス更新に失敗しました(" + tempID.ToString() + ")", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            cUp.Close();
        }
コード例 #5
0
        private void ShowPosting(DataGridView tempDGV, long tempID)
        {
            string          mySql = "";
            OleDbDataReader dR;
            int             iX = 0;

            mySql += "select 受注.ID, 配布指示.ID as 指示番号,配布指示.配布日, 配布員.ID AS 配布員ID, 配布員.氏名 AS 配布員氏名,";
            mySql += "町名.ID AS 町名ID, 町名.名称 AS 町名,";
            mySql += "配布エリア.予定枚数,配布エリア.完了区分 ";
            mySql += "from 受注 inner join 配布エリア ";
            mySql += "on 受注.ID = 配布エリア.受注ID left join 配布指示 ";
            mySql += "on 配布エリア.配布指示ID = 配布指示.ID left join 町名 ";
            mySql += "on 配布エリア.町名ID = 町名.ID left join 配布員 ";
            mySql += "on 配布指示.配布員ID = 配布員.ID ";
            mySql += "where 受注.ID = " + tempID.ToString() + " ";
            mySql += "order by 配布指示.配布日 desc";

            Control.FreeSql fCon = new Control.FreeSql();
            dR = fCon.free_dsReader(mySql);

            tempDGV.RowCount = 0;
            button1.Enabled  = false;

            while (dR.Read())
            {
                tempDGV.Rows.Add();
                tempDGV[0, iX].Value = dR["ID"].ToString();

                if (dR["指示番号"] == DBNull.Value)
                {
                    tempDGV[1, iX].Value = "** 未設定 **";
                }
                else
                {
                    tempDGV[1, iX].Value = dR["指示番号"].ToString();
                }

                if (dR["配布日"] == DBNull.Value)
                {
                    tempDGV[2, iX].Value = "";
                }
                else
                {
                    tempDGV[2, iX].Value = DateTime.Parse(dR["配布日"].ToString()).ToShortDateString();
                }

                if (dR["配布員ID"] == DBNull.Value)
                {
                    tempDGV[3, iX].Value = "";
                }
                else
                {
                    tempDGV[3, iX].Value = dR["配布員ID"].ToString();
                }

                if (dR["配布員氏名"] == DBNull.Value)
                {
                    tempDGV[4, iX].Value = "";
                }
                else
                {
                    tempDGV[4, iX].Value = dR["配布員氏名"].ToString();
                }

                if (dR["町名ID"] == DBNull.Value)
                {
                    tempDGV[5, iX].Value = "";
                }
                else
                {
                    tempDGV[5, iX].Value = dR["町名ID"].ToString();
                }

                if (dR["町名"] == DBNull.Value)
                {
                    tempDGV[6, iX].Value = "";
                }
                else
                {
                    tempDGV[6, iX].Value = dR["町名"].ToString();
                }

                if (dR["予定枚数"] == DBNull.Value)
                {
                    tempDGV[7, iX].Value = 0;
                }
                else
                {
                    tempDGV[7, iX].Value = int.Parse(dR["予定枚数"].ToString());
                }

                //残枚数
                if (dR["予定枚数"] == DBNull.Value)
                {
                    tempDGV[8, iX].Value = 0;
                }
                else
                {
                    if (dR["完了区分"].ToString() == "1")
                    {
                        tempDGV[8, iX].Value = 0;
                    }
                    else
                    {
                        tempDGV[8, iX].Value = int.Parse(dR["予定枚数"].ToString());
                    }
                }

                iX++;

                button1.Enabled = true;
            }

            //if (tempDGV.RowCount <= 13)
            //{
            //    tempDGV.Columns[6].Width = 330;
            //}
            //else
            //{
            //    tempDGV.Columns[6].Width = 313;
            //}

            tempDGV.CurrentCell = null;

            dR.Close();
            fCon.Close();

            label1.Text = "【" + dataGridView2[2, dataGridView2.SelectedRows[0].Index].Value.ToString() + " 配布状況】";
        }
コード例 #6
0
            public static void ShowData(DataGridView tempDGV, int tempSel, string tempCName)
            {
                string sqlSTRING = "";
                int    iX;

                try
                {
                    tempDGV.RowCount = 0;

                    //データリーダーを取得する
                    Control.DataControl Con = new Control.DataControl();
                    OleDbConnection     cn  = new OleDbConnection();
                    cn = Con.GetConnection();

                    OleDbDataReader dR;

                    sqlSTRING  = "";
                    sqlSTRING += "select 受注.ID,社員.氏名,得意先.略称,受注.チラシ名,受注.税込金額,";
                    sqlSTRING += "受注.枚数 as 納品数,h_tbl.配布件数,";
                    sqlSTRING += "受注.枚数 - h_tbl.配布件数 as 残枚数 ";
                    sqlSTRING += "from 受注 left join  ";

                    sqlSTRING += "(select 受注ID,sum(予定枚数) as 配布件数 ";
                    sqlSTRING += "from 配布エリア ";
                    sqlSTRING += "where 完了区分 = 1 ";
                    sqlSTRING += "group by 受注ID ) as h_tbl ";

                    sqlSTRING += "on 受注.ID = h_tbl.受注ID left join 得意先 ";
                    sqlSTRING += "on 受注.得意先ID = 得意先.ID left join 社員 ";
                    sqlSTRING += "on 得意先.担当社員コード = 社員.ID ";
                    sqlSTRING += "where (受注.受注種別ID = 1) ";

                    switch (tempSel)
                    {
                    case 1:
                        sqlSTRING += "and (((受注.枚数 - h_tbl.配布件数) > 0) or h_tbl.配布件数 is null) ";
                        break;

                    case 2:
                        sqlSTRING += "and (受注.枚数 - h_tbl.配布件数 = 0) ";
                        break;
                    }

                    if (tempCName.Trim().Length > 0)
                    {
                        sqlSTRING += "and (受注.チラシ名 like ?)";
                    }

                    sqlSTRING += "order by 受注.ID desc";

                    OleDbCommand SCom = new OleDbCommand();

                    SCom.CommandText = sqlSTRING;

                    if (tempCName.Trim().Length > 0)
                    {
                        SCom.Parameters.AddWithValue("@CName", "%" + tempCName + "%");
                    }

                    SCom.Connection = cn;

                    //配布進捗状況のデータリーダーを取得する
                    //Control.FreeSql fCon = new Control.FreeSql();
                    //dR = fCon.free_dsReader(sqlSTRING);

                    dR = SCom.ExecuteReader();

                    //グリッドビューに表示する
                    iX = 0;

                    while (dR.Read())
                    {
                        try
                        {
                            tempDGV.Rows.Add();

                            tempDGV[0, iX].Value = long.Parse(dR["ID"].ToString());
                            tempDGV[1, iX].Value = dR["略称"].ToString() + "";
                            tempDGV[2, iX].Value = dR["チラシ名"].ToString();
                            tempDGV[3, iX].Value = dR["氏名"].ToString() + "";
                            tempDGV[4, iX].Value = int.Parse(dR["税込金額"].ToString(), System.Globalization.NumberStyles.Any);
                            tempDGV[5, iX].Value = int.Parse(dR["納品数"].ToString(), System.Globalization.NumberStyles.Any);

                            if (dR["配布件数"] == DBNull.Value)
                            {
                                tempDGV[6, iX].Value = 0;
                            }
                            else
                            {
                                tempDGV[6, iX].Value = int.Parse(dR["配布件数"].ToString(), System.Globalization.NumberStyles.Any);
                            }

                            if (dR["残枚数"] == DBNull.Value)
                            {
                                tempDGV[7, iX].Value = int.Parse(dR["納品数"].ToString(), System.Globalization.NumberStyles.Any);
                            }
                            else
                            {
                                tempDGV[7, iX].Value = int.Parse(dR["残枚数"].ToString(), System.Globalization.NumberStyles.Any);
                            }

                            //配布完了日
                            if (int.Parse(tempDGV[7, iX].Value.ToString(), System.Globalization.NumberStyles.Any) == 0)
                            {
                                string          sqlSTR;
                                OleDbDataReader r;
                                Control.FreeSql rCon = new Control.FreeSql();
                                sqlSTR  = "";
                                sqlSTR += "select max(配布指示.配布日) as 完了日 ";
                                sqlSTR += "from 配布エリア inner join 配布指示 ";
                                sqlSTR += "on 配布エリア.配布指示ID = 配布指示.ID ";
                                sqlSTR += "where ";
                                sqlSTR += "(配布エリア.受注ID = " + long.Parse(dR["ID"].ToString()) + ") and ";
                                sqlSTR += "(配布エリア.完了区分 = 1)";

                                r = rCon.free_dsReader(sqlSTR);

                                while (r.Read())
                                {
                                    if (r["完了日"] != DBNull.Value)
                                    {
                                        tempDGV[8, iX].Value = DateTime.Parse(r["完了日"].ToString()).ToShortDateString();
                                    }
                                    else
                                    {
                                        tempDGV[8, iX].Value = "";
                                    }
                                }

                                r.Close();
                                rCon.Close();
                            }
                            else
                            {
                                tempDGV[8, iX].Value = "";
                            }


                            iX++;

                            //frmP.valueCount = iX;
                            //frmP.ShowProgress();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }

                    dR.Close();
                    Con.Close();
                    cn.Close();

                    //fCon.Close();

                    //frmP.Close();

                    //frmP.Dispose();

                    //if (tempDGV.RowCount <= 12)
                    //{
                    //    tempDGV.Columns[3].Width = 97;
                    //}
                    //else
                    //{
                    //    tempDGV.Columns[3].Width = 80;
                    //}
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
コード例 #7
0
        private void HaifuUpdate(int sRow, int eRow)
        {
            try
            {
                HaifuShijiData();   //配布指示クラスにデータセット

                Control.DataControl Con;
                OleDbConnection     cn;
                OleDbTransaction    tran;
                OleDbCommand        SCom;

                //IDを採番
                string sqlStr = "";
                int    gID    = (int)(1);

                sqlStr = "select max(ID) as ID from 配布指示 ";
                OleDbDataReader dR;
                Control.FreeSql fCon = new Control.FreeSql();
                dR = fCon.free_dsReader(sqlStr);

                while (dR.Read())
                {
                    if (dR["ID"] == DBNull.Value)
                    {
                        gID = (int)(1);
                    }
                    else
                    {
                        gID = Int32.Parse(dR["ID"].ToString()) + 1;
                    }
                }

                dR.Close();
                fCon.Close();

                //IDを設定
                cMaster.ID = gID;

                //登録処理
                Con = new Control.DataControl();
                cn  = new OleDbConnection();

                cn = Con.GetConnection();

                //トランザクション開始
                tran = cn.BeginTransaction();

                SCom             = new OleDbCommand();
                SCom.Connection  = cn;
                SCom.Transaction = tran;

                try
                {
                    //配布指示データ登録処理
                    sqlStr  = "";
                    sqlStr += "insert into 配布指示 ";
                    sqlStr += "(ID,配布日,入力日,配布員ID,交通費,交通区間開始,交通区間終了,";
                    sqlStr += "配布開始時刻,配布終了時刻,終了レポート,未配布区分,未配布理由,";
                    sqlStr += "登録年月日,変更年月日) ";
                    sqlStr += "values (";
                    sqlStr += cMaster.ID + ",";
                    sqlStr += "'" + cMaster.配布日 + "',";
                    sqlStr += "'" + cMaster.入力日 + "',";
                    sqlStr += cMaster.配布員ID + ",";
                    sqlStr += cMaster.交通費 + ",";
                    sqlStr += "'" + cMaster.交通区間開始 + "',";
                    sqlStr += "'" + cMaster.交通区間終了 + "',";
                    sqlStr += "'" + cMaster.配布開始時刻 + "',";
                    sqlStr += "'" + cMaster.配布終了時刻 + "',";
                    sqlStr += "'" + cMaster.終了レポート + "',";
                    sqlStr += "'" + cMaster.未配布区分 + "',";
                    sqlStr += "'" + cMaster.未配布理由 + "',";
                    sqlStr += "'" + cMaster.登録年月日 + "',";
                    sqlStr += "'" + cMaster.更年月日 + "')";

                    SCom.CommandText = sqlStr;

                    SCom.ExecuteNonQuery();

                    //配布エリアデータ更新
                    string       sID;
                    const string sSTATUS = "2";

                    for (int i = sRow; i <= eRow; i++)
                    {
                        sID = dataGridView1[1, i].Value.ToString();

                        sqlStr  = "";
                        sqlStr += "update 配布エリア ";
                        sqlStr += "set ";
                        sqlStr += "配布指示ID = " + gID.ToString() + ",";
                        sqlStr += "実残数 = 予定枚数,";
                        sqlStr += "報告残数 = 予定枚数,";
                        sqlStr += "ステータス = " + sSTATUS + ",";
                        sqlStr += "変更年月日 = '" + DateTime.Today + "' ";
                        sqlStr += "where (配布エリア.ID = " + sID + ") and ";
                        sqlStr += "(ステータス <> 0)";

                        //if (dataGridView1[0, i].Value.ToString() == "2")
                        //{
                        //    sqlStr += "(ステータス <> 0)";
                        //}


                        SCom.CommandText = sqlStr;

                        SCom.ExecuteNonQuery();
                    }

                    tran.Commit();

                    //更新結果書き込み
                    UpdateFlg(sRow, eRow, UPDATE_OK);

                    //MessageBox.Show("新規登録されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    tran.Rollback();

                    //更新結果書き込み
                    UpdateFlg(sRow, eRow, UPDATE_NO);

                    MessageBox.Show(ex.Message, MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    MessageBox.Show("登録に失敗しました。ロールバックしました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    //未登録配布データのステータスを戻す
                    //StatusBack();
                }

                cn.Close();

                Con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
コード例 #8
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("併配表示を行います。よろしいですか?", MESSAGE_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }

            int      toID;
            DateTime sDate;
            DateTime eDate;

            int      targetID;
            DateTime tsDate;
            DateTime teDate;

            string sqlStr, msgStr;

            // 自分のループ
            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                // 配布期間が登録されているものを対象とする
                // 併配除外案件は対象外とします 2014/11/26
                if (dataGridView2[6, i].Value.ToString().Trim() != "" &&
                    dataGridView2[7, i].Value.ToString().Trim() != "" &&
                    dataGridView2["col14", i].Value.ToString() != "1")
                {
                    // ID
                    toID = Int32.Parse(dataGridView2[3, i].Value.ToString());

                    //配布開始日
                    sDate = Convert.ToDateTime(dataGridView2[6, i].Value.ToString());

                    //配布終了日
                    eDate = Convert.ToDateTime(dataGridView2[7, i].Value.ToString());

                    //相手のループ
                    for (int iX = i + 1; iX < dataGridView2.Rows.Count; iX++)
                    {
                        // 配布期間が登録されているものを対象とする
                        // 併配除外案件は対象外とします 2014/11/26
                        if (dataGridView2[6, iX].Value.ToString().Trim() != "" &&
                            dataGridView2[7, iX].Value.ToString().Trim() != "" &&
                            dataGridView2["col14", iX].Value.ToString() != "1")
                        {
                            //相手のID
                            targetID = Int32.Parse(dataGridView2[3, iX].Value.ToString());

                            //相手の配布開始日
                            tsDate = Convert.ToDateTime(dataGridView2[6, iX].Value.ToString());

                            //相手の配布終了日
                            teDate = Convert.ToDateTime(dataGridView2[7, iX].Value.ToString());

                            if (toID == targetID)
                            {
                                //配布期間が重複する場合、併配扱い
                                //パターン�@ 期間の一部重複
                                if (((tsDate >= sDate) && (tsDate <= eDate)) || ((teDate >= sDate) && (teDate <= eDate)))
                                {
                                    dataGridView2[8, i].Value  = "○";
                                    dataGridView2[8, iX].Value = "○";
                                    dataGridView2.Rows[i].DefaultCellStyle.ForeColor  = Color.Red;
                                    dataGridView2.Rows[iX].DefaultCellStyle.ForeColor = Color.Red;
                                }

                                //パターン�A 相手の期間中そのまま
                                if ((tsDate <= sDate) && (eDate <= teDate))
                                {
                                    dataGridView2[8, i].Value  = "○";
                                    dataGridView2[8, iX].Value = "○";
                                    dataGridView2.Rows[i].DefaultCellStyle.ForeColor  = Color.Red;
                                    dataGridView2.Rows[iX].DefaultCellStyle.ForeColor = Color.Red;
                                }
                            }
                        }
                    }

                    //配布指示済みで配布未完了のデータを対象に検索
                    // ・・・> 比較する配布日:受注データの配布開始日〜配布終了日 2009/10/13

                    sqlStr = "";

                    //////sqlStr += "select 配布エリア.配布指示ID,配布エリア.町名ID,配布指示.配布日 ";
                    //////sqlStr += "from 配布エリア inner join 配布指示 ";
                    //////sqlStr += "on 配布エリア.配布指示ID = 配布指示.ID ";
                    //////sqlStr += "where ";
                    //////sqlStr += "(配布エリア.配布指示ID <> 0) and ";
                    //////sqlStr += "(配布エリア.ステータス = 2) and ";
                    //////sqlStr += "(配布エリア.完了区分 = 0) and ";
                    //////sqlStr += "(配布エリア.町名ID = " + toID.ToString() + ") ";
                    //////sqlStr += "order by 配布エリア.配布指示ID";

                    sqlStr += "select 配布エリア.配布指示ID,配布エリア.町名ID,受注.配布開始日,受注.配布終了日 ";
                    sqlStr += "from 配布エリア inner join 受注 ";
                    sqlStr += "on 配布エリア.受注ID = 受注.ID ";
                    sqlStr += "where ";
                    sqlStr += "(配布エリア.配布指示ID <> 0) and ";
                    sqlStr += "(配布エリア.ステータス = 2) and ";
                    sqlStr += "(配布エリア.完了区分 = 0) and ";
                    sqlStr += "(配布エリア.町名ID = " + toID.ToString() + ") ";
                    sqlStr += "order by 配布エリア.受注ID";

                    OleDbDataReader dR;
                    Control.FreeSql fCon = new Control.FreeSql();
                    dR = fCon.free_dsReader(sqlStr);

                    while (dR.Read())
                    {
                        //////配布指示書の配布日
                        ////tsDate = Convert.ToDateTime(dR["配布日"].ToString());

                        //////配布指示書の配布日が配布期間に該当するか
                        ////if ((tsDate >= sDate) && (tsDate <= eDate))
                        ////{
                        ////    msgStr = dataGridView2[8, i].Value.ToString();

                        ////    if (msgStr != "")
                        ////    {
                        ////        msgStr += "、";
                        ////    }

                        ////    msgStr += "指示��:" + dR["配布指示ID"].ToString();
                        ////    dataGridView2[8, i].Value = msgStr;
                        ////    dataGridView2.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                        ////}

                        //相手の配布開始日(受注データより)
                        tsDate = Convert.ToDateTime(dR["配布開始日"].ToString());

                        //相手の配布終了日(受注データより)
                        teDate = Convert.ToDateTime(dR["配布終了日"].ToString());

                        //配布期間が重複する場合、併配扱い
                        //パターン�@ 期間の一部重複
                        if (((tsDate >= sDate) && (tsDate <= eDate)) || ((teDate >= sDate) && (teDate <= eDate)))
                        {
                            msgStr = dataGridView2[8, i].Value.ToString();

                            if (msgStr != "")
                            {
                                msgStr += "、";
                            }

                            msgStr += "指示��:" + dR["配布指示ID"].ToString();
                            dataGridView2[8, i].Value = msgStr;
                            dataGridView2.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                        }
                        else
                        {
                            //パターン�A 相手の期間中そのまま
                            if ((tsDate <= sDate) && (eDate <= teDate))
                            {
                                msgStr = dataGridView2[8, i].Value.ToString();

                                if (msgStr != "")
                                {
                                    msgStr += "、";
                                }

                                msgStr += "指示��:" + dR["配布指示ID"].ToString();
                                dataGridView2[8, i].Value = msgStr;
                                dataGridView2.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                            }
                        }
                    }

                    dR.Close();
                    fCon.Close();
                }
            }

            MessageBox.Show("終了しました", "併配表示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #9
0
ファイル: frmNyukinRep.cs プロジェクト: ymgw0867/posting
            public static void ShowData(DataGridView tempDGV, int tempKBN, TextBox tempTxt, TextBox tempTotal, DateTime tempSDate, DateTime tempEDate, string tempCstr)
            {
                string sqlSTRING = "";
                int    sZan      = 0;
                int    sTotal    = 0;

                try
                {
                    // データリーダーを取得する
                    OleDbDataReader dR;

                    sqlSTRING += "SELECT 請求書.ID,請求書.得意先ID,請求書.請求金額,請求書.消費税,";
                    sqlSTRING += "請求書.値引額,請求書.売上金額,請求書.税率,";
                    sqlSTRING += "請求書.入金予定日,請求書.発行日,請求書.入金残,請求書.完了区分,";
                    sqlSTRING += "請求書.振込口座ID1,請求書.振込口座ID2,請求書.備考,";
                    sqlSTRING += "請求書.登録年月日,請求書.変更年月日,得意先.略称,社員.氏名,n_tbl.入金日,n_tbl.入金額 ";
                    sqlSTRING += "from 請求書 LEFT OUTER JOIN 得意先 ";
                    sqlSTRING += "ON 請求書.得意先ID = 得意先.ID LEFT OUTER JOIN 社員 ";
                    sqlSTRING += "ON 得意先.担当社員コード = 社員.ID LEFT OUTER JOIN ";
                    sqlSTRING += "(SELECT 請求書ID, MAX(入金年月日) AS 入金日,sum(金額) as 入金額 ";
                    sqlSTRING += "FROM 入金 ";
                    sqlSTRING += "GROUP BY 請求書ID) AS n_tbl ON 請求書.ID = n_tbl.請求書ID ";
                    sqlSTRING += "where ";

                    if (tempKBN == 1)
                    {
                        sqlSTRING += "(請求書.完了区分 = 0) and ";
                    }

                    sqlSTRING += "(請求書.入金予定日 >= '" + tempSDate + "') and (請求書.入金予定日 <= '" + tempEDate + "') ";

                    if (tempCstr != "")
                    {
                        sqlSTRING += " and (得意先.略称 like '%" + tempCstr + "%') ";
                    }

                    // 不要データ 2010/02/16
                    sqlSTRING += " and ((請求書.ID != 709) and (請求書.ID != 771) and (請求書.ID != 723) and (請求書.ID != 822) and (請求書.ID != 765) and (請求書.ID != 776) and (請求書.ID != 743) and (請求書.ID != 899) and (請求書.ID != 1017) and (請求書.ID != 847) and (請求書.ID != 849) and (請求書.ID != 990) and (請求書.ID != 1190)) ";

                    sqlSTRING += "ORDER BY 請求書.得意先ID, 請求書.発行日 DESC ";

                    Control.FreeSql fCon = new Control.FreeSql();
                    dR = fCon.free_dsReader(sqlSTRING);

                    // グリッドビューに表示する
                    int iX = 0;

                    tempDGV.RowCount = 0;

                    while (dR.Read())
                    {
                        tempDGV.Rows.Add();

                        tempDGV[0, iX].Value = int.Parse(dR["得意先ID"].ToString());
                        tempDGV[1, iX].Value = dR["略称"].ToString();
                        tempDGV[2, iX].Value = dR["氏名"].ToString();
                        tempDGV[3, iX].Value = DateTime.Parse(dR["発行日"].ToString()).ToShortDateString();
                        tempDGV[4, iX].Value = int.Parse(dR["請求金額"].ToString(), System.Globalization.NumberStyles.Any);

                        if (dR["入金予定日"] == DBNull.Value)
                        {
                            tempDGV[5, iX].Value = "";
                        }
                        else
                        {
                            tempDGV[5, iX].Value = DateTime.Parse(dR["入金予定日"].ToString()).ToShortDateString();
                        }

                        if (dR["入金日"] == DBNull.Value)
                        {
                            tempDGV[6, iX].Value = "";
                        }
                        else
                        {
                            tempDGV[6, iX].Value = DateTime.Parse(dR["入金日"].ToString()).ToShortDateString();
                        }

                        if (dR["入金額"] == DBNull.Value)
                        {
                            tempDGV[7, iX].Value = 0;
                        }
                        else
                        {
                            tempDGV[7, iX].Value = int.Parse(dR["入金額"].ToString(), System.Globalization.NumberStyles.Any);
                        }

                        tempDGV[8, iX].Value = int.Parse(dR["入金残"].ToString(), System.Globalization.NumberStyles.Any);

                        // 請求書ID 2010/2/16
                        tempDGV[9, iX].Value = dR["ID"].ToString();

                        // 備考 2015/07/22
                        tempDGV[10, iX].Value = dR["備考"].ToString();

                        // 入金合計
                        if (dR["入金額"] != DBNull.Value)
                        {
                            sTotal += int.Parse(dR["入金額"].ToString(), System.Globalization.NumberStyles.Any);
                        }

                        // 入金残合計
                        sZan += int.Parse(dR["入金残"].ToString(), System.Globalization.NumberStyles.Any);

                        iX++;
                    }

                    dR.Close();
                    fCon.Close();

                    //if (tempDGV.RowCount > 25)
                    //    //if (tempDGV.RowCount > 25)
                    //{
                    //    tempDGV.Columns[1].Width = 253;
                    //}
                    //else
                    //{
                    //    tempDGV.Columns[1].Width = 270;
                    //}

                    tempTotal.Text      = sTotal.ToString("#,##0");
                    tempTxt.Text        = sZan.ToString("#,##0");
                    tempDGV.CurrentCell = null;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
コード例 #10
0
            public static void ShowData(DataGridView tempDGV)
            {
                string sqlSTRING = "";
                string strDate;
                int    iX;

                try
                {
                    tempDGV.RowCount = 0;


                    //データリーダーを取得する

                    OleDbDataReader dR;

                    sqlSTRING  = "";
                    sqlSTRING += "select 配布エリア.ID,配布エリア.受注ID,受注.チラシ名,";
                    sqlSTRING += "配布エリア.町名ID,町名.名称 as 町名,受注.配布開始日,受注.配布終了日,";
                    sqlSTRING += "配布エリア.併配区分,配布エリア.予定枚数,";
                    sqlSTRING += "受注.配布条件,配布形態.名称 as 配布形態 ";
                    sqlSTRING += "from ((配布エリア left join 受注 on 配布エリア.受注ID = 受注.ID) ";
                    sqlSTRING += "left join 町名 on 配布エリア.町名ID = 町名.ID) ";
                    sqlSTRING += "left join 配布形態 on 受注.配布形態 = 配布形態.ID ";
                    sqlSTRING += "where (配布エリア.配布指示ID = 0) and (配布エリア.ステータス = 0) ";
                    sqlSTRING += "order by 配布エリア.受注ID,配布エリア.町名ID";

                    //配布指示データのデータリーダーを取得する
                    Control.FreeSql cArea = new Control.FreeSql();
                    dR = cArea.free_dsReader(sqlSTRING);

                    //グリッドビューに表示する
                    iX = 0;

                    while (dR.Read())
                    {
                        try
                        {
                            tempDGV.Rows.Add();

                            tempDGV[0, iX].Value = int.Parse(dR["ID"].ToString());
                            tempDGV[1, iX].Value = long.Parse(dR["受注ID"].ToString());
                            tempDGV[2, iX].Value = dR["チラシ名"].ToString();
                            tempDGV[3, iX].Value = int.Parse(dR["町名ID"].ToString());
                            tempDGV[4, iX].Value = dR["町名"].ToString();
                            tempDGV[5, iX].Value = int.Parse(dR["予定枚数"].ToString());

                            strDate = dR["配布開始日"].ToString() + "";
                            if (strDate == "")
                            {
                                tempDGV[6, iX].Value = "";
                            }
                            else
                            {
                                tempDGV[6, iX].Value = Convert.ToDateTime(dR["配布開始日"].ToString() + "");
                            }

                            strDate = dR["配布終了日"].ToString() + "";
                            if (strDate == "")
                            {
                                tempDGV[7, iX].Value = "";
                            }
                            else
                            {
                                tempDGV[7, iX].Value = Convert.ToDateTime(dR["配布終了日"].ToString() + "");
                            }

                            if (dR["併配区分"].ToString() == "1")
                            {
                                tempDGV[8, iX].Value = "○";
                            }
                            else
                            {
                                tempDGV[8, iX].Value = "";
                            }

                            //tempDGV[8, iX].Value = dR["配布条件"].ToString();
                            //tempDGV[9, iX].Value = dR["配布形態"].ToString() + "";
                            //tempDGV[10, iX].Value = dR["単価"].ToString();
                            //tempDGV[11, iX].Value = dR["枚数"].ToString();

                            iX++;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }

                    dR.Close();
                    cArea.Close();

                    //if (tempDGV.RowCount <= 27)
                    //{
                    //    tempDGV.Columns[8].Width = 77;
                    //}
                    //else
                    //{
                    //    tempDGV.Columns[8].Width = 60;
                    //}
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
コード例 #11
0
ファイル: frmTown.cs プロジェクト: ymgw0867/posting
        private void GetExcelPos()
        {
            DialogResult ret;

            //ダイアログボックスの初期設定
            openFileDialog1.Title            = "市区町村コード表の選択";
            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.FileName         = "";
            openFileDialog1.Filter           = "Microsoft Office Excelファイル(*.xls)|*.xls|全てのファイル(*.*)|*.*";

            //ダイアログボックスの表示
            ret = openFileDialog1.ShowDialog();
            if (ret == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            if (MessageBox.Show(openFileDialog1.FileName + Environment.NewLine + " が選択されました。よろしいですか?", "市区町村コード表取り込み", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            const int S_GYO = 1;    //エクセルファイル見出し行(明細は1行目から)

            //マウスポインタを待機にする
            this.Cursor = Cursors.WaitCursor;

            //string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory;

            Excel.Application oXls = new Excel.Application();

            Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(openFileDialog1.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                           Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                           Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                           Type.Missing, Type.Missing));

            Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[1];

            Excel.Range   dRng;
            Excel.Range[] rng = new Microsoft.Office.Interop.Excel.Range[2];

            int    iX = S_GYO;
            int    err;
            string cellID, cellItem1, cellItem2;
            string sqlSTR;

            try
            {
                while (true)
                {
                    err = 0;

                    //市区町村コード
                    dRng = (Excel.Range)oxlsSheet.Cells[iX, 2];

                    //空白なら処理終了
                    if ((dRng.Text.ToString().Trim() + "") == "")
                    {
                        break;
                    }

                    cellID = dRng.Text.ToString();

                    //都道府県
                    dRng      = (Excel.Range)oxlsSheet.Cells[iX, 3];
                    cellItem1 = dRng.Text.ToString();

                    //市区町村名
                    dRng      = (Excel.Range)oxlsSheet.Cells[iX, 4];
                    cellItem2 = dRng.Text.ToString();

                    //コードチェック
                    if (Utility.NumericCheck(cellID) == false)
                    {
                        err = 1;
                    }

                    //エラーのときは読み飛ばし
                    if (err == 0)
                    {
                        Control.FreeSql fCon = new Control.FreeSql();

                        sqlSTR  = "";
                        sqlSTR += "insert into 市区町村 ";
                        sqlSTR += "(ID,都道府県,市区町村,区分1,区分2,備考,登録年月日,変更年月日) ";
                        sqlSTR += "values (" + cellID + ",";
                        sqlSTR += "'" + cellItem1 + "',";
                        sqlSTR += "'" + cellItem2 + "',";
                        sqlSTR += "0,0,'',";
                        sqlSTR += "'" + DateTime.Today.ToShortDateString() + "',";
                        sqlSTR += "'" + DateTime.Today.ToShortDateString() + "')";

                        if (fCon.Execute(sqlSTR) == false)
                        {
                            MessageBox.Show("市区町村マスターの登録に失敗しました。" + cellID, "市区町村コード表読み込み", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            fCon.Close();
                            break;
                        }

                        fCon.Close();
                    }

                    iX++;
                }

                MessageBox.Show("終了しました", "市区町村コード表読み込み", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //マウスポインタを元に戻す
                this.Cursor = Cursors.Default;

                // 確認のためExcelのウィンドウを表示する
                //oXls.Visible = true;

                //印刷
                //oxlsSheet.PrintPreview(true);

                //保存処理
                oXls.DisplayAlerts = false;

                //Bookをクローズ
                oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing);

                //Excelを終了
                oXls.Quit();
            }

            catch (Exception e)
            {
                MessageBox.Show(e.Message, "印刷", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            finally
            {
                // COM オブジェクトの参照カウントを解放する
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls);

                //マウスポインタを元に戻す
                this.Cursor = Cursors.Default;
            }
        }
コード例 #12
0
ファイル: frmTown.cs プロジェクト: ymgw0867/posting
        //登録データチェック
        private Boolean fDataCheck()
        {
            string str;
            double d;

            try
            {
                //登録モードのとき、コードをチェック
                if (fMode.Mode == 0)
                {
                    // 数字か?
                    if (txtCode.Text == null)
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードは数字で入力してください");
                    }

                    str = this.txtCode.Text;

                    if (double.TryParse(str, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out d))
                    {
                    }
                    else
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードは数字で入力してください");
                    }

                    // 未入力またはスペースのみは不可
                    if ((this.txtCode.Text).Trim().Length < 1)
                    {
                        this.txtCode.Focus();
                        throw new Exception("コードを入力してください");
                    }

                    //ゼロは不可
                    if (Convert.ToInt32(this.txtCode.Text.ToString()) == 0)
                    {
                        this.txtCode.Focus();
                        throw new Exception("ゼロは登録できません");
                    }

                    //登録済みコードか調べる
                    string          sqlStr;
                    Control.町名      Town = new Control.町名();
                    OleDbDataReader dr;

                    sqlStr = " where ID = " + txtCode.Text.ToString();
                    dr     = Town.FillBy(sqlStr);

                    if (dr.HasRows == true)
                    {
                        txtCode.Focus();
                        dr.Close();
                        Town.Close();
                        throw new Exception("既に登録済みのコードです");
                    }

                    dr.Close();
                    Town.Close();
                }

                //名称チェック
                if (txtName1.Text.Trim().Length < 1)
                {
                    txtName1.Focus();
                    throw new Exception("名称を入力してください");
                }

                //市区町村コード
                if (Utility.NumericCheck(txtCityCode.Text) == false)
                {
                    txtCityCode.Focus();
                    throw new Exception("市区町村コードは数字で入力してください");
                }

                //マスターチェック
                if (txtCityCode.Text != "0")
                {
                    string          sqlSTR;
                    OleDbDataReader dR;
                    Control.FreeSql fCon = new Control.FreeSql();

                    sqlSTR  = "";
                    sqlSTR += "select * from 市区町村 where ID = " + txtCityCode.Text;
                    dR      = fCon.free_dsReader(sqlSTR);

                    if (dR.HasRows == false)
                    {
                        txtCityCode.Focus();
                        dR.Close();
                        fCon.Close();
                        throw new Exception("該当する市区町村コードがありません");
                    }

                    dR.Close();
                    fCon.Close();
                }


                //クラスにデータセット
                cMaster.ID      = Convert.ToInt32(txtCode.Text.ToString());
                cMaster.称       = txtName1.Text.ToString();
                cMaster.市区町村コード = int.Parse(txtCityCode.Text.ToString(), System.Globalization.NumberStyles.Any);
                cMaster.備考      = txtMemo.Text.ToString();

                if (fMode.Mode == 0)
                {
                    cMaster.登録年月日 = DateTime.Today;
                }
                cMaster.更年月日 = DateTime.Today;

                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MESSAGE_CAPTION + "保守", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
コード例 #13
0
ファイル: frmNyukinRep.cs プロジェクト: ymgw0867/posting
        private void DataDelete()
        {
            string sqlString;

            Control.FreeSql fSql = new Control.FreeSql();

            //sqlSTRING += " and ((請求書.ID != 709) and (請求書.ID != 771) and (請求書.ID != 723) and
            //(請求書.ID != 822) and (請求書.ID != 765) and (請求書.ID != 776) and (請求書.ID != 743) and
            //(請求書.ID != 899) and (請求書.ID != 1017) and (請求書.ID != 847) and (請求書.ID != 849) and
            //(請求書.ID != 990) and (請求書.ID != 1190)) ";

            //ソシエワールド
            sqlString = "delete from 請求書 where ID = 709";
            fSql.Execute(sqlString);

            //ごっぱち
            sqlString = "delete from 請求書 where ID = 771";
            fSql.Execute(sqlString);

            //キャメルリンク
            sqlString = "delete from 請求書 where ID = 723";
            fSql.Execute(sqlString);

            //DAテクニカルサービス
            sqlString = "delete from 請求書 where ID = 822";
            fSql.Execute(sqlString);

            //
            sqlString = "delete from 請求書 where ID = 765";
            fSql.Execute(sqlString);

            //HAKU
            sqlString = "delete from 請求書 where ID = 776";
            fSql.Execute(sqlString);

            //表参道接骨院
            sqlString = "delete from 請求書 where ID = 743";
            fSql.Execute(sqlString);

            //レコプロ
            sqlString = "delete from 請求書 where ID = 899";
            fSql.Execute(sqlString);

            //レコプロ
            sqlString = "delete from 請求書 where ID = 1017";
            fSql.Execute(sqlString);

            //プリズミック
            sqlString = "delete from 請求書 where ID = 847";
            fSql.Execute(sqlString);

            //DAテクニカルサービス
            sqlString = "delete from 請求書 where ID = 849";
            fSql.Execute(sqlString);

            //庭の音
            sqlString = "delete from 請求書 where ID = 990";
            fSql.Execute(sqlString);

            //早稲田ゼミナール
            sqlString = "delete from 請求書 where ID = 1190";
            fSql.Execute(sqlString);

            fSql.Close();
        }
コード例 #14
0
ファイル: frmMihaifuRep.cs プロジェクト: ymgw0867/posting
        private void ShowPosting(DataGridView tempDGV, long tempID)
        {
            string          mySql = "";
            OleDbDataReader dR;
            int             iX = 0;

            mySql += "SELECT 受注.ID,受注.チラシ名,配布エリア.町名ID,町名.名称,未配布情報.番地号,";
            mySql += "未配布情報.マンション名,未配布情報.理由,未配布理由.摘要,未配布情報.その他内容,";
            mySql += "配布指示.配布日 ";
            mySql += "from 受注 ";
            mySql += "inner join 配布エリア ON 受注.ID = 配布エリア.受注ID ";
            mySql += "inner join 未配布情報 on 配布エリア.ID = 未配布情報.配布エリアID ";
            mySql += "inner join 町名 ON 配布エリア.町名ID = 町名.ID ";
            mySql += "inner join 未配布理由 ON 未配布情報.理由 = 未配布理由.ID ";
            mySql += "inner join 配布指示 ON 配布エリア.配布指示ID = 配布指示.ID ";
            mySql += "where 受注.ID = " + tempID.ToString() + " ";
            mySql += " ORDER BY 配布日,配布エリア.町名ID,番地号";

            Control.FreeSql fCon = new Control.FreeSql();
            dR = fCon.free_dsReader(mySql);

            tempDGV.RowCount = 0;

            while (dR.Read())
            {
                tempDGV.Rows.Add();

                if (dR["配布日"] != DBNull.Value)
                {
                    tempDGV[0, iX].Value = DateTime.Parse(dR["配布日"].ToString()).ToShortDateString() + "";
                }
                else
                {
                    tempDGV[0, iX].Value = "";
                }

                tempDGV[1, iX].Value = dR["町名ID"].ToString() + "";
                tempDGV[2, iX].Value = dR["名称"].ToString() + "";
                tempDGV[3, iX].Value = dR["番地号"].ToString() + "";
                tempDGV[4, iX].Value = dR["マンション名"].ToString() + "";

                if (dR["摘要"].ToString() == "その他")
                {
                    tempDGV[5, iX].Value = dR["その他内容"].ToString() + "";
                }
                else
                {
                    tempDGV[5, iX].Value = dR["摘要"].ToString() + "";
                }

                iX++;
            }

            //////if (tempDGV.RowCount <= 27)
            //////{
            //////    tempDGV.Columns[3].Width = 200;
            //////}
            //////else
            //////{
            //////    tempDGV.Columns[3].Width = 183;
            //////}

            tempDGV.CurrentCell = null;

            dR.Close();
            fCon.Close();
        }
コード例 #15
0
            ///----------------------------------------------------------------
            /// <summary>
            ///     グリッドに受注データを表示する </summary>
            /// <param name="tempDGV">
            ///     データグリッドビューオブジェクト名</param>
            ///----------------------------------------------------------------
            public static void ShowData(DataGridView tempDGV, DateTime sDay, DateTime eDay)
            {
                string sqlSTRING = "";
                string strDate;
                int    iX;

                try
                {
                    tempDGV.RowCount = 0;

                    //データリーダーを取得する

                    OleDbDataReader dR;

                    sqlSTRING  = "";
                    sqlSTRING += "select 配布エリア.ID,配布エリア.受注ID,受注.チラシ名,";
                    sqlSTRING += "配布エリア.町名ID,町名.名称 as 町名,受注.配布開始日,受注.配布終了日,";
                    sqlSTRING += "配布エリア.併配区分,配布エリア.予定枚数,";
                    sqlSTRING += "受注.配布条件,配布形態.名称 as 配布形態,受注.併配除外 ";
                    sqlSTRING += "from ((配布エリア left join 受注 on 配布エリア.受注ID = 受注.ID) ";
                    sqlSTRING += "left join 町名 on 配布エリア.町名ID = 町名.ID) ";
                    sqlSTRING += "left join 配布形態 on 受注.配布形態 = 配布形態.ID ";
                    sqlSTRING += "where (配布エリア.配布指示ID = 0) and (配布エリア.ステータス = 0) ";
                    sqlSTRING += "order by 配布エリア.受注ID,配布エリア.町名ID";

                    //配布指示データのデータリーダーを取得する
                    Control.FreeSql cArea = new Control.FreeSql();
                    dR = cArea.free_dsReader(sqlSTRING);

                    //グリッドビューに表示する
                    iX = 0;

                    while (dR.Read())
                    {
                        try
                        {
                            tempDGV.Rows.Add();

                            tempDGV[0, iX].Value = int.Parse(dR["ID"].ToString());
                            tempDGV[1, iX].Value = long.Parse(dR["受注ID"].ToString());
                            tempDGV[2, iX].Value = dR["チラシ名"].ToString();
                            tempDGV[3, iX].Value = int.Parse(dR["町名ID"].ToString());
                            tempDGV[4, iX].Value = dR["町名"].ToString();
                            tempDGV[5, iX].Value = int.Parse(dR["予定枚数"].ToString());

                            strDate = dR["配布開始日"].ToString() + "";
                            if (strDate == "")
                            {
                                tempDGV[6, iX].Value = "";
                            }
                            else
                            {
                                tempDGV[6, iX].Value = Convert.ToDateTime(dR["配布開始日"].ToString() + "");
                            }

                            strDate = dR["配布終了日"].ToString() + "";
                            if (strDate == "")
                            {
                                tempDGV[7, iX].Value = "";
                            }
                            else
                            {
                                tempDGV[7, iX].Value = Convert.ToDateTime(dR["配布終了日"].ToString() + "");
                            }

                            if (dR["併配区分"].ToString() == "1")
                            {
                                tempDGV[8, iX].Value = "○";
                            }
                            else
                            {
                                tempDGV[8, iX].Value = "";
                            }

                            //tempDGV[8, iX].Value = dR["配布条件"].ToString();
                            //tempDGV[9, iX].Value = dR["配布形態"].ToString() + "";
                            //tempDGV[10, iX].Value = dR["単価"].ToString();
                            //tempDGV[11, iX].Value = dR["枚数"].ToString();

                            // 併配除外 2014/11/26
                            tempDGV["col14", iX].Value = Utility.nullToInt(dR["併配除外"]).ToString();

                            // 配布日マーキング
                            for (int i = 0; sDay.AddDays(i) <= eDay; i++)
                            {
                                if (sDay.AddDays(i) >= DateTime.Parse(dR["配布開始日"].ToString()) &&
                                    sDay.AddDays(i) <= DateTime.Parse(dR["配布終了日"].ToString()))
                                {
                                    tempDGV["day" + i.ToString(), iX].Value           = "●";
                                    tempDGV["day" + i.ToString(), iX].Style.BackColor = Color.LightPink;
                                    tempDGV["day" + i.ToString(), iX].Style.ForeColor = Color.LightPink;
                                }
                                else
                                {
                                    tempDGV["day" + i.ToString(), iX].Value           = "";
                                    tempDGV["day" + i.ToString(), iX].Style.BackColor = Color.White;
                                    tempDGV["day" + i.ToString(), iX].Style.ForeColor = Color.White;
                                }
                            }

                            iX++;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }

                    dR.Close();
                    cArea.Close();

                    //if (tempDGV.RowCount <= 27)
                    //{
                    //    tempDGV.Columns[8].Width = 77;
                    //}
                    //else
                    //{
                    //    tempDGV.Columns[8].Width = 60;
                    //}
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
コード例 #16
0
ファイル: frmMihaifuRep.cs プロジェクト: ymgw0867/posting
        private void KanryoReport(int tempPage, int tempCurrentPage, int tempFixRows)
        {
            const int S_GYO = 13;    //エクセルファイル明細は13行目から印字
            int       dgvIndex;
            int       i;

            try
            {
                //マウスポインタを待機にする
                this.Cursor = Cursors.WaitCursor;

                string sAppPath = System.AppDomain.CurrentDomain.BaseDirectory;

                Excel.Application oXls = new Excel.Application();

                Excel.Workbook oXlsBook = (Excel.Workbook)(oXls.Workbooks.Open(sAppPath + Properties.Settings.Default.エクセル配布完了報告書, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                               Type.Missing, Type.Missing));

                Excel.Worksheet oxlsSheet = (Excel.Worksheet)oXlsBook.Sheets[1];

                try
                {
                    //得意先情報
                    long   sID;
                    string sqlSTR;

                    sID = long.Parse(dataGridView2[0, dataGridView2.SelectedRows[0].Index].Value.ToString());

                    sqlSTR  = "";
                    sqlSTR += "select 得意先.名称,得意先.担当者名,得意先.電話番号 ";
                    sqlSTR += "from 受注 inner join 得意先 ";
                    sqlSTR += "on 受注.得意先ID = 得意先.ID ";
                    sqlSTR += "where 受注.ID = " + sID.ToString();

                    OleDbDataReader dR;
                    Control.FreeSql fCon = new Control.FreeSql();
                    dR = fCon.free_dsReader(sqlSTR);

                    while (dR.Read())
                    {
                        oxlsSheet.Cells[1, 3] = dR["名称"].ToString() + " " + dR["担当者名"].ToString() + "様";
                        oxlsSheet.Cells[2, 3] = dR["電話番号"].ToString();
                    }

                    dR.Close();
                    fCon.Close();

                    //納品数
                    oxlsSheet.Cells[8, 2] = int.Parse(dataGridView2[2, dataGridView2.SelectedRows[0].Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                    //前回まで
                    oxlsSheet.Cells[9, 2] = int.Parse(dataGridView2[3, dataGridView2.SelectedRows[0].Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                    //残部数
                    oxlsSheet.Cells[10, 2] = int.Parse(dataGridView2[4, dataGridView2.SelectedRows[0].Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                    //チラシ名
                    oxlsSheet.Cells[10, 3] = dataGridView2[1, dataGridView2.SelectedRows[0].Index].Value.ToString();

                    //配布エリア明細
                    i = 0;
                    while (true)
                    {
                        dgvIndex = tempFixRows * (tempCurrentPage - 1) + i; //データグリッドビューの行インデックスを求める

                        //oxlsSheet.Cells[i + S_GYO, 2] = dateTimePicker1.Value.ToShortDateString();   //チラシ名
                        oxlsSheet.Cells[i + S_GYO, 3] = dataGridView1[0, dgvIndex].Value.ToString();   //配布区分
                        oxlsSheet.Cells[i + S_GYO, 4] = int.Parse(dataGridView1[1, dgvIndex].Value.ToString(), System.Globalization.NumberStyles.Any);

                        //グリッド最終行のとき終了
                        if (dgvIndex == (dataGridView1.Rows.Count - 1))
                        {
                            break;
                        }

                        //印刷明細最大行のとき終了
                        if (i == (tempFixRows - 1))
                        {
                            break;
                        }

                        i++;
                    }

                    //配布枚数合計
                    oxlsSheet.Cells[45, 4] = int.Parse(dataGridView2[5, dataGridView2.SelectedRows[0].Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                    //残部数
                    oxlsSheet.Cells[46, 4] = int.Parse(dataGridView2[6, dataGridView2.SelectedRows[0].Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                    //マウスポインタを元に戻す
                    this.Cursor = Cursors.Default;

                    // 確認のためExcelのウィンドウを表示する
                    oXls.Visible = true;

                    //印刷
                    oxlsSheet.PrintPreview(true);

                    // ウィンドウを非表示にする
                    oXls.Visible = false;

                    //保存処理
                    oXls.DisplayAlerts = false;

                    DialogResult ret;

                    //ダイアログボックスの初期設定
                    saveFileDialog1.Title            = MESSAGE_CAPTION + "保存";
                    saveFileDialog1.OverwritePrompt  = true;
                    saveFileDialog1.RestoreDirectory = true;
                    saveFileDialog1.FileName         = MESSAGE_CAPTION + "_" + dataGridView2[1, dataGridView2.SelectedRows[0].Index].Value.ToString() + "_" + DateTime.Today.ToLongDateString();

                    //複数ページのとき、ページ数も付与
                    if (tempPage > 1)
                    {
                        saveFileDialog1.FileName += "_" + tempCurrentPage.ToString();
                    }

                    saveFileDialog1.Filter = "Microsoft Office Excelファイル(*.xls)|*.xls|全てのファイル(*.*)|*.*";

                    //ダイアログボックスを表示し「保存」ボタンが選択されたらファイル名を表示
                    string fileName;
                    ret = saveFileDialog1.ShowDialog();

                    if (ret == System.Windows.Forms.DialogResult.OK)
                    {
                        fileName = saveFileDialog1.FileName;
                        oXlsBook.SaveAs(fileName, Type.Missing, Type.Missing,
                                        Type.Missing, Type.Missing, Type.Missing,
                                        Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing,
                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    }

                    //Bookをクローズ
                    oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing);

                    //Excelを終了
                    oXls.Quit();
                }

                catch (Exception e)
                {
                    MessageBox.Show(e.Message, MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    //Bookをクローズ
                    oXlsBook.Close(Type.Missing, Type.Missing, Type.Missing);

                    //Excelを終了
                    oXls.Quit();
                }

                finally
                {
                    // COM オブジェクトの参照カウントを解放する
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oxlsSheet);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oXlsBook);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls);

                    //マウスポインタを元に戻す
                    this.Cursor = Cursors.Default;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            //マウスポインタを元に戻す
            this.Cursor = Cursors.Default;
        }
コード例 #17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string sqlString;

            Control.FreeSql fSql = new Control.FreeSql();

            // 受注テーブルに「外注発注書回収フラグ」フィールドを追加する : 2019/10/18
            sqlString  = "";
            sqlString += "ALTER TABLE 受注 add 外注発注書回収フラグ int default 0 NOT NULL";
            fSql.Execute(sqlString);

            // 受注テーブルに「配布完了報告書提出済フラグ」フィールドを追加する : 2019/10/18
            sqlString  = "";
            sqlString += "ALTER TABLE 受注 add 配布完了報告書提出済フラグ int default 0 NOT NULL";
            fSql.Execute(sqlString);


            // 受注テーブルに「編集ロック」フィールドを追加する : 2019/10/03
            sqlString  = "";
            sqlString += "ALTER TABLE 受注 add 編集ロック int default 0 NOT NULL";
            fSql.Execute(sqlString);

            // 受注テーブルに「注文書受領済み」フィールドを追加する : 2019/10/03
            sqlString  = "";
            sqlString += "ALTER TABLE 受注 add 注文書受領済み int default 0 NOT NULL";
            fSql.Execute(sqlString);

            // ログインタイプヘッダテーブルに「受注個別ロック権限」フィールドを追加する : 2019/10/03
            sqlString  = "";
            sqlString += "ALTER TABLE ログインタイプヘッダ add 受注個別ロック権限 int default 0 NOT NULL";
            fSql.Execute(sqlString);

            // ログインタイプヘッダテーブルに「受注個別制限」フィールドを追加する : 2019/10/03
            sqlString  = "";
            sqlString += "ALTER TABLE ログインタイプヘッダ add 受注個別制限 int default 0 NOT NULL";
            fSql.Execute(sqlString);

            // ログインタイプヘッダテーブルに「注文書受領済み権限」フィールドを追加する : 2019/10/03
            sqlString  = "";
            sqlString += "ALTER TABLE ログインタイプヘッダ add 注文書受領済み権限 int default 0 NOT NULL";
            fSql.Execute(sqlString);

            fSql.Close();

            //// 会社情報テーブルに「受注確定書入力シートパス」フィールドを追加する : 2019/03/06
            //sqlString = "";
            //sqlString += "ALTER TABLE 会社情報 add 受注確定書入力シートパス nvarchar(255) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「営業備考」フィールドを追加する : 2019/03/01
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 営業備考 nvarchar(255) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //// 得意先テーブルに「請求先・部署名」「請求先・敬称」フィールドを追加する : 2019/02/19
            //sqlString = "";
            //sqlString += "ALTER TABLE 得意先 add 請求先部署名 nvarchar(50) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 得意先 add 請求先敬称 nvarchar(5) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //fSql.Close();


            // 以下、コメント化 2019/02/19
            // 外注先マスターに「支払日」フィールドを追加する:2018/01/03
            //sqlString = "";
            //sqlString += "ALTER TABLE 外注先 add 支払日 int default 0 NOT NULL";

            //fSql.Execute(sqlString);

            //fSql.Close();

            // 以下のALTER TABLE SQL コメント化 2018/01/03
            //// 新請求書示テーブルに「口座」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 新請求書 add 口座 nvarchar(10) default '' NOT NULL";

            //fSql.Execute(sqlString);

            //fSql.Close();

            ///* 受注テーブルに「外注先ID支払2」「外注支払日支払2」「外注原価支払2」「外注先ID支払3」
            //「外注支払日支払3」「外注原価支払3」フィールドを追加する */

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注先ID支払2 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注支払日支払2 datetime";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注原価支払2 money default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注先ID支払3 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注支払日支払3 datetime";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注原価支払3 money default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「外注依頼日支払2」「外注依頼日支払3」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注依頼日支払2 datetime";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注依頼日支払3 datetime";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「外注委託枚数2」「外注委託枚数3」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注委託枚数2 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注委託枚数3 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「外注渡し日2」「外注渡し日3」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注渡し日2 datetime";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注渡し日3 datetime";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「外注受け渡し担当者2」「外注受け渡し担当者3」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注受け渡し担当者2 nvarchar(50) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注受け渡し担当者3 nvarchar(50) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //// 外注支払テーブルに「調整額」「調整日付」「調整備考」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 外注支払 add 調整額 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 外注支払 add 調整日付 nvarchar(10) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 外注支払 add 調整備考 nvarchar(100) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「外注支払ID2」「外注支払ID3」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注支払ID2 nvarchar(14) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 外注支払ID3 nvarchar(14) default '' NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルに「納品書発行」フィールドを追加する
            //sqlString = "";
            //sqlString += "ALTER TABLE 受注 add 納品書発行 int default 0 NOT NULL";
            //fSql.Execute(sqlString);

            //// 受注テーブルにインデックスを追加する 2016/11/02
            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_受注種別ID ";
            //sqlString += "ON 受注(受注種別ID) ";
            //sqlString += "INCLUDE(ID,得意先ID,チラシ名,枚数,税込金額)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_受注チラシ名 ";
            //sqlString += "ON 受注(チラシ名 ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_受注日 ";
            //sqlString += "ON 受注(受注日 ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_登録ユーザーID ";
            //sqlString += "ON 受注(登録ユーザーID ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_配布形態 ";
            //sqlString += "ON 受注(配布形態 ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_得意先ID ";
            //sqlString += "ON 受注(得意先ID ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //// 配布エリアテーブルにインデックスを追加する 2016/11/02
            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_配布指示ID ";
            //sqlString += "ON 配布エリア(配布指示ID) ";
            //sqlString += "INCLUDE(予定枚数,受注ID) ";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_完了区分配布指示ID ";
            //sqlString += "ON 配布エリア(完了区分,配布指示ID) ";
            //sqlString += "INCLUDE(予定枚数, 受注ID)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_配布エリア受注ID ";
            //sqlString += "ON 配布エリア(受注ID ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_ステータス ";
            //sqlString += "ON 配布エリア(ステータス ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_完了区分 ";
            //sqlString += "ON 配布エリア(完了区分 ASC) ";
            //sqlString += "INCLUDE(予定枚数, 受注ID) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //// 配布指示テーブルにインデックスを追加する 2016/11/02
            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_配布指示 ";
            //sqlString += "ON 配布指示(配布員ID ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_ユーザーID ";
            //sqlString += "ON 配布指示(ユーザーID ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);

            //// 得意先テーブルにインデックスを追加する 2016/11/02
            //sqlString = "";
            //sqlString += "CREATE NONCLUSTERED INDEX IX_担当社員コード ";
            //sqlString += "ON 得意先(担当社員コード ASC) ";
            //sqlString += "WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)";
            //fSql.Execute(sqlString);


            //////受注データの請求書IDを書き換える 2010/02/17
            //////DAテクニカルサービス 受注ID:201001150004 請求書ID:822 → 726
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 726 ";
            ////sqlString += "where ID = 201001150004";

            ////fSql.Execute(sqlString);

            //////受注データの請求書IDを書き換える 2010/03/03
            //////HAKU 受注ID:200911040013 請求書ID:776 → 613
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 613 ";
            ////sqlString += "where ID = 200911040013";

            ////fSql.Execute(sqlString);

            //////受注データの請求書IDを書き換える 2010/03/03
            //////表参道接骨院 受注ID:200912210002 請求書ID:743 → 660
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 660 ";
            ////sqlString += "where ID = 200912210002";

            ////fSql.Execute(sqlString);

            //////受注データの請求書IDを書き換える 2010/03/04
            //////レコプロ 受注ID:201001150002 請求書ID:899 → 744
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 744 ";
            ////sqlString += "where ID = 201001150002";

            ////fSql.Execute(sqlString);

            //////受注データの請求書IDを書き換える 2010/04/14
            //////レコプロ 受注ID:201003300007 請求書ID:0 → 1018
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 1018 ";
            ////sqlString += "where (ID = 201003300007) and (請求書ID = 0)";

            ////fSql.Execute(sqlString);

            //////受注データの請求書IDを書き換える 2010/04/14
            //////レコプロ 受注ID:201002190001 請求書ID:1017 → 900
            ////sqlString = "";
            ////sqlString += "update 受注 set 請求書ID = 900 ";
            ////sqlString += "where (ID = 201002190001) and (請求書ID = 1017)";

            ////fSql.Execute(sqlString);

            //fSql.Close();

            // メニュータイトルクラス 2015/07/07
            clsMenu cm = new clsMenu();

            // メニュータイトルCSVの読込 2015/07/07
            cm.loadMenu();

            // メニュータイトルをセット 2015/07/07
            Utility.getMenuTittle(button14, cm);
            Utility.getMenuTittle(button15, cm);
            Utility.getMenuTittle(button16, cm);
            Utility.getMenuTittle(button24, cm);
            Utility.getMenuTittle(button18, cm);
            Utility.getMenuTittle(button17, cm);
            Utility.getMenuTittle(button23, cm);
            Utility.getMenuTittle(button2, cm);
            Utility.getMenuTittle(button25, cm);
            Utility.getMenuTittle(button26, cm);
            Utility.getMenuTittle(button5, cm);
            Utility.getMenuTittle(button4, cm);
            Utility.getMenuTittle(button8, cm);
            Utility.getMenuTittle(button7, cm);
            Utility.getMenuTittle(button19, cm);
            Utility.getMenuTittle(button20, cm);
            Utility.getMenuTittle(button21, cm);
            Utility.getMenuTittle(button22, cm);
            Utility.getMenuTittle(button9, cm);
            Utility.getMenuTittle(button10, cm);
            Utility.getMenuTittle(button11, cm);
            Utility.getMenuTittle(button6, cm);
            Utility.getMenuTittle(button12, cm);
            Utility.getMenuTittle(button27, cm);
            Utility.getMenuTittle(button28, cm);
            Utility.getMenuTittle(button29, cm);
            Utility.getMenuTittle(button30, cm);
            Utility.getMenuTittle(button31, cm);
            Utility.getMenuTittle(button13, cm);
            Utility.getMenuTittle(button32, cm);
            Utility.getMenuTittle(button33, cm);
            Utility.getMenuTittle(button34, cm);

            // メニューボタン表示状態初期化
            button14.Enabled = false;
            button15.Enabled = false;
            button16.Enabled = false;
            button24.Enabled = false;
            button18.Enabled = false;
            button17.Enabled = false;
            button23.Enabled = false;
            button2.Enabled  = false;
            button25.Enabled = false;
            button26.Enabled = false;
            button5.Enabled  = false;
            button4.Enabled  = false;
            button8.Enabled  = false;
            button7.Enabled  = false;
            button19.Enabled = false;
            button20.Enabled = false;
            button21.Enabled = false;
            button22.Enabled = false;
            button9.Enabled  = false;
            button10.Enabled = false;
            button11.Enabled = false;
            button6.Enabled  = false;
            button12.Enabled = false;
            button27.Enabled = false;
            button28.Enabled = false;
            button29.Enabled = false;
            button30.Enabled = false;
            button31.Enabled = false;
            button13.Enabled = false;
            button32.Enabled = false;
            button33.Enabled = false;
            button34.Enabled = false;

            // ログインユーザーごとのメニュー制御
            darwinDataSet dts = new darwinDataSet();

            darwinDataSetTableAdapters.ログインタイプヘッダTableAdapter hAdp = new darwinDataSetTableAdapters.ログインタイプヘッダTableAdapter();
            darwinDataSetTableAdapters.ログインタイプタグTableAdapter  tAdp = new darwinDataSetTableAdapters.ログインタイプタグTableAdapter();
            hAdp.Fill(dts.ログインタイプヘッダ);
            tAdp.Fill(dts.ログインタイプタグ);

            foreach (var h in dts.ログインタイプヘッダ.Where(a => a.Id == global.loginType))
            {
                foreach (var item in h.GetログインタイプタグRows())
                {
                    if (menuButtonStatus(button14, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button15, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button16, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button24, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button18, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button17, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button23, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button2, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button25, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button26, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button5, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button4, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button8, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button7, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button19, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button20, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button21, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button22, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button9, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button10, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button11, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button6, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button12, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button27, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button28, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button29, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button30, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button31, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button13, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button32, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button33, item.tag))
                    {
                        continue;
                    }
                    if (menuButtonStatus(button34, item.tag))
                    {
                        continue;
                    }
                }
            }

            // ログイン中ユーザー
            //lblLogin.Text = "ログイン中ユーザー:" + global.loginUser;
            lblLogin.Text = global.loginUser + "さんがログイン中です";


            //// 自分自身のバージョン情報を取得する 2016/11/08
            //System.Diagnostics.FileVersionInfo ver =
            //    System.Diagnostics.FileVersionInfo.GetVersionInfo(
            //    System.Reflection.Assembly.GetExecutingAssembly().Location);

            // キャプションにバージョンを追加 2016/11/08
            this.Text += " ver " + Application.ProductVersion;
        }