private void SignatoriesGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.Name == "colPerson") { if (SignatoriesGridView.GetRow(e.RowHandle) is Signatories item) { UnitOfWork unitOfWork = new UnitOfWork(); var office = unitOfWork.OfficesRepo.Find(x => x.Chief == item.Person); item.Office = office.OfficeName; item.Position = office.ChiefPosition; } } }
private void btnDeleteSignatory_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (MessageBox.Show("Do you want to delete this?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } try { if (SignatoriesGridView.GetFocusedRow() is Signatories item) { UnitOfWork unitOfWork = new UnitOfWork(); unitOfWork.Signatories.Delete(m => m.Id == item.Id); unitOfWork.Save(); Init(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }