private void btnEditPo_Click(object sender, EventArgs e) { var res = OfficeGrid.GetFocusedRow(); if (res is Offices item) { frmAddEditOffices frm = new frmAddEditOffices(item, MethodType.Edit); frm.ShowDialog(); this.OfficeBindingSource.DataSource = new UnitOfWork().OfficesRepo.Get(); } }
private void repositoryItemButtonEdit1_ButtonClick_1(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (MessageBox.Show("Do you want to delete this row", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } var res = OfficeGrid.GetFocusedRow(); using (UnitOfWork unitOfWork = new UnitOfWork()) { if (res is Offices item) { unitOfWork.OfficesRepo.Delete(item); } unitOfWork.Save(); } this.OfficeBindingSource.DataSource = new UnitOfWork().OfficesRepo.Get(); }