private void okButton_Click(object sender, EventArgs e) { // Click on OK button > Apply then close try { // According to selected update mode if (selectResourceRadioButton.Checked) { // Another resource id string columnName = _DbTopic.Structure[_ColumnId].name; DatabaseHelper.UpdateCellFromTopicWithEntryId(_DbTopic, columnName, _ResourceId, _EntryId); } else { // Changed resource value DBResource.Entry editedEntry = _DbResource.GetEntryFromId(_ResourceId); editedEntry.value = resourceValueTextBox.Text; _DbResource.UpdateEntry(editedEntry); } DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } }
private void editOKButton_Click(object sender, EventArgs e) { // Clic sur le bouton 'OK' if (!_EditedEntry.isValid) { return; } // EVO_xx : line adding feature bool isAddingEntry = (_EditedEntry.id == null); // Prépare les données pour la mise à jour string newId = idTextBox.Text; string value = valueTextBox.Text; try { Cursor = Cursors.WaitCursor; // According to mode if (isAddingEntry) { // Add // Is this identifier a UID ? if (_LeDB.GetEntryFromId(newId).isValid) { idTextBox.Focus(); throw new Exception(_ERROR_ID_EXISTS); } // Identifier update if (!_EditedEntry.isComment) { _EditedEntry.id = new ResourceIdentifier(newId, _LeDB.CurrentTopic); } // Value update _EditedEntry.value = value; // Update file data _LeDB.InsertEntry(_EditedEntry); _LeDB.Save(); // List update _UpdateEntryList(true); // Signals if (_EditedFile == null) { StatusBarLogManager.ShowEvent(this, _STATUS_INS_SUCCESS_1); } else { StatusBarLogManager.ShowEvent(this, _STATUS_INS_SUCCESS_2); } } else { // Modify // Is update necessary ? if (!newId.Equals(_EditedEntry.id.Id) || !value.Equals(_EditedEntry.value)) { // Identifier update if (!_EditedEntry.isComment) { _EditedEntry.id = new ResourceIdentifier(newId, _LeDB.CurrentTopic); } // Value update _EditedEntry.value = value; // Met à jour les données du fichier DBResource.Entry entryAfterUpdate = _LeDB.UpdateEntry(_EditedEntry); _LeDB.Save(); // Met à jour la ligne dans le tableau _UpdateEntryFromLine(entryAfterUpdate); // Signals if (_EditedFile == null) { StatusBarLogManager.ShowEvent(this, _STATUS_MOD_SUCCESS_1); } else { StatusBarLogManager.ShowEvent(this, _STATUS_MOD_SUCCESS_2); } } else { StatusBarLogManager.ShowEvent(this, ""); } } // Clearing fields lineLabel.Text = ""; idTextBox.Clear(); valueTextBox.Clear(); Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } }