Example #1
0
        //
        // GET: /Abono/Create

        public ActionResult Create(string id, string controlador, string fechaActual)
        {
            string idDecrypted = MiUtil.desEncriptar(id);
            int    intId       = Convert.ToInt32(idDecrypted);
            cuota  cuota       = db.cuota.Find(intId);

            ViewBag.cuotaId     = intId;
            ViewBag.CreditoId   = cuota.CreditoId;
            ViewBag.CreditoNro  = cuota.credito.CreditoNro;
            ViewBag.cuotaNumero = cuota.Numero;
            ViewBag.saldo       = cuota.calcularSaldoxCapital() + cuota.calcularSaldoxInteres();
            ViewBag.EmpresaId   = cuota.credito.EmpresaId;
            ViewBag.fechaActual = fechaActual;
            //ViewBag.CuotaId = new SelectList(db.Cuotas, "CuotaId", "CuotaId", cuotaId);

            abono a = new abono();

            a.CuotaId           = intId;
            a.cuota             = cuota;
            a.Valor             = ViewBag.saldo;
            a.Paga              = a.Valor;
            a.Fecha             = DateTime.Now;
            a.Estado            = true;
            ViewBag.controlador = controlador;
            return(View(a));
        }
Example #2
0
        public async Task <ActionResult <abono> > PostTaskItem(abono item)
        {
            _context.abono.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GETabono), new { id = item.Id }, item));
        }
Example #3
0
        // GET: /Abono/Details/5

        public ViewResult Details(string id, string controlador)
        {
            ViewBag.controlador = controlador;


            string idDecrypted = MiUtil.desEncriptar(id);
            int    intId       = Convert.ToInt32(idDecrypted);

            abono abono = db.abono.Find(intId);

            ViewBag.AbonoId = intId;
            return(View(abono));
        }
Example #4
0
        //
        // GET: /Abono/Edit/5

        public ActionResult Edit(string id, string controlador)
        {
            string idDecrypted = MiUtil.desEncriptar(id);
            int    intId       = Convert.ToInt32(idDecrypted);

            ViewBag.controlador = controlador;
            abono abono = db.abono.Find(intId);
            cuota cuota = db.cuota.Find(abono.CuotaId);

            abono.cuota         = cuota;
            ViewBag.CuotaId     = cuota.CuotaId;
            ViewBag.idcuota     = cuota.CuotaId;
            ViewBag.cuotaNumero = cuota.Numero;
            ViewBag.CreditoId   = cuota.CreditoId;
            // ViewBag.CuotaId = new SelectList(db.Cuotas, "CuotaId", "CuotaId", abono.CuotaId);

            return(View(abono));
        }
Example #5
0
        public ActionResult Edit(abono abono, string controlador)
        {
            ViewBag.controlador = controlador;
            if (ModelState.IsValid)
            {
                db.Entry(abono).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = MiUtil.encriptar(abono.CuotaId.ToString()), controlador = controlador }));
            }
            cuota cuota = db.cuota.Find(abono.CuotaId);

            ViewBag.cuotaId     = cuota.CuotaId;
            ViewBag.cuotaNumero = cuota.Numero;
            ViewBag.CreditoId   = cuota.CreditoId;
            ViewBag.CuotaId     = abono.CuotaId;
            ViewBag.idcuota     = cuota.CuotaId;
            //  ViewBag.CuotaId = new SelectList(db.Cuotas, "CuotaId", "CuotaId", abono.CuotaId);

            return(View(abono));
        }
