protected void gvAdmProd_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            TextBox t1 = new TextBox();
            TextBox t2 = new TextBox();
            TextBox t3 = new TextBox();
            TextBox t4 = new TextBox();
            TextBox t5 = new TextBox();
            TextBox t6 = new TextBox();
            //Convert.ToInt16(HiddenField1.Value)

            t1 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[0].Controls[0];
            t2 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[1].Controls[0];
            t3 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[2].Controls[0];
            t4 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[3].Controls[0];
            t5 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[4].Controls[0];
            t6 = (TextBox)gvAdmProd.Rows[Convert.ToInt16(HiddenField1.Value)].Cells[5].Controls[0];

            string id = t1.Text;
            string nombre = t2.Text;
            string descripcion = t3.Text;
            string stock = t4.Text;
            string precio = t5.Text;
            string categoria = t6.Text;

            Producto producto = new Producto();
            producto.ID = Convert.ToInt32(id);
            producto.Nombre = nombre;
            producto.Descripcion = descripcion;
            producto.Stock = Convert.ToInt32(stock);
            producto.Precio = (float)System.Convert.ToSingle(precio);

            CategoriaServicio categoriaServicio = new CategoriaServicio();
            int idCategoria = categoriaServicio.obtenerIdDeCategoria(categoria);
            producto.IdCategoria = idCategoria;

            ProductoServicio productoServicio = new ProductoServicio();
            productoServicio.editar(producto);

            //DSTable.Rows[e.RowIndex]["Id"] = id;
            DSTable.Rows[e.RowIndex]["Nombre"] = nombre;
            DSTable.Rows[e.RowIndex]["Descripcion"] = descripcion;
            DSTable.Rows[e.RowIndex]["Stock"] = stock;
            DSTable.Rows[e.RowIndex]["Precio"] = precio;
            DSTable.Rows[e.RowIndex]["Categoria"] = categoria;

            gvAdmProd.EditIndex = -1;
            gvAdmProd.DataSource = DSTable;
            gvAdmProd.DataBind();
        }
        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);
        }
        internal void editarProducto(Producto producto)
        {
            if (conectar())
            {
                SqlParameter paramId = new SqlParameter("@ID", producto.ID);
                SqlParameter paramEmail = new SqlParameter("@NOMBRE", producto.Nombre); //Envio el paramerto a insertar
                SqlParameter paramRazonSocial = new SqlParameter("@DESCRIPCION", producto.Descripcion);
                SqlParameter paramCUIT = new SqlParameter("@STOCK", producto.Stock);
                SqlParameter paramPassword = new SqlParameter("@PRECIO", producto.Precio);
                SqlParameter paramEstado = new SqlParameter("@CATEGORIA", producto.IdCategoria);

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

                miComando.ExecuteNonQuery();
                sqlconn.Close();
            }
        }
        public void insertarNuevoProducto(Producto producto)
        {
            if (conectar())
            {
                List<SqlParameter> lista = new List<SqlParameter>();

                SqlParameter paramIdTienda = new SqlParameter("@IDTIENDA", producto.idTienda); //Envio el paramerto a insertar
                SqlParameter parmaNombre = new SqlParameter("@NOMBRE", producto.Nombre);
                SqlParameter paramDescripcion = new SqlParameter("@DESCRIPCION", producto.Descripcion);
                SqlParameter parmaPrecio = new SqlParameter("@PRECIO", producto.Precio);
                SqlParameter paramStock = new SqlParameter("@STOCK", producto.Stock);
                SqlParameter paramImg = new SqlParameter("@IMAGEN", producto.Imagen);
                SqlParameter paramIdCat = new SqlParameter("@IDCATEGORIA", producto.IdCategoria);

                SqlCommand miComando = new SqlCommand("p_CrearProducto", sqlconn); //ejecuto la StoreProcedure en la BD
                miComando.CommandType = CommandType.StoredProcedure;
                // Parameters:

                miComando.Parameters.Add(paramIdTienda);
                miComando.Parameters.Add(parmaNombre);
                miComando.Parameters.Add(paramDescripcion);
                miComando.Parameters.Add(parmaPrecio);
                miComando.Parameters.Add(paramStock);
                miComando.Parameters.Add(paramImg);
                miComando.Parameters.Add(paramIdCat);

                miComando.ExecuteNonQuery();
            }
            sqlconn.Close();
        }
 public void insertar(Producto producto)
 {
     nuevo.insertarNuevoProducto(producto);
 }
 //public DataTable listar()
 //{
 //    return nuevo.obtenerEmpresa();
 //}
 public void editar(Producto producto)
 {
     nuevo.editarProducto(producto);
 }