Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

desafio techStarPro #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ModelER_store.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions StoreOlist/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="Libs/mysql-connector-java-8.0.21.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions StoreOlist/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>StoreOlist</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions StoreOlist/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
46 changes: 46 additions & 0 deletions StoreOlist/ConnectBD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package br.com.olist.store;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;



public class ConnectBD {

public Connection getConnect() {

//System.out.println("Teste ao acesso a uma BD MySQL\n");
Connection con = null;
try {
//Indica que será utilizado o driver Connector/J
Class.forName("com.mysql.cj.jdbc.Driver");

/* Liga ao servidor de BD local, com o utilizador "root"
e sem password, acedendo à BD "bd1" */
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/store?useSSL=false", "ana", "123");
//System.out.println("Ligação efectuada com sucesso\n");

}
//Trata a excepção lançada pelo método forName da classe Class
catch(ClassNotFoundException cnfe) {
System.out.println("ClassNotFoundException");
}
//Trata a excepção lançada pelo método getConnection da classe DriverManager
catch(SQLException sqle) {
System.out.println("SQLException");
}
return con;
}

public void closeConnection (Connection con) {

try {
con.close();
//System.out.println("\nLigação fechada com sucesso\n");
}
catch(SQLException sqle) {
System.out.println("SQLException");
}
}
}
Binary file added StoreOlist/Libs/mysql-connector-java-8.0.21.jar
Binary file not shown.
102 changes: 102 additions & 0 deletions StoreOlist/MainScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package br.com.olist.store;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;

public class MainScreen extends JFrame {

/**
*
*/
private static final long serialVersionUID = 1L;
JMenuBar barMenu = new JMenuBar();
JMenu product = new JMenu("Inserir/Alterar");
JMenu search = new JMenu ("Pesquisar");
JMenuItem prod = new JMenuItem("Criar novo produto");
JMenuItem resarch= new JMenuItem("Ler dados do produto");
JMenuItem upgread = new JMenuItem("Atualizar dados do produto");
JMenuItem del = new JMenuItem("Excluir os dados do produto");
JMenu exit = new JMenu("Sair");

NewProduct newProduct;
//

public MainScreen() {
setTitle("Store Products & Categories");
setSize(550,590);
setLocation(50,50);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setLayout(new FlowLayout());
setJMenuBar(barMenu);
product.add(prod);

product.add(upgread);
product.add(del);
search.add(resarch);
barMenu.add(product);
barMenu.add(search);

barMenu.add(exit);



prod.addActionListener(new EventoJMenuItem());
resarch.addActionListener(new EventoJMenuItem());
upgread.addActionListener(new EventoJMenuItem());
del.addActionListener(new EventoJMenuItem());

exit.addMouseListener(new EventoJMenuSair());
}

public static void main(String[] args) {
new MainScreen();
}

private class EventoJMenuItem implements ActionListener {

public void actionPerformed(ActionEvent ev) {
if (ev.getSource() == prod) {
newProduct = new NewProduct();
newProduct.setVisible(true);
}
else if (ev.getSource() == resarch) {
// novoCliente = new NovoCliente();
// novoCliente.setVisible(true);
}
else if (ev.getSource() == upgread) {
// novoAluguer = new NovoAluguer();
// novoAluguer.setVisible(true);
}
else if (ev.getSource() == del) {
// novoTipoCarro = new NovoTipoCarro();
// novoTipoCarro.setVisible(true);
}

}
}

private class EventoJMenuSair implements MouseListener {

public void mouseClicked(MouseEvent ev) {
System.exit(0);
}

public void mouseEntered (MouseEvent ev) {}

public void mouseExited(MouseEvent ev) {}

public void mouseReleased(MouseEvent ev) {}

public void mousePressed(MouseEvent ev) {}
}
}


Loading