protected void Page_Load(object sender, EventArgs e){}//Page_Load protected void btnBuscar_Click(object sender, EventArgs e) { bool flag = false; LinkedList<Producto> productos = pb.obtenerTodosProductos(); foreach (Producto productoActual in productos) { if(productoActual.IdProct == int.Parse(this.tbBuscar.Text)) { flag = true; } } if (flag) { this.p = this.pb.obtenerProductoPorID(int.Parse(tbBuscar.Text)); this.tbCodigo.Text = p.IdProct.ToString(); this.tbNombreP.Text = p.Nombre; this.tbDescrpciom.Text = p.Descripcion; this.tbCosto.Text = p.Costo.ToString(); this.tbPrecio.Text = p.Precio.ToString(); this.tbCant.Text = p.Cantidad.ToString(); this.tbCodigo.Enabled = false; this.tbNombreP.Enabled = true; this.tbDescrpciom.Enabled = true; this.tbCosto.Enabled = true; this.tbPrecio.Enabled = true; this.tbCant.Enabled = true; this.btnActualizar.Enabled = true; } else { ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.error('El producto ingresado no esta registrado en el sistema')", true); }////ver si el producto existe }// btnBuscar_Click
}//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