public Producto Buscar(int id)
        {
            Producto producto_nueva = new Producto();

            producto_nueva.Buscar(id);
            return(producto_nueva);
        }
Example #2
0
 private void gridProductos_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         Producto p = new Producto();
         p.Codigo = gridProductos.Rows[e.RowIndex].Cells[0].Value.ToString();
         p.Buscar();
         txtCodigoProducto.Text     = p.Codigo;
         txtNombreProducto.Text     = p.Nombre;
         cboProveedor.SelectedValue = p.Proveedor.Id;
         cboMetrica.SelectedValue   = p.Metrica.Medida;
         idMetrica = p.Metrica.Id;
         return;
     }
     MetroFramework.MetroMessageBox.Show(this, "Seleccione una fila correcta", "Seleccionar Producto");
 }
Example #3
0
        protected void TiendaDataList_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataListItem Item           = TiendaDataList.Items[TiendaDataList.SelectedIndex];
            Label        IdLabel        = (Label)Item.FindControl("IdLabel");
            TextBox      Objetocantidad = (TextBox)Item.FindControl("CantidadTextBox");

            int cantidad = Utils.ConvertirEntero(Objetocantidad.Text);

            Producto p = new Producto();

            if (p.Buscar(Utils.ConvertirEntero(IdLabel.Text)))
            {
                if (cantidad > p.Cantidad)
                { //Informar que no tenemos suficiente inventario
                    Page.ClientScript.RegisterStartupScript(this.GetType(),
                                                            "toastr_message", "toastr.error('There was an error', 'no hay inventario')", true);
                }
                else
                {
                    Cart Carrito = new Cart();

                    if (Session["carrito"] == null)
                    {
                        Session["carrito"] = Carrito;
                    }
                    else
                    {
                        Carrito = (Cart)Session["carrito"];
                    }

                    Carrito.Agregar(p, cantidad);

                    Page.ClientScript.RegisterStartupScript(this.GetType(),
                                                            "toastr_message", "toastr.success('Agregado', 'su articulo fue agregado')", true);
                }
            }
        }