Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string captchacode = Session["captchacode"].ToString();
            if (captchacode == txtbxCaptcha.Text)
            {

                Tienda tienda = new Tienda();
                tienda.RazonSocial = txtbxRazonSocial.Text;
                tienda.Email = txtbxMail.Text;
                tienda.Password = txtbxContrasena.Text;
                tienda.CUIT = txtbxCUIT.Text;

                TiendaServicio tiendaServicio = new TiendaServicio();
                tiendaServicio.insertar(tienda);

            }
        }
        protected void Log_Click(object sender, EventArgs e)
        {
            TiendaServicio tiendaServicio = new TiendaServicio();
            string email = txtEmail.Text;
            int validador = tiendaServicio.loginTienda(email);
            if (validador==1)
            {
                Tienda userTienda = new Tienda();
                DataTable tabla = new DataTable();

                tabla = tiendaServicio.obtener(txtEmail.Text);

                userTienda.Password = Convert.ToString(tabla.Rows[0]["Password"]);
                userTienda.Id = Convert.ToInt32(tabla.Rows[0]["Id"]);
                userTienda.Email = Convert.ToString(tabla.Rows[0]["Email"]);
                userTienda.RazonSocial = Convert.ToString(tabla.Rows[0]["RazonSocial"]);
                userTienda.CUIT = Convert.ToString(tabla.Rows[0]["CUIT"]);
                userTienda.Estado = Convert.ToString(tabla.Rows[0]["Estado"]);

                Session["TiendaOnline"] = userTienda;

                noLog.Visible = false;
                loge.Visible = true;
                menu.Visible = true;
                Tienda tienda = new Tienda();
                tienda = (Tienda)Session["TiendaOnline"];
                lblPrueba.Text = tienda.RazonSocial;

            }

            //TiendaServicio servicioTienda = new TiendaServicio();
            //Tienda userLog = new Tienda();
            //userLog = servicioTienda.login(txtEmail.Text,txtPassword.Text);
            //if (userLog != null)
            //{
            //    Session["userLog"] = userLog;
            //}
            //else {
            //    lblMsjLog.Text = "Acceso Denegado";
            //}
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["TiendaOnline"] != null)
            {
                Master.FindControl("noLog").Visible = false;
                Master.FindControl("loge").Visible = true;
                Master.FindControl("menu").Visible = true;
            }
            else
                Response.Redirect("default.aspx");

            if (!Page.IsPostBack)
            {
                Tienda tienda = new Tienda();
                tienda = (Tienda)Session["TiendaOnline"];
                txtbxRazonSocial.Text = tienda.RazonSocial;
                txtbxCUIT.Text = tienda.CUIT;
                txtbxMail.Text = tienda.Email;
                txtbxPassword.Text = tienda.Password;
            }
        }
