private void btnUpdate_Click(object sender, EventArgs e) { try { if (fDataCheck() == true) { Control.振込口座 Kouza = new Control.振込口座(); switch (fMode.Mode) { case 0: //新規登録 if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Kouza.Close(); return; } if (Kouza.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) { Kouza.Close(); return; } if (Kouza.DataUpdate(cMaster) == true) { MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新に失敗しました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Stop); } break; } Kouza.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.振込口座 Kouza = new Control.振込口座(); OleDbDataReader dr; sqlStr = " where 振込口座.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value; dr = Kouza.FillBy(sqlStr); if (dr.HasRows == true) { while (dr.Read() == true) { tempC.ID = Convert.ToInt32(dr["ID"].ToString()); tempC.金融機関名 = dr["金融機関名"].ToString() + ""; tempC.支店名 = dr["支店名"].ToString(); tempC.口座種別 = Convert.ToInt32(dr["口座種別"].ToString()); tempC.口座番号 = dr["口座番号"].ToString(); tempC.口座名義 = dr["口座名義"].ToString(); } } else { dr.Close(); Kouza.Close(); return(false); } dr.Close(); Kouza.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(); //他に登録されているときは削除不可とする�A SqlStr = " where "; SqlStr += "(請求書.振込口座ID1 = " + cMaster.ID.ToString() + ") or "; SqlStr += "(請求書.振込口座ID2 = " + cMaster.ID.ToString() + ") "; Control.請求書 Seikyu = new Control.請求書(); dr = Seikyu.FillBy(SqlStr); //該当振込口座の受注データが登録されているときは削除不可とする if (dr.HasRows == true) { MessageBox.Show(txtName1.Text.ToString() + "の請求データが登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error); dr.Close(); Seikyu.Close(); return; } dr.Close(); Seikyu.Close(); //削除確認 if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } //データ削除 Control.振込口座 Kouza = new Control.振込口座(); if (Kouza.DataDelete(cMaster.ID) == true) { MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } Kouza.Close(); DispClear(); //データを 'darwinDataSet.振込口座' テーブルに読み込みます。 this.振込口座TableAdapter.Fill(this.darwinDataSet.振込口座); }