Ejemplo n.º 1
0
        private void editarFechasCuotasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dtgPrestamos.SelectedRows.Count > 0)
            {
                int prestamo = Convert.ToInt32(dtgPrestamos.CurrentRow.Cells["ID"].Value);

                Prestamos_CuotasCL oCuotas = new Prestamos_CuotasCL();

                DataSet oDatos = oCuotas.TraerPrestamoCuotas_NoPago(prestamo.ToString());

                if (oDatos.Tables[0].Rows.Count > 0)
                {
                    frmEdicionCuotaFecha oEfecha = new frmEdicionCuotaFecha(prestamo, lblDescripcion.Text);

                    oEfecha.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Este prestamo no presenta cuotas pendientes", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Debes seleccionar algun prestamo", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        private void recargoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.dtgPrestamos.SelectedRows.Count > 0)
            {
                int oPrestamo = Convert.ToInt32(this.dtgPrestamos.CurrentRow.Cells["ID"].Value);
                Prestamos_CuotasCL prestamos_CuotasCL = new Prestamos_CuotasCL();
                DataSet            dataSet            = prestamos_CuotasCL.TraerPrestamoCuotas_NoPago(oPrestamo.ToString());

                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    double             oMontoCuota        = Convert.ToDouble(this.dtgPrestamos.CurrentRow.Cells["Cuotas"].Value);
                    double             oSaldoPrestamo     = Convert.ToDouble(this.dtgPrestamos.CurrentRow.Cells["Saldo"].Value);
                    double             oTotalPrestamo     = Convert.ToDouble(this.dtgPrestamos.CurrentRow.Cells["Total"].Value);
                    int                oDia_pago          = Convert.ToInt32(this.dtgPrestamos.CurrentRow.Cells["dia_pago"].Value);
                    frmRecargoPrestamo frmRecargoPrestamo = new frmRecargoPrestamo(this, oPrestamo, oMontoCuota, oSaldoPrestamo, oTotalPrestamo, oDia_pago, this.lblDescripcion.Text);
                    frmRecargoPrestamo.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Este prestamo no presenta cuotas pendientes", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("Debes seleccionar algun prestamo", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
0
        public static List <ECierreCaja> ObtenerCuotasPagadas(string fecha_desde, string fecha_hasta)
        {
            Prestamos_CuotasCL prestamos_CuotasCL = new Prestamos_CuotasCL();
            DataSet            dataSet            = prestamos_CuotasCL.TraerPrestamoCuotas_FechaPago(fecha_desde, fecha_hasta);
            List <ECierreCaja> list = new List <ECierreCaja>();

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                if (Convert.ToInt32(dataRow.ItemArray[10]) == 0)
                {
                    list.Add(new ECierreCaja
                    {
                        id_cuota            = Convert.ToInt32(dataRow.ItemArray[0]),
                        id_prestamo         = Convert.ToInt32(dataRow.ItemArray[1]),
                        fecha_pactada_cuota = Convert.ToDateTime(dataRow.ItemArray[2]),
                        fecha_pago_cuota    = Convert.ToDateTime(dataRow.ItemArray[3]),
                        monto_cuota         = Convert.ToDouble(dataRow.ItemArray[4]),
                        num_cuota           = Convert.ToInt32(dataRow.ItemArray[5]),
                        pago_cuota          = Convert.ToBoolean(dataRow.ItemArray[6]),
                        saldo_cuota         = Convert.ToDouble(dataRow.ItemArray[7]),
                        nombre_cliente      = Convert.ToString(dataRow.ItemArray[8]),
                        cedula_cliente      = Convert.ToString(dataRow.ItemArray[9])
                    });
                }
            }
            return(list);
        }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 7
0
        // CARGA LAS CUOTAS PENDIENTES DE LA FECHA Y MENOR

        public void CargarCuotas(string fecha)
        {
            Prestamos_CuotasCL oCuotas = new Prestamos_CuotasCL();

            dtgPrestamosCuotas.DataSource = oCuotas.TraerPrestamoCuotas_Filtros(fecha).Tables[0];

            OrdernarColumnas();

            TotalPlanilla();
        }
Ejemplo n.º 8
0
        // CARGAS LAS CUOTAS
        public void traerCuotas(int prestamo)
        {
            Prestamos_CuotasCL oCuotas = new Prestamos_CuotasCL();

            DataSet oDatos = oCuotas.TraerPrestamoCuotas_NoPago(prestamo.ToString());

            dCuotas = oDatos.Tables[0];

            dtgCuotas.DataSource = dCuotas;
        }
Ejemplo n.º 9
0
        public void CargarPrestamosCuotas(string prestamo)
        {
            // INSTANCIAS
            Prestamos_CuotasCL oPrestamosCuotas = new Prestamos_CuotasCL();

            Abonos_CuotasCL oAbonosCuotas = new Abonos_CuotasCL();

            // TRAE LAS CUOTAS DE LOS PRESTAMOS
            DataSet oDatos = oPrestamosCuotas.TraerPrestamoCuotas(prestamo);

            // ASIGNA LOS DATOS AL DATAGRID DE CUOTAS
            dtgCuotas.DataSource = oDatos.Tables[0];

            // CICLO QUE REVISA LAS FILAS DEL DATAGRID DE CUOTAS
            foreach (DataGridViewRow row in dtgCuotas.Rows)
            {
                if (Convert.ToBoolean(row.Cells["pago"].Value.ToString()) == true)
                {
                    // ESTABLECE COLOR VERDE SI LA COLUMNA PAGO ESTA CON CHECK
                    row.DefaultCellStyle.BackColor = Color.LightGreen;
                }
                else
                {
                    // ESTABLECE COLOR SALMON SI LA COLUMNA PAGO ESTA SIN CHECK
                    row.DefaultCellStyle.BackColor = Color.Salmon;
                }

                // TRAE LOS ABONOS DE UNA CUOTA
                DataSet oDatosAbonos = oAbonosCuotas.TraerAbono_Cuotas(row.Cells["id"].Value.ToString());

                // CALCULA LA CANTIDAD DE ABONOS
                int cantidadAbonos = Convert.ToInt32(oDatosAbonos.Tables[0].Rows.Count);

                // COMPRUEBA LA CANTIDAD
                if (cantidadAbonos > 0)
                {
                    // ESTABLECE EL TEXTO DEL BOTON DE ABONOS
                    row.Cells["abonos"].Value = "Abonos";
                }
                else
                {
                    // CAMBIA EL TIPO DE COLUMNA A TEXTO
                    row.Cells["abonos"]       = new DataGridViewTextBoxCell();
                    row.Cells["abonos"].Value = "";
                }
            }

            // LLAMA AL METODO QUE ORDENA LAS COLUMNAS
            OrdenColumnas();
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        public static List <ECuotas> ObtenerCuotas(string cedula, string prestamo)
        {
            Prestamos_CuotasCL prestamos_CuotasCL = new Prestamos_CuotasCL();
            DataSet            dataSet            = prestamos_CuotasCL.TraerPrestamoCuotas_Cliente_Prestamo(cedula, prestamo);
            List <ECuotas>     list = new List <ECuotas>();

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                if (Convert.ToString(dataRow.ItemArray[3]) == "")
                {
                    list.Add(new ECuotas
                    {
                        id_cuota            = Convert.ToInt32(dataRow.ItemArray[0]),
                        id_prestamo         = Convert.ToInt32(dataRow.ItemArray[1]),
                        fecha_pactada_cuota = string.Format("{0:d}", Convert.ToDateTime(Convert.ToDateTime(dataRow.ItemArray[2]))),
                        fecha_pago_cuota    = Convert.ToString(dataRow.ItemArray[3]),
                        monto_cuota         = Convert.ToDouble(dataRow.ItemArray[4]),
                        numero_cuota        = Convert.ToInt32(dataRow.ItemArray[5]),
                        pago_cuota          = Convert.ToBoolean(dataRow.ItemArray[6]),
                        saldo_cuota         = Convert.ToDouble(dataRow.ItemArray[7]),
                        nombre_cliente      = Convert.ToString(dataRow.ItemArray[8]),
                        cedula_cliente      = Convert.ToString(dataRow.ItemArray[9]),
                        total_abonos        = Convert.ToInt32(dataRow.ItemArray[10])
                    });
                }
                else
                {
                    list.Add(new ECuotas
                    {
                        id_cuota            = Convert.ToInt32(dataRow.ItemArray[0]),
                        id_prestamo         = Convert.ToInt32(dataRow.ItemArray[1]),
                        fecha_pactada_cuota = string.Format("{0:d}", Convert.ToDateTime(Convert.ToDateTime(dataRow.ItemArray[2]))),
                        fecha_pago_cuota    = string.Format("{0:d}", Convert.ToDateTime(Convert.ToDateTime(dataRow.ItemArray[3]))),
                        monto_cuota         = Convert.ToDouble(dataRow.ItemArray[4]),
                        numero_cuota        = Convert.ToInt32(dataRow.ItemArray[5]),
                        pago_cuota          = Convert.ToBoolean(dataRow.ItemArray[6]),
                        saldo_cuota         = Convert.ToDouble(dataRow.ItemArray[7]),
                        nombre_cliente      = Convert.ToString(dataRow.ItemArray[8]),
                        cedula_cliente      = Convert.ToString(dataRow.ItemArray[9]),
                        total_abonos        = Convert.ToInt32(dataRow.ItemArray[10])
                    });
                }
            }
            return(list);
        }
Ejemplo n.º 12
0
        private void eliminarAbonoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listAbonosCuotas.CheckedItems.Count == 0)
            {
                MessageBox.Show("Debes marcar en la casila los abonos que deseas eliminar", "Informacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else
            {
                DialogResult opcion = MessageBox.Show("Desea eliminar los siguientes abonos marcados", "Informacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);


                double saldo = 0;

                // ELIMINA LOS ABONOS MARCADS CON EL CHECK
                if (opcion == DialogResult.OK)
                {
                    Abonos_CuotasCL oAbonos = new Abonos_CuotasCL();

                    Prestamos_CuotasCL oCuotas = new Prestamos_CuotasCL();

                    oCuotas.EditarPrestamoCuotas(cuota, Convert.ToDateTime(null), false, "eliminar");



                    foreach (ListViewItem item in listAbonosCuotas.Items)
                    {
                        if (item.Checked)
                        {
                            oAbonos.EliminarAbono_Cuotas_Id(lAbonos.Rows[item.Index].ItemArray[0].ToString());

                            saldo += Convert.ToDouble(lAbonos.Rows[item.Index].ItemArray[2]);
                        }
                    }
                }

                EditarSaldoPrestamo(saldo);

                LimpiarValores();

                CargarAbonos(cuota);

                abonos.CargarPrestamos();
            }
        }
Ejemplo n.º 13
0
        // VALIDA SI LAS CUOTAS YA HAN SIDO PAGADAS
        public bool ValidarPago()
        {
            Prestamos_CuotasCL oCuotas = new Prestamos_CuotasCL();

            errores = "";

            int    cont_cuotas_pagadas       = 0;
            int    diferencia_cuotas_pagadas = 0;
            int    cont_cuotas_pendientes    = 0;
            string errores_coutas_pagadas    = "Las siguientes cuotas ya han sido pagadas:";
            string errores_coutas_pendientes = "\nLos siguientes prestamos tienen cuotas pendientes: ";

            var prestamos = dtgPrestamosCuotas.Rows.Cast <DataGridViewRow>().GroupBy(r => r.Cells["Prestamo"].Value);

            foreach (var prestamo in prestamos)
            {
                cont_cuotas_pagadas       = 0;
                diferencia_cuotas_pagadas = 0;
                cont_cuotas_pendientes    = 0;

                int idPrestamo = Convert.ToInt32(prestamo.Key);

                DataTable cuotas_prestamo = oCuotas.TraerPrestamoCuotas(idPrestamo.ToString()).Tables[0];

                var cuotas = prestamo.ToList();

                DataGridViewRow primer_row = prestamo.First();

                // PRIMER COUTA DE LA PLANILLA DEL RESPECTIVO PRESTAMO

                string primer_cuota = primer_row.Cells["Numero_cuota"].Value.ToString();

                // RECORRE LAS CUOTAS PARA CALCULAR LA DIFERENCIA DE CUOTAS NO PAGADAS

                foreach (DataRow cuota_prestamo in cuotas_prestamo.Rows)
                {
                    string cuota = cuota_prestamo["num_cuota"].ToString();

                    if (cuota == primer_cuota)
                    {
                        break;
                    }

                    if (Convert.ToBoolean(cuota_prestamo["pago"]) == false)
                    {
                        diferencia_cuotas_pagadas++;
                    }
                }


                // CORROBORA ESTADO DE COUTAS YA PAGADAS

                if (diferencia_cuotas_pagadas > 0)
                {
                    cont_cuotas_pendientes++;
                    string pendienteTexto = diferencia_cuotas_pagadas > 1 ? "pendientes" : "pendiente";
                    string cuotaTexto     = diferencia_cuotas_pagadas > 1 ? "cuotas" : "cuota";

                    errores_coutas_pendientes += String.Format("\nEl prestamo {0} tiene {1} {2} {3}", idPrestamo, diferencia_cuotas_pagadas, cuotaTexto, pendienteTexto);
                }

                // CORROBORA ESTADO DE COUTAS YA PAGADAS

                foreach (DataGridViewRow cuota in cuotas)
                {
                    foreach (DataRow cuota_prestamo in cuotas_prestamo.Rows)
                    {
                        if (Convert.ToBoolean(cuota_prestamo["pago"]) == true && cuota_prestamo["num_cuota"].ToString() == cuota.Cells["Numero_cuota"].Value.ToString())
                        {
                            cont_cuotas_pagadas++;
                            errores_coutas_pagadas += "\n" + "La cuota numero " + cuota.Cells["Numero_cuota"].Value.ToString() + " del prestamo " + cuota.Cells["Prestamo"].Value.ToString();
                        }
                    }
                }


                errores += cont_cuotas_pagadas > 0 ? errores_coutas_pagadas : "";
                errores += cont_cuotas_pendientes > 0 ? errores_coutas_pendientes : "";
            }

            if (errores != "")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            var dia  = dtFechaInicial.Value.Day;
            var mes  = dtFechaInicial.Value.Month;
            var ano  = dtFechaInicial.Value.Year;
            var tipo = ValidacionesCL.ValidarDiaPagoIndex(cmbDiaPago.SelectedItem.ToString());
            var validacionQuincena = ValidacionesCL.validarQuincena(dia, mes, ano, tipo);

            if (_dCuotasGeneradas == null || _dCuotasGeneradas.Rows.Count == 0)
            {
                MessageBox.Show("Debe hacer clic en Generar previsualización para poder procesar la edición", "Información", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }



            if (validacionQuincena == false)
            {
                var countErrors   = 0;
                var oCuotas       = new Prestamos_CuotasCL();
                var oPlanilla     = new PlanillaCL();
                var oAbonosCuotas = new Abonos_CuotasCL();


                foreach (DataRow item in _dCuotas.Rows)
                {
                    var id = item["id"].ToString();

                    // ELIMINAR ABONOS DE UNA CUOTA
                    oAbonosCuotas.EliminarAbono_Cuotas_Id_Cuota(id);

                    // ELIMINA DETALLE DE PLANILLA REFERENTE A UNA CUOTA
                    oPlanilla.EliminarPlanillaDetalle(id);

                    // ELIMINAR LA CUOTA
                    oCuotas.EliminarCuota(id);

                    if (oCuotas.IsError)
                    {
                        countErrors++;
                    }
                }

                foreach (DataRow item in _dCuotasGeneradas.Rows)
                {
                    // INSERTA NUEVAS CUOTAS
                    oCuotas.InsertarPrestamo_Cuotas(
                        _prestamoId,
                        Convert.ToInt32(item["Numero couta"].ToString()),
                        Convert.ToDateTime(item["Fecha de pago"].ToString()),
                        Convert.ToDouble(item["Monto"].ToString()),
                        Convert.ToDouble(item["Saldo"].ToString()));

                    if (oCuotas.IsError)
                    {
                        countErrors++;
                    }
                }

                if (countErrors > 0)
                {
                    MessageBox.Show("Se presentaron errores al editar las cuotas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Préstamo modificado con éxito", "Información", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    this.Dispose();
                }
            }
        }
Ejemplo n.º 17
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);
        }