public override void Edit() { Domain.Colouring l = (Domain.Colouring)mainGridView.GetRow(mainGridView.FocusedRowHandle); if (l == null) { return; } FormColouring f = new FormColouring(); f.Text = GetLocalized("Edit Colouring"); f.Colouring = l; if (f.ShowDialog(OwnerForm) == DialogResult.OK) { try { ClientEnvironment.ColouringService.SaveOrUpdate(f.Colouring); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveColouring"); form.ShowDialog(this); } } } RefreshData(); }
private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e) { if (!isUserWriteRight) { return; } GridHitInfo info = gridViewColor.CalcHitInfo(e.X, e.Y); if (info.InRowCell && gridViewColor.IsDataRow(info.RowHandle)) { Domain.Colouring color = GetEntityByRowHandle(info.RowHandle); if (color != null) { FireEditEntity(color); } } }
public override void Delete() { //XtraMessageBox.Show(this, "Delete", this.Name, MessageBoxButtons.OK); List <long> ids = new List <long>(); foreach (int rowHandle in mainGridView.GetSelectedRows()) { Domain.Colouring col = (Domain.Colouring)mainGridView.GetRow(rowHandle); ids.Add(col.ID); } if (ids.Count == 1) { try { ClientEnvironment.ColouringService.DeleteByID(ids[0]); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotDeleteColouring"); form.ShowDialog(this); } } } else { try { ClientEnvironment.ColouringService.DeleteListByID(ids); } catch (EntityException) { // can't obtain more details while deleting list ErrorMessage(GetLocalized("SomeColouringsNotDeleted")); } } RefreshData(); }
public void FireEditEntity(Domain.Colouring color) { Domain.Colouring c = color; if (c == null) { c = FocusedEntity; } if (c == null) { return; } FormColour form = new FormColour(); form.Entity = c; if (form.ShowDialog() == DialogResult.OK) { _bindingList.ResetItemById(c.ID); } }