예제 #1
0
        public ActionResult Insertar(string correo, string total)
        {
            compraBLL         = new CompraBLLImp();
            compraProductoBLL = new CompraProductoBLLImp();
            string idCompra = fb.ConsecutivoModifica("CMP");
            Compra compra   = new Compra()
            {
                idCompra        = idCompra,
                correo          = correo,
                fecha           = DateTime.Now,
                total           = total,
                idNombreEmpresa = Session["empresa"].ToString()
            };
            bool a = compraBLL.Agregar(compra);
            bool b = compraProductoBLL.Crear(idCompra, productos);

            try
            {
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress("*****@*****.**");
                    mail.To.Add(correo);
                    mail.Subject    = "Usuario de Ragnarok";
                    mail.Body       = Mensaje(total);
                    mail.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient
                    {
                        Host                  = "smtp.gmail.com",
                        Port                  = 587,
                        EnableSsl             = true,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials           = new NetworkCredential("*****@*****.**", ""),
                        Timeout               = 20000
                    };
                    smtp.Send(mail);
                }
            }
            catch (Exception e)
            {
                string aa = e.Message;
                return(Json(new { bol = false }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { result = a, result2 = b }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Segunda(string id)
        {
            compraProductoBLL = new CompraProductoBLLImp();
            productobll       = new ProductoBLLImp();
            List <CompraProducto> resultado = compraProductoBLL.BuscarCierre(id);
            String htmlCode = String.Empty;

            foreach (CompraProducto per in resultado)
            {
                Producto pro = productobll.BuscarPorId(per.idProducto);
                htmlCode += "<tr>" +
                            "<td>" + pro.idProducto + "</td>" +
                            "<td>" + pro.nombre + "</td>" +
                            "<td>" + per.cantidad + "</td>" +
                            "<td>" + pro.precioVenta + "</td>" +
                            "<tr>";
            }
            return(Json(new { result = htmlCode }, JsonRequestBehavior.AllowGet));
        }