private void btnUpdate_Click(object sender, EventArgs e) { try { if (fDataCheck() == true) { Control.受注種別 Shubetsu = new Control.受注種別(); switch (fMode.Mode) { case 0: //新規登録 if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Shubetsu.Close(); return; } if (Shubetsu.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) { Shubetsu.Close(); return; } if (Shubetsu.DataUpdate(cMaster) == true) { MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新に失敗しました", "所属マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop); } break; } Shubetsu.Close(); DispClear(); //データを 'darwinDataSet.受注種別' テーブルに読み込みます。 this.受注種別TableAdapter.Fill(this.darwinDataSet.受注種別); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "更新処理", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// <summary> /// データグリッドビューの指定行のデータを取得する /// </summary> /// <param name="dgv">対象とするデータグリッドビューオブジェクト</param> public static Boolean GetData(DataGridView dgv, ref Entity.受注種別 tempC) { int iX = 0; string sqlStr; Control.受注種別 Shubetsu = new Control.受注種別(); OleDbDataReader dr; sqlStr = " where 受注種別.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value; dr = Shubetsu.FillBy(sqlStr); if (dr.HasRows == true) { while (dr.Read() == true) { tempC.ID = Convert.ToInt32(dr["ID"].ToString()); tempC.称 = dr["名称"].ToString() + ""; tempC.備考 = dr["備考"].ToString() + ""; } } else { dr.Close(); Shubetsu.Close(); return(false); } dr.Close(); Shubetsu.Close(); return(true); }
private void btnDel_Click(object sender, EventArgs e) { //他に登録されているときは削除不可とする string SqlStr; SqlStr = " where "; SqlStr += "(受注.受注種別ID = " + cMaster.ID.ToString() + ") "; OleDbDataReader dr; Control.受注 Order = new Control.受注(); dr = Order.FillBy(SqlStr); //該当種別の受注データが登録されているときは削除不可とする if (dr.HasRows == true) { MessageBox.Show(txtName1.Text.ToString() + "の受注データが登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error); dr.Close(); Order.Close(); return; } dr.Close(); Order.Close(); //削除確認 if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } //データ削除 Control.受注種別 Shubetsu = new Control.受注種別(); if (Shubetsu.DataDelete(cMaster.ID) == true) { MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } Shubetsu.Close(); DispClear(); //データを 'darwinDataSet.所属' テーブルに読み込みます。 this.受注種別TableAdapter.Fill(this.darwinDataSet.受注種別); }