}// btnBuscar_Click

        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            this.pb = new ProductoBusiness();
            this.p = this.pb.obtenerProductoPorID(int.Parse(tbBuscar.Text));
            if (String.IsNullOrWhiteSpace(this.tbNombreP.Text) || String.IsNullOrWhiteSpace(this.tbDescrpciom.Text) || String.IsNullOrWhiteSpace(this.tbCosto.Text) || String.IsNullOrWhiteSpace(this.tbPrecio.Text) || String.IsNullOrWhiteSpace(this.tbCant.Text))
            {//si existe un tb en blanco se indica al usuario y no se aplica ningún cambio
                ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.error('Error, campos en blanco')", true);
            }
            else
            {
                if (this.pb.actualizarProducto(new Producto(int.Parse(tbCodigo.Text), tbNombreP.Text, tbDescrpciom.Text, float.Parse(tbCosto.Text), float.Parse(tbPrecio.Text), int.Parse(tbCant.Text), p.IdProveedor, p.IdCategoria)) == true)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.success('Se actualizó exitosamente')", true);
                    this.tbCodigo.Text = "";
                    this.tbNombreP.Text = "";
                    this.tbDescrpciom.Text = "";
                    this.tbCosto.Text = "";
                    this.tbPrecio.Text = "";
                    this.tbCant.Text = "";
                    this.tbNombreP.Enabled = false;
                    this.tbDescrpciom.Enabled = false;
                    this.tbCosto.Enabled = false;
                    this.tbPrecio.Enabled = false;
                    this.tbCant.Enabled = false;
                    this.btnActualizar.Enabled = false;
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.success('¡Ha sucedido un error!')", true);

                }//else-if
            }//validar campos
        }//btnActualizar_Click
Ejemplo n.º 2
0
        public void FiltrarCategoria()
        {
            ProductoBusiness ctr   = new ProductoBusiness();
            ProductoModel    model = new ProductoModel();

            model.TextoBuscar       = txt_buscar.Text;
            DRG_Producto.DataSource = ctr.BuscarProducto(model);
            OcultarColumnas();
        }
        public void ListarProducto()
        {
            ClassResult      cr  = new ClassResult();
            ProductoBusiness ctr = new ProductoBusiness();

            cr = ctr.Producto_Cons();
            DataTable data = cr.Dt1;

            DRG_Producto.DataSource = data;
        }
