private void btnUpdate_Click(object sender, EventArgs e) { try { if (fDataCheck() == true) { Control.未配布理由 Shozoku = new Control.未配布理由(); switch (fMode.Mode) { case 0: //新規登録 if (MessageBox.Show("新規登録します。よろしいですか?", "登録確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Shozoku.Close(); return; } if (Shozoku.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) { Shozoku.Close(); return; } if (Shozoku.DataUpdate(cMaster) == true) { MessageBox.Show("更新されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("更新に失敗しました", "所属マスター", MessageBoxButtons.OK, MessageBoxIcon.Stop); } break; } Shozoku.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.未配布理由 Shozoku = new Control.未配布理由(); OleDbDataReader dr; sqlStr = " where 未配布理由.ID = " + (int)dgv[0, dgv.SelectedRows[iX].Index].Value; dr = Shozoku.FillBy(sqlStr); if (dr.HasRows == true) { while (dr.Read() == true) { tempC.ID = Convert.ToInt32(dr["ID"].ToString()); tempC.摘要 = dr["摘要"].ToString() + ""; } } else { dr.Close(); Shozoku.Close(); return(false); } dr.Close(); Shozoku.Close(); return(true); }
private void txtRiyu_Validating(object sender, CancelEventArgs e) { //無記入はOK if (txtRiyu.Text == "") { txtRiyuName.Text = ""; txtSonota.Enabled = false; return; } //数字か? if (Utility.NumericCheck(txtRiyu.Text) == false) { MessageBox.Show("数字で入力してください", "未配布理由", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.Cancel = true; return; } //マスター登録されているか? OleDbDataReader dR; Control.未配布理由 cRiyu = new Control.未配布理由(); dR = cRiyu.FillBy("where ID = " + txtRiyu.Text); if (dR.HasRows == false) { MessageBox.Show("マスター未登録です", "未配布理由", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.Cancel = true; dR.Close(); cRiyu.Close(); return; } //摘要名を表示 while (dR.Read()) { txtRiyuName.Text = dR["摘要"].ToString().Trim(); } dR.Close(); cRiyu.Close(); //その他のとき if (txtRiyuName.Text == "その他") { txtSonota.Enabled = true; txtSonota.Focus(); } else { txtSonota.Enabled = false; } }
private void ShowData() { lblID.Text = _ID.ToString(); lblAdd.Text = _Add; //データ取得 OleDbDataReader dR; string sqlSTR; sqlSTR = "where ID = " + _ID.ToString(); Control.未配布情報 cMihaifu = new Control.未配布情報(); dR = cMihaifu.FillBy(sqlSTR); while (dR.Read()) { cMaster.ID = int.Parse(dR["ID"].ToString()); cMaster.配布エリアID = int.Parse(dR["配布エリアID"].ToString()); cMaster.番地号 = dR["番地号"].ToString(); cMaster.マンション名 = dR["マンション名"].ToString(); cMaster.理由 = int.Parse(dR["理由"].ToString()); cMaster.その他内容 = dR["その他内容"].ToString(); } dR.Close(); cMihaifu.Close(); //データ画面表示 txtBanchi.Text = cMaster.番地号; txtManshon.Text = cMaster.マンション名; txtRiyu.Text = cMaster.理由.ToString(); txtSonota.Text = cMaster.その他内容; //理由摘要表示 //OleDbDataReader dR; Control.未配布理由 cRiyu = new Control.未配布理由(); dR = cRiyu.FillBy("where ID = " + txtRiyu.Text); //摘要名を表示 while (dR.Read()) { txtRiyuName.Text = dR["摘要"].ToString().Trim(); } dR.Close(); cRiyu.Close(); }
private void btnDel_Click(object sender, EventArgs e) { //配布エリアデータに登録されているときは削除不可とする string SqlStr; SqlStr = " where "; SqlStr += "(配布エリア.理由 = " + txtCode.Text.ToString() + ") "; OleDbDataReader dr; Control.配布エリア Shain = new Control.配布エリア(); dr = Shain.FillBy(SqlStr); //配布エリアデータに登録されているときは削除不可とする if (dr.HasRows == true) { MessageBox.Show("未配布理由が「" + txtName1.Text.ToString() + "」の配布エリアデータが登録されています", txtName1.Text.ToString() + "は削除できません", MessageBoxButtons.OK, MessageBoxIcon.Error); dr.Close(); Shain.Close(); return; } dr.Close(); Shain.Close(); //削除確認 if (MessageBox.Show("削除します。よろしいですか?", "削除確認", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } //データ削除 Control.未配布理由 Shozoku = new Control.未配布理由(); if (Shozoku.DataDelete(Convert.ToInt32(txtCode.Text.ToString())) == true) { MessageBox.Show("削除されました", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information); } Shozoku.Close(); DispClear(); //データを 'darwinDataSet.所属' テーブルに読み込みます。 this.未配布理由TableAdapter.Fill(this.darwinDataSet.未配布理由); }
//登録データチェック 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.未配布理由 Shozoku = new Control.未配布理由(); OleDbDataReader dr; sqlStr = " where ID = " + txtCode.Text.ToString(); dr = Shozoku.FillBy(sqlStr); if (dr.HasRows == true) { txtCode.Focus(); dr.Close(); Shozoku.Close(); throw new Exception("既に登録済みのコードです"); } dr.Close(); Shozoku.Close(); } //名称チェック if (txtName1.Text.Trim().Length < 1) { txtName1.Focus(); throw new Exception("摘要を入力してください"); } //所属クラスにデータセット cMaster.ID = Convert.ToInt32(txtCode.Text.ToString()); cMaster.摘要 = txtName1.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); } }