-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCadastroLead.java
152 lines (122 loc) · 4.5 KB
/
CadastroLead.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package upFlow;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import java.sql.*;
public class CadastroLead extends JFrame implements ActionListener{
//id_lead nome email user_fb user_insta
JLabel jlIcone, jlNome, jlEmail, jlUserFb, jlUserInsta, jlID_Lead;
JLabel rotulouserName,rotulosenha, rotuloEmail;
JTextField jtfNome, jtfEmail, jtfUserFb, jtfUserInsta, jtfID_Lead;
JPasswordField jpsenha;
JButton btnCadastrar;
ResultSet resultSet;
Statement statement;
public CadastroLead(){
super("Cadastro de Leads - upFlow");
Container tela = getContentPane();
tela.setLayout(new FlowLayout(FlowLayout.LEFT));
ImageIcon icone = new ImageIcon("icon-upFlow@72ppi.png");
setIconImage(icone.getImage());
setLayout(null);
getContentPane().setBackground(new Color(237, 242, 248));
//setLocationRelativeTo(null);
//Painel cPainel = new Painel();
//tela.add(cPainel.menu());
//JButton.setBackground(new Color(75, 88, 164));
//--------------CRIANDO CAMPOS DE INSER��O DE DADOS ------INICIO-------
//Campo nome --------------
jlNome = new JLabel("Nome e Sobrenome");
// jlNome.setBounds(x, y, l,a);
jlNome.setBounds(30,30,150, 20);
tela.add(jlNome);
jtfNome = new JTextField(150);
jtfNome.setBounds(150,30,300,20);
tela.add(jtfNome);
//Campo nome --------FIM
//Campo Email --------------
jlEmail = new JLabel("Email");
jlEmail.setBounds(30,60,150, 20);
tela.add(jlEmail);
jtfEmail = new JTextField(150);
jtfEmail.setBounds(150,60,300,20);
tela.add(jtfEmail);
//Campo Email --------FIM
//Campo User FB --------------
jlUserFb = new JLabel("Usuario Facebook");
jlUserFb.setBounds(30,120,150, 20);
tela.add(jlUserFb);
jtfUserFb = new JTextField(20);
jtfUserFb.setBounds(150,120,300,20);
tela.add(jtfUserFb);
//Campo User FB --------------
jlUserInsta = new JLabel("Usuario Instagram");
jlUserInsta.setBounds(30,150,150, 20);
tela.add(jlUserInsta);
jtfUserInsta = new JTextField(20);
jtfUserInsta.setBounds(150,150,300,20);
tela.add(jtfUserInsta);
//-------------------------------------
//Campo ID User --------------
jlID_Lead = new JLabel("ID do Usuario");
jlID_Lead.setBounds(30,200,150, 20);
tela.add(jlID_Lead);
jtfID_Lead = new JTextField(20);
jtfID_Lead.setBounds(150,200,300,20);
tela.add(jtfID_Lead);
//-------------------------------------
btnCadastrar = new JButton("Cadastrar");
btnCadastrar.setBackground(new Color(97,0,237));
btnCadastrar.setForeground(new Color(255, 255, 255));
btnCadastrar.setBounds(150,250,300,35);
btnCadastrar.addActionListener(this);
tela.add(btnCadastrar);
//Campo Email --------FIM
//------// FIM //--------CRIANDO CAMPOS DE INSER��O DE DADOS -------------
setSize(800,600);
setVisible(true);
setLocationRelativeTo(null);
carregaResultSet();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btnCadastrar) {
try {
//id_lead nome email user_fb user_insta
String sql = "INSERT INTO lead(id_lead,nome,email,user_fb,user_insta)Values('"+
jtfID_Lead.getText()+"','"+
jtfNome.getText()+"','"+
jtfEmail.getText()+"','"+
jtfUserFb.getText()+"','"+
jtfUserInsta.getText()+"')";
statement.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Lead Cadastrado com sucesso!");
} catch (SQLException erro) {
JOptionPane.showMessageDialog(null,"ERRO NA GRAVACAO");
}
// JOptionPane.showMessageDialog(null,"Lead cadastrado com sucesso!","+1 um lead no sistema");
}
}
public static void main(String args[]){
CadastroLead app = new CadastroLead();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void carregaResultSet(){
//String
// url="jdbc:mysql://localhost:3306/upflow";
String url = "jdbc:mysql://127.0.0.1:3306/upflow?useSSL=false";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection minhaConexao = DriverManager.getConnection(url,"root","");
statement = minhaConexao.createStatement(resultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);;
resultSet = statement.executeQuery("SELECT * FROM lead");
}catch(ClassNotFoundException erro){
System.out.println("Driver nao encontrado");
}
catch(SQLException erro){
System.out.println("Problemas na conexao com a fonte de dados");
}
}
}