private void Login_Click(object sender, RoutedEventArgs e) { if (txtUser.Text != "" && pwdUser.Password != "") { DBconnection objconn = new DBconnection(); try { objconn.connection(); //calling connection SqlCommand com = new SqlCommand("Loginsp", objconn.con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@UserId", txtUser.Text); com.Parameters.AddWithValue("@password", pwdUser.Password); int IsValidUser = Convert.ToInt32(com.ExecuteScalar()); if (IsValidUser == 1) //if user found it returns 1 { MainWindow obj = new MainWindow(); App.Current.MainWindow = obj; obj.Show(); //after login Redirect to second window this.Close();//after login hide the Login window } else { MessageBox.Show("InValid UserId or Password"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objconn.Close(); } } else { MessageBox.Show("UserId and Password Is Required"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)