Ejemplo n.º 4
0
        protected void Borrar_Click(object sender, EventArgs e)
        {
            ProductoBusiness productoBusiness = new ProductoBusiness();

            try
            {
                //  productoBusiness.deleteBrandProducts(selected.id);
                marcaBusiness.delete(selected.id);
                Response.Redirect("Marcas.aspx");
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        public void llernarDatos(ProductoModel productoModel)
        {
            try
            {
                ProductoBusiness ctr   = new ProductoBusiness();
                ProductoModel    model = new ProductoModel();
                model.Cd_Prod = productoModel.Cd_Prod;

                ClassResult cr = ctr.Producto_ConsUn(model);
                if (cr.Dt1.Rows.Count > 0)
                {
                    DataRow row = cr.Dt1.Rows[0];
                    txt_nom1.Text        = row["Nombre1"].ToString();
                    txt_nom2.Text        = row["Nombre2"].ToString();
                    txt_nomcorto.Text    = row["NCorto"].ToString();
                    txt_Descripcion.Text = row["Descrip"].ToString();

                    txt_categoria.Text    = row["Categoria"].ToString();
                    txt_marca.Text        = row["Marca"].ToString();
                    txt_presentacion.Text = row["Presentacion"].ToString();

                    Id_Categoria    = Convert.ToInt32(row["Id_Categoria"].ToString());
                    Id_Mca          = Convert.ToInt32(row["Id_Mca"].ToString());
                    Id_Presentacion = Convert.ToInt32(row["Id_Presentacion"].ToString());

                    nud_stockmin.Value = Convert.ToInt32(row["StockMin"].ToString());
                    nud_stockmax.Value = Convert.ToInt32(row["StockMax"].ToString());

                    if (!(row["Img"] == DBNull.Value))
                    {
                        Byte[] data = new Byte[0];
                        data   = (Byte[])(row["Img"]);
                        Imagen = data;
                        MemoryStream mem = new MemoryStream(data);
                        pic_producto.Image = Image.FromStream(mem);
                    }

                    Cd_Prod = productoModel.Cd_Prod;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error :" + ex.Message + "-" + ex.StackTrace.ToString());
                this.Dispose();
            }
        }
        }//btnActualizar_Click


        /// <summary>
        /// Este método llama al metdod cargarDatos()
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            bool flag = false;
            ProductoBusiness productoBusiness = new ProductoBusiness();
            LinkedList<Producto> productos = productoBusiness.obtenerTodosProductos();
            foreach(Producto productoActual in productos)
            {
                if (productoActual.IdProct == int.Parse(this.TbProducto.Text))
                {
                    flag = true;
                }//saber si existe el producto
            }//recorrer los productos para validar
            if (flag)
            {
                cargarDatos();
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.error('El producto ingresado no se encuentra en el sistema')", true);
            }//si se encontro el producto
        }//Button1_Click
        }//pageload

        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            int mostrar = int.Parse(ddlCategorias.SelectedItem.Value.ToString());//item seleccionado en el ddl para que se haga un criterio de visualización
            
            this.productoBusiness = new ProductoBusiness();
            productos = this.productoBusiness.obtenerTodosProductos();
            DataTable table = new DataTable("Ventas");

            table.Columns.Add(new DataColumn("ID", typeof(int)));
            table.Columns.Add(new DataColumn("Nombre", typeof(string)));
            table.Columns.Add(new DataColumn("Descripcion", typeof(string)));
            table.Columns.Add(new DataColumn("Costo", typeof(float)));
            table.Columns.Add(new DataColumn("Precio", typeof(float)));
            table.Columns.Add(new DataColumn("Cantidad", typeof(string)));
            table.Columns.Add(new DataColumn("Proveedor", typeof(string)));
            table.Columns.Add(new DataColumn("Categoría", typeof(string)));
            foreach (Producto productoActual in productos)
            {
                DataRow row = table.NewRow();
                if (productoActual.IdCategoria.Equals(mostrar))
                {//selecciona productos pro categoría antes cargada                    
                    row["ID"] = productoActual.IdProct;
                    row["Nombre"] = productoActual.Nombre;
                    row["Descripcion"] = productoActual.Descripcion;
                    row["Costo"] = productoActual.Costo;
                    row["Precio"] = productoActual.Precio;
                    row["Cantidad"] = productoActual.Cantidad;
                    row["Proveedor"] = productoActual.IdProveedor;
                    row["Categoría"] = mostrar;
                    table.Rows.Add(row);
                }//if

            }//foreach
            this.gvProductos.DataSource = table;
            this.gvProductos.DataBind();
        }//buscar Click
 public IEnumerable <Producto> Get()
 {
     productoBusiness = new ProductoBusiness(configuration.GetConnectionString("VideoContext").ToString());
     return(productoBusiness.GetAll());
 }
 public ClienteServiceTests()
 {
     _unitOfWork      = GetInstance();
     _productoService = new ProductoBusiness(GetInstance());
 }
 public ProductosController()
 {
     _productosBusiness = new ProductoBusiness();
 }
Ejemplo n.º 11
0
 public ProductController()
 {
     ProductoBus = new ProductoBusiness();
 }
Ejemplo n.º 12
0
        private void Btn_guardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Validar())
                {
                    return;
                }

                ProductoBusiness ctr   = new ProductoBusiness();
                ProductoModel    model = new ProductoModel();
                model.Nombre1         = txt_nom1.Text;
                model.Nombre2         = txt_nom2.Text;
                model.NCorto          = txt_nomcorto.Text;
                model.Descrip         = txt_Descripcion.Text;
                model.Id_Categoria    = Id_Categoria;
                model.Id_Presentacion = Id_Presentacion;
                model.Id_Mca          = Id_Mca;
                model.StockMin        = Convert.ToInt32(nud_stockmin.Value);
                model.StockMax        = Convert.ToInt32(nud_stockmax.Value);

                if (Imagen == null)
                {
                    model.Img = null;
                }
                else
                {
                    model.Img = Imagen;
                }

                if (Cd_Prod == "")
                {
                    ClassResult cr = ctr.Producto_Crea(model);
                    if (cr.HuboError)
                    {
                        MessageBox.Show("error: " + cr.ErrorMsj);
                    }
                    else
                    {
                        incializarControles();
                        this.Dispose();
                    }
                }
                else if (Cd_Prod != "")
                {
                    model.Cd_Prod = Cd_Prod;
                    ClassResult cr = ctr.Producto_Mdf(model);
                    if (cr.HuboError)
                    {
                        MessageBox.Show("error: " + cr.ErrorMsj);
                    }
                    else
                    {
                        incializarControles();
                        this.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error  al getionar el registro o  actualizacion de producto : " + ex.Message);
            }
        }
Ejemplo n.º 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.productobusiness = new ProductoBusiness();
 }//Page_Load