private void AcceptBtn_Click(object sender, EventArgs e) { string user = UserTextBox.Text; string password = PasswordTexBox.Text; DashBoard d = new DashBoard(u); if (user == u.UserName && password == u.Password) { d.Show(); } else { } }
private void Submit_Click(object sender, RoutedEventArgs e) { if (textBoxEmail.Text.Length == 0) { MessageBox.Show("Enter an email."); textBoxEmail.Focus(); } else if (!Regex.IsMatch(textBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("Enter a valid email."); textBoxEmail.Select(0, textBoxEmail.Text.Length); textBoxEmail.Focus(); } else { string email = textBoxEmail.Text; string password = passwordBox1.Password; SqlConnection con = new SqlConnection("Data Source=DESKTOP-262BJ4G;Initial Catalog=EmpDB;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand("Select * from Registration 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) { string username = dataSet.Tables[0].Rows[0]["FirstName"].ToString() + " " + dataSet.Tables[0].Rows[0]["LastName"].ToString(); // mainwindow.TextBlockName.Text = username;//Sending value from one form to another form. DashBoard dashboard = new DashBoard(); dashboard.Show(); Close(); } else { MessageBox.Show("Sorry! Please enter existing emailid/password."); } con.Close(); } }