protected override void HandleAddButtonClick(object sender, EventArgs e) { SimpleInputForm inputForm = new SimpleInputForm(); while (true) { inputForm.ShowDialog(); try { SimpleIOManager.CurrentEntity.Add(inputForm.Value); } catch (CapacityOverflowException) { MessageBox.Show("Достигнуто предельное число записей"); return; } catch (ValueAlreadyExistsException) { MessageBox.Show("Такое значение уже есть в базе"); continue; } catch (EmptyValueException) { return; } catch (LongArgumentException) { MessageBox.Show("Слишком длинная строка"); continue; } break; } SimpleIOManager.CurrentEntity.Apply(); DataSource = SimpleIOManager.CurrentEntity.Values; }
protected override void HandleSetButtonClick(object sender, EventArgs e) { string oldvalue = listBox.GetItemText(listBox.SelectedItem); SimpleInputForm inputForm = new SimpleInputForm(oldvalue); while (true) { inputForm.ShowDialog(); try { SimpleIOManager.CurrentEntity.Set(oldvalue, inputForm.Value); } catch (ValueAlreadyExistsException) { MessageBox.Show("Такое значение уже есть в базе"); continue; } catch (NoSuchValueException) { MessageBox.Show("Невозможно найти элемент с таким значением"); return; } catch (EmptyValueException) { return; } catch (LongArgumentException) { MessageBox.Show("Слишком длинная строка"); continue; } break; } SimpleIOManager.CurrentEntity.Apply(); DataSource = SimpleIOManager.CurrentEntity.Values; }