private void BtnLogout_Click(object sender, EventArgs e) { this.Close(); loginFrm lf = new loginFrm(); lf.Show(); }
private void BtnMaximize_Click(object sender, EventArgs e) { this.Close(); loginFrm Lf = new loginFrm(); Lf.Show(); }
private void RbtnLogin_Click(object sender, EventArgs e) { try { SqlCommand cmd1; SqlCommand cmd2; sqlCon = new SqlConnection(conStrInv); sqlCon.Open(); cmd = new SqlCommand("select * from UserLogin where userName = '******'", sqlCon); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (RtxtPassword.Text == RtxtConfirm.Text) // checking if password is entered correctly { if (reader["password"].ToString().Trim() == RtxtOldPass.Text.Trim()) { // authenticating empId and username if (reader["password"].ToString().Trim().Equals(RtxtOldPass.Text) && reader["username"].ToString().Trim().Equals(RtxtUserName.Text)) { sqlCon2 = new SqlConnection(conStrInv); sqlCon2.Open(); cmd2 = new SqlCommand("update UserLogin set password=@password where username='******'", sqlCon2); cmd2.Parameters.AddWithValue("@password", RtxtConfirm.Text); cmd2.ExecuteNonQuery(); sqlCon2.Close(); MessageBox.Show("Password changed successfully!!"); // fieldClear(); // return; this.Close(); loginFrm Lf = new loginFrm(); Lf.Show(); } } else if (reader["reset"].ToString() == "0") { MessageBox.Show("You should ask the Manager to reset your password first."); return; } else if (reader["reset"].ToString() == "1") { if (reader["username"].ToString().Trim() + "123" == RtxtOldPass.Text.Trim()) { sqlCon1 = new SqlConnection(conStrInv); sqlCon1.Open(); cmd1 = new SqlCommand("update UserLogin set password=@password, reset=@reset where username='******'", sqlCon1); cmd1.Parameters.AddWithValue("@password", RtxtConfirm.Text); cmd1.Parameters.AddWithValue("@reset", "0"); cmd1.ExecuteNonQuery(); sqlCon1.Close(); MessageBox.Show("Password changed successfully!!"); // fieldClear(); // return; this.Close(); loginFrm Lf = new loginFrm(); Lf.Show(); } else { MessageBox.Show("Please enter default reset password."); return; } } else { MessageBox.Show("Your old password should match."); return; } } else { MessageBox.Show("Confirm password doesn't match to new password"); } } else { MessageBox.Show("Username does not exist."); } } catch (Exception ex) { Console.WriteLine(ex); // throw; } finally { sqlCon.Close(); } }