Beispiel #1
0
        public void CargarAbonosCuotas()
        {
            Abonos_CuotasCL oAbonosCuotas = new Abonos_CuotasCL();

            foreach (DataGridViewRow row in dtgPrestamosCuotas.Rows)
            {
                // TRAE LOS ABONOS DE UNA CUOTA
                DataSet oDatosAbonos = oAbonosCuotas.TraerAbono_Cuotas(row.Cells["Prestamos_cuotas_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 = "";
                }
            }
        }
Beispiel #2
0
        // REVISAR SI LAS CUOTAS TIENE ABONOS PENDIENTES
        public bool revisarAbonos()
        {
            Abonos_CuotasCL oAbonosCuotas = new Abonos_CuotasCL();

            bool hayAbonos = false;

            // RECORRE LAS CUOTAS DE LA TABLA EN BUSCA DE ABONOS DE LAS CUOTAS
            foreach (DataGridViewRow row in dtgCuotas.Rows)
            {
                DataSet oDatosAbonos = oAbonosCuotas.TraerAbono_Cuotas(row.Cells["id_cuota"].Value.ToString());

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

                // COMPRUEBA LA CANTIDAD
                if (cantidadAbonos > 0)
                {
                    // ESTABLECE COLOR VERDE SI LA CUOTA TIENE ABONOS
                    row.DefaultCellStyle.BackColor = Color.Salmon;
                    row.Selected = false;
                    hayAbonos    = true;
                }
            }

            return(hayAbonos);
        }
Beispiel #3
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);
     }
 }
Beispiel #4
0
        public void CargarAbonos(int id_cuota)
        {
            // INSTANCIAS
            Abonos_CuotasCL oAbonosCuotas = new Abonos_CuotasCL();

            // TRAE LOS ABONOS DE CUOTAS Y LOS GUARDA EN DATATABLE
            DataTable oTable = oAbonosCuotas.TraerAbono_Cuotas(Convert.ToString(id_cuota)).Tables[0];

            lAbonos = oTable;

            //CICLO QUE RECORRE LOS ROWS
            foreach (DataRow item in oTable.Rows)
            {
                // CREAR UN GRUPO
                ListViewGroup grupo = new ListViewGroup(item["fecha_abono"].ToString());

                // CREAR UN ITEM DE GRUPO
                ListViewItem item_grupo = new ListViewItem("MONTO: ₡" + item["monto"].ToString(), grupo);

                // AGREGAR EL GRUPO
                listAbonosCuotas.Groups.Add(grupo);

                // AGREGAR EL ITEM
                listAbonosCuotas.Items.Add(item_grupo);
            }
        }
Beispiel #5
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();
        }
Beispiel #6
0
        public static List <EAbonos> ObtenerAbonos(string id_cuota)
        {
            Abonos_CuotasCL abonos_CuotasCL = new Abonos_CuotasCL();
            DataSet         dataSet         = abonos_CuotasCL.TraerAbono_Cuotas(id_cuota);
            List <EAbonos>  list            = new List <EAbonos>();

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                list.Add(new EAbonos
                {
                    id_abono    = Convert.ToInt32(dataRow.ItemArray[0]),
                    id_cuota    = Convert.ToInt32(dataRow.ItemArray[1]),
                    monto_abono = Convert.ToDouble(dataRow.ItemArray[2]),
                    fecha_abono = Convert.ToDateTime(dataRow.ItemArray[3])
                });
            }
            return(list);
        }
Beispiel #7
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();
            }
        }
Beispiel #8
0
        public string Abonos()
        {
            Abonos_CuotasCL abonos_CuotasCL = new Abonos_CuotasCL();

            DataTable dataTable = abonos_CuotasCL.TraerAbono_Cuotas(this.idCuota.ToString()).Tables[0];

            string result;
            double totalAbonosCuota = 0;

            if (dataTable.Rows.Count == 0)
            {
                return(result = "");
            }
            else
            {
                // CICLO QUE RECORRE LOS ABONOS DE LAS CUTOAS
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    this.saldoPrestamo -= Convert.ToDouble(dataRow["monto"].ToString());

                    totalAbonosCuota += Convert.ToDouble(dataRow["monto"].ToString());


                    this.abonosCuota = string.Concat(new string[]
                    {
                        this.abonosCuota,
                        Convert.ToDateTime(dataRow["fecha_abono"].ToString()).ToShortDateString(),
                        " - ",
                        Convert.ToDouble(dataRow["monto"].ToString()).ToString("C", Moneda()),
                        "\n"
                    });
                }

                // EN EL CASO DE QUE EXISTAN ABONOS SE VEA REFLEJADO EL SALDO DE LA CUOTA EXISTENTE
                this.saldoPrestamo = this.saldoPretamoAnterior - totalAbonosCuota;

                return(result = this.abonosCuota);
            }
            return(result);
        }
Beispiel #9
0
        public static List <EAbonos> ObtenerAbonos_RangoFecha(string fecha_desde, string fecha_hasta)
        {
            Abonos_CuotasCL abonos_CuotasCL = new Abonos_CuotasCL();
            DataSet         dataSet         = abonos_CuotasCL.TraerAbonos_Cuotas_RangoFechas(fecha_desde, fecha_hasta);
            List <EAbonos>  list            = new List <EAbonos>();

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                list.Add(new EAbonos
                {
                    id_abono       = Convert.ToInt32(dataRow.ItemArray[0]),
                    id_cuota       = Convert.ToInt32(dataRow.ItemArray[1]),
                    monto_abono    = Convert.ToDouble(dataRow.ItemArray[2]),
                    fecha_abono    = Convert.ToDateTime(dataRow.ItemArray[3]),
                    num_cuota      = Convert.ToInt32(dataRow.ItemArray[4]),
                    id_prestamo    = Convert.ToInt32(dataRow.ItemArray[5]),
                    cedula_cliente = Convert.ToString(dataRow.ItemArray[6]),
                    nombre_cliente = Convert.ToString(dataRow.ItemArray[7])
                });
            }
            return(list);
        }
        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();
                }
            }
        }
Beispiel #11
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);
            }
        }
Beispiel #12
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);
        }