internal void EditItem() { if (grdDataView.SelectedRowsCount <= 0) { MessageBox.Show("You must select the row you want to edit.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Get the current row int[] rows = grdDataView.GetSelectedRows(); ORMIdentifiableEntity row = grdDataView.GetRow(rows[0]) as ORMIdentifiableEntity; if (row == null) { return; } if (this.CurrentFileType != FileType.Unknown) { switch (this.CurrentFileType) { case FileType.Categories: Category category = Category.Get(row.ID); if (category != null) { CategoryEditorView formCategoryEditor = new CategoryEditorView(category); formCategoryEditor.ShowDialog(); } break; case FileType.Manufacturers: Manufacturer manufacturer = Manufacturer.Get(row.ID); if (manufacturer != null) { ManufacturerEditorView formStore = new ManufacturerEditorView(manufacturer); formStore.ShowDialog(); } break; case FileType.Stores: Store store = Store.Get(row.ID); if (store != null) { StoreEditorView formStore = new StoreEditorView(store); formStore.ShowDialog(); } break; case FileType.Gauges: Rwm.Otc.Trains.Gauge scale = Rwm.Otc.Trains.Gauge.Get(row.ID); if (scale != null) { GaugeEditorView formScale = new GaugeEditorView(scale); formScale.ShowDialog(); } break; case FileType.Decoders: TrainDecoder decoder = TrainDecoder.Get(row.ID); if (decoder != null) { DecoderEditorView formDecoder = new DecoderEditorView(decoder); formDecoder.ShowDialog(); } break; case FileType.RailwayCompanies: Company admin = Company.Get(row.ID); if (admin != null) { CompanyEditorView formAdmin = new CompanyEditorView(admin); formAdmin.ShowDialog(); } break; default: break; } } else if (this.CurrentCategory != null) { StudioContext.OpenPluginModule(ModelModuleDescriptor.MODULE_GUID, row.ID); } this.Refresh(); }
internal void DeleteItem() { if (grdDataView.SelectedRowsCount <= 0) { MessageBox.Show("You must select the row you want to delete.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Are you sure you want to delete the selected record?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No) { return; } // Get the current row int[] rows = grdDataView.GetSelectedRows(); ORMIdentifiableEntity row = grdDataView.GetRow(rows[0]) as ORMIdentifiableEntity; if (row == null) { return; } if (this.CurrentFileType != FileType.Unknown) { switch (this.CurrentFileType) { case FileType.Categories: Category.Delete(row.ID); break; case FileType.Manufacturers: Manufacturer.Delete(row.ID); break; case FileType.Stores: Store.Delete(row.ID); break; case FileType.Gauges: Gauge.Delete(row.ID); break; case FileType.Decoders: TrainDecoder.Delete(row.ID); break; case FileType.RailwayCompanies: Company.Delete(row.ID); break; default: break; } } else if (this.CurrentCategory != null) { Train.Delete(row.ID); } this.Refresh(); }