0
I’m making a system of login in C# where the login user will be verified his login, password and the time left to use the system. Until the login and password check part I managed to do, but I’m having trouble checking the usage time. For example, it cannot use when a certain date arrives.
Follow my code here:
try
{
string sql = "SELECT * FROM users WHERE userName = @login AND userPass = @senha ";
MySqlConnection con = new MySqlConnection("host=; user=; password=; database=; Port=3306;");
MySqlCommand cmd = new MySqlCommand(sql, con);
cmd.Parameters.AddWithValue("@login", this.usuario.Text);
cmd.Parameters.AddWithValue("@senha", this.senha.Text);
con.Open();
int a = (int)cmd.ExecuteScalar();
if (a > 0)// caso login e senha e tempo de uso OK
{
Form1 segundo = new Form1();
this.Hide();
segundo.ShowDialog();
}
else
{
MessageBox.Show("Seu tempo de uso acabou");
}
}
catch
{
MessageBox.Show("User or Pass Incorrect!");
usuario.Text = "";
senha.Text = "";
}
In my bank I have the following fields: userid, username, userPass, Dateexpiration
Simulating a situation, the user was registered today and can only log in until the day 25/02/2017. I want the day 26/02/2017 he can no longer login.
Oblige worked exactly as I wanted
– Cesar Augusto