예제 #1
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);
                }
            }
        }
예제 #2
0
        private void dtgClientes_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Hide();

            if (clientes != null)
            {
                this.clientes.ActivarCajas(2);
                this.clientes.txtCedula.Text    = this.dtgClientes["Cedula", this.dtgClientes.CurrentCell.RowIndex].Value.ToString();
                this.clientes.txtNombre.Text    = this.dtgClientes["Nombre", this.dtgClientes.CurrentCell.RowIndex].Value.ToString();
                this.clientes.txtTelefono.Text  = this.dtgClientes["Telefono", this.dtgClientes.CurrentCell.RowIndex].Value.ToString();
                this.clientes.txtCelular.Text   = this.dtgClientes["Celular", this.dtgClientes.CurrentCell.RowIndex].Value.ToString();
                this.clientes.txtDireccion.Text = this.dtgClientes["Direccion", this.dtgClientes.CurrentCell.RowIndex].Value.ToString();
                this.clientes.ckMoroso.Checked  = Convert.ToBoolean(this.dtgClientes["Moroso", this.dtgClientes.CurrentCell.RowIndex].Value.ToString());
            }

            if (prestamos != null)
            {
                prestamos.txtCliente.Text = dtgClientes["Cedula", dtgClientes.CurrentCell.RowIndex].Value.ToString();
                prestamos.CargarClientes();
                prestamos.CargarPrestamos();
            }

            if (abonos != null)
            {
                abonos.txtCliente.Text = dtgClientes["Cedula", dtgClientes.CurrentCell.RowIndex].Value.ToString();
                abonos.CargarClientes();
                abonos.CargarPrestamos();
            }

            if (filtroPrestamos != null)
            {
                filtroPrestamos.txtCliente.Text = dtgClientes["Cedula", dtgClientes.CurrentCell.RowIndex].Value.ToString();
                filtroPrestamos.ComprobarPrestamos();
            }

            if (filtroPrestamos_Cuotas != null)
            {
                filtroPrestamos_Cuotas.txtCliente.Text = dtgClientes["Cedula", dtgClientes.CurrentCell.RowIndex].Value.ToString();
                filtroPrestamos_Cuotas.ComprobarPrestamos();
            }
        }
예제 #3
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);
            }
        }