Example #6
0
        public ImpresionAbono impresionAbono(int abonoId)
        {
            ImpresionAbono ia    = null;
            abono          abono = (abono)db.abono.Find(abonoId);

            if (abono.Estado)
            {
                cuota   cuota   = (cuota)db.cuota.Find(abono.CuotaId);
                credito credito = (credito)db.credito.Find(cuota.CreditoId);
                empresa empresa = (empresa)db.empresa.Find(credito.cliente.EmpresaId);
                ia                   = new ImpresionAbono();
                ia.LogoEmpresa       = "~/Uploads/Logos/" + empresa.LogoUrl;
                ia.EmpresaId         = empresa.EmpresaId;
                ia.EmpresaNit        = empresa.Nit;
                ia.EmpresaNombre     = empresa.Nombre;
                ia.ClienteNit        = credito.cliente.Nit;
                ia.ClienteNombre     = credito.cliente.Nombre;
                ia.EmailCliente      = credito.cliente.Email;
                ia.CreditoId         = credito.CreditoId;
                ia.CreditoNro        = credito.CreditoNro;
                ia.CreditoValor      = credito.Valor;
                ia.CreditoCantCuotas = credito.cuota.Count;
                ia.CuotaNro          = cuota.Numero;
                ia.CuotaValor        = cuota.AbonoCapital + cuota.AbonoInteres + MiUtil.nullTodecimal(cuota.AjusteAbonoCapital) + MiUtil.nullTodecimal(cuota.AjusteAbonoInteres);
                ia.AbonoId           = abonoId;
                ia.AbonoNro          = abono.AbonoNro;
                ia.AbonoFecha        = abono.Fecha;
                ia.AbonoValor        = abono.Valor;
                decimal?porcenInteres = cuota.porcentajeInteres();
                decimal?porcenCapital = cuota.porcentajeCapital();
                ia.AbonoInteres        = ia.AbonoValor * (porcenInteres / 100);
                ia.AbonoCapital        = ia.AbonoValor * (porcenCapital / 100);
                ia.CreditoSaldoInteres = credito.calcularTotalInteres() - credito.calcularAbonoInteres(abono.Fecha);
                ia.CreditoSaldoCapital = credito.calcularTotalCapital() - credito.calcularAbonoCapital(abono.Fecha);
                ia.TotalAbono          = ia.AbonoCapital + ia.AbonoInteres;
                ia.SaldoCuota          = cuota.calcularSaldoxCapital(abono.Fecha) + cuota.calcularSaldoxInteres(abono.Fecha);
                //ia.CuotaValor - ia.TotalAbono;
            }
            return(ia);
        }
Example #7
0
        public ActionResult Create(abono abono, string controlador, int EmpresaId, string fechaActual)
        {
            ViewBag.EmpresaId = EmpresaId;
            if (ModelState.IsValid)
            {
                if (abono.Paga > abono.Valor)
                {
                    abono.Devolucion = abono.Paga - abono.Valor;
                }
                else
                {
                    abono.Valor      = abono.Paga;
                    abono.Devolucion = 0;
                }
                consecutivo c = db.consecutivo.Find(EmpresaId);
                c.AbonoNro     = c.AbonoNro + 1;
                abono.AbonoNro = c.AbonoNro;

                db.abono.Add(abono);
                db.SaveChanges();
                // return RedirectToAction("EnviarCorreoFromAWS", new { abonoId = MiUtil.encriptar(abono.AbonoId.ToString()), abonoNro = abono.AbonoNro });
                //return RedirectToAction("Index", controlador, new { id = MiUtil.encriptar(abono.CuotaId.ToString()), controlador = controlador, fechaActual=fechaActual });
                return(RedirectToAction("Index", new { id = MiUtil.encriptar(abono.CuotaId.ToString()), controlador = controlador, fechaActual = fechaActual }));
            }
            ViewBag.CuotaId = abono.CuotaId;
            cuota cuota = db.cuota.Find(abono.CuotaId);

            abono.cuota = cuota;

            ViewBag.cuotaId     = abono.CuotaId;
            ViewBag.CreditoId   = cuota.CreditoId;
            ViewBag.CreditoNro  = cuota.credito.CreditoNro;
            ViewBag.cuotaNumero = cuota.Numero;
            ViewBag.saldo       = cuota.calcularSaldoxCapital() + cuota.calcularSaldoxInteres();
            ViewBag.controlador = controlador;
            //ViewBag.CuotaId = new SelectList(db.Cuotas, "CuotaId", "CuotaId", abono.CuotaId);
            return(View(abono));
        }
