private void btnEditOffice_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (OfficesGridView.GetFocusedRow() is Offices item) { frmAddEditOffice frm = new frmAddEditOffice(item, MethodType.Edit); frm.ShowDialog(); Init(); } }
private void OfficesGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.Name == "colChief") { if (OfficesGridView.GetRow(e.RowHandle) is Offices item) { var employees = new UnitOfWork().EmployeesRepo.Get() .FirstOrDefault(x => x.EmployeeName == item.Chief); if (employees == null) { return; } item.ChiefPosition = item.ChiefPosition; } } }
private void BtnDeleteUserRepo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (OfficesGridView.GetFocusedRow() is Offices item) { try { if (MessageBox.Show("Do you want to delete this?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } UnitOfWork unitOfWork = new UnitOfWork(); unitOfWork.OfficesRepo.Delete(m => m.Id == item.Id); unitOfWork.Save(); Init(); } catch (Exception exception) { MessageBox.Show(exception.Message, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }