/// <summary> /// Handles the Validated event of the txtID control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void txtID_Validated(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtID.Text.Trim())) return; var db = new LoketBase(); Loket r = db.GetById(txtID.Text.Trim()); db.Dispose(); try { txtDescription.Text = r.LoketDescription; txtID.Enabled = false; } catch (NullReferenceException) { MessageBox.Show(@"ID tidak dikenal !", @"Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetData(); } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnSave_Click(object sender, EventArgs e) { try { var r = new Loket { LoketID = txtID.Text.Trim(), LoketDescription = txtDescription.Text.Trim() }; // --- Confirm if (Confirm("Do you want to save this data?") != DialogResult.Yes) return; DialogResult dlg; using (var f = new LogonPresentation()) { dlg = f.ShowDialog(this); } if (dlg == DialogResult.OK) { IDataAccess<Loket> db = new LoketBase(); if (db.Update(r) == 1) ResetData(); } } catch (ArgumentNullException ex) { MessageBox.Show(ex.Message, @"Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } catch (Exception ex) { MessageBox.Show(ex.Message, @"Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
/// <summary> /// Inits the loket. /// </summary> private void InitLoket() { List<Loket> dsLoket = new LoketBase().GetAll(); cboLoket.DataSource = dsLoket; cboLoket.DisplayMember = "LoketID"; }