Exemple #1
0
        private void button5_Click(object sender, EventArgs e)
        //配布エリアの町名を一括登録する
        {
            if (MessageBox.Show("選択されている町名を一括追加登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            foreach (DataGridViewRow r in dataGridView3.SelectedRows)
            {
                txtAreaID.Text     = dataGridView3[0, r.Index].Value.ToString();
                txtHaihuMaisu.Text = "0";

                if (fDataCheck() == true)
                {
                    Control.配布エリア dArea = new Control.配布エリア();
                    if (dArea.DataInsert(cArea) == false)
                    {
                        MessageBox.Show(dataGridView3[1, r.Index].Value.ToString() + "の新規登録に失敗しました", "町名一括登録", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    dArea.Close();
                }
            }

            DispClear2();

            txtAreaID.Focus();

            //配布エリア再表示
            GridviewSet.AreaShowData(dataGridView2, long.Parse(txtID.Text.ToString()));
            MaisuSum();
        }
Exemple #2
0
        private void txtAdd_Click(object sender, EventArgs e)
        {
            //配布エリア登録
            try
            {
                if (fDataCheck() == true)
                {
                    Control.配布エリア dArea = new Control.配布エリア();

                    switch (aMode.Mode)
                    {
                    case 0:     //新規登録
                        if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            break;
                        }

                        if (dArea.DataInsert(cArea) == false)
                        {
                            MessageBox.Show("新規登録に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;

                    case 1:     //更新
                        if (MessageBox.Show("更新します。よろしいですか?", "更新確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            break;
                        }

                        if (dArea.DataUpdate(cArea) == false)
                        {
                            MessageBox.Show("更新に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;
                    }

                    dArea.Close();

                    DispClear2();

                    txtAreaID.Focus();

                    //配布エリア再表示
                    GridviewSet.AreaShowData(dataGridView2, long.Parse(txtID.Text.ToString()));
                    MaisuSum();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MESSAGE_CAPTION + "保守", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #3
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //他に登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(配布エリア.町名ID = " + txtCode.Text.ToString() + ")  ";

            OleDbDataReader dr;

            Control.配布エリア Area = new Control.配布エリア();
            dr = Area.FillBy(SqlStr);

            //該当町名が登録されているときは削除不可とする
            if (dr.HasRows == true)
            {
                MessageBox.Show(txtName1.Text.ToString() + "が配布エリアデータに登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                Area.Close();
                return;
            }

            dr.Close();
            Area.Close();

            //削除確認
            if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            //データ削除
            Control.町名 Town = new Control.町名();
            if (Town.DataDelete(Convert.ToInt32(txtCode.Text.ToString())) == true)
            {
                MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Town.Close();

            DispClear();

            //データを 'darwinDataSet.町名' テーブルに読み込みます。
            this.町名TableAdapter.Fill(this.darwinDataSet.町名);
            dataGridView1.DataSource = this.darwinDataSet.町名;
        }
Exemple #4
0
            public static void AreaShowData(DataGridView tempDGV, long tempID)
            {
                int iX;

                try
                {
                    tempDGV.RowCount = 0;

                    //配布エリアデータを取得する
                    OleDbDataReader dr;
                    Control.配布エリア   dArea = new Control.配布エリア();
                    dr = dArea.FillBy("where 受注ID = " + tempID.ToString() + " order by 町名ID");

                    iX = 0;

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

                        tempDGV[0, iX].Value = long.Parse(dr["ID"].ToString());
                        tempDGV[1, iX].Value = dr["町名ID"].ToString();
                        tempDGV[3, iX].Value = Int32.Parse(dr["予定枚数"].ToString());
                        tempDGV[4, iX].Value = Int32.Parse(dr["配布指示ID"].ToString());
                        iX++;
                    }

                    tempDGV.CurrentCell = null;

                    //if (tempDGV.RowCount <= 18)
                    //{
                    //    tempDGV.Columns[2].Width = 218;
                    //}
                    //else
                    //{
                    //    tempDGV.Columns[2].Width = 201;
                    //}

                    dr.Close();
                    dArea.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK);
                }
            }
Exemple #5
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            //配布エリアデータに登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(配布エリア.理由 = " + txtCode.Text.ToString() + ")  ";

            OleDbDataReader dr;

            Control.配布エリア Shain = new Control.配布エリア();
            dr = Shain.FillBy(SqlStr);

            //配布エリアデータに登録されているときは削除不可とする
            if (dr.HasRows == true)
            {
                MessageBox.Show("未配布理由が「" + txtName1.Text.ToString() + "」の配布エリアデータが登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
                Shain.Close();
                return;
            }

            dr.Close();
            Shain.Close();

            //削除確認
            if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            //データ削除
            Control.未配布理由 Shozoku = new Control.未配布理由();
            if (Shozoku.DataDelete(Convert.ToInt32(txtCode.Text.ToString())) == true)
            {
                MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Shozoku.Close();

            DispClear();

            //データを 'darwinDataSet.所属' テーブルに読み込みます。
            this.未配布理由TableAdapter.Fill(this.darwinDataSet.未配布理由);
        }
Exemple #6
0
            public static Boolean GetPostingData(int tempID, ref Entity.配布エリア tempC)
            {
                string sqlStr;

                Control.配布エリア   dArea = new Control.配布エリア();
                OleDbDataReader dr;

                sqlStr = " where 配布エリア.ID = " + tempID.ToString();
                dr     = dArea.FillBy(sqlStr);

                if (dr.HasRows == true)
                {
                    while (dr.Read() == true)
                    {
                        tempC.ID     = Convert.ToInt32(dr["ID"].ToString());
                        tempC.町名ID   = Int32.Parse(dr["町名ID"].ToString());
                        tempC.予定枚数   = Int32.Parse(dr["予定枚数"].ToString());
                        tempC.受注ID   = long.Parse(dr["受注ID"].ToString());
                        tempC.配布指示ID = Int32.Parse(dr["配布指示ID"].ToString());
                        tempC.配布単価   = double.Parse(dr["配布単価"].ToString(), System.Globalization.NumberStyles.AllowDecimalPoint);
                        tempC.配布日    = dr["配布日"].ToString();
                        tempC.実配布枚数  = Int32.Parse(dr["実配布枚数"].ToString());
                        tempC.実残数    = Int32.Parse(dr["実残数"].ToString());
                        tempC.報告枚数   = Int32.Parse(dr["報告枚数"].ToString());
                        tempC.報告残数   = Int32.Parse(dr["報告残数"].ToString());
                        tempC.併配区分   = Int32.Parse(dr["併配区分"].ToString());
                        tempC.枝番記入   = dr["枝番記入"].ToString();
                        tempC.完了区分   = Int32.Parse(dr["完了区分"].ToString());
                        tempC.ステータス  = Int32.Parse(dr["ステータス"].ToString());
                    }
                }
                else
                {
                    dr.Close();
                    dArea.Close();
                    return(false);
                }

                dr.Close();
                dArea.Close();
                return(true);
            }
Exemple #7
0
        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 + " が選択されました。よろしいですか?", "ポスティングエリアExcelシート取り込み", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

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

            //マウスポインタを待機にする
            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    Cnt = 0;
            int    err;
            string cellID;
            string cellMaisu;
            int    d;

            try
            {
                while (true)
                {
                    err = 0;

                    //エリアID
                    dRng = (Excel.Range)oxlsSheet.Cells[iX, 1];

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

                    cellID = dRng.Text.ToString().Trim();

                    //IDチェック
                    if (cellID == null)
                    {
                        err = 1;
                        MessageBox.Show("エリアIDが正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellID, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (int.TryParse(cellID, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out d) == false)
                    {
                        err = 1;
                        MessageBox.Show("エリアIDが正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellID, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (Int32.Parse(cellID, System.Globalization.NumberStyles.Any) < 0)
                    {
                        err = 1;
                        MessageBox.Show("エリアIDが正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellID, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    //配布枚数
                    dRng      = (Excel.Range)oxlsSheet.Cells[iX, 3];
                    cellMaisu = dRng.Text.ToString().Trim();

                    //チェック
                    if (cellMaisu == null)
                    {
                        err = 1;
                        MessageBox.Show("配布枚数が正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellMaisu, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (int.TryParse(cellMaisu, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out d) == false)
                    {
                        err = 1;
                        MessageBox.Show("配布枚数が正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellMaisu, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (Int32.Parse(cellMaisu, System.Globalization.NumberStyles.Any) < 0)
                    {
                        err = 1;
                        MessageBox.Show("配布枚数が正しくありません。この行はスキップされます。 " + Environment.NewLine + iX.ToString() + "行目 : " + cellMaisu, "取り込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    //エラーのときは読み飛ばし
                    if (err == 0)
                    {
                        txtAreaID.Text     = cellID.ToString();
                        txtHaihuMaisu.Text = cellMaisu.ToString();

                        if (fDataCheck() == true)
                        {
                            Control.配布エリア dArea = new Control.配布エリア();
                            if (dArea.DataInsert(cArea) == false)
                            {
                                MessageBox.Show("新規登録に失敗しました", "Excelシート取り込み", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                Cnt++;
                            }

                            dArea.Close();
                        }
                    }

                    iX++;
                }

                MessageBox.Show(Cnt.ToString() + " 件の配布エリアを取り込みました", "取り込み終了", 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;
            }


            DispClear2();

            txtAreaID.Focus();

            //配布エリア再表示
            GridviewSet.AreaShowData(dataGridView2, long.Parse(txtID.Text.ToString()));

            MaisuSum();
        }
Exemple #8
0
        private void txtAdel_Click(object sender, EventArgs e)
        {
            if (dataGridView2.SelectedRows.Count == 0)
            {
                MessageBox.Show("ポスティングエリアデータが選択されていません", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (MessageBox.Show("選択された " + dataGridView2.SelectedRows.Count.ToString() + "件のポスティングエリアデータを削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                dataGridView2.CurrentCell = null;
                return;
            }

            foreach (DataGridViewRow r in dataGridView2.SelectedRows)
            {
                int aID;
                aID = int.Parse(dataGridView2[0, r.Index].Value.ToString(), System.Globalization.NumberStyles.Any);

                //レコード削除
                Control.配布エリア dArea = new Control.配布エリア();

                if (dArea.DataDelete(aID) == false)
                {
                    MessageBox.Show("削除に失敗しました。エリアID:" + aID.ToString(), MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                dArea.Close();
            }

            DispClear2();

            //配布エリア再表示
            GridviewSet.AreaShowData(dataGridView2, long.Parse(txtID.Text.ToString()));
            MaisuSum();



            ////削除
            //if (MessageBox.Show(txtAreaName.Text + " を削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            //    return;

            ////データ削除
            //Control.配布エリア dArea = new Control.配布エリア();
            //if (dArea.DataDelete(cArea.ID) == true)
            //{
            //    MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
            //else
            //{
            //    MessageBox.Show("削除に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}

            //dArea.Close();

            //DispClear2();

            ////配布エリア再表示
            //GridviewSet.AreaShowData(dataGridView2, long.Parse(txtID.Text.ToString()));
            //MaisuSum();
        }