public List<Entidades.LineaPedido> buscarXPedido(int id)
        {
            List<Entidades.LineaPedido> lista = new List<Entidades.LineaPedido>();
            Entidades.LineaPedido lp = null;
            try
            {
                OleDbConnection conexion = Entidades.Conexion.GetInstancia().crearConexion();
                OleDbCommand cmd = new OleDbCommand("Select * From LineaPedido Where IdPedido=@id", conexion);
                cmd.Parameters.AddWithValue("@id", id);
                OleDbDataReader datos = cmd.ExecuteReader();
                while (datos.Read())
                {
                    lp = new Entidades.LineaPedido();
                    lp.IdPedido = Convert.ToInt32(datos["IdPedido"]);
                    lp.IdProducto = Convert.ToInt32(datos["IdProducto"]);
                    lp.Cantidad = Convert.ToInt32(datos["Cantidad"]);
                    lp.Activo = Convert.ToInt32(datos["Activo"]);
                    lista.Add(lp);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Ocurrio un problema al listar " + ex.Message);
            }

            return lista;
        }
Example #2
0
 protected void btnAgregar_Click1(object sender, ImageClickEventArgs e)
 {
     Entidades.Plato plato = fachadaPlatos.buscarXID(Convert.ToInt32(ddlProducto.SelectedValue));
     Entidades.LineaPedido lp = new Entidades.LineaPedido();
     lp.IdProducto = plato.Id;
     lp.IdPedido = pd.Id;
     lp.Cantidad = Convert.ToInt32(txtCantidad.Text);
     lp.Activo = 1;
     lp.Persist = PersistenciaOleDb.PersistenciaOleDbLineaPedido.getInstancia();
     lp.guardar(lp);
     pd.ListaProductos.Add(plato);
     lbProductos.Items.Add("Producto: " + plato.Descripcion + " " + "Cantidad: " + txtCantidad.Text + " " + "SubTotal: " + plato.Precio + " " + "Total: " + (Convert.ToInt32(txtCantidad.Text) * plato.Precio).ToString());
     lblSubTotal.Text = (Convert.ToDouble(lblSubTotal.Text) + plato.Precio).ToString();
     lblTotal.Text = (Convert.ToDouble(lblTotal.Text) + (Convert.ToDouble(lblSubTotal.Text) * Convert.ToInt32(txtCantidad.Text))).ToString();
 }