Exemplo n.º 1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            // 他に登録されているときは削除不可とする
            string SqlStr;

            SqlStr  = " where ";
            SqlStr += "(配布指示.配布員ID = " + txtCode.Text.ToString() + ")  ";

            OleDbDataReader dr;

            Control.配布指示 Shiji = new Control.配布指示();
            dr = Shiji.FillBy(SqlStr);

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

            dr.Close();
            Shiji.Close();

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

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

            DispClear();

            // データを 'darwinDataSet.配布員' テーブルに読み込みます。
            this.配布員TableAdapter.Fill(this.darwinDataSet.配布員);
            //this.配布員TableAdapter.Fill(this.darwinDataSet.配布員gridview);

            // グリッド再表示
            gridSerach(dataGridView1);
        }