コード例 #1
0
        //AGREGAR AUTORIZACION DEL SOCIO (CREDENCIALES)
        public void agregarAutorizacion(long id, string nip)
        {
            using (var bd = new Conexion())
            {
                string nipautorizacion = seguridad.Encriptar(nip);

                autorizacion autorizacion = new autorizacion
                {
                    aut_asociado = id,
                    aut_nip      = nipautorizacion
                };

                long consulta = bd.autorizacion.LongCount();

                if (consulta == 0)
                {
                    bd.Database.ExecuteSqlCommand("ALTER TABLE autorizacion AUTO_INCREMENT=1");
                }
                else
                {
                    long maxVal = bd.autorizacion.Max(a => a.aut_id) + 1;

                    bd.Database.ExecuteSqlCommand("ALTER TABLE autorizacion AUTO_INCREMENT={0}", maxVal);
                }

                bd.autorizacion.Add(autorizacion);
                bd.SaveChanges();
            }
        }
コード例 #2
0
        private void btnCancelar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvPrestamos.CurrentRow == null)
                {
                    MessageBox.Show("¡No hay prestamos disponibles para seleccionar!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    DialogResult mensaje = MessageBox.Show("¿Desea cancelar el prestamo?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (mensaje == DialogResult.Yes)
                    {
                        Prestamos_nip prestamosnip = new Prestamos_nip();
                        prestamosnip.ShowDialog();
                        string nip = prestamosnip.nip;

                        if (nip == null)
                        {
                            MessageBox.Show("¡No introdució la clave de autorización!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            autorizacion = prestamoscontroller.autorizacion(Convert.ToInt64(txtClave.Text), nip);

                            if (autorizacion != null)
                            {
                                prestamoscontroller.eliminarPagos(long.Parse(dgvPrestamos.CurrentRow.Cells[0].Value.ToString()));

                                prestamoscontroller.eliminarPrestamo(long.Parse(dgvPrestamos.CurrentRow.Cells[0].Value.ToString()));

                                MessageBox.Show("¡El prestamo ha sido cancelado exitosamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                txtClave.Clear();
                                txtCorreo.Clear();
                                txtDomicilio.Clear();
                                txtMovil.Clear();
                                txtNombre.Clear();
                                txtTelefono.Clear();
                                pbxPerfil.Image         = null;
                                dgvPrestamos.DataSource = null;

                                btnCancelar.Enabled = true;

                                panel2.Enabled = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void btnContratos_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult mensaje = MessageBox.Show("¿Desea mostrar los contratos de prestamo del socio?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (mensaje == DialogResult.Yes)
                {
                    Prestamos_nip prestamosnip = new Prestamos_nip();
                    prestamosnip.ShowDialog();
                    string nip = prestamosnip.nip;

                    if (nip == null)
                    {
                        btnConfirmar.Focus();
                    }
                    else
                    {
                        autorizacion = prestamoscontroller.autorizacion(Convert.ToInt64(txtClave.Text), nip);

                        if (autorizacion != null)
                        {
                            Prestamos_contratos prestamoscontratos = new Prestamos_contratos();
                            prestamoscontratos.id = Convert.ToInt32(txtClave.Text);
                            prestamoscontratos.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("¡El NIP de autorización es incorrecto!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvCalculadora.CurrentRow == null)
                {
                    MessageBox.Show("¡Falta por calcular sus cuotas a pagar por el prestamo!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    int bandera1 = 0, bandera2 = 0, bandera3 = 0;

                    if (txtMonto.Text == "")
                    {
                        lblValidacion1.Text    = "* Complete este campo";
                        lblValidacion1.Visible = true;
                        bandera1 = 0;
                    }
                    else
                    {
                        lblValidacion1.Visible = false;
                        bandera1 = 1;
                    }

                    if (txtCuotas.Text == "")
                    {
                        lblValidacion2.Text    = "* Complete este campo";
                        lblValidacion2.Visible = true;
                        bandera2 = 0;
                    }
                    else
                    {
                        lblValidacion2.Visible = false;
                        bandera2 = 1;
                    }

                    if (cbxTipo.Text == "")
                    {
                        lblValidacion3.Text    = "* Complete este campo";
                        lblValidacion3.Visible = true;
                        bandera3 = 0;
                    }
                    else
                    {
                        lblValidacion3.Visible = false;
                        bandera3 = 1;
                    }

                    if (bandera1 == 1 && bandera2 == 1 && bandera3 == 1)
                    {
                        Prestamos_nip prestamosnip = new Prestamos_nip();
                        prestamosnip.ShowDialog();
                        string nip = prestamosnip.nip;

                        if (nip == null)
                        {
                            btnConfirmar.Focus();
                        }
                        else
                        {
                            autorizacion = prestamoscontroller.autorizacion(Convert.ToInt64(txtClave.Text), nip);

                            if (autorizacion != null)
                            {
                                DialogResult mensaje = MessageBox.Show("¿Confirma la autorización del prestamo?", "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (mensaje == DialogResult.Yes)
                                {
                                    //SE AUTORIZA EL PRESTAMO//

                                    //ALTA DEL PRESTAMO
                                    long id = prestamoscontroller.agregarPrestamo(Convert.ToInt64(txtClave.Text), Convert.ToDecimal(txtMonto.Text), Convert.ToInt32(txtCuotas.Text), Convert.ToDateTime(DateTime.Now.ToShortDateString()), Convert.ToInt32(numInteres.Value.ToString()), Convert.ToInt32(lblMeses.Text), Convert.ToDateTime(dtpPrimer.Value.ToShortDateString()), Convert.ToInt32(numInteres.Value.ToString()) * Convert.ToInt32(lblMeses.Text), txtObservaciones.Text, Convert.ToInt32(lblSemanas.Text), cbxTipo.Text, Convert.ToDecimal(lblPagofinal.Text.Replace("$", "").Replace(",", "")), decimal.Parse(lblPagofinal.Text.Replace("$", "").Replace(",", "")) - decimal.Parse(txtMonto.Text));

                                    //PAGOS DEL PRESTAMO - ALTA
                                    for (int i = 0; i < dgvCalculadora.RowCount; i++)
                                    {
                                        prestamoscontroller.agregarPago(decimal.Parse(dgvCalculadora.Rows[i].Cells[1].Value.ToString()), Convert.ToDateTime(dgvCalculadora.Rows[i].Cells[5].Value.ToString()), id, decimal.Parse(dgvCalculadora.Rows[i].Cells[4].Value.ToString()), decimal.Parse(dgvCalculadora.Rows[i].Cells[3].Value.ToString()), decimal.Parse(dgvCalculadora.Rows[i].Cells[2].Value.ToString()));
                                    }

                                    //AGREGAR A CONTABILIDAD EL PRESTAMO OTORGADO
                                    ContabilidadController contabilidadcontroller = new ContabilidadController();
                                    contabilidadcontroller.agregarContabilidad("Prestamo a socio No. " + asociados.aso_id.ToString() + " a nombre de: " + asociados.aso_nombre + " " + asociados.aso_apellidos, -Convert.ToDecimal(txtMonto.Text), 0, -Convert.ToDecimal(txtMonto.Text), DateTime.Now, "S");

                                    //MOSTRAMOS EL CONTRATO GENERADO
                                    Reportes.Rep_Prestamos rep_prestamos = new Reportes.Rep_Prestamos();
                                    rep_prestamos.idprestamo = id;
                                    rep_prestamos.ShowDialog();

                                    MessageBox.Show("¡El prestamo ha sido otorgado!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    btnCalcular.Enabled  = false;
                                    btnCancelar.Enabled  = false;
                                    btnConfirmar.Enabled = false;
                                    btnContratos.Enabled = false;

                                    btnBuscar.Enabled = true;

                                    lblPagofinal.Visible = false;
                                    lblMeses.Visible     = false;
                                    lblSemanas.Visible   = false;

                                    groupBox1.Enabled = true;
                                    groupBox3.Enabled = false;
                                    groupBox4.Enabled = false;

                                    txtClave.Clear();
                                    txtCorreo.Clear();
                                    txtCuotas.Clear();
                                    txtDomicilio.Clear();
                                    txtMonto.Clear();
                                    txtMovil.Clear();
                                    txtNombre.Clear();
                                    txtTelefono.Clear();
                                    txtObservaciones.Clear();
                                    cbxTipo.SelectedIndex = -1;

                                    //LIMPIAR DGV
                                    dgvCalculadora.Columns.Clear();
                                    dgvCalculadora.Rows.Clear();

                                    numInteres.Value = 0;
                                    dtpPrimer.Value  = DateTime.Now;

                                    txtClave.Enabled = true;
                                    txtClave.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show("¡El NIP de autorización es incorrecto!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }