Esempio n. 1
0
 private void btnProcesar_Click(object sender, EventArgs e)
 {
     if (this.dtgPrestamosCuotas.Rows.Count != 0)
     {
         PrestamosCL        prestamosCL        = new PrestamosCL();
         Prestamos_CuotasCL prestamos_CuotasCL = new Prestamos_CuotasCL();
         Abonos_CuotasCL    abonos_CuotasCL    = new Abonos_CuotasCL();
         PlanillaCL         planillaCL         = new PlanillaCL();
         if (this.ValidarPago())
         {
             if (this.ObtenerFechaPago())
             {
                 foreach (DataGridViewRow dataGridViewRow in dtgPrestamosCuotas.Rows)
                 {
                     int       num        = Convert.ToInt32(dataGridViewRow.Cells["Prestamos_cuotas_id"].Value.ToString());
                     int       id         = Convert.ToInt32(dataGridViewRow.Cells["Prestamo"].Value.ToString());
                     DataSet   dataSet    = prestamosCL.TraerPrestamoSaldo(id.ToString());
                     DataTable dataTable  = dataSet.Tables[0];
                     DataRow   dataRow    = dataTable.Rows[0];
                     double    num2       = (double)Convert.ToInt32(dataRow.ItemArray.GetValue(0).ToString());
                     DataSet   dataSet2   = abonos_CuotasCL.TraerSuma_Abonos(dataGridViewRow.Cells["Prestamos_cuotas_id"].Value.ToString());
                     DataTable dataTable2 = dataSet2.Tables[0];
                     DataRow   dataRow2   = dataTable2.Rows[0];
                     if (!string.IsNullOrEmpty(dataRow2.ItemArray.GetValue(0).ToString()))
                     {
                         double num3  = Convert.ToDouble(dataRow2.ItemArray.GetValue(0).ToString());
                         double monto = (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString()) - num3;
                         abonos_CuotasCL.InsertarAbono_Cuotas(num, monto, this.fechaPago);
                         num2 -= (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString()) - num3;
                     }
                     else
                     {
                         num2 -= (double)Convert.ToInt32(dataGridViewRow.Cells["Monto"].Value.ToString());
                     }
                     prestamosCL.EditarPrestamo(id, num2);
                     prestamos_CuotasCL.EditarPrestamoCuotas(num, this.fechaPago, true, "");
                 }
                 planillaCL.EditarPlanilla(Convert.ToInt32(this.numPlanilla), true);
                 if (planillaCL.IsError)
                 {
                     MessageBox.Show(planillaCL.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 }
                 else
                 {
                     MessageBox.Show("Planilla procesada con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     this.iPlanilla.CargarPlanilla("");
                     base.Dispose();
                 }
             }
         }
         else
         {
             MessageBox.Show(this.errores, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
     }
     else
     {
         MessageBox.Show("No hay cuotas que procesar", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Esempio n. 2
0
        private void ImprimirTicket_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            FontFamily family = new FontFamily("Microsoft Sans Serif");
            Font       font   = new Font(family, 9f);

            oEPrestamos = new EPrestamos();
            clientesCL  = new ClientesCL();
            oPrestamos  = new PrestamosCL();
            DataTable dataTable  = clientesCL.TraerClientes(this.cliente).Tables[0];
            DataTable dataTable2 = oPrestamos.TraerFechaFinalPrestamo(this.Prestamo.ToString()).Tables[0];

            oEPrestamos.encabezado           = oEncabezado.encabezado;
            oEPrestamos.clientePrestamo      = this.cliente;
            oEPrestamos.nombreCliente        = dataTable.Rows[0].ItemArray.GetValue(1).ToString();
            oEPrestamos.telefonoCliente      = dataTable.Rows[0].ItemArray.GetValue(4).ToString();
            oEPrestamos.direccionCliente     = dataTable.Rows[0].ItemArray.GetValue(2).ToString();
            oEPrestamos.totalPrestamo        = this.totalPrestamo;
            oEPrestamos.fechaPactada         = fechaPactada;
            oEPrestamos.fechaAbono           = Convert.ToDateTime(Convert.ToString(this.dtFechaPago.Value));
            oEPrestamos.fechaFinalPrestamo   = Convert.ToDateTime(dataTable2.Rows[0].ItemArray.GetValue(0).ToString());
            oEPrestamos.numeroCuota          = Convert.ToInt32(Convert.ToString(this.NumCuota));
            oEPrestamos.idCuota              = idCuota;
            oEPrestamos.prestamo             = Convert.ToString(this.Prestamo);
            oEPrestamos.saldoPrestamo        = this.saldo;
            oEPrestamos.saldoPretamoAnterior = this.saldo + this.Monto;
            oEPrestamos.montoAbono           = this.Monto;
            e.Graphics.PageUnit              = GraphicsUnit.Pixel;
            e.Graphics.DrawString(oEPrestamos.ticket, font, Brushes.Black, 20f, 10f);
        }
Esempio n. 3
0
        public void CancelarPrestamo(int prestamoId)
        {
            DateTime           fechaPago          = DateTime.Now;
            PrestamosCL        oPrestamos         = new PrestamosCL();
            Prestamos_CuotasCL oPrestamosCuotasCl = new Prestamos_CuotasCL();;

            oPrestamos.CancelarPrestamo(prestamoId);

            if (oPrestamos.IsError)
            {
                MessageBox.Show(string.Format("Error al cancelar el préstamo {0}", prestamoId), "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                oPrestamosCuotasCl.CancelarCuotasPrestamo(prestamoId, fechaPago);

                if (oPrestamosCuotasCl.IsError)
                {
                    MessageBox.Show(string.Format("Error al cancelar el préstamo {0}", prestamoId), "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(string.Format("Préstamo cancelado con éxito {0}", prestamoId), "Información", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }

            CargarPrestamos();
        }
Esempio n. 4
0
        public void CargarPrestamos()
        {
            var oPrestamos = new PrestamosCL();

            var oDatos = oPrestamos.TraerPrestamo(txtCliente.Text, true, false);

            if (cliente != null)
            {
                dtgPrestamos.DataSource = oDatos.Tables[0];

                foreach (DataGridViewRow row in dtgPrestamos.Rows)
                {
                    if (Convert.ToInt32(row.Cells["saldoPrestamo"].Value.ToString()) == 0)
                    {
                        // ESTABLECE COLOR VERDE SI LA COLUMNA SALDO ES 0
                        row.DefaultCellStyle.BackColor = Color.LightGreen;
                    }
                    else
                    {
                        // ESTABLECE COLOR SALMON SI AUN HAY PAGOS PENDIENTES
                        row.DefaultCellStyle.BackColor = Color.Salmon;
                    }
                }

                if (oDatos.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Este cliente no presenta prestamos", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CargarPrestamosCuotas("0");
                }
            }
        }
Esempio n. 5
0
        // TRAE LA FECHA FINAL DEL PRESTAMO
        public void TraerFechaFinal()
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            // CICLO QUE RECORRE LAS FILAS DEL DATAGRID
            foreach (DataGridViewRow row in dtgPrestamos.Rows)
            {
                DataSet oDatos = oPrestamos.TraerFechaFinalPrestamo(row.Cells["idPrestamo"].Value.ToString());

                DateTime fechaFinal = Convert.ToDateTime(oDatos.Tables[0].Rows[0].ItemArray.GetValue(0));

                row.Cells["fechaFinalPrestamo"].Value = fechaFinal.ToShortDateString();

                // CAMBIA DE COLOR DE COLOR LAS FILAS ROJO = VENCIDAS - VERDE: NO VENCIDAS

                if (fechaFinal < DateTime.Today)
                {
                    row.DefaultCellStyle.BackColor = Color.Salmon;
                }
                else
                {
                    row.DefaultCellStyle.BackColor = Color.LightGreen;
                }
            }

            OrdenarColumnas();
        }
Esempio n. 6
0
        public void imprimirTicketsValores()
        {
            EPrestamos  ePrestamos           = new EPrestamos();
            PrestamosCL prestamosCL          = new PrestamosCL();
            DataTable   dataTable            = prestamosCL.TraerPrestamo_planilla(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Cedula"].Value.ToString(), this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Prestamo"].Value.ToString(), true).Tables[0];
            DataTable   dataTable2           = prestamosCL.TraerFechaFinalPrestamo(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Prestamo"].Value.ToString()).Tables[0];
            ClientesCL  clientesCL           = new ClientesCL();
            DataTable   dataTable3           = clientesCL.TraerClientes(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Cedula"].Value.ToString()).Tables[0];
            double      saldoPretamoAnterior = Convert.ToDouble(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Saldo"].Value.ToString()) + Convert.ToDouble(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Monto"].Value.ToString());

            ePrestamos.encabezado           = this.encabezado;
            ePrestamos.clientePrestamo      = this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Cedula"].Value.ToString();
            ePrestamos.nombreCliente        = dataTable3.Rows[0].ItemArray.GetValue(1).ToString();
            ePrestamos.telefonoCliente      = dataTable3.Rows[0].ItemArray.GetValue(4).ToString();
            ePrestamos.direccionCliente     = dataTable3.Rows[0].ItemArray.GetValue(2).ToString();
            ePrestamos.totalPrestamo        = Convert.ToDouble(dataTable.Rows[0].ItemArray.GetValue(6).ToString());
            ePrestamos.fechaPactada         = Convert.ToDateTime(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Fecha_pactada"].Value.ToString());
            ePrestamos.fechaAbono           = Convert.ToDateTime(this.lblFecha.Text);
            ePrestamos.numeroCuota          = Convert.ToInt32(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Numero_cuota"].Value.ToString());
            ePrestamos.idCuota              = Convert.ToInt32(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Prestamos_cuotas_id"].Value.ToString());
            ePrestamos.prestamo             = this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Prestamo"].Value.ToString();
            ePrestamos.saldoPrestamo        = Convert.ToDouble(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Saldo"].Value.ToString());
            ePrestamos.saldoPretamoAnterior = saldoPretamoAnterior;
            ePrestamos.montoAbono           = Convert.ToDouble(this.dtgPrestamosCuotas.Rows[this.cRows].Cells["Monto"].Value.ToString());
            ePrestamos.fechaFinalPrestamo   = Convert.ToDateTime(dataTable2.Rows[0].ItemArray.GetValue(0).ToString());
            this.ticket = ePrestamos.ticket;
        }
Esempio n. 7
0
        // TRAE LOS PRESTAMOS Y LOS MUESTRA EN LA TABLA
        public void TraerPrestamos()
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            DataSet oDatos = oPrestamos.TraerPrestamosNoCancelados();

            dtgPrestamos.DataSource = oDatos.Tables[0];
        }
Esempio n. 8
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            int  dia  = dtFechaInicial.Value.Day;
            int  mes  = dtFechaInicial.Value.Month;
            int  ano  = dtFechaInicial.Value.Year;
            int  tipo = ValidacionesCL.ValidarDiaPagoIndex(cmbDiaPago.SelectedItem.ToString());
            bool ValidacionQuincena = ValidacionesCL.validarQuincena(dia, mes, ano, tipo);

            // COMPRUEBA SI EL DIA DE PAGO NO ES QUINCENA
            if (ValidacionQuincena == false)
            {
                if (dtgCuotas.RowCount > 0)
                {
                    if (txtMonto.Text == "" || txtInteres.Text == "" || txtCuotas.Text == "")
                    {
                        MessageBox.Show("Rellene todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        PrestamosCL        oPrestamos        = new PrestamosCL();
                        Prestamos_CuotasCL oPrestamos_Cuotas = new Prestamos_CuotasCL();

                        double saldo = total;

                        oPrestamos.InsertarPrestamo(numeroPrestamo, dtFecha.Value, cliente, monto, interes, Convert.ToInt32(txtCuotas.Text), saldo, total, false, tipo);

                        foreach (DataRow item in cuotasGeneradas)
                        {
                            oPrestamos_Cuotas.InsertarPrestamo_Cuotas(

                                numeroPrestamo,
                                Convert.ToInt32(item.ItemArray[0]),
                                Convert.ToDateTime(item.ItemArray[1]),
                                Convert.ToInt32(item.ItemArray[2]),
                                Convert.ToInt32(item.ItemArray[3])

                                );
                        }

                        if (oPrestamos.IsError)
                        {
                            MessageBox.Show(oPrestamos.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("Prestamo creado con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            prestamos.CargarPrestamos();
                            this.Dispose();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Genere primero las cuotas antes de crear un prestamo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 9
0
        public void EditarSaldoPrestamo(double saldo)
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            DataSet oDatos = oPrestamos.TraerPrestamoSaldo(prestamo.ToString());

            double saldoPrestamo = Convert.ToDouble(oDatos.Tables[0].Rows[0].ItemArray[0]) + saldo;

            oPrestamos.EditarPrestamo(prestamo, saldoPrestamo);
        }
Esempio n. 10
0
        public void ImprimirCuotas()
        {
            frmFechaPreliminarPagoCuota frmFechaPreliminarPagoCuota = new frmFechaPreliminarPagoCuota(this);

            frmFechaPreliminarPagoCuota.ShowDialog();
            if (this.fechaPreliminarPago.ToShortDateString() != "01/01/0001")
            {
                frmEncabezadoAbono oEncabezado = new frmEncabezadoAbono("Reimprimir abono");
                oEncabezado.ShowDialog();

                if (oEncabezado.cancelar)
                {
                    oEncabezado.Dispose();
                    return;
                }

                // DATOS DE LA FECHA FINAL DEL PRESTAMO
                PrestamosCL prestamosCL = new PrestamosCL();

                DataTable fechaFinalPrestamo = prestamosCL.TraerFechaFinalPrestamo(Convert.ToString(this.dtgCuotas["id_prestamos", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString())).Tables[0];

                // DATOS DEL CLIENTE
                ClientesCL clientesCL    = new ClientesCL();
                DataTable  clientesDatos = clientesCL.TraerClientes(this.cliente).Tables[0];

                // DATOS DEL PRESTAMO
                this.oEPrestamos = new EPrestamos();
                this.oEPrestamos.clientePrestamo  = this.cliente;
                this.oEPrestamos.nombreCliente    = clientesDatos.Rows[0].ItemArray.GetValue(1).ToString();
                this.oEPrestamos.telefonoCliente  = clientesDatos.Rows[0].ItemArray.GetValue(4).ToString();
                this.oEPrestamos.direccionCliente = clientesDatos.Rows[0].ItemArray.GetValue(2).ToString();

                this.oEPrestamos.totalPrestamo      = Convert.ToDouble(this.dtgPrestamos["Total1", this.dtgPrestamos.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaAbono         = fechaPreliminarPago;
                this.oEPrestamos.fechaFinalPrestamo = Convert.ToDateTime(fechaFinalPrestamo.Rows[0].ItemArray.GetValue(0).ToString());

                // ORDENA LAS CUOTAS BASADO EN EL INDICE
                var cuotasOrdenadas = dtgCuotas.SelectedRows.Cast <DataGridViewRow>().OrderBy(row => row.Index);


                // CICLO QUE RECORRE LAS CUOTAS PARA SER IMPRESAS COMO PRELIMINARES
                foreach (DataGridViewRow item in cuotasOrdenadas)
                {
                    this.oEPrestamos.encabezado           = oEncabezado.encabezado;
                    this.oEPrestamos.prestamo             = Convert.ToString(item.Cells["id_prestamos"].Value.ToString());
                    this.oEPrestamos.saldoPrestamo        = Convert.ToDouble(item.Cells["saldo"].Value.ToString());
                    this.oEPrestamos.fechaPactada         = Convert.ToDateTime(item.Cells["fecha_pactada"].Value.ToString());
                    this.oEPrestamos.numeroCuota          = Convert.ToInt32(item.Cells["num_cuota"].Value.ToString());
                    this.oEPrestamos.idCuota              = Convert.ToInt32(item.Cells["id"].Value.ToString());
                    this.oEPrestamos.saldoPretamoAnterior = Convert.ToDouble(item.Cells["saldo"].Value.ToString()) + Convert.ToDouble(item.Cells["monto_cuota"].Value.ToString());
                    this.oEPrestamos.montoAbono           = Convert.ToDouble(item.Cells["monto_cuota"].Value.ToString());
                    this.ImprimirTicket.Print();
                }
            }
        }
Esempio n. 11
0
        // CARGA EL TOTAL DE SALDO DE TODOS LOS PRESTAMOS
        public void CargarTotalSaldo()
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            DataRow oTotalSaldo = oPrestamos.TraerPrestamoSaldoTotal().Tables[0].Rows[0];

            EPrestamos oPrestamosMoneda = new EPrestamos();

            string totalSaldo = oTotalSaldo.ItemArray.GetValue(0).ToString();

            lblTotalSaldoPrestamos.Text = Convert.ToDouble(totalSaldo).ToString("C", oPrestamosMoneda.Moneda());
        }
Esempio n. 12
0
        // CARGAS LAS CUOTSA
        public void TraerCuotas(int prestamo)
        {
            var oCuotas   = new Prestamos_CuotasCL();
            var oPrestamo = new PrestamosCL();

            var oDatos         = oCuotas.TraerPrestamoCuotas_NoPago(prestamo.ToString());
            var oDatosPrestamo = oPrestamo.TraerPrestamoSaldo(prestamo.ToString());

            _prestamoSaldo = Convert.ToDouble(oDatosPrestamo.Tables[0].Rows[0].ItemArray[0]);

            _dCuotas = oDatos.Tables[0];

            // OBTIENE EL PRIMER NUMERO DE CUOTA
            _primerNumeroCuota = Convert.ToInt32(_dCuotas.Rows[0]["num_cuota"].ToString());

            dtgCuotas.DataSource = _dCuotas;
        }
Esempio n. 13
0
        public void SecuenciaPrestamo()
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            int secuencia;

            try
            {
                secuencia = Convert.ToInt32(SecuenciasCL.TraerSecuenciaPrestamo().Tables[0].Rows[0].ItemArray[0]) + 1;
            }
            catch (System.IndexOutOfRangeException e)
            {
                secuencia = 1;
            }

            lblNumeroPrestamo.Text = Convert.ToString("00000" + secuencia);
            numeroPrestamo         = secuencia;
        }
Esempio n. 14
0
        public void CargarPrestamos()
        {
            DataSet     oDatos;
            PrestamosCL oPrestamos        = new PrestamosCL();
            string      busquedaCliente   = getBusquedaCliente();
            bool        mostrarRecargos   = getMostrarRecargos();
            bool        mostrarEliminados = getMostrarEliminados();

            totalPrestamoMonto    = 0000000;
            totalPrestamoGanancia = 0000000;
            totalPrestamoSaldos   = 0000000;
            totalPrestamoRecargos = 0000000;

            oDatos = oPrestamos.TraerPrestamo(busquedaCliente, mostrarRecargos, mostrarEliminados);

            if (cliente != null)
            {
                // NUEVA COLUMNA
                oDatos.Tables[0].Columns.Add("montoRecargo");

                foreach (DataRow row in oDatos.Tables[0].Rows)
                {
                    // MONTO
                    totalPrestamoMonto += Convert.ToDouble(row.ItemArray[2]);
                    // MONTO * INTERES = GANANCIA
                    totalPrestamoGanancia += Convert.ToDouble(row.ItemArray[2]) * (Convert.ToDouble(row.ItemArray[3]) / 100);
                    // SALDO
                    totalPrestamoSaldos += Convert.ToDouble(row.ItemArray[5]);
                    // TOTAL - ((MONTO * INTERES) + MONTO) = RECARGOS
                    totalPrestamoRecargos += Convert.ToDouble(row.ItemArray[6]) - ((Convert.ToDouble(row.ItemArray[2]) * (Convert.ToDouble(row.ItemArray[3]) / 100)) + Convert.ToDouble(row.ItemArray[2]));

                    // MONTO DE RECARGOS
                    row["montoRecargo"] = Convert.ToDouble(row.ItemArray[6]) - ((Convert.ToDouble(row.ItemArray[2]) * (Convert.ToDouble(row.ItemArray[3]) / 100)) + Convert.ToDouble(row.ItemArray[2]));
                }

                lblTotalPrestamoMonto.Text    = totalPrestamoMonto.ToString("C", Moneda());
                lblTotalPrestamoGanancia.Text = totalPrestamoGanancia.ToString("C", Moneda());
                lblTotalSaldos.Text           = totalPrestamoSaldos.ToString("C", Moneda());
                lblTotalRecargos.Text         = totalPrestamoRecargos.ToString("C", Moneda());


                dtgPrestamos.DataSource = oDatos.Tables[0];
            }
        }
Esempio n. 15
0
        private void btnReimprimir_Click(object sender, EventArgs e)
        {
            if (!Convert.ToBoolean(this.dtgCuotas["pago", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString()))
            {
                MessageBox.Show("Esta cuota no tiene registros de pagos que imprimir", "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                frmEncabezadoAbono oEncabezado = new frmEncabezadoAbono("Reimprimir abono");
                oEncabezado.ShowDialog();

                if (oEncabezado.cancelar)
                {
                    oEncabezado.Dispose();
                    return;
                }

                //VALORES DEL TICKET ABONO
                ClientesCL  clientesCL  = new ClientesCL();
                PrestamosCL prestamosCL = new PrestamosCL();
                DataTable   dataTable   = clientesCL.TraerClientes(this.cliente).Tables[0];
                DataTable   dataTable2  = prestamosCL.TraerFechaFinalPrestamo(Convert.ToString(this.dtgCuotas["id_prestamos", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString())).Tables[0];
                this.oEPrestamos                      = new EPrestamos();
                this.oEPrestamos.encabezado           = oEncabezado.encabezado;
                this.oEPrestamos.clientePrestamo      = this.cliente;
                this.oEPrestamos.nombreCliente        = dataTable.Rows[0].ItemArray.GetValue(1).ToString();
                this.oEPrestamos.telefonoCliente      = dataTable.Rows[0].ItemArray.GetValue(4).ToString();
                this.oEPrestamos.direccionCliente     = dataTable.Rows[0].ItemArray.GetValue(2).ToString();
                this.oEPrestamos.totalPrestamo        = Convert.ToDouble(this.dtgPrestamos["Total1", this.dtgPrestamos.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaPactada         = Convert.ToDateTime(this.dtgCuotas["fecha_pactada", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaAbono           = Convert.ToDateTime(this.dtgCuotas["fecha_pago", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.numeroCuota          = Convert.ToInt32(this.dtgCuotas["num_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.idCuota              = Convert.ToInt32(this.dtgCuotas["id", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.prestamo             = Convert.ToString(this.dtgCuotas["id_prestamos", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.saldoPrestamo        = Convert.ToDouble(this.dtgCuotas["saldo", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.saldoPretamoAnterior = Convert.ToDouble(this.dtgCuotas["saldo", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString()) + Convert.ToDouble(this.dtgCuotas["monto_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.montoAbono           = Convert.ToDouble(this.dtgCuotas["monto_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaFinalPrestamo   = Convert.ToDateTime(dataTable2.Rows[0].ItemArray.GetValue(0).ToString());
                this.ImprimirTicket.Print();

                oEncabezado.Dispose();
            }
        }
Esempio n. 16
0
        // COMPRUEBA LOS PRESTAMOS Y LOS CARGA
        public bool ComprobarPrestamos()
        {
            PrestamosCL oPrestamos = new PrestamosCL();

            DataSet oDatos = oPrestamos.TraerPrestamo(txtCliente.Text, true, false);


            if (oDatos.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Este cliente no presenta prestamos", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);

                LimpiarTabla();
                return(false);
            }
            else
            {
                dtgPrestamos.DataSource = oDatos.Tables[0];
                return(true);
            }
        }
Esempio n. 17
0
        private void btnImprimirPreliminar_Click(object sender, EventArgs e)
        {
            frmFechaPreliminarPagoCuota frmFechaPreliminarPagoCuota = new frmFechaPreliminarPagoCuota(this);

            frmFechaPreliminarPagoCuota.ShowDialog();
            if (this.fechaPreliminarPago.ToShortDateString() != "01/01/0001")
            {
                frmEncabezadoAbono oReimprimir = new frmEncabezadoAbono("Imprimir preliminar");
                oReimprimir.ShowDialog();

                if (oReimprimir.cancelar)
                {
                    oReimprimir.Dispose();
                    return;
                }

                //VALORES DEL TICKET ABONO
                this.oEPrestamos = new EPrestamos();
                ClientesCL  clientesCL  = new ClientesCL();
                PrestamosCL prestamosCL = new PrestamosCL();
                DataTable   dataTable   = clientesCL.TraerClientes(this.cliente).Tables[0];
                DataTable   dataTable2  = prestamosCL.TraerFechaFinalPrestamo(Convert.ToString(this.dtgCuotas["id_prestamos", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString())).Tables[0];
                this.oEPrestamos.encabezado           = oReimprimir.encabezado;
                this.oEPrestamos.clientePrestamo      = this.cliente;
                this.oEPrestamos.nombreCliente        = dataTable.Rows[0].ItemArray.GetValue(1).ToString();
                this.oEPrestamos.telefonoCliente      = dataTable.Rows[0].ItemArray.GetValue(4).ToString();
                this.oEPrestamos.direccionCliente     = dataTable.Rows[0].ItemArray.GetValue(2).ToString();
                this.oEPrestamos.totalPrestamo        = Convert.ToDouble(this.dtgPrestamos["Total1", this.dtgPrestamos.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaPactada         = Convert.ToDateTime(this.dtgCuotas["fecha_pactada", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaAbono           = this.fechaPreliminarPago;
                this.oEPrestamos.numeroCuota          = Convert.ToInt32(this.dtgCuotas["num_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.idCuota              = Convert.ToInt32(this.dtgCuotas["id", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.prestamo             = Convert.ToString(this.dtgCuotas["id_prestamos", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.saldoPrestamo        = Convert.ToDouble(this.dtgCuotas["saldo", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.saldoPretamoAnterior = Convert.ToDouble(this.dtgCuotas["saldo", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString()) + Convert.ToDouble(this.dtgCuotas["monto_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.montoAbono           = Convert.ToDouble(this.dtgCuotas["monto_cuota", this.dtgCuotas.CurrentCell.RowIndex].Value.ToString());
                this.oEPrestamos.fechaFinalPrestamo   = Convert.ToDateTime(dataTable2.Rows[0].ItemArray.GetValue(0).ToString());
                this.ImprimirTicket.Print();
            }
        }
Esempio n. 18
0
 private void restaurarPrestamoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.dtgPrestamos.SelectedRows.Count > 0)
     {
         PrestamosCL prestamosCL = new PrestamosCL();
         // Prestamo ID
         int id = Convert.ToInt16(this.dtgPrestamos.CurrentRow.Cells["ID"].Value.ToString());
         prestamosCL.RestaurarPrestamoEliminado(id);
         if (prestamosCL.IsError)
         {
             MessageBox.Show(prestamosCL.ErrorDescripcion, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
         else
         {
             MessageBox.Show("Prestamo restaurado con éxito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             this.CargarPrestamos();
         }
     }
     else
     {
         MessageBox.Show("Debes seleccionar algún prestamo", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
Esempio n. 19
0
        private void btnEliminarAbono_Click(object sender, EventArgs e)
        {
            // COMPRUEBA SI LA CUOTA TIENE UN PAGO REGISTRADO
            if (Convert.ToBoolean(dtgCuotas["pago", dtgCuotas.CurrentCell.RowIndex].Value.ToString()) == true)
            {
                DialogResult opcion = MessageBox.Show("Esta seguro de eliminar este abono", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                // SI EL USUARIO DIGITA SI EN EL DIALOGO ENTONCES PROCEDE A ELIMINAR EL ABONO
                if (opcion == DialogResult.Yes)
                {
                    // INSTANCIAS
                    Prestamos_CuotasCL oCuotas    = new Prestamos_CuotasCL();
                    Abonos_CuotasCL    oAbonos    = new Abonos_CuotasCL();
                    PrestamosCL        oPrestamos = new PrestamosCL();

                    StringBuilder errores    = new StringBuilder();
                    int           idPrestamo = Convert.ToInt32(dtgPrestamos["idPrestamo", dtgPrestamos.CurrentCell.RowIndex].Value.ToString());
                    double        saldo      = Convert.ToInt32(dtgPrestamos["saldoPrestamo", dtgPrestamos.CurrentCell.RowIndex].Value.ToString());

                    foreach (DataGridViewRow dtg in dtgCuotas.SelectedRows)
                    {
                        // ELIMINA SOLO LOS ABONOS QUE HAN SIDO PAGADOS
                        if (Convert.ToBoolean(dtg.Cells["pago"].Value) == true)
                        {
                            // EDITAMOS PRESTAMO CUOTAS
                            oCuotas.EditarPrestamoCuotas(
                                Convert.ToInt32(dtg.Cells["id"].Value.ToString()),
                                Convert.ToDateTime(null),
                                false,
                                "eliminar"
                                );

                            // ELIMINA LOS ABONOS DE LA CUOTA
                            oAbonos.EliminarAbono_Cuotas_Id_Cuota(dtg.Cells["id"].Value.ToString());

                            // CALCULA EL NUEVO SALDO
                            saldo += Convert.ToInt32(dtg.Cells["monto_cuota"].Value.ToString());

                            // SI ENCUENTRA ERRORES
                            if (oCuotas.IsError)
                            {
                                errores.AppendLine(oCuotas.ErrorDescripcion);
                            }
                        }
                    }


                    // EDITA EL PRESTAMO
                    oPrestamos.EditarPrestamo(idPrestamo, saldo);

                    // GUARDA LA POSICION DEL PRESTAMO EN EL DATAGRID
                    int prestamoSelecion = dtgPrestamos.CurrentCell.RowIndex;

                    // LLAMA AL METODO CARGAR PRESTAMO
                    CargarPrestamos();

                    //ESTABLECE LA SELECION DEL PRESTAMO EN EL DATAGRID
                    dtgPrestamos.CurrentCell = dtgPrestamos.Rows[prestamoSelecion].Cells[0];

                    if (errores.Length == 0)
                    {
                        MessageBox.Show("Abono eliminado con exito", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                // EN CASO DE QUE LA CUOTA NO TUVIERA PAGOS REGISTRADOS
                MessageBox.Show("Esta cuota no tiene registros de pagos que eliminar", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 20
0
        // PROCESA LAS CUOTAS CON SU RESPECTIVA MODIFICACION DE FECHAS
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            // REVISA SI EL DATAGRID TIENE CUOTAS
            if (dtgCuotasPrevias.Rows.Count > 0)
            {
                Prestamos_CuotasCL oCuotas    = new Prestamos_CuotasCL();
                PrestamosCL        oPrestamos = new PrestamosCL();

                for (int i = 0; i < dtgCuotasPrevias.Rows.Count; i++)
                {
                    double monto = Convert.ToDouble(dtgCuotasPrevias["montoPre", i].Value);
                    double saldo = Convert.ToDouble(dtgCuotasPrevias["saldoPre", i].Value);



                    // ESTE IF COMPRUEBA LAS CUOTAS QUE SE DEBEN EDITAR
                    if (i < dtgCuotas.Rows.Count)
                    {
                        int id = Convert.ToInt32(dtgCuotasPrevias["idPre", i].Value);

                        oCuotas.EditarPrestamoCuotas_RecargoPrestamo(id, monto, saldo);
                    }
                    else
                    {
                        // AGREGA NUEVAS CUOTAS AL PRESTAMO COMO PARTE DE UN RECARGO
                        int      num_cuota     = Convert.ToInt32(dtgCuotasPrevias["num_cuotaPre", i].Value);
                        DateTime fecha_pactada = Convert.ToDateTime(dtgCuotasPrevias["fecha_pactadaPre", i].Value);

                        oCuotas.InsertarPrestamo_Cuotas(prestamo, num_cuota, fecha_pactada, monto, saldo);
                    }
                }

                if (oCuotas.IsError)
                {
                    MessageBox.Show(oCuotas.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    // CALCULA EL NUEVO SALDO DEL PRESTAMO
                    double oSaldoPrestamo = saldoPrestamo + Convert.ToDouble(txtMonto.Text);

                    // EDITA EL PRESTAMO AGREGANDOLE UN NUEVO SALDO Y ESTABLECIENDOLO COMO TIPO RECARGO
                    oPrestamos.EditarPrestamo_Recargo(prestamo, oSaldoPrestamo, totalPrestamo, true);

                    if (oPrestamos.IsError)
                    {
                        MessageBox.Show(oPrestamos.ErrorDescripcion, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Recargo creado con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ofrmPrestamos.CargarPrestamos();
                        this.Dispose();
                    }
                }
            }
            else
            {
                MessageBox.Show("Debes generar primero la previsualización de cuotas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 21
0
        public void PagoCuotas()
        {
            // INSTANCIAS
            oPrestamosCuotas = new Prestamos_CuotasCL();

            oPrestamos = new PrestamosCL();

            oAbonosCuotas = new Abonos_CuotasCL();

            // VARIABLE CONTIENE SALDO DEL PRESTAMO
            saldo = Convert.ToDouble(oPrestamos.TraerPrestamoSaldo(Convert.ToString(Prestamo)).Tables[0].Rows[0].ItemArray[0]);

            double saldoActual = saldo;

            double MontoAbono = Convert.ToDouble(txtMonto.Text);

            if (Abonos.dtgCuotas["num_cuota", 0].Value.ToString() != "0")
            {
                NumCuota -= 1;
            }


            for (int i = NumCuota; i < Abonos.dtgCuotas.Rows.Count; i++)
            {
                Monto = Convert.ToDouble(Abonos.dtgCuotas["monto_cuota", i].Value.ToString());

                DataSet oAbonosSuma = oAbonosCuotas.TraerSuma_Abonos(Abonos.dtgCuotas["id", i].Value.ToString());

                saldo = Convert.ToDouble(Abonos.dtgCuotas["saldo", i].Value.ToString());

                NumCuota     = Convert.ToInt32(Abonos.dtgCuotas["num_cuota", i].Value.ToString());
                fechaPactada = Convert.ToDateTime(Abonos.dtgCuotas["fecha_pactada", i].Value.ToString());


                DataSet oAbonosCantidad = oAbonosCuotas.TraerCantidad_Abonos(Abonos.dtgCuotas["id", i].Value.ToString());

                // TERMINA EL PAGO DE CUOTAS
                if (MontoAbono <= 0 || saldoActual <= 0)
                {
                    break;
                }

                if (oAbonosCantidad.Tables[0].Rows.Count > 0)
                {
                    double totalAbonos = Convert.ToDouble(oAbonosSuma.Tables[0].Rows[0].ItemArray.GetValue(0));

                    double totalFaltante = Monto - totalAbonos;

                    if (MontoAbono >= totalFaltante)
                    {
                        saldoActual -= totalFaltante;

                        oPrestamos.EditarPrestamo(Prestamo, saldoActual);

                        oAbonosCuotas.InsertarAbono_Cuotas(
                            Convert.ToInt32(Abonos.dtgCuotas["id", i].Value.ToString()),
                            totalFaltante,
                            dtFechaPago.Value);

                        oPrestamosCuotas.EditarPrestamoCuotas(
                            Convert.ToInt32(Abonos.dtgCuotas["id", i].Value.ToString()),
                            dtFechaPago.Value,
                            true,
                            null);

                        MontoAbono -= totalFaltante;

                        mensajeImpresion();
                    }
                    else
                    {
                        saldoActual -= MontoAbono;

                        oAbonosCuotas.InsertarAbono_Cuotas(
                            Convert.ToInt32(Abonos.dtgCuotas["id", i].Value.ToString()),
                            MontoAbono,
                            dtFechaPago.Value);

                        oPrestamos.EditarPrestamo(Prestamo, saldoActual);

                        MontoAbono -= MontoAbono;
                    }
                }
                else
                {
                    // PAGA LA CUOTA O CUOTAS
                    if (MontoAbono >= Monto)
                    {
                        saldoActual -= Monto;

                        oPrestamos.EditarPrestamo(Prestamo, saldoActual);

                        oPrestamosCuotas.EditarPrestamoCuotas(
                            Convert.ToInt32(Abonos.dtgCuotas["id", i].Value.ToString()),
                            dtFechaPago.Value,
                            true,
                            null);

                        MontoAbono -= Monto;

                        mensajeImpresion();
                    }
                    else
                    {
                        saldoActual -= MontoAbono;

                        oAbonosCuotas.InsertarAbono_Cuotas(
                            Convert.ToInt32(Abonos.dtgCuotas["id", i].Value.ToString()),
                            MontoAbono,
                            dtFechaPago.Value);

                        oPrestamos.EditarPrestamo(Prestamo, saldoActual);

                        MontoAbono -= MontoAbono;
                    }
                }
            }



            //  DialogResult opcion = MessageBox.Show("El monto es mayor al pactado \nDesea pagar esta cuota y abonar el resto a las demas cuotas?", "Informacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }