private void cmdDelete_Click(object sender, EventArgs e) { if (drpSystems.CurrentItem == null) { MessageBox.Show("Debe seleccionar un controlador.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (MessageBox.Show("¿Está ud. seguro que desea eliminar este controlador?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } Cursor.Current = Cursors.WaitCursor; try { _systems.Systems.Remove((OTCSystem)drpSystems.CurrentItem.Tag); _systems.Save(); ListSystems(); } catch (Exception err) { Cursor.Current = Cursors.Default; MessageBox.Show(err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; }
private void btnRegister_Click(object sender, EventArgs e) { try { FileInfo file = new FileInfo(txtFilename.Text); if (!file.Exists) { throw new Exception("No se encuentra el archivo " + file.FullName); } OTCSystem system = new OTCSystem(); system.Name = (string)lblInfo.Tag; system.Filename = file.Name; system.Class = cboClasses.Text; OTCSystems systems = new OTCSystems(); foreach (OTCSystem regsys in systems.Systems) { if (regsys.Name.Trim().ToLower().Equals(system.Name.Trim().ToLower()) && regsys.Class.Trim().ToLower().Equals(system.Class.Trim().ToLower())) { MessageBox.Show("El controlador seleccionado ya está registrado. Si ha actualizado la librería (archivo DLL) no hace falta volver a registrar el controlador.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } systems.Systems.Add(system); systems.Save(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception err) { MessageBox.Show(err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }