· 8 years ago · Nov 16, 2017, 05:22 PM
1@Override
2protected void onCreate(Bundle savedInstanceState) {
3 super.onCreate(savedInstanceState);
4 setContentView(R.layout.activity_relatorio);
5
6
7/*
8 Intent intent = getIntent();
9 if (intent!=null){
10 Bundle parametro = intent.getExtras();
11 if(parametro != null){
12
13 String nome1 = parametro.getString("nome");
14 String cpf = parametro.getString("cpf");
15 String profissao = parametro.getString("profissao");
16 String nascimento = parametro.getString("nascimento");
17
18 TextView nomeView = (TextView)findViewById(R.id.nome);
19 TextView cpfView = (TextView)findViewById(R.id.cpf);
20 TextView profissaoView = (TextView)findViewById(R.id.profissao);
21 TextView nascimentoView = (TextView)findViewById(R.id.nascimento);
22
23 nomeView.setText(nome1);
24 cpfView.setText(cpf);
25 profissaoView.setText(profissao);
26 nascimentoView.setText(nascimento);
27
28 }
29
30 }
31 */
32
33 Intent intente = getIntent();
34 if(intente!=null){
35 Bundle parametroo = intente.getExtras();
36 if(parametroo !=null){
37 String cronometro=parametroo.getString("cronometro");
38 TextView tempoView=(TextView)findViewById(R.id.tempoRealizado);
39 tempoView.setText(cronometro);
40
41 int resultado = parametroo.getInt("pagamento");
42 TextView precoo =(TextView)findViewById(R.id.precoEstimado);
43 precoo.setText(""+resultado+"R$");
44
45 String nome1 = parametroo.getString("nome");
46 TextView nomeView = (TextView)findViewById(R.id.nome);
47 nomeView.setText(""+nome1);
48
49 String cpf = parametroo.getString("cpf");
50 TextView cpfView = (TextView)findViewById(R.id.cpf);
51 cpfView.setText(""+cpf);
52
53 String profissao = parametroo.getString("profissao");
54 TextView profissaoView = (TextView)findViewById(R.id.profissao);
55 profissaoView.setText(profissao);
56
57
58
59
60
61 }
62 }
63
64}
65
66package com.example.scrumfacil;
67
68private Button comfirmar;
69
70@Override
71protected void onCreate(Bundle savedInstanceState) {
72 super.onCreate(savedInstanceState);
73 setContentView(R.layout.activity_cadastro);
74
75
76
77 comfirmar = (Button)findViewById(R.id.btnComfirmarCadastro);
78
79 comfirmar.setOnClickListener(new View.OnClickListener() {
80
81 @Override
82 public void onClick(View v) {
83
84
85 EditText edtN=(EditText)findViewById(R.id.editNome);
86 String nome1 =edtN.getText().toString();
87
88 EditText edtU=(EditText)findViewById(R.id.editUsuario);
89 String usuario =edtU.getText().toString();
90
91 EditText edts=(EditText)findViewById(R.id.editSenha);
92 String senha =edts.getText().toString();
93
94 EditText edtc=(EditText)findViewById(R.id.editCpf);
95 String cpf =edtc.getText().toString();
96
97 EditText edtp=(EditText)findViewById(R.id.editProf);
98 String profissao =edtp.getText().toString();
99
100 EditText edtn=(EditText)findViewById(R.id.editNasc);
101 String nascimento =edtn.getText().toString();
102
103 if(edtN.getText().toString().trim().equals("")){
104 edtN.setError("Campo nome vazio");
105
106
107 }else if (edtU.getText().toString().trim().equals("")){
108
109 edtU.setError("Campo usuario vazio");
110
111 }
112 else if (edts.getText().toString().trim().equals("")){
113
114 edts.setError("Campo senha vazio");
115
116 }
117 else if (edtc.getText().toString().trim().equals("")){
118
119 edtc.setError("Campo CPF vazio");
120
121 }
122 else if (edtp.getText().toString().trim().equals("")){
123 edtp.setError("Campo profissao vazio");
124
125 }
126 else if (edtn.getText().toString().trim().equals("")){
127
128 edtn.setError("Campo nascimento vazio");
129
130 }else{
131
132 CriaBanco cb = new CriaBanco(CadastroActivity.this,CadastroActivity.this);
133 cb.salvar(nome1, usuario, senha, cpf, profissao, nascimento);
134 Intent intent = new Intent(CadastroActivity.this,RelatorioActivity.class);
135
136 Bundle parametroo = new Bundle();
137 String nome =edtN.getText().toString();
138 String cpff =edtc.getText().toString();
139 String profissaoo =edtp.getText().toString();
140 parametroo.putString("nome",nome);
141 parametroo.putString("cpf",cpff);
142 parametroo.putString("profissao",profissaoo);
143 intent.putExtras(parametroo);
144
145
146 startActivity(new Intent(CadastroActivity.this,MainActivity.class));
147
148
149 }
150 }
151 });
152
153
154
155}
156
157package com.example.scrumfacil;
158
159public CriaBanco(Context context, Activity activity) {
160
161 super(context, NOME_BANCO, null, VERSAO);
162 this.context = context;
163 this.activity = activity;
164}
165
166@Override
167public void onCreate(SQLiteDatabase db) {
168
169 try {
170 String sql = "create table if not exists CadastroUsuario("
171 + "usuario varchar(20) primary key not null,"
172 + "nome varchar(80)not null,"
173 + "senha varchar (15) not null ,"
174 + "cpf varchar(11)not null ,"
175 + "Profissao varchar(35) not null,"
176 + " nascimento date not null)";
177 db.execSQL(sql);
178 } catch (Exception ex) {
179 Toast.makeText(context, "Error ao criar banco", Toast.LENGTH_LONG)
180 .show();
181 }
182}
183
184@Override
185public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
186
187}
188
189public void salvar(String nome1, String usuario, String senha, String cpf,
190 String profissao, String nascimento) {
191
192 try {
193
194 String sql = "insert into CadastroUsuario(nome,usuario,senha,cpf,profissao,nascimento) values ('"
195 + nome1
196 + "','"
197 + usuario
198 + "','"
199 + senha
200 + "','"
201 + cpf
202 + "','" + profissao + "','" + nascimento + "')";
203 getWritableDatabase().execSQL(sql);
204 } catch (Exception ex) {
205 ex.getMessage();
206 Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
207 }
208
209}
210
211public void validar(String usuario, String senha) {
212 try {
213 String sql = "select * from CadastroUsuario where usuario ='"
214 + usuario + "' and senha ='" + senha + "' ";
215
216 Cursor c = getReadableDatabase().rawQuery(sql, null);
217
218 if (c.getCount() == 1) {
219
220
221
222 Intent i = new Intent(activity, PlanejamentoActivity.class);
223
224 while (c.moveToNext()) {
225 Bundle parametro = new Bundle();
226
227 parametro.putString("nome",
228 c.getString(c.getColumnIndex("nome")));
229 parametro.putString("cpf",
230 c.getString(c.getColumnIndex("cpf")));
231 parametro.putString("profissao",
232 c.getString(c.getColumnIndex("Profissao")));
233 //parametro.putString("nascimento",
234 //c.getString(c.getColumnIndex("nascimento")));
235
236 i.putExtras(parametro);
237
238 activity.startActivity(i);
239 }
240 } else {
241 Toast.makeText(context, "Usuario ou senha incorreta",
242 Toast.LENGTH_LONG).show();
243
244 }
245 } catch (Exception ex) {
246 ex.getMessage();
247 Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
248 } finally {
249
250 }
251
252}
253
254public void passarDados(String nome1, String usuario, String senha,
255 String cpf, String profissao, String nascimento) {
256
257 String sql = "select nome1,cpf,profissao,nascimento from CadastroUsuario where usuario ='"
258 + usuario + "' ";
259
260 Cursor c = getReadableDatabase().rawQuery(sql, null);
261
262 if (c.getCount() == 1) {
263
264 } else {
265
266 }
267
268}