public void authenticate() { SqlConnection CN = new SqlConnection(gd.ConString); string qry = "SELECT * from USERACCOUNTS WHERE Username = @username AND Password = @password"; SqlCommand SqlCom = new SqlCommand(qry, CN); SqlCom.Parameters.Add(new SqlParameter("@username", (object)txtUsername.Text.Trim())); SqlCom.Parameters.Add(new SqlParameter("@password", (object)gd.getMd5Hash(txtPassword.Text.Trim()))); SqlDataReader dr; try { CN.Open(); dr = SqlCom.ExecuteReader(); if (dr.HasRows) { dr.Read(); GlobalVariables.User = txtUsername.Text.Trim(); GlobalVariables.profileID = filter.fetchProfileId(Convert.ToInt32(dr["ID"].ToString())); if (checkIfFirstTimeLogin(Convert.ToInt32(dr["ID"]))) { FirstTimeLogin p = new FirstTimeLogin(Convert.ToInt32(dr["ID"].ToString())); p.Show(); this.Close(); } else { Form1 f1 = new Form1(Convert.ToInt32(dr["ID"].ToString())); f1.Show(); this.Close(); } } else { toolTip1.Show("Invalid Username or Password.", label6); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString()); } }
public void authenticate() { SqlConnection CN = new SqlConnection(gd.ConString); string qry = "SELECT * from USERACCOUNTS WHERE Username = @username AND Password = @password"; SqlCommand SqlCom = new SqlCommand(qry, CN); SqlCom.Parameters.Add(new SqlParameter("@username", (object)txtUsername.Text.Trim())); SqlCom.Parameters.Add(new SqlParameter("@password", (object)gd.getMd5Hash(txtPassword.Text.Trim()))); SqlDataReader dr; try { CN.Open(); dr = SqlCom.ExecuteReader(); if (dr.HasRows) { dr.Read(); GlobalVariables.User = txtUsername.Text.Trim(); GlobalVariables.profileID = filter.fetchProfileId(Convert.ToInt32(dr["ID"].ToString())); if (checkIfFirstTimeLogin(Convert.ToInt32(dr["ID"]))) { FirstTimeLogin p = new FirstTimeLogin(Convert.ToInt32(dr["ID"].ToString())); p.Show(); this.Close(); } else { Form1 f1 = new Form1(Convert.ToInt32(dr["ID"].ToString())); f1.Show(); this.Close(); } } else { toolTip1.Show("Invalid Username or Password.",label6); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString()); } }