/
login.cs
123 lines (92 loc) · 3.36 KB
/
login.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace uniBaterFrenteLoja
{
public partial class login : Form
{
Form1 frm1 = new Form1();
public static int idUsuario;
public static int idLoja;
public login()
{
InitializeComponent();
}
private void imgCupomFiscal_MouseHover(object sender, EventArgs e)
{
imgCupomFiscal.ImageLocation = "img/btnCupomFiscalHover.png";
}
private void imgCupomFiscal_MouseLeave(object sender, EventArgs e)
{
imgCupomFiscal.ImageLocation = "img/btnCupomFiscal.png";
}
private void login_Load(object sender, EventArgs e)
{
this.Width = 231;
conexao objConexao = new conexao();
objConexao.preencheCB(cbLojas, "Select * from ubloja",Form1.conexao);
txtUsuario.Focus();
}
private void imgCupomFiscal_Click(object sender, EventArgs e)
{
this.Hide();
Form1 vendaCupom = new Form1();
vendaCupom.Show();
}
private void btnEntrar_Click(object sender, EventArgs e)
{
efetuarLogin();
}
public void efetuarLogin() {
MySqlConnection con = new MySqlConnection(Form1.conexao);
con.Open();
MySqlCommand comando = new MySqlCommand("Select id,fcNomeAcesso,fcSenha,fcLoja from ubfuncionario where fcNomeAcesso =?Nome and fcSenha =?Senha and fcLoja=?Loja");
comando.Connection = con;
MySqlParameter Parametros = new MySqlParameter();
comando.Parameters.AddWithValue("?Senha", txtSenha.Text);
comando.Parameters.AddWithValue("?Loja", cbLojas.SelectedValue);
comando.Parameters.AddWithValue("?Nome", txtUsuario.Text);
MySqlDataAdapter daLogin = new MySqlDataAdapter(comando);
DataTable dtLogin = new DataTable();
daLogin.Fill(dtLogin);
try
{
idLoja = Int32.Parse(dtLogin.Rows[0][3].ToString());
idUsuario = Int32.Parse(dtLogin.Rows[0][0].ToString());
lblStatus.Text = "LOGIN EFETUADO!";
lblStatus.ForeColor = System.Drawing.Color.Green;
for (int i = 231; i <= 483; i += 50)
{
this.Width = i;
}
}
catch
{
lblStatus.Text ="USUÁRIO INEXISTENTE!";
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void txtSenha_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13) {
efetuarLogin();
}
}
private void txtUsuario_TextChanged(object sender, EventArgs e)
{
}
private void pictureBox5_Click(object sender, EventArgs e)
{
this.Hide();
vendaOrcamento frmVenOrc = new vendaOrcamento();
frmVenOrc.Show();
}
}
}