Example #8
0
        public JsonResult EnviarAbonoDesdeAWS(string Servidor, int Puerto, string Usuario, string Empresa, string Destinatario, string Password, string Asunto,
                                              string Mensaje, string Adjunto, string AbonoId)
        {
            EnviarCorreo c = new EnviarCorreo();

            c.Servidor     = Servidor;
            c.Puerto       = Puerto;
            c.Usuario      = Usuario;
            c.Empresa      = Empresa;
            c.Destinatario = Destinatario;
            c.Password     = Password;
            c.Asunto       = Asunto;
            c.Mensaje      = Mensaje;
            c.Adjunto      = Adjunto;

            // Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials.
            String SMTP_USERNAME = ConfigurationManager.AppSettings["AWSAccessKey"].ToString();
            //  "AKIAIZOJPFIFCACIJ53A";  // Replace with your SMTP username.
            String SMTP_PASSWORD = ConfigurationManager.AppSettings["AWSSecretKey"].ToString();
            //   "Au9jMcd8Z07RmDNYgEvxs9f+3rpf46RruJ+1LgGEbzr5";  // Replace with your SMTP password.
            // Amazon SES SMTP host name. This example uses the US West (Oregon) region.
            String   HOST       = ConfigurationManager.AppSettings["AWSServer"].ToString();
            DateTime?fechaEnvio = DateTime.Now;

            //FechaCreacion=new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day)
            string s  = "";
            bool   ok = false;

            if (TryValidateModel(c))
            {
                if (ModelState.IsValid)
                {
                    var    fromAddress  = new MailAddress(Usuario, Empresa);
                    var    toAddress    = new MailAddress(Destinatario, "");
                    string fromPassword = Password;
                    string subject      = Asunto;
                    string body         = Mensaje;

                    System.Net.Mail.Attachment attachment;
                    attachment = new System.Net.Mail.Attachment(Adjunto);


                    MailMessage message = new MailMessage(fromAddress, toAddress);
                    message.Subject = subject;
                    message.Body    = body;
                    message.Attachments.Add(attachment);

                    // Create an SMTP client with the specified host name and port.
                    using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, Puerto))
                    {
                        // Create a network credential with your SMTP user name and password.
                        client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);

                        // Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then
                        // the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
                        client.EnableSsl = true;
                        // Send the email.
                        try
                        {
                            //  Console.WriteLine("Attempting to send an email through the Amazon SES SMTP interface...");
                            //client.Send(FROM, TO, SUBJECT, BODY);
                            client.Send(message);
                            //Console.WriteLine("Email sent!");
                            ok = true;
                            //string idDecrypted = MiUtil.desEncriptar(AbonoId);
                            int intAbonoId = 0;
                            //Int32.TryParse(idDecrypted, out intAbonoId);
                            Int32.TryParse(AbonoId, out intAbonoId);
                            abono ab = db.abono.Find(intAbonoId);
                            if (ab != null)
                            {
                                ab.FechaEnvio = DateTime.Now;
                                db.SaveChanges();
                                fechaEnvio = ab.FechaEnvio;
                            }
                        }
                        catch (Exception ex)
                        {
                            s = ex.ToString().Substring(0, 200);
                            ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}" + ex.ToString();
                            Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString());
                        }
                    }
                }
            }
            if (!ok)
            {
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        s = s + error.ErrorMessage;
                    }
                }
            }
            // return Json(new { success = false });
            return(Json(new { success = ok, Error = s, FechaEnvio = fechaEnvio.ToString() }, JsonRequestBehavior.AllowGet));
        }
