private void Login_Click(object sender, RoutedEventArgs e) { if (textbox1.Text.Length == 0) { MessageBox.Show("Enter Email", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); textbox1.Focus(); } else if (textbox2.Password.Length == 0) { MessageBox.Show("Enter Password", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); textbox2.Focus(); } else { string email = textbox1.Text; string password = textbox2.Password; SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-NN9ENGI\SQLEXPRESS;Initial Catalog=SOURCE;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand("Select * from Register where Email='" + email + "' and password='******'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataSet dataSet = new DataSet(); adapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count > 0) { textbox1_name.Text = dataSet.Tables[0].Rows[0]["Name"].ToString(); string a = textbox1_name.Text; textbox1_Email.Text = dataSet.Tables[0].Rows[0]["Email"].ToString(); string b = textbox1_Email.Text; textbox1_Password.Password = dataSet.Tables[0].Rows[0]["Password"].ToString(); string c = textbox1_Password.Password; QueryForm qf = new QueryForm(a, b, c); qf.Owner = this; this.Hide(); qf.ShowDialog(); //string username = dataSet.Tables[0].Rows[0]["FirstName"].ToString() + " " + dataSet.Tables[0].Rows[0]["LastName"].ToString(); // welcome.TextBlockName.Text = username;//Sending value from one form to another form. // welcome.Show(); // Close(); } else { MessageBox.Show("Sorry! Please enter existing emailid/password.", "Alert", MessageBoxButton.OK, MessageBoxImage.Warning); // errormessage.Text = ""; } con.Close(); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (textbox1.Text == "Admin" && textbox2.Password == "Admin") { if (Combobox1.Text == "System Progress") { ADMINFLATE AF = new ADMINFLATE(); AF.Owner = this; this.Hide(); AF.ShowDialog(); } if (Combobox1.Text == "Query") { string a = "Admin"; string b = "Admin"; string c = "Admin"; QueryForm qf = new QueryForm(a, b, c); qf.Owner = this; this.Hide(); qf.ShowDialog(); // Close(); /// normal form of query } } else if (textbox1.Text != "admin" && textbox2.Password != "admin") { if (textbox1.Text != "admin") { MessageBox.Show("Invalid Email"); } else { MessageBox.Show("Invalid Password"); } } else { MessageBox.Show("Invalid Email & Password"); } }