Example #1
0
        private void ActualizarGrillaPrestamos()
        {
            I_MenuPrincipal F_MenuPrincipal = this.Owner as I_MenuPrincipal;

            this.GrillaPrestamos.DataSource = null;

            if (F_MenuPrincipal != null)
            {
                DateTime?fechaDesde = null;
                if (CHKB_FechaDesde.Checked)
                {
                    fechaDesde = Convert.ToDateTime(dateTimePicker1.Text);
                }

                DateTime?fechaHasta = null;
                if (CHKB_FechaHasta.Checked)
                {
                    fechaHasta = Convert.ToDateTime(dateTimePicker2.Text);
                }

                TipoCliente?tipoCliente;
                switch (this.CB_TipoCliente.Text)
                {
                case "Regular":
                    tipoCliente = TipoCliente.Regular;
                    break;

                case "VIP":
                    tipoCliente = TipoCliente.VIP;
                    break;

                default:
                    tipoCliente = null;
                    break;
                }

                string nombre = null;
                if (CHKB_Busqueda.Checked)
                {
                    nombre = TB_Busqueda.Text;
                }

                this.GrillaPrestamos.DataSource = F_MenuPrincipal.ObtenerPrestamos(fechaDesde, fechaHasta, tipoCliente, nombre);
            }
        }
        private void F_ReporteDePagos_Load(object sender, EventArgs e)
        {
            List <Prestamo> ListaPrestamos  = new List <Prestamo>();
            I_MenuPrincipal F_MenuPrincipal = this.Owner as I_MenuPrincipal;

            if (F_MenuPrincipal != null)
            {
                ListaPrestamos = F_MenuPrincipal.ObtenerPrestamos(null, null, null, null);
            }

            if (ListaPrestamos.Count != 0)
            {
                decimal monto_prestado = ListaPrestamos.Sum(x => x.MontoCredito);
                decimal cuotas_pagadas = ListaPrestamos.Sum(x => x.CuotasPagadas * x.MontoCuota);

                LBL_MontoPrestado.Text = "$ " + Convert.ToString(Math.Round(monto_prestado, 2));
                LBL_CuotasPagadas.Text = "$ " + Convert.ToString(Math.Round(cuotas_pagadas, 2));
                LBL_TasaInteres.Text   = Convert.ToString(Math.Round(ListaPrestamos.Average(x => x.Tasa), 2)) + " %";

                decimal resultado = cuotas_pagadas - monto_prestado;
                LBL_Resultado.Text = "$ " + Convert.ToString(resultado);
                if (resultado > 0)
                {
                    LBL_Resultado.ForeColor = Color.Green;
                }
                else if (resultado < 0)
                {
                    LBL_Resultado.ForeColor = Color.Red;
                }
                else
                {
                    LBL_Resultado.ForeColor = Color.Black;
                }
            }
            else
            {
                LBL_MontoPrestado.Text = "$ 0";
                LBL_CuotasPagadas.Text = "$ 0";
                LBL_TasaInteres.Text   = " - %";
                LBL_Resultado.Text     = "$ 0";
            }
        }