Example #9
0
        //[HttpPost]
        //public ActionResult EnviarCorreo(EnviarCorreo enviarcorreo, string button, string urlPapa, string abonoId)
        //{
        //    //if (button.Equals("Cancelar"))
        //    //    return RedirectToAction("Index", "CuotasxCobrar", new { controlador = controlador });

        //    if (ModelState.IsValid)
        //    {
        //        var fromAddress = new MailAddress(enviarcorreo.Usuario,enviarcorreo.Empresa);
        //        var toAddress = new MailAddress(enviarcorreo.Destinatario,"");
        //        string fromPassword = enviarcorreo.Password;
        //        string subject = enviarcorreo.Asunto;
        //        string body = enviarcorreo.Mensaje;

        //        System.Net.Mail.Attachment attachment;
        //        attachment = new System.Net.Mail.Attachment(enviarcorreo.Adjunto);

        //        var smtp = new SmtpClient
        //        {
        //            Host = enviarcorreo.Servidor,
        //            Port = enviarcorreo.Puerto,
        //            EnableSsl = true,
        //            DeliveryMethod = SmtpDeliveryMethod.Network,
        //           // UseDefaultCredentials = true,
        //            UseDefaultCredentials = false,
        //            Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword)
        //        };
        //        MailMessage message = new MailMessage(fromAddress, toAddress);
        //        message.Subject = subject;
        //        message.Body = body;
        //        message.Attachments.Add(attachment);
        //        try
        //        {
        //            smtp.Send(message);
        //            Response.Redirect(urlPapa, true);
        //        }
        //        catch (Exception ex)
        //        {
        //            ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}"+ ex.ToString();
        //            Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",ex.ToString());
        //        }
        //    }

        //    //return View("../Shared/Mensaje");
        //   // return View("");
        //    return RedirectToAction("EnviarAbono", new { abonoId = abonoId, urlPapa = urlPapa });
        //}


        public JsonResult EnviarAbono(string Servidor, int Puerto, string Usuario, string Empresa, string Destinatario, string Password, string Asunto,
                                      string Mensaje, string Adjunto, string AbonoId)
        {
            EnviarCorreo c = new EnviarCorreo();

            c.Servidor     = Servidor;
            c.Puerto       = Puerto;
            c.Usuario      = Usuario;
            c.Empresa      = Empresa;
            c.Destinatario = Destinatario;
            c.Password     = Password;
            c.Asunto       = Asunto;
            c.Mensaje      = Mensaje;
            c.Adjunto      = Adjunto;

            //FechaCreacion=new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day)
            string s  = "";
            bool   ok = false;

            if (TryValidateModel(c))
            {
                if (ModelState.IsValid)
                {
                    var    fromAddress  = new MailAddress(Usuario, Empresa);
                    var    toAddress    = new MailAddress(Destinatario, "");
                    string fromPassword = Password;
                    string subject      = Asunto;
                    string body         = Mensaje;

                    System.Net.Mail.Attachment attachment;
                    attachment = new System.Net.Mail.Attachment(Adjunto);

                    var smtp = new SmtpClient
                    {
                        Host           = Servidor,
                        Port           = Puerto,
                        EnableSsl      = true,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        // UseDefaultCredentials = true,
                        UseDefaultCredentials = false,
                        Credentials           = new System.Net.NetworkCredential(fromAddress.Address, fromPassword)
                    };
                    MailMessage message = new MailMessage(fromAddress, toAddress);
                    message.Subject = subject;
                    message.Body    = body;
                    message.Attachments.Add(attachment);
                    try
                    {
                        smtp.Send(message);
                        //Response.Redirect(urlPapa, true);
                        ok = true;
                        //string idDecrypted = MiUtil.desEncriptar(AbonoId);
                        int intAbonoId = 0;
                        Int32.TryParse(AbonoId, out intAbonoId);
                        abono ab = db.abono.Find(intAbonoId);
                        //abono ab = db.abono.Find(AbonoId);
                        if (ab != null)
                        {
                            ab.FechaEnvio = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        s = ex.ToString().Substring(0, 200);
                        ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}" + ex.ToString();
                        Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString());
                    }
                }
            }
            if (!ok)
            {
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        s = s + error.ErrorMessage;
                    }
                }
            }
            // return Json(new { success = false });
            return(Json(new { success = ok, Error = s }, JsonRequestBehavior.AllowGet));
        }