private void btnlogin_Click(object sender, EventArgs e)
{
login();
}
private void ClearFields()
{
txtusername.Text = String.Empty;
txtpwd.Text = String.Empty;
}
private void btncancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtpwd_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
login();
}
}
private void login()
{
try
{
ConnectionClass l_ConnectionClass = new ConnectionClass();
DataSet l_UserDataSet = l_ConnectionClass.FetchDataInDataSet("select * from tbluserlogin where userName = '" + txtusername.Text.ToLower().Trim() + "' and userPwd = '" + txtpwd.Text.Trim() + "'");
if (l_UserDataSet.Tables[0].Rows.Count > 0)
{
PublicVariables.CheckLoginFlag = true;
PublicVariables.OSUserID = Convert.ToInt16(l_UserDataSet.Tables[0].Rows[0]["userId"]);
PublicVariables.UserRole = l_UserDataSet.Tables[0].Rows[0]["userRole"].ToString();
DateTime getdatefrm = l_ConnectionClass.getlogouttime();
DateTime datenow = DateTime.Now;
if ((getdatefrm.AddMinutes(0) > datenow) && (getdatefrm != DateTime.MinValue))
{
MessageBox.Show("please wait");
ClearFields();
PublicVariables.CheckLoginFlag = false;
}
else
{
l_ConnectionClass.updateuserlogin();
Close();
this.Hide();
}
}
else
{
MessageBox.Show("Login Failed !!!!", "Error", MessageBoxButtons.OK);
PublicVariables.CheckLoginFlag = false;
txtusername.Text = "";
txtpwd.Text = "";
txtusername.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show("Connection Failed. Plz Check your Network Cable Connection", "Error", MessageBoxButtons.OK);
}
}
private void txtusername_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
txtpwd.Focus();
}
}