Пример #1
0
        public void mandarEmail(Cliente cliente, string tipo, Cesta cesta, string tempPath)
        {
            string url, html = "", subject = "";

            if (tipo == "Recuperar contraseña")
            {
                url = "http://*****:*****@gmail.com");
            nuevoCorreo.Subject = subject;
            nuevoCorreo.IsBodyHtml = true;
            nuevoCorreo.Body = html;
            Task task = null;
            if (tipo == "Cesta")
            {
                task = new Task(() => crearPDF(cesta, cliente, "Cesta", tempPath));
                task.Start();
                task.Wait();
                nuevoCorreo.Attachments.Add(new Attachment(tempPath + "/ReciboCompra" + cesta.id + ".pdf"));
            }

            SmtpClient servidor = new SmtpClient();
            servidor.Host = "smtp.gmail.com";
            servidor.Port = 587;
            servidor.EnableSsl = true;
            servidor.DeliveryMethod = SmtpDeliveryMethod.Network;
            servidor.Credentials = new NetworkCredential("*****@*****.**", "solosequenosenada");
            servidor.Timeout = 20000;

            servidor.Send(nuevoCorreo);
        }
Пример #2
0
        public void añadirCesta(string path, Cesta cesta)
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(path);
            XmlNode padre = xDoc.FirstChild;
            XmlNode hijo = xDoc.CreateNode(XmlNodeType.Element, "Cesta", null);

            XmlNode nuevo = xDoc.CreateNode(XmlNodeType.Element, "Estado", null);
            nuevo.InnerText = cesta.estado;
            hijo.AppendChild(nuevo);

            nuevo = xDoc.CreateNode(XmlNodeType.Element, "ID", null);
            nuevo.InnerText = cesta.id;
            hijo.AppendChild(nuevo);

            nuevo = xDoc.CreateNode(XmlNodeType.Element, "Cliente", null);
            nuevo.InnerText = cesta.cliente;
            hijo.AppendChild(nuevo);

            foreach (string key in cesta.listaProductos.Keys)
            {
                nuevo = xDoc.CreateNode(XmlNodeType.Element, "Producto", null);
                XmlAttribute attr = xDoc.CreateAttribute("Precio");
                attr.Value = cesta.listaProductos[key];
                nuevo.Attributes.Append(attr);
                attr = xDoc.CreateAttribute("Cantidad");
                attr.Value = "1";
                nuevo.Attributes.Append(attr);
                nuevo.InnerText = key;
                hijo.AppendChild(nuevo);
            }

            nuevo = xDoc.CreateNode(XmlNodeType.Element, "Direccion", null);
            nuevo.InnerText = cesta.direccion;
            hijo.AppendChild(nuevo);

            nuevo = xDoc.CreateNode(XmlNodeType.Element, "Telefono", null);
            nuevo.InnerText = cesta.direccion;
            hijo.AppendChild(nuevo);

            padre.AppendChild(hijo);

            xDoc.Save(path);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if(Request.QueryString["Cesta"] != null)
            {
                cesta = cXml.fabricarCestaID(Server.MapPath("~/ficheros/Cestas.xml"), Request.QueryString["Cesta"]);
                button_Finalizar.Visible = false;
                tabla_RowPago.Visible = false;
                row_imagen.Visible = false;
                row_pedido.Visible = false;
            }
            else
            {
                // Recupero Cesta

                cesta = cXml.fabricarCesta(Server.MapPath("~/ficheros/Cestas.xml"), Request.Cookies["Cliente"].Value);
            }

            // Recupero Cliente

            cliente = cXml.fabricarCliente(Server.MapPath("~/ficheros/Clientes.xml"), Request.Cookies["Cliente"].Value);

            if (IsPostBack)
            {
                foreach(string key in Request.Params)
                {
                    if (key.Contains("button_Finalizar"))
                    {
                        Task task = new Task(()=> cEmail.mandarEmail(cliente, "Cesta", cesta, Server.MapPath("~/Temp")));
                        task.Start();
                        cesta.direccion = Request.Params["list_Direcciones"];
                        cesta.telefono = Request.Params["list_Telefonos"];
                        cXml.cerrarCesta(Server.MapPath("~/ficheros/Cestas.xml"), cesta);
                        Response.Redirect("~/Vistas/Principales/index.aspx");
                    }
                }
            }

            rellenarTablaCesta();
            rellenarTablaCliente();
            equilibrarTablas();
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Para que nadie entre en esta pagina sin loguearse primero

            if (Request.Cookies["Cliente"] == null) Response.Redirect("~/Vistas/Principales/entrada.aspx");

            Cliente cliente = cXml.fabricarCliente(Server.MapPath("~/ficheros/Clientes.xml"), Request.Cookies["Cliente"].Value);

            if (IsPostBack)
            {
                foreach (string key in Request.Params)
                {

                    // Para saber categoria

                    if (key == "__EVENTARGUMENT" && Request.Params[key].Split('\\').Count() > 1)
                    {
                        ViewState["Categoria"] = Request.Params[key].Split('\\')[1];
                    }

                    // Para comprar Producto

                    if (key.Contains("imgButton_Productos_") && key.Contains("x"))
                    {
                       cXml.añadirProducto(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF, Server.MapPath("~/ficheros/SECCIONES_SUBSECCIONES.xml"), ViewState["Categoria"].ToString(), key.Split('_')[2], key.Split('_')[3].Split('.')[0]);
                    }

                    // Para borrar Producto

                    if (key.Contains("imgButton_BorrarProducto_") && key.Contains("x"))
                    {
                        cXml.borrarProducto(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF, key.Split('_')[2].Split('.')[0]);
                    }

                    // Para ir a Formalizar

                    if(key.Contains("imgButton_Formalizar") && key.Contains("x"))
                    {
                        Response.Redirect("~/Vistas/Carrito/formalizar.aspx");
                    }

                    // Para añadir un Producto con el boton + de la cesta

                    if (key.Contains("button_SumarProducto_Cesta"))
                    {
                        cXml.añadirProducto(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF, Server.MapPath("~/ficheros/SECCIONES_SUBSECCIONES.xml"), ViewState["Categoria"].ToString(), key.Split('_')[3], "1");
                    }

                    // Para restar un Producto con el boton - de la cesta

                    if (key.Contains("button_RestarProducto_Cesta"))
                    {
                        cXml.añadirProducto(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF, Server.MapPath("~/ficheros/SECCIONES_SUBSECCIONES.xml"), ViewState["Categoria"].ToString(), key.Split('_')[3], "-1");
                    }

                    // Para añadir un Producto con el boton + del panel centra

                    if (key.Contains("button_SumarProducto_Body_"))
                    {
                        queProducto = key.Split('_')[3];
                        cantidad = int.Parse(key.Split('_')[4]) + 1;
                    }

                    // Para restar un Producto con el boton - del panel central

                    if (key.Contains("button_RestarProducto_Body_"))
                    {
                        queProducto = key.Split('_')[3];
                        int cuantos = int.Parse(key.Split('_')[4]);
                        cantidad = cuantos - 1 >= 1 ? cuantos - 1 : cuantos;
                    }

                    // Para ir a altaCliente a Modificar Datos

                    if (key.Contains("BotonModDatos"))
                    {
                        Session["cliente"] = cliente;
                        Response.Cookies.Add(new HttpCookie("lastPage", "~/Vistas/Carrito/carrito.aspx"));
                        Response.Redirect("~/Vistas/Popups/altaCliente.aspx");
                    }

                    // Para ver, comprobar ( imprimir y desgargar no se como hacerlo ) los pedidos que existen para el Cliente

                    if (key.Contains("BotonModPedido"))
                    {
                        Response.Cookies.Add(new HttpCookie("Cliente", cliente.NIF));
                        Response.Redirect("~/Vistas/Carrito/pedidos.aspx");
                    }
                }
            }
            else
            {
                rellenarTreeView();
            }

            // Dibujo Categoria

            if (ViewState["Categoria"] != null)
            {
                categoria = ViewState["Categoria"].ToString();
                rellenarTableProductos();
            }

            // Recupero Cliente

            if(Request.Cookies["Cliente"] != null)
            {
                cliente = cXml.fabricarCliente(Server.MapPath("~/ficheros/Clientes.xml"), Request.Cookies["Cliente"].Value);
            }

            // Recupero Cesta

            if (cXml.comprobarCestaAbierta(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF))
            {
                cesta = cXml.fabricarCesta(Server.MapPath("~/ficheros/Cestas.xml"), cliente.NIF);
            }
            else
            {
                cesta = new Cesta();
                cesta.cliente = cliente.NIF;
                cXml.añadirCesta(Server.MapPath("~/ficheros/Cestas.xml"), cesta);
            }

            Label tx = (Label)Master.FindControl("LabelDireccion");
            tx.Text = "<b>Cliente: </b> " + cliente.nombre + " " + cliente.apellido + " " + cliente.apellido2 + "<b>&nbsp;NIF: </b>" + cliente.NIF;

            rellenarTablaCesta();
        }
