private void btnUpdate_Click(object sender, EventArgs e) { try { if (fDataCheck() == true) { Control.締日パターン Shimebi = new Control.締日パターン(); switch (fMode.Mode) { case 0: //新規登録 if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Shimebi.Close(); return; } if (Shimebi.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) { Shimebi.Close(); return; } if (Shimebi.DataUpdate(cMaster) == true) { MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新に失敗しました", "所属マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop); } break; } Shimebi.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.締日パターン Shimebi = new Control.締日パターン(); OleDbDataReader dr; sqlStr = " where 締日パターン.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value; dr = Shimebi.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(); Shimebi.Close(); return(false); } dr.Close(); Shimebi.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.締日パターン Shimebi = new Control.締日パターン(); if (Shimebi.DataDelete(cMaster.ID) == true) { MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } Shimebi.Close(); DispClear(); //データを 'darwinDataSet.所属' テーブルに読み込みます。 this.締日パターンTableAdapter.Fill(this.darwinDataSet.締日パターン); }