/// <summary> /// Event handler for the Edit button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnEditButtonClicked(Object sender, EventArgs e) { if (this.attributeTypesListView.SelectedItems.Count < 1) { return; } // Get a reference to the first selected item. DataStorageItem <AttributeTypeDTO> selectedEditItem = this.attributeTypesListView.SelectedItems[0].Tag as DataStorageItem <AttributeTypeDTO>; InputBox dlg = new InputBox(InputBoxValidationProc, selectedEditItem.Data.Description); switch (dlg.ShowDialog(this)) { case DialogResult.OK: { if (!String.IsNullOrWhiteSpace(dlg.Value)) { // Update the data item selectedEditItem.Data.Description = dlg.Value.Trim(); selectedEditItem.Modified = true; // Update the item in the list view this.attributeTypesListView.SelectedItems[0].Text = selectedEditItem.Data.Description; // Enable the apply button. this.applyButton.Enabled = true; } } break; default: break; } }
/// <summary> /// Adds an attribute type to the collection. /// </summary> /// <param name="attributeType"> /// New value. /// </param> public void AddAttributeDataType(AttributeTypeDTO attributeType) { DataStorageItem <AttributeTypeDTO> newRec = new DataStorageItem <AttributeTypeDTO>(new AttributeTypeDTO(GetNextAttributeDataTypeId(), attributeType.Description)); newRec.Added = true; this.mAttributeDataTypes.Add(newRec); this.IsModified = true; }
/// <summary> /// Event handler for the Add button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnAddButtonClicked(Object sender, EventArgs e) { // The contained value of this object will be set to an instance of a DataStorageItem if a previously deleted item was restored. ObjectContainer <DataStorageItem <AttributeTypeDTO> > restoredRec = new ObjectContainer <DataStorageItem <AttributeTypeDTO> >(); InputBox dlg = new InputBox(InputBoxValidationProc, null, null, restoredRec); switch (dlg.ShowDialog(this)) { case DialogResult.OK: { if (!String.IsNullOrWhiteSpace(dlg.Value)) { AttributeTypeDTO newRec = new AttributeTypeDTO(0, dlg.Value.Trim()); DataStorageItem <AttributeTypeDTO> addRec = new DataStorageItem <AttributeTypeDTO>(newRec) { Added = true }; this.mAttributeDataTypes.Add(addRec); // Show in the list view ListViewItem newListViewItem = new ListViewItem(addRec.Data.Description); newListViewItem.Tag = addRec; attributeTypesListView.Items.Add(newListViewItem); attributeTypesListView.SelectedItems.Clear(); newListViewItem.Selected = true; this.applyButton.Enabled = true; } } break; default: break; } }