Пример #5
0
        public List<Cesta> lecturaXMLCestas(string path, string NIF)
        {
            List<Cesta> lista = new List<Cesta>();
            Cesta cesta;
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(path);

            foreach (XmlNode xNode in xDoc.DocumentElement.SelectNodes("/Cestas/Cesta"))
            {
                if(xNode.SelectSingleNode("Cliente").InnerText == NIF)
                {
                    cesta = new Cesta();
                    cesta.cliente = xNode.SelectSingleNode("Cliente").InnerText;
                    cesta.direccion = xNode.SelectSingleNode("Direccion").InnerText;
                    cesta.estado = xNode.SelectSingleNode("Estado").InnerText;
                    cesta.id = xNode.SelectSingleNode("ID").InnerText;
                    cesta.telefono = xNode.SelectSingleNode("Telefono").InnerText;
                    if (xNode.SelectNodes("Producto").Count > 0)
                    {
                        foreach (XmlNode xxNode in xNode.SelectNodes("Producto"))
                        {
                            cesta.listaProductos.Add(xxNode.InnerText, xxNode.Attributes["Precio"].Value);
                        }
                    }
                    lista.Add(cesta);
                }
            }
            return lista;
        }
Пример #6
0
 public Cesta fabricarCestaID(string path, string idCesta)
 {
     Cesta cesta = null;
     XmlDocument xDoc = new XmlDocument();
     xDoc.Load(path);
     foreach (XmlNode xNode in xDoc.DocumentElement.SelectNodes("/Cestas/Cesta"))
     {
         if (xNode.SelectSingleNode("ID").InnerText == idCesta)
         {
             cesta = new Cesta();
             cesta.estado = xNode.SelectSingleNode("Estado").InnerText;
             cesta.id = xNode.SelectSingleNode("ID").InnerText;
             cesta.cliente = xNode.SelectSingleNode("Cliente").InnerText;
             cesta.direccion = xNode.SelectSingleNode("Direccion").InnerText;
             cesta.telefono = xNode.SelectSingleNode("Telefono").InnerText;
             foreach (XmlNode xxNode in xNode.SelectNodes("Producto"))
             {
                 cesta.listaProductos.Add(xxNode.InnerText, xxNode.Attributes["Cantidad"].Value + "/" + xxNode.Attributes["Precio"].Value);
             }
         }
     }
     return cesta;
 }
