Ejemplo n.º 1
0
 public frmAbonarSaldar(Deudores saldador)
 {
     InitializeComponent();
     abonador    = saldador;
     label3.Text = saldador.Nombres + " " + saldador.Apellidos;
     label4.Text = saldador.Capital.ToString();
     label6.Text = saldador.ReditoAcumulado.ToString();
 }
Ejemplo n.º 2
0
 private void btnPagos_Click(object sender, EventArgs e)
 {
     using (SistemaPrestamosPVEntities db = new SistemaPrestamosPVEntities())
     {
         var             id   = GetId();
         Deudores        deu  = db.Deudores.Find(id);
         frmAbonarSaldar form = new frmAbonarSaldar(deu);
         form.ShowDialog();
         LoadData();
     }
 }
Ejemplo n.º 3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int?id = GetId();

            if (id != null)
            {
                using (SistemaPrestamosPVEntities db = new SistemaPrestamosPVEntities())
                {
                    Deudores oTabla = db.Deudores.Find(id);
                    db.Deudores.Remove(oTabla);
                    db.SaveChanges();
                    MessageBox.Show("Regristro Borrado!");
                }
                LoadData();
            }
        }
Ejemplo n.º 4
0
 private void CargarDatos()
 {
     using (SistemaPrestamosPVEntities db = new SistemaPrestamosPVEntities())
     {
         oTabla            = db.Deudores.Find(id);
         txtNombres.Text   = oTabla.Nombres;
         txtApellidos.Text = oTabla.Apellidos;
         txtCapital.Text   = oTabla.Capital.ToString();
         var interes = oTabla.Interes;
         txtInteres.Text = interes.ToString();
         dtpFechaInicializacionPrestamo.Value = oTabla.FechaInicializacionPrestamo;
         txtTelefono.Text  = oTabla.Telefono;
         txtTelefono2.Text = oTabla.Telefono2;
         txtDireccion.Text = oTabla.Direccion;
         txtEmail.Text     = oTabla.Email;
     }
 }
Ejemplo n.º 5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SistemaPrestamosPVEntities db = new SistemaPrestamosPVEntities())
                {
                    TimeSpan cuotasGen;
                    DateTime fechaActual = DateTime.Now;

                    if (id == null)
                    {
                        oTabla           = new Deudores();
                        oTabla.Nombres   = txtNombres.Text;
                        oTabla.Apellidos = txtApellidos.Text;
                        oTabla.Capital   = Convert.ToSingle(txtCapital.Text);
                        var interes = Convert.ToSingle(txtInteres.Text);
                        oTabla.Interes       = interes;
                        oTabla.ReditoMensual = Convert.ToSingle(txtCapital.Text) * (interes / 100);
                        oTabla.CuotasPagadas = 0;
                        oTabla.FechaInicializacionPrestamo = oTabla.UltimoPago = dtpFechaInicializacionPrestamo.Value;
                        cuotasGen = fechaActual - oTabla.FechaInicializacionPrestamo;
                        oTabla.CuotasGeneradas = cuotasGen.Days / 30;
                        oTabla.CuotasVencidas  = oTabla.CuotasGeneradas - oTabla.CuotasPagadas;
                        if (oTabla.CuotasVencidas == 0)
                        {
                            oTabla.ReditoAcumulado = oTabla.ReditoMensual;
                        }
                        else
                        {
                            oTabla.ReditoAcumulado = oTabla.ReditoMensual * oTabla.CuotasVencidas;
                        }
                        oTabla.CuotasPagadasATiempo = 0;
                        oTabla.Score     = 1;
                        oTabla.Telefono  = txtTelefono.Text;
                        oTabla.Telefono2 = txtTelefono2.Text;
                        oTabla.Email     = txtEmail.Text;
                        oTabla.Direccion = txtDireccion.Text;
                        oTabla.Cedula    = txtCedula.Text;

                        db.Deudores.Add(oTabla);
                        MessageBox.Show("Registro agregado");
                    }
                    else
                    {
                        oTabla.Nombres     = txtNombres.Text;
                        oTabla.Apellidos   = txtApellidos.Text;
                        txtCapital.Enabled = false;
                        var interes = Convert.ToSingle(txtInteres.Text);
                        oTabla.Interes       = interes;
                        oTabla.ReditoMensual = Convert.ToSingle(txtCapital.Text) * (interes / 100);
                        dtpFechaInicializacionPrestamo.Enabled = false;
                        oTabla.Interes   = interes;
                        oTabla.Telefono  = txtTelefono.Text;
                        oTabla.Telefono2 = txtTelefono2.Text;
                        oTabla.Email     = txtEmail.Text;
                        oTabla.Direccion = txtDireccion.Text;
                        oTabla.Cedula    = txtCedula.Text;

                        db.Entry(oTabla).State = EntityState.Modified;
                        MessageBox.Show("Registro editado");
                    }

                    db.SaveChanges();
                    Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Campos obligatorios: Nombres, capital(solo numéricos) e interes(solo numéricos)", "Error!!");
            }
        }
