private void mnuEmployer_Click(object sender, EventArgs e) { Employer employer = (Employer)bindingEmployers.Current; if (sender.Equals(mnuEmployerNew)) { /******************************************************************************** * New ********************************************************************************/ if (CanChangeCurrentEmployer()) { _GridViewState = GridViewState.Adding; bindingEmployers.AddNew(); _GridViewState = GridViewState.None; this.txtEmployerName.Focus(); } } else if (sender.Equals(mnuEmployerRemove)) { /******************************************************************************** * Remove ********************************************************************************/ if (DialogResult.OK == MyMessageBox.Show(this, "Employer", MyDisplayMessage.RemoveConfirm)) { try { bindingEmployers.RemoveCurrent(); bindingEmployers.ResetBindings(false); this.ucFilter.Focus(); } catch (MyException ex) { MyMessageBox.Show(this, "Employer", MyDisplayMessage.RemoveError, ex); } } } else if (sender.Equals(mnuEmployerRefresh)) { /******************************************************************************** * Refresh ********************************************************************************/ if (!employer.MyState.Equals(MyObjectState.Current)) { if (DialogResult.Cancel == MyMessageBox.Show(this, "Employer", MyDisplayMessage.RefreshConfirm)) { return; } } try { employer.Refresh(); bindingEmployers.ResetBindings(false); this.txtEmployerName.Focus(); this.txtEmployerName.Select(0, 0); } catch (MyException ex) { MyMessageBox.Show(this, "Employer", MyDisplayMessage.RefreshError, ex); } } else if (sender.Equals(mnuEmployerSave)) { /******************************************************************************** * Save ********************************************************************************/ bindingEmployers.EndEdit(); try { employer.Save(true); bindingEmployers.ResetBindings(false); bindingEmployers.Sort = ""; if (dgvEmployers.SortOrder == SortOrder.Descending) { bindingEmployers.Sort = dgvEmployers.SortedColumn.DataPropertyName + " DESC"; } else { bindingEmployers.Sort = dgvEmployers.SortedColumn.DataPropertyName + " ASC"; } ResetDataGridViewEmployer(employer); } catch (MyException ex) { MyMessageBox.Show(this, "Employer", MyDisplayMessage.SaveError, ex); } } else if (sender.Equals(mnuEmployerCancel)) { /******************************************************************************** * Cancel ********************************************************************************/ if (employer.MyState == MyObjectState.New) { bindingEmployers.RemoveCurrent(); if (bindingEmployers.Count > 0) { bindingEmployers.Position = 0; this.txtEmployerName.Focus(); this.txtEmployerName.Select(0, 0); } else { this.ucFilter.Focus(); } } else { employer.Reset(); bindingEmployers.ResetCurrentItem(); } } }