Пример #7
0
 public void cerrarCesta(string path, Cesta cesta)
 {
     XmlDocument xDoc = new XmlDocument();
     xDoc.Load(path);
     foreach (XmlNode xNode in xDoc.DocumentElement.SelectNodes("/Cestas/Cesta"))
     {
         if (xNode.SelectSingleNode("Estado").InnerText == "Abierta" && xNode.SelectSingleNode("Cliente").InnerText == cesta.cliente)
         {
             xNode.SelectSingleNode("Direccion").InnerText = cesta.direccion;
             xNode.SelectSingleNode("Telefono").InnerText = cesta.telefono;
             xNode.SelectSingleNode("Estado").InnerText = "Cerrada";
             xDoc.Save(path);
             break;
         }
     }
 }
Пример #8
0
        private void crearPDF(Cesta cesta, Cliente cliente, string tipo, string tempPath)
        {
            if (tipo == "Cesta")
            {
                PdfDocument pdf = new PdfDocument();
                PdfPageBase pagina = pdf.Pages.Add();
                string salida =
                        "Estimado " + cliente.nombre + " " + cliente.apellido + " " + cliente.apellido2
                      + "\n\nGracias por hacer su pedido en nuestra tienda Online"
                      + "\nNo dude en ponerse en contacto con nosotros si tiene algun problema o si hay algun dato erroneo al telefono: 900 500 103 o"
                      + "\na nuestro departamento de <a href='~/Vistas/Empresa/atencion.aspx'>Atencion al cliente</a> donde podra aprovechar tambien para darnos su opinion si lo desea y nuestros tecnicos la valoraran lo antes posible pudiendose llegar a poner en contacto con usted si asi lo desea."
                      + "\nLos datos de su pedido son:"
                      + "\nCESTA"
                      + "\n  ID: " + cesta.id
                      + "\n  LISTA PRODUCTOS:\n";
                foreach (string producto in cesta.listaProductos.Keys)
                {
                    salida += "    " + cesta.listaProductos[producto].Split('/')[0] + "x " + producto + "\n";
                }
                salida +=
                        "\n\nCLIENTE"
                      + "\n  Nombre: " + cliente.nombre + " " + cliente.apellido + " " + cliente.apellido2
                      + "\n  NIF: " + cliente.NIF
                      + "\n  Telefonos: \n"
                      + "\n    " + cesta.telefono
                      + "\n  Direccion: \n"
                      + "\n    " + cesta.direccion
                      + "\nSu pedido saldra cuanto antes de nuestros almacenes."
                      + "\n\nMuchas gracias por confiar en nosotros. \n\n\nAtentamente, equipo de post-venta de Mercadona";

                pagina.Canvas.DrawString(salida, new PdfFont(PdfFontFamily.TimesRoman, 14), new PdfSolidBrush(Color.Black), 10, 10);

                pdf.SaveToFile(tempPath + "/ReciboCompra" + cesta.id + ".pdf");
                pdf.Close();
            }
        }