Ejemplo n.º 4
0
        //Listar Provincias
        /* public DataSet mostrarProvincias()
        {
            if (conectar())
            {
                DataSet ds = new DataSet();
                string consulta = "SELECT * FROM Provincia"; //Consulta q lista todas las Provincias
                SqlDataAdapter data = new SqlDataAdapter(consulta, sqlconn);
                data.Fill(ds);
                return ds;
            }
            else return null;
        }*/
        public void editarTienda(Tienda tienda)
        {
            if (conectar())
            {

                SqlParameter paramEmail = new SqlParameter("@EMAIL",tienda.Email); //Envio el paramerto a insertar
                SqlParameter paramRazonSocial = new SqlParameter("@RAZONSOCIAL", tienda.RazonSocial);
                SqlParameter paramCUIT = new SqlParameter("@CUIT", tienda.CUIT  );
                SqlParameter paramPassword = new SqlParameter("@PASSWORD", tienda.Password);
                SqlParameter paramEstado = new SqlParameter("@ESTADO", tienda.Estado);

                SqlCommand miComando = new SqlCommand("p_ModificarTienda", sqlconn); //ejecuto la StoreProcedure en la BD
                miComando.CommandType = CommandType.StoredProcedure;
                miComando.Parameters.Add(paramEmail);
                miComando.Parameters.Add(paramRazonSocial);
                miComando.Parameters.Add(paramCUIT);
                miComando.Parameters.Add(paramPassword);
                miComando.Parameters.Add(paramEstado);

                miComando.ExecuteNonQuery();
            sqlconn.Close();
            }
        }
        protected void create_Click(object sender, EventArgs e)
        {
            ProductoServicio productoServicio = new ProductoServicio();
            Producto producto = new Producto();
            Tienda tiendaLog = new Tienda();
            tiendaLog = (Tienda)Session["TiendaOnline"];
            producto.idTienda = tiendaLog.Id;
            producto.Nombre = txtbxNombre.Text;
            producto.Descripcion = txtbxDescripcion.Text;
            producto.Precio = Convert.ToInt32(txtbxPrecio.Text);
            producto.Stock = Convert.ToInt32(txtbxStock.Text);
            String pathImagen = "";

            if (fuTiendaImg.HasFile)
            {

                if (
                   (fuTiendaImg.PostedFile.ContentType == "image/jpeg") ||
                   (fuTiendaImg.PostedFile.ContentType == "image/pjpeg") ||
                   (fuTiendaImg.PostedFile.ContentType == "image/x-png") ||
                   (fuTiendaImg.PostedFile.ContentType == "image/bmp") ||
                   (fuTiendaImg.PostedFile.ContentType == "image/jpg") ||
                   (fuTiendaImg.PostedFile.ContentType == "image/gif")
                  )
                {
                    if (Convert.ToInt64(fuTiendaImg.PostedFile.ContentLength) < 100000000)
                    {
                        // Esto debería cambiarse porque tiene el dir de mi PC.
                        String photoFolder = Path.Combine(@"C:\Users\maxi\Desktop\Fork\VisualStudio\VS\photos", tiendaLog.Email);
                        if (!Directory.Exists(photoFolder))
                        {
                            Directory.CreateDirectory(photoFolder);
                            String extension = Path.GetExtension(fuTiendaImg.FileName);
                            String uniqueFileName = Path.ChangeExtension(fuTiendaImg.FileName, DateTime.Now.Ticks.ToString());

                            fuTiendaImg.SaveAs(Path.Combine(photoFolder, uniqueFileName + extension));
                            pathImagen = photoFolder + fuTiendaImg.FileName;

                        }
                        else
                        {
                            String extension = Path.GetExtension(fuTiendaImg.FileName);
                            String uniqueFileName = Path.ChangeExtension(fuTiendaImg.FileName, DateTime.Now.Ticks.ToString());

                            fuTiendaImg.SaveAs(Path.Combine(photoFolder, uniqueFileName + extension));
                            pathImagen = photoFolder + fuTiendaImg.FileName;
                        }
                    }
                    else
                        lblStatus.Text = "El archivo debe ser menor a 10MB.";
                }
                else
                    lblStatus.Text = "El archivo debe ser una imagen.";

            }
            else
                lblStatus.Text = "No se seleccionó ningún archivo.";

            producto.Imagen = pathImagen;
            producto.IdCategoria = Convert.ToInt32(ucElegirCategoria.SelectedValue);
            productoServicio.insertar(producto);

            // Una vez que se guarda habria que vaciar los datos y mostrar un cartelito de OK!!.

            //Producto producto = new Producto();
            //producto.Nombre= txtbxNombre.Text;
            //producto.Descripcion= txtbxDescripcion.Text;
            //producto.Precio= Convert.ToInt32(txtbxPrecio.Text);
            //producto.Stock = Convert.ToInt32(txtbxStock.Text);

            //Int32 tamaño = System.Convert.ToInt32(fileUploadTiendaImg.FileBytes.Length);
            //string nombre = fileUploadTiendaImg.FileName.ToString();
            //byte[] contenido = new byte[tamaño + 1];

            //fileUploadTiendaImg.PostedFile.InputStream.Read(contenido, 0, tamaño);

            // Get the name of the file to upload. string fileName = Server.HtmlEncode(FileUpload1.FileName);

            // Get the extension of the uploaded file. string extension = System.IO.Path.GetExtension(fileName);

            //productoServicio.insertar(producto);
        }
 public void insertar(Tienda tienda)
 {
     nuevo.insertarNuevaTienda(tienda);
 }
 public void editar(Tienda tienda)
 {
     nuevo.editarTienda(tienda);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["TiendaOnline"] != null)
            {
                Master.FindControl("noLog").Visible = false;
                Master.FindControl("loge").Visible = true;
                Master.FindControl("menu").Visible = true;
            }
            else
                Response.Redirect("default.aspx");

            if (!IsPostBack)
            {
                ProductoServicio service = new ProductoServicio();
                Tienda tienda = new Tienda();
                tienda = (Tienda)Session["TiendaOnline"];

                int idTienda = tienda.Id;
                DSTable = service.obtenerProductos(idTienda);
                gvAdmProd.DataSource = service.obtenerProductos(idTienda);
                gvAdmProd.DataBind();

            }
        }