Esempio n. 1
0
def inclusao(cpf_cnpj, senha, login, nome, telefone, email, endereco,
             especialidade):
    stmt = f''' select "id_usuario" from "Usuarios" where "CPF_CNPJ" = '{cpf_cnpj}' '''
    result = sql.query(stmt)
    if result == []:

        stmt = f'''INSERT INTO public."Usuarios"("CPF_CNPJ", senha, login)
	    VALUES ('{cpf_cnpj}', '{senha}', '{login}') '''
        result = sql.update(stmt)
        if result == 'Feito':
            stmt = f'''select "id_usuario" from "Usuarios" where login = '******' and "CPF_CNPJ" = '{cpf_cnpj}' '''
            result = sql.query(stmt)
            for x in result:

                stmt = f''' INSERT INTO public."Funcionarios"(id_usuario, nome, telefone, email, endereco, especialidade)
	    VALUES ('{x['id_usuario']}', '{nome}', '{telefone}', '{email}','{endereco}', '{especialidade}');'''
            result = sql.update(stmt)
    else:
        stmt = f'''select "Id_Usuario" from Usuarios where "CPF_CNPJ" = '{cpf_cnpj}' '''
        result = sql.query(stmt)
        for x in result:

            stmt = f''' INSERT INTO public."Funcionarios"("Id_Usuario", "Responsavel", "Codigo_Forma_Pagamento", "Dia_Pagamento")
	    VALUES ('{x['Id_Usuario']}',  ); '''
            result = sql.update(stmt)
    return (result)
Esempio n. 2
0
def login():
    request.get_json(force=True)
    senha = request.json['senha']
    login = request.json['login']
    stmt = f'''select "id_usuario" from "Usuarios" where "login" = '{login}' and "senha" = '{senha}' '''
    result = sql.query(stmt)
    return jsonify(result)
Esempio n. 3
0
def edicao(cpf_cnpj, nome, endereco, telefone, email, senha, idusuario,
           responsavel, diaPagamento, login):

    stmt = f'''UPDATE "Clientes" set "nome_razaosocial" = '{nome}', "endereco" = '{endereco}', "telefone" = '{telefone}', "email" = '{email}' , "responsavel" = '{responsavel}', "dia_pagamento" = {diaPagamento} where  "id_clientes" = {idusuario}'''
    result = sql.update(stmt)
    stmt = f'''select "id_usuario" from "Clientes" where  "id_clientes" = {idusuario} '''
    result = sql.query(stmt)
    for x in result:
        stmt = f''' UPDATE "Usuarios" set "CPF_CNPJ" = '{cpf_cnpj}' , "senha" = '{senha}',"login" = '{login}' where  "id_usuario" = {x['id_usuario']}'''
        result = sql.update(stmt)
    return result
Esempio n. 4
0
def todos():
    stmt = 'select "id_funcionario","CPF_CNPJ", "email", "telefone","especialidade","nome" from "Usuarios" inner join "Funcionarios" on "Usuarios"."id_usuario" = "Funcionarios"."id_usuario" '
    result = sql.query(stmt)
    return (result)
Esempio n. 5
0
def busca(idcliente):
    stmt = f'select "id_clientes","nome_razaosocial","CPF_CNPJ", "telefone", "email" ,"endereco","senha","login","responsavel", "dia_pagamento" from "Usuarios" inner join "Clientes" on "Usuarios"."id_usuario" = "Clientes"."id_usuario" where "Clientes"."id_clientes" = {idcliente}'
    result = sql.query(stmt)
    return (result)
Esempio n. 6
0
def todos():
    stmt = 'select "id_clientes","CPF_CNPJ", "email", "telefone","nome_razaosocial" from "Usuarios" inner join "Clientes" on "Usuarios"."id_usuario" = "Clientes"."id_usuario" order by "id_clientes"'
    result = sql.query(stmt)
    return (result)