private void btnAceptarEspe_Click(object sender, EventArgs e) { if (this.Operacion == 1) //Modificar { if (!this.ValidarNumero(tbxCosto.Text, "Costo")) { return; } Espe = (Especialidad)this.cbxEspecialidad.SelectedItem; EspeAux = Espe.nombre; MedicoNegocio MN = new MedicoNegocio(); if (chbBajaDef.Checked == true) { Espe.estado = 0; } else { Espe.estado = 1; } if (MN.ModificarEspe(txbDni.Text.Trim(), Espe.id, float.Parse(tbxCosto.Text), Espe.estado) == false) { MessageBox.Show("Error al Modificar la Especialidad"); return; } MessageBox.Show("Modificación realizada"); cbxEspecialidad.DataSource = null; cbxEspecialidad.Text = ""; tbxCosto.Text = "0"; cbxEspecialidad.DataSource = MN.EspeMedico(txbDni.Text.Trim()); for (int i = 0; i < cbxEspecialidad.Items.Count; i++) { Especialidad aux = (Especialidad)cbxEspecialidad.Items[i]; if (aux.nombre == EspeAux) { cbxEspecialidad.SelectedIndex = i; break; } } } if (this.Operacion == 2) // Baja { if (this.cbxEspecialidad.Items.Count < 1) { return; } if (this.medico == null) { return; } if (this.medico.dni.Length < 1) { return; } if (chbBajaEsp.Checked == true) { MessageBox.Show("Especialidad con baja registrada!!!"); } else { Espe = (Especialidad)this.cbxEspecialidad.SelectedItem; EspeAux = Espe.nombre; MedicoNegocio MN = new MedicoNegocio(); if (MN.EliminarEspe(txbDni.Text.Trim(), Espe.id) == false) { MessageBox.Show("Error al Eliminar la Especialidad"); return; } MessageBox.Show("Baja Realizada"); //cbxEspecialidad.DataSource = null; //cbxEspecialidad.Text = ""; //tbxCosto.Text = "0"; cbxEspecialidad.DataSource = MN.EspeMedico(txbDni.Text.Trim()); for (int i = 0; i < cbxEspecialidad.Items.Count; i++) { Especialidad aux = (Especialidad)cbxEspecialidad.Items[i]; if (aux.nombre == EspeAux) { cbxEspecialidad.SelectedIndex = i; break; } } } } this.btnBuscar.Enabled = true; this.btnModificar.Enabled = true; this.lklActualizarHorarios.Enabled = true; this.btnAceptarEspe.Visible = false; this.btnCancelarEspe.Visible = false; // this.cbxEspecialidad.Enabled = false; this.tbxCosto.Enabled = false; this.chbBajaEsp.Enabled = false; this.cbxEspecialidad.Enabled = true; this.llbAgregarEspecialidad.Enabled = true; this.linkLabel1.Enabled = true; this.linkLabel2.Enabled = true; }