Ejemplo n.º 6
0
        private void btnPagarUltimaCuota_Click(object sender, EventArgs e)
        {
            try
            {
                var      id    = GetId();
                DateTime fecha = DateTime.Now;
                using (SistemaPrestamosPVEntities db = new SistemaPrestamosPVEntities())
                {
                    Deudores deu = db.Deudores.Find(id);
                    if (id != null)
                    {
                        if (deu.CuotasVencidas < 2)
                        {
                            deu.CuotasPagadasATiempo++;
                        }
                        deu.CuotasVencidas--;
                        deu.UltimoPago = fecha;
                        deu.CuotasPagadas++;
                        deu.ReditoAcumulado -= deu.ReditoMensual;
                        db.Entry(deu).State  = EntityState.Modified;
                        var pregunta = MessageBox.Show("Desea guardar factura?", "Factura", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (pregunta == DialogResult.Yes)          //Imprime factura para una cuota
                        {
                            #region Factura

                            try
                            {
                                string     nombreMasFecha = deu.Nombres + " " + fecha.ToString("MM - dd - yy");
                                string     pdfFilename    = $@"C:\Sistema Repuestos Pavel\Facturas de Cuotas\{nombreMasFecha}.pdf";
                                FileStream fs             = new FileStream(pdfFilename, FileMode.Create, FileAccess.Write, FileShare.None);
                                Document   doc            = new Document();
                                PdfWriter  writer         = PdfWriter.GetInstance(doc, fs);
                                doc.Open();

                                Paragraph espacioEntreParrrafos = new Paragraph("  ");
                                Paragraph fechaFactura          = new Paragraph(fecha.ToString());
                                fechaFactura.Alignment = Element.ALIGN_RIGHT;
                                Paragraph linea       = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
                                Chunk     titulo      = new Chunk("GRUPO INVERSIONES VERAS");
                                Chunk     subtitulo   = new Chunk("República Dominicana ");
                                Chunk     descripcion = new Chunk("DESCRIPCION - PAGO DE CUOTA");

                                descripcion.Font.Size = 15;
                                descripcion.Font.SetStyle("Bold");
                                titulo.Font.SetStyle("Bold");
                                titulo.Font.Size = 40;
                                subtitulo.Font.SetStyle("Bold");
                                subtitulo.Font.Size = 20;
                                Paragraph Titulo      = new Paragraph(titulo);
                                Paragraph Subtitulo   = new Paragraph(subtitulo);
                                Paragraph Descripcion = new Paragraph(descripcion);

                                Descripcion.Alignment = Element.ALIGN_CENTER;
                                Titulo.Alignment      = Element.ALIGN_CENTER;
                                Subtitulo.Alignment   = Element.ALIGN_CENTER;
                                doc.Add(linea);
                                doc.Add(Titulo);
                                doc.Add(Subtitulo);
                                doc.Add(Descripcion);
                                doc.Add(linea);


                                Chunk deudorNombre = new Chunk("A nombre del deudor: " + deu.Nombres + " " + deu.Apellidos);
                                deudorNombre.Font.Size = 20;
                                deudorNombre.Font.SetStyle("Bold");
                                Paragraph DeudorNombre = new Paragraph(deudorNombre);
                                doc.Add(DeudorNombre);
                                doc.Add(espacioEntreParrrafos);
                                doc.Add(espacioEntreParrrafos);


                                Chunk cuota = new Chunk("Monto pagado:RD$" + deu.ReditoMensual.ToString());
                                cuota.Font.Size = 20;
                                cuota.Font.SetStyle("Bold");
                                Paragraph Cuota = new Paragraph(cuota);
                                doc.Add(Cuota);
                                doc.Add(espacioEntreParrrafos);
                                doc.Add(espacioEntreParrrafos);


                                Chunk reditoPendiente = new Chunk("Reditos Pendientes:RD$" + deu.ReditoAcumulado.ToString());
                                reditoPendiente.Font.Size = 20;
                                reditoPendiente.Font.SetStyle("Bold");
                                Paragraph ReditoPendiente = new Paragraph(reditoPendiente);
                                doc.Add(ReditoPendiente);
                                doc.Add(espacioEntreParrrafos);
                                doc.Add(espacioEntreParrrafos);

                                Chunk capitalPendiente = new Chunk("Capital Pendientes:RD$" + deu.Capital.ToString());
                                capitalPendiente.Font.Size = 20;
                                capitalPendiente.Font.SetStyle("Bold");
                                Paragraph CapitalPendiente = new Paragraph(capitalPendiente);
                                doc.Add(CapitalPendiente);

                                for (int i = 0; i < 8; i++)
                                {
                                    doc.Add(espacioEntreParrrafos);
                                }
                                doc.Add(linea);
                                doc.Add(fechaFactura);

                                doc.Close();
                                string pdfPath = Path.Combine(Application.StartupPath, pdfFilename);

                                Process.Start(pdfPath);
                            }

                            catch (Exception m)
                            {
                                MessageBox.Show(m.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }

                            #endregion
                        }

                        else //De lo contrario solo se muestra MessageBox.
                        {
                            MessageBox.Show(deu.Nombres + " " + deu.Apellidos + " Ha pagado" +
                                            " una cuota, le quedan " + deu.CuotasVencidas.ToString() + " Cuotas vencidas");
                        }
                    }
                    db.SaveChanges();
                    LoadData();
                }
            }
            catch (Exception Men)
            {
                MessageBox.Show(Men.Message);
                MessageBox.Show("Por haga click en algun registro!", "Error:No cliente seleccionado");
            }
        }