Skip to content

Commit

Permalink
Ajustes - Tela login Adm (criação de um adm raíz) e Tela Nova Insti
Browse files Browse the repository at this point in the history
  • Loading branch information
TassiaBastos committed Aug 18, 2017
1 parent 1747ca6 commit 1bfe4d1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ProjetoIp2/src/gui/Tela_Nova_Instituicao.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<Text layoutX="14.0" layoutY="113.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Cidade:" />
<Text layoutX="14.0" layoutY="145.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Estado:" />
<Text layoutX="15.0" layoutY="179.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Número da conta:" />
<Text layoutX="17.0" layoutY="209.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Senha:" />
<PasswordField layoutX="101.0" layoutY="192.0" />
<TextField layoutX="101.0" layoutY="34.0" />
<TextField layoutX="101.0" layoutY="65.0" />
<TextField layoutX="100.0" layoutY="128.0" />
<TextField layoutX="101.0" layoutY="96.0" />
<TextField layoutX="172.0" layoutY="159.0" prefHeight="25.0" prefWidth="97.0" />
<Button fx:id="bt_cadastrar" layoutX="95.0" layoutY="233.0" mnemonicParsing="false" onAction="#CadastrarInstituicao" text="Finalizar cadastro" />
<Text layoutX="17.0" layoutY="209.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Senha:" />
<PasswordField layoutX="101.0" layoutY="192.0" />
</children>
</Pane>
<Text layoutX="246.0" layoutY="43.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Cadastro">
Expand Down
61 changes: 55 additions & 6 deletions ProjetoIp2/src/gui/Tela_Nova_InstituicaoController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gui;

import hope.excecao.ErroDeNegocioExcecao;
import hope.instituicao.ControladorInstituicao;
import hope.instituicao.Instituicao;

import java.io.IOException;
Expand All @@ -13,6 +15,7 @@
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import aplicacao.Fachada;
Expand All @@ -30,16 +33,18 @@ public class Tela_Nova_InstituicaoController {
@FXML
private TextField tf_num_conta;
@FXML
private TextField tf_senha;
private PasswordField ps_senha;

@FXML
private Button bt_cadastrar;
@FXML
private Button bt_voltar;

Fachada fachada;
//private ControladorInstituicao rep;
private Mestre mestre;


@FXML
public void initialize(){
fachada = fachada.getInstance();
Expand All @@ -49,28 +54,72 @@ public void setMestre(Mestre mestre){
this.mestre = mestre;
}

/*
private void CadastrarInstituicao() throws ErroDeNegocioExcecao{
rep = ControladorInstituicao.getInstance();
String nome = tf_nome.getText();
String cnpj = tf_cnpj.getText();
String cidade = tf_cidade.getText();
String estado = tf_estado.getText();
String numeroConta = tf_num_conta.getText();
String senha = tf_senha.getText();
if(nome != null && nome != "" && cnpj != null && cnpj != ""
&& cidade != null && cidade != "" && estado != null
&& estado != "" && numeroConta != null && numeroConta != ""
&& senha != null && senha != ""){
Random rand = new Random();
int x = rand.nextInt(100);
Instituicao i = new Instituicao(nome, cnpj, cidade, estado, numeroConta, x, senha);
rep.cadastrarI(i);
tf_nome.setText("");
tf_cnpj.setText("");
tf_cidade.setText("");
tf_estado.setText("");
tf_num_conta.setText("");
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Sucesso");
alert.setHeaderText("Cadastro Instituicao");
alert.setContentText("Instituicao cadastrada com sucesso");
alert.showAndWait();
}else{
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Informações inválidas");
alert.setContentText("Informações fornecidas são inválidas");
alert.showAndWait();
}
}
private void setApp(Mestre app){
this.mestre = app;
}
*/

public void CadastrarInstituicao(ActionEvent event) throws IOException {
Parent root;
Stage stage;

if(validarCampos()){

try {
String nome, cnpj, cidade, estado, senha, numeroConta;
String nome, cnpj, cidade, estado, numeroConta, senha;

nome = tf_nome.getText();
cnpj = tf_cnpj.getText();
cidade = tf_cidade.getText();
estado = tf_estado.getText();
numeroConta = tf_num_conta.getText();
senha = tf_senha.getText();
senha = ps_senha.getText();

Random rand = new Random();
int x = rand.nextInt(100);

//senha = ps_senha.getText(); aqui vai ser a senha

Instituicao insti = new Instituicao("nome", "cnpj", "cidade", "estado", "numeroConta", x, "senha");
Instituicao insti = new Instituicao(nome, cnpj, cidade, estado, numeroConta, x, senha);
fachada.cadastrarI(insti);

stage = (Stage) bt_cadastrar.getScene().getWindow();
Expand All @@ -92,9 +141,9 @@ public void CadastrarInstituicao(ActionEvent event) throws IOException {
private boolean validarCampos() throws IOException {
boolean validade = false;
try {
if (tf_nome.getText().isEmpty() || tf_cnpj.getText().isEmpty()
if ((tf_nome.getText().isEmpty() || tf_cnpj.getText().isEmpty()
|| tf_cidade.getText().isEmpty() || tf_estado.getText().isEmpty()
|| tf_num_conta.getText().isEmpty() || tf_senha.getText().isEmpty()) {
|| tf_num_conta.getText().isEmpty() || ps_senha.getText().isEmpty())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Error");
alert.setHeaderText("Informacoes invalidas");
Expand Down
5 changes: 5 additions & 0 deletions ProjetoIp2/src/gui/Tela_login_AdmController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gui;

import hope.administrador.Adm;
import hope.excecao.ErroDeNegocioExcecao;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -31,6 +32,10 @@ public void setMestre(Mestre mestre){
this.mestre = mestre;
}

public void initialize(){
this.mestre = Mestre.getInstance();
Adm adm = new Adm("tassia", "023494", "123456", "Recife", "Pernambuco");
}

@FXML
public void acessarLogin(ActionEvent event) throws ErroDeNegocioExcecao {
Expand Down

0 comments on commit 1bfe4d1

Please sign in to comment.