diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml index 105ce2d..dd4c951 100644 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -1,5 +1,6 @@ + diff --git a/main.py b/main.py index 3e3f94c..0bd188e 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,10 @@ from kivy.event import EventDispatcher from kivy.lang import Builder from kivy.properties import StringProperty -from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button -from kivy.uix.label import Label from kivy.uix.popup import Popup from kivy.uix.screenmanager import ScreenManager, NoTransition -from kivy.uix.textinput import TextInput +from kivy.uix.spinner import Spinner from kivymd.uix.label import MDLabel from kivymd.uix.screen import MDScreen from kivy.core.window import Window @@ -286,6 +284,10 @@ def confirm(self): self.dismiss() +class CustomSpinner(Spinner): + pass + + # --------------------- CLASES MDSCREEN -------------------- @@ -380,7 +382,6 @@ def principal(self): def salvar_dados(self): try: - idaluno = self.ids.idaluno.text nome = self.ids.idnome.text cpf = self.ids.idcpf.text @@ -458,7 +459,6 @@ def principal(self): def salvar_dados(self): try: - idprof = self.ids.idprof.text nome = self.ids.nome.text cpf = self.ids.cpf.text @@ -533,17 +533,14 @@ def salvar_dados(self): conn = conectar() cur = conn.cursor() - - cur.execute("""INSERT into Funcionario (nome, login, senha)Values (%s, %s, %s) - """, (nome, login, senha)) - + cur.execute("""INSERT into Funcionario (nome, login, senha)Values (%s, %s, %s)""", (nome, login, senha)) conn.commit() toast("Salvo com sucesso!", duration=2) self.principal() else: - toast('senhas não coincidem', duration=4) + toast('Senhas não coincidem', duration=4) except Exception as e: toast(f"Erro ao salvar dados: {e}", duration=5) @@ -577,7 +574,7 @@ def pesquisar(self, texto): print(e) def novo(self): - self.manager.current = 'cad_aluno' + self.manager.current = 'cad_funcionario' class CadastrarSala(MDScreen): @@ -642,6 +639,47 @@ def novo(self): self.manager.current = 'cad_sala' +class CadastrarCurso(MDScreen): + + def principal(self): + principal(self) + + def salvar_dados(self): + try: + + idsala = '1' + + idcurso = self.ids.idcurso.text + ch = self.ids.ch.text + descricao = self.ids.desc.text + numod = self.ids.numod.text + valor = self.ids.valor.text + dupli = self.ids.dupli.text + + conn = conectar() + cur = conn.cursor() + + if idcurso == '-': + cur.execute("""INSERT into Curso (id_sala, descricao, CH, num_modulos, VLR_total, num_duplicatas) + Values (%s, %s, %s, %s, %s, %s)""", (idsala, descricao, ch, numod, valor, dupli)) + else: + cur.execute("""UPDATE Curso + SET id_sala = %s, descricao = %s, CH = %s, num_modulos = %s, VLR_total = %s, num_duplicatas = %s + WHERE id_curso = %s""", (idsala, descricao, ch, numod, valor, dupli, idcurso)) + + conn.commit() # Confirma a transação + + toast("Salvo com sucesso!", duration=2) + self.principal() + + except Exception as e: + toast(f"Erro ao salvar dados: {e}", duration=2) + + +class ConsultarCurso(MDScreen): + pass + + class CadastrarTurma(MDScreen): pass @@ -666,14 +704,6 @@ class ConsultarPagamento(MDScreen): pass -class CadastrarCurso(MDScreen): - pass - - -class ConsultarCurso(MDScreen): - pass - - # --------------------------- APP --------------------------------- class DibTopApp(MDApp): diff --git a/screens.kv b/screens.kv index 8340305..134dfae 100644 --- a/screens.kv +++ b/screens.kv @@ -18,4 +18,4 @@ #:include screens/consultar_curso.kv #:include screens/consultar_alunoturma.kv #:include screens/consultar_turma.kv -#:include screens/consultar_pagamento.kv +#:include screens/consultar_pagamento.kv \ No newline at end of file diff --git a/screens/cadastrar_curso.kv b/screens/cadastrar_curso.kv index a12860f..3c9e136 100644 --- a/screens/cadastrar_curso.kv +++ b/screens/cadastrar_curso.kv @@ -1 +1,137 @@ - \ No newline at end of file +#: import Factory kivy.factory.Factory + + + BoxLayout: + orientation:'horizontal' + + BoxLayout: + size_hint_x: 0.2 + + CustomBoxLayout: + + orientation: 'vertical' + padding: '40dp' + spacing: 2 + + MDLabel: + text: "CADASTRO DE CURSO" + halign: "center" + pos_hint: {'center_x': 0.5, 'center_y': 0.75} + font_size: 35 + + BoxLayout: + orientation: 'horizontal' + spacing: 5 + + MDLabel: + id: idcurso + hint_text:"ID" + text: '-' + pos_hint: {'center_x':0.5,'center_y':0.8} + size_hint_x: 0.07 + + + MDTextField: + id: desc + hint_text:"Descriçao" + pos_hint: {'center_x':0.5,'center_y':0.8} + size_hint_x: 0.7 + write_tab: False + multiline: False + max_text_length: 100 + #line_color_normal: [0,1,1,1] + #line_color_focus: [0,1,0,1] + + MDTextField: + id: ch + hint_text:"CH" + pos_hint: {'center_x':0.5,'center_y':0.8} + size_hint_x: 0.23 + max_text_length: 11 + #line_color_normal: [0,1,1,1] + #line_color_focus: [0,1,0,1] + write_tab: False + + CustomSpinner: + id: sala + text: 'Sala' + size_hint: 0.1, None # Reduz o tamanho verticalmente (altura) + height: dp(30) # Define uma altura específica (30 pixels neste exemplo) + size_hint_x: None # Permite definir uma largura fixa + width: dp(150) # Define uma largura específica (80 pixels neste exemplo) + pos_hint: {'center_x':0.5,'center_y':0.8} # Centraliza horizontalmente + values: 'a', 'a', 'a', 'v' # Os valores do spinner + font_size: '17sp' # Define o tamanho da fonte + color: 'black' # Define a cor do texto como branco (RGBA) + background_normal: '' # Remove o fundo padrão do Spinner + background_color: 0.18,0.53,1,1 # Define a cor de fundo do Spinner + + option_cls: Factory.get('SpinnerOption') # Define a classe das opções do spinner + + BoxLayout: + orientation: 'horizontal' + spacing: 5 + MDTextField: + id: numod + hint_text:"Nº de modulos" + pos_hint: {'center_x':0.5,'center_y':0.8} + #line_color_normal: [0,1,1,1] + #line_color_focus: [0,1,0,1] + write_tab: False + + + MDTextField: + id: valor + hint_text:"valor" + pos_hint: {'center_x':0.5,'center_y':0.8} + max_text_length: 120 + #line_color_normal: [0,1,1,1] + #line_color_focus: [0,1,0,1] + write_tab: False + + MDTextField: + id: dupli + hint_text:"nº duplicatas" + pos_hint: {'center_x':0.5,'center_y':0.8} + max_text_length: 50 + #line_color_normal: [0,1,1,1] + #line_color_focus: [0,1,0,1] + write_tab: False + + BoxLayout: + orientation: 'horizontal' + BoxLayout: + BoxLayout: + spacing: 15 + MDFillRoundFlatButton: + id:btnsalvar + text: "SALVAR" + md_bg_color: 0.18,0.53,1,1 + pos_hint: {'center_x':0.5} + size_hint_x: 0.75 + font_size: 20 + on_release: root.salvar_dados() + + MDFillRoundFlatButton: + id: btncancelar + text: 'CANCELAR' + md_bg_color: 'red' + pos_hint: {'center_x':0.5} + size_hint_x: 0.75 + font_size: 20 + on_release: root.principal() + + BoxLayout: + size_hint_x: 0.2 + + + +: + background_normal: '' # Remove o fundo padrão do Spinner + background_color: 0.18,0.53,1,1 # Define a cor de fundo do Spinner + color: 'black' # Define a cor do texto das opções + size_hint: 0.1, None # Reduz o tamanho verticalmente (altura) + height: dp(30) # Define uma altura específica (30 pixels neste exemplo) + size_hint_x: None # Permite definir uma largura fixa + width: dp(150) # Define uma largura específica (80 pixels neste exemplo) + font_size: '15sp' # Define o tamanho da fonte \ No newline at end of file