Beispiel #1
0
            /// <summary>
            /// データグリッドビューの指定行のデータを取得する
            /// </summary>
            /// <param name="dgv">対象とするデータグリッドビューオブジェクト</param>
            public static Boolean GetData(DataGridView dgv, ref Entity.町名 tempC)
            {
                int    iX = 0;
                string sqlStr;

                Control.町名      Town = new Control.町名();
                OleDbDataReader dr;

                sqlStr = " where 町名.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value;
                dr     = Town.FillBy(sqlStr);

                if (dr.HasRows == true)
                {
                    while (dr.Read() == true)
                    {
                        tempC.ID      = Convert.ToInt32(dr["ID"].ToString());
                        tempC.称       = dr["名称"].ToString() + "";
                        tempC.市区町村コード = int.Parse(dr["市区町村コード"].ToString(), System.Globalization.NumberStyles.Any);
                        tempC.備考      = dr["備考"].ToString() + "";
                    }
                }
                else
                {
                    dr.Close();
                    Town.Close();
                    return(false);
                }

                dr.Close();
                Town.Close();
                return(true);
            }
Beispiel #2
0
        private string GetTownName(string tempID)
        {
            //配布エリア町名検索
            string          strName = "";
            OleDbDataReader dr;

            Control.町名 cTown = new Control.町名();
            dr = cTown.FillBy("where ID = " + tempID);

            while (dr.Read())
            {
                strName = dr["名称"].ToString();
            }

            dr.Close();
            return(strName);
        }
Beispiel #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.町名;
        }
Beispiel #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                //配布エリア町名検索
                OleDbDataReader dr;
                int             iX = 0;

                Control.町名 cTown = new Control.町名();
                dr = cTown.FillBy("where 名称 like '%" + textBox5.Text.ToString() + "%' order by ID");
                dataGridView3.Rows.Clear();

                while (dr.Read())
                {
                    dataGridView3.Rows.Add();
                    dataGridView3[0, iX].Value = dr["ID"];
                    dataGridView3[1, iX].Value = dr["名称"];
                    iX++;
                }

                //if (dataGridView3.RowCount <= 11)
                //{
                //    dataGridView3.Columns[1].Width = 280;
                //}
                //else
                //{
                //    dataGridView3.Columns[1].Width = 263;
                //}

                dr.Close();
                cTown.Close();

                dataGridView3.Focus();
                dataGridView3.CurrentCell = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK);
            }
        }
Beispiel #5
0
        //登録データチェック
        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);
            }
        }
Beispiel #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (fDataCheck() == true)
                {
                    Control.町名 Town = new Control.町名();

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

                        if (Town.DataInsert(cMaster) == true)
                        {
                            MessageBox.Show("新規登録されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("新規登録に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;

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

                        if (Town.DataUpdate(cMaster) == true)
                        {
                            MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("更新に失敗しました", "所属マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }

                        break;
                    }

                    Town.Close();

                    DispClear();

                    //データを 'darwinDataSet.町名' テーブルに読み込みます。
                    this.町名TableAdapter.Fill(this.darwinDataSet.町名);
                    dataGridView1.DataSource = this.darwinDataSet.町名;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }