示例#1
0
def vendedor():

    title = "Cadastro de Vendedores"

    #lista todos os carros na tela
    vendedor_grid  = SQLFORM.smartgrid(db2.vendedor)

    #CRUD
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mostra a mensagem de falha sozinho
    vendedor_crud = crud.create(db2.vendedor)

    ####SQL####################################################
    #######################################################
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mas não mostra a mensagem de falha ou aceitação sozinho
    vendedor_sqlform = SQLFORM(db2.vendedor)

    if vendedor_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif vendedor_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    form_vendedor = detalhes_geral(db2.vendedor, 1)

    (form_crud,table_crud) = pesquisa_geral(db2.vendedor)

    return locals()
示例#2
0
def venda():

     if not session.flashed:
        response.flash = T('Bem vindo a tela de vendas!')

     title = "Venda"

     ####SQL####################################################
     #######################################################
     #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
     #mas não mostra a mensagem de falha ou aceitação sozinho
     venda_sqlform = SQLFORM(db2.venda)

     if venda_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
        formulario = db2().select(db2.venda.ALL).last()
        fecha_venda(formulario)
     elif venda_sqlform.errors:
        response.flash = 'Form has errors'
     else:
        response.flash = 'Please fill the form'

     form_venda = detalhes_geral(db2.venda, 2)

     (form_crud,table_crud) = pesquisa_geral(db2.venda)

     return locals()
示例#3
0
def detalhes_geral(tabela, tb_id):

    registro_geral = tabela(tb_id) or redirect(URL('Inicio'))

    form_geral =SQLFORM(tabela,registro_geral,deletable=True,upload=URL('veiculo','download'))

    if form_geral.accepts(request.vars,session):
        response.flash = 'Sucesso'
    elif form_geral.errors:
        response.flash = 'Erro'

    return form_geral
示例#4
0
def vendor_sqlform():
    """
    Create a simple form using the SQLFORM function of web2py.

    Some notes:
        The accepts function validates each field and write the results to de database.
    """

    vendor_sqlform = SQLFORM(db.vendor)

    if vendor_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif vendor_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    return locals()
示例#5
0
def vendor_sqlform():
    """
    Create a simple form using the SQLFORM function of web2py.

    Some notes:
        The accepts function validates each field and write the results to de database.
    """

    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mas não mostra a mensagem de falha ou aceitação sozinho
    vendor_sqlform = SQLFORM(db.vendor)

    if vendor_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif vendor_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    return locals()
示例#6
0
def carro():

    title = "Cadastro de Carros"

    if not session.flashed:
        response.flash = T('Bem vindo a loja de carros!')

    #lista todos os carros na tela
    car_grid = SQLFORM.smartgrid(db2.carro)

    #CRUD
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mostra a mensagem de falha sozinho
    carro_crud = crud.create(db2.carro)

    #######################################################
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mas não mostra a mensagem de falha ou aceitação sozinho
    carro_sqlform = SQLFORM(db2.carro)

    if carro_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif carro_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    excluir_carro(1)

    alterar_carro(2)

    #######################################################
     # Must repeat the field validators declared in the db.py
    marca_input=INPUT(_name='marca_input', requires=IS_IN_DB(db2, 'marca.id','marca.nome',error_message=e_m['not_in_db']))
    modelo_input=INPUT(_name='modelo_input')
    y1 = request.now.year-20
    y2 = request.now.year+2
    ano_input=INPUT(_name='ano_input', requires=IS_INT_IN_RANGE(y1,y2,error_message=e_m['not_in_range']))
    cor_input=INPUT(_name='cor_input', requires=IS_IN_SET(cores))
    valor_input=INPUT(_name='valor_input')
    itens_input=INPUT(_name='itens_input',requires=IS_IN_SET(('Alarme','Trava','Som', 'Ar'),multiple=True,error_message=e_m['not_in_set']))
    estado_input=INPUT(_name='estado_input',requires=IS_IN_SET(estados,error_message=e_m['not_in_set']))
    desc_input=INPUT(_name='desc_input')
    foto_input=INPUT(_name='foto_input',requires=IS_IMAGE(IS_IMAGE(extensions=('jpeg', 'png', '.gif'),error_message=e_m['image'])))

    #neste ponto define a posição dos dados dentro de uma tabela
    # Manual creation of the html table
    table_rows = []
    table_rows.append(TR('Marca:', marca_input))
    table_rows.append(TR('Modelo:', modelo_input))
    table_rows.append(TR('Ano:', ano_input))
    table_rows.append(TR('Cor:', cor_input))
    table_rows.append(TR('Valor:', valor_input))
    table_rows.append(TR('Itens:', itens_input))
    table_rows.append(TR('Estado:', estado_input))
    table_rows.append(TR('Descrição:', desc_input))
    table_rows.append(TR('Foto:', foto_input))
    # Fields starting with _ are passed to the html as attribute elements
    table_rows.append(TR(TD(INPUT(_type='submit'), _colspan='2', _align='center')))
    table = TABLE(table_rows)

    form = FORM(table)

    #momento em que realmente o dado é colocado dentro do banco de dados
    # Processing the form submition
    if form.accepts(request,session):
        # Retriving the form fields
        form_marca_input = form.vars.marca
        form_modelo_input = form.vars.modelo
        form_ano_input = form.vars.ano
        form_cor_input = form.vars.cor
        form_valor_input = form.vars.valor
        form_itens_input = form.vars.itens
        form_estado_input = form.vars.estado
        form_desc_input = form.vars.desc
        form_foto_input = form.vars.foto
        # Inserting in the database
        db.car_model.insert(marca=form_marca_input, modelo = form_modelo_input,ano = form_ano_input, cor = form_cor_input, valor = form_valor_input, itens = form_itens_input, estado = form_estado_input, desc = form_desc_input, foto = form_foto_input)
        # Tell the user about the insertion
        response.flash = 'New car: ' + form_modelo_input
    elif form.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    #######################################################
    form_carro = detalhes_geral(db2.carro,2)

    (form_crud,table_crud) = pesquisa_geral(db2.carro)

    return locals()