private void lstAtenciones_SelectedIndexChanged(object sender, EventArgs e) { lblError.Visible = true; lblError.Text = "Consultando aseguradora..."; lblError.ForeColor = System.Drawing.Color.Violet; mostrarLabelDescuento(); try { ATENCION_AGEN atencion = new ATENCION_AGEN(); PACIENTE paciente = new PACIENTE(); PRESTACION prestacion = new PRESTACION(); ResultadoVerificacionSeguro seguro = new ResultadoVerificacionSeguro(); using (var context = new CMHEntities()) { atencion = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value); paciente = context.PACIENTE.Find(atencion.ID_PACIENTE); prestacion = context.PRESTACION.Find(atencion.ID_PRESTACION); } seguro = at.verificarSeguro(prestacion, paciente); lblSubtotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString(); lblTotal.Text = seguro.Descuento.ToString(); if (seguro.Aseguradora == "No tiene seguro") { lblTotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString(); lblDescuento.Text = "0"; } else { lblTotal.Text = seguro.Descuento.ToString(); lblDescuento.Text = (int.Parse(lblSubtotal.Text) - int.Parse(lblTotal.Text)).ToString(); } lblAseguradora.Text = seguro.Aseguradora; btnIngresar.Enabled = true; lblError.Visible = false; } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Error al buscar descuento"; lblError.ForeColor = System.Drawing.Color.Red; lblSubtotal.Text = string.Empty; lblTotal.Text = string.Empty; lblDescuento.Text = string.Empty; btnIngresar.Enabled = false; } }