Example #1
0
        void Uc_Datos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string codigo = Convert.ToString(e.CommandArgument);

            if (e.CommandName == "Modificar")
            {
                //encriptar
                Response.Redirect("wfmProductoNuevo.aspx?cod=" + codigo, true);
            }
            if (e.CommandName == "Eliminar")
            {
                TBL_PRODUCTO _infoProducto = new TBL_PRODUCTO();
                var          taskProducto  = Task.Run(() => LogicaProducto.getProductxId(int.Parse(codigo)));
                taskProducto.Wait();
                _infoProducto = taskProducto.Result;
                if (_infoProducto != null)
                {
                    Task <bool> _taskSaveProduct = Task.Run(() => LogicaProducto.deleteProduct(_infoProducto));
                    _taskSaveProduct.Wait();
                    var resultado = _taskSaveProduct.Result;
                    if (resultado)
                    {
                        // Response.Write("<script>alert('Registro Eliminado correctamente');</script>");
                        Task <List <TBL_PRODUCTO> > _taskProductos = Task.Run(() => LogicaProducto.getAllProduct());
                        _taskProductos.Wait();
                        var _listaProductos = _taskProductos.Result;
                        loadProductos(_listaProductos);
                    }
                }
            }
        }
Example #2
0
        private void loadProducto(int idProducto)
        {
            TBL_PRODUCTO _infoProducto = new TBL_PRODUCTO();
            var          task          = Task.Run(() => LogicaProducto.getProductxId(idProducto));

            task.Wait();
            _infoProducto = task.Result;
            if (_infoProducto != null)
            {
                imgProducto.ImageUrl   = _infoProducto.pro_imagen;
                lblIdProducto.Text     = _infoProducto.pro_id.ToString();
                lblCodigoProducto.Text = _infoProducto.pro_codigo.ToString();
                lblNombre.Text         = _infoProducto.pro_nombre;
                lblDescripcion.Text    = _infoProducto.pro_descripcion;
                lblPrecio.Text         = _infoProducto.pro_precioventa.ToString("0.00");
            }
        }
Example #3
0
        private void loadProducto(int idProducto)
        {
            TBL_PRODUCTO _infoProducto = new TBL_PRODUCTO();
            var          task          = Task.Run(() => LogicaProducto.getProductxId(idProducto));

            task.Wait();
            _infoProducto = task.Result;
            if (_infoProducto != null)
            {
                lblId.Text     = _infoProducto.pro_id.ToString();
                txtCodigo.Text = _infoProducto.pro_codigo;
                UC_Categoria1.DropDownList.SelectedValue = _infoProducto.cat_id.ToString();
                txtNombre.Text      = _infoProducto.pro_nombre;
                txtDescripcion.Text = _infoProducto.pro_descripcion;
                txtPrc.Text         = _infoProducto.pro_preciocompra.ToString();
                txtPrv.Text         = _infoProducto.pro_precioventa.ToString();
                txtStockMin.Text    = _infoProducto.pro_stockminimo.ToString();
                txtStockMax.Text    = _infoProducto.pro_stockmaximo.ToString();
            }
        }
Example #4
0
 private void updateProduct()
 {
     try
     {
         TBL_PRODUCTO _infoProducto = new TBL_PRODUCTO();
         var          taskProducto  = Task.Run(() => LogicaProducto.getProductxId(int.Parse(lblId.Text)));
         taskProducto.Wait();
         _infoProducto = taskProducto.Result;
         if (_infoProducto != null)
         {
             _infoProducto.pro_id          = int.Parse(lblId.Text);
             _infoProducto.cat_id          = Convert.ToInt16(UC_Categoria1.DropDownList.SelectedValue);
             _infoProducto.pro_codigo      = txtCodigo.Text;
             _infoProducto.pro_nombre      = txtNombre.Text;
             _infoProducto.pro_descripcion = txtDescripcion.Text;
             //validacion de la imagen
             if (FileUpload1.HasFile)
             {
                 if (!string.IsNullOrEmpty(txtCodigo.Text))
                 {
                     try
                     {
                         if (FileUpload1.PostedFile.ContentType == "image/png" || FileUpload1.PostedFile.ContentType == "image/jpeg")
                         {
                             if (FileUpload1.PostedFile.ContentLength < 100000)
                             {
                                 string nombreArchivo = txtCodigo.Text + ".jpg";
                                 FileUpload1.SaveAs(Server.MapPath("~/Images/Products/") + nombreArchivo);
                             }
                             else
                             {
                                 lblMensaje.Text = "El tamaƱo maximo de la imagen es de 100kb";
                             }
                         }
                         else
                         {
                             lblMensaje.Text = "Solo se aceptan imagenes de tipo png/jpeg";
                         }
                     }
                     catch (Exception)
                     {
                         lblMensaje.Text = "Error al cargar la imagen del producto";
                     }
                 }
                 else
                 {
                     lblMensaje.Text = "El campo codigo de producto es obligatorio para la carga de la iamgen";
                 }
             }
             _infoProducto.pro_imagen       = "~/Images/Products/" + txtCodigo.Text + ".jpg";
             _infoProducto.pro_preciocompra = Convert.ToDecimal(txtPrc.Text);
             _infoProducto.pro_precioventa  = Convert.ToDecimal(txtPrv.Text);
             _infoProducto.pro_stockminimo  = Convert.ToInt32(txtStockMin.Text);
             _infoProducto.pro_stockmaximo  = Convert.ToInt32(txtStockMax.Text);
             Task <bool> _taskSaveProduct = Task.Run(() => LogicaProducto.updateProduct(_infoProducto));
             _taskSaveProduct.Wait();
             var resultado = _taskSaveProduct.Result;
             if (resultado)
             {
                 lblMensaje.Text = "Registro Modificado Correctamente";
                 Response.Redirect("wfmProductoLista.aspx", true);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }