コード例 #1
0
        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;
            }
        }
コード例 #2
0
        private void lstAtenciones_SelectedIndexChanged(object sender, EventArgs e)
        {
            mostrarLabelDescuento();
            try
            {
                ATENCION_AGEN atencion             = new ATENCION_AGEN();
                PACIENTE      paciente             = new PACIENTE();
                PRESTACION    prestacion           = new PRESTACION();
                BONO          bono                 = new BONO();
                ASEGURADORA   aseguradora          = new ASEGURADORA();
                ResultadoVerificacionSeguro seguro = new ResultadoVerificacionSeguro();
                bool necesitaDevolucion            = false;

                using (var context = new CMHEntities())
                {
                    atencion             = context.ATENCION_AGEN.Find(((ComboboxItem)lstAtenciones.SelectedItem).Value);
                    atencion.ESTADO_ATEN = context.ESTADO_ATEN.Find(atencion.ID_ESTADO_ATEN);
                    if (atencion.ESTADO_ATEN.NOM_ESTADO_ATEN.ToUpper() == "PAGADO")
                    {
                        necesitaDevolucion = true;
                    }
                    if (necesitaDevolucion)
                    {
                        paciente   = context.PACIENTE.Find(atencion.ID_PACIENTE);
                        prestacion = context.PRESTACION.Find(atencion.ID_PRESTACION);
                        pago       = context.PAGO.Where(d => d.ID_ATENCION_AGEN == atencion.ID_ATENCION_AGEN).FirstOrDefault();
                        if (pago.ID_BONO != null)
                        {
                            bono        = context.BONO.Find(pago.ID_BONO);
                            aseguradora = context.ASEGURADORA.Find(bono.ID_ASEGURADORA);
                        }
                    }
                }
                if (necesitaDevolucion)
                {
                    lblSubtotal.Text = atencion.PRESTACION.PRECIO_PRESTACION.ToString();
                    lblTotal.Text    = pago.MONTO_PAGO.ToString();
                    if (pago.ID_BONO != null)
                    {
                        lblDescuento.Text   = pago.BONO.CANT_BONO.ToString();
                        lblAseguradora.Text = aseguradora.NOM_ASEGURADORA;
                    }
                    else
                    {
                        lblDescuento.Text   = "0";
                        lblAseguradora.Text = "No tiene seguro";
                    }
                    btnAnular.Enabled = true;
                    lblError.Visible  = false;
                    txtRazon.Enabled  = true;
                }
                else
                {
                    txtRazon.Enabled  = false;
                    btnAnular.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Visible   = true;
                lblError.Text      = "Error al buscar pago";
                lblError.ForeColor = System.Drawing.Color.Red;
                lblSubtotal.Text   = string.Empty;
                lblTotal.Text      = string.Empty;
                lblDescuento.Text  = string.Empty;
                btnAnular.Enabled  = false;
            }
        }