private void Submit_Click(object sender, RoutedEventArgs e) { string ConnectionString = ConfigurationManager.ConnectionStrings["dataConnection"].ConnectionString; connection = new SqlConnection(ConnectionString); users = new ObservableCollection <User>(); command = new SqlCommand(); command.Connection = connection; command.CommandText = "SELECT * FROM USERS"; connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { user = new User(); user.UserID = (string)reader["userid"]; user.Password = (string)reader["password"]; users.Add(user); } String username = textBoxUsername.Text; String pass = passwordBox.Password; foreach (var kullanici in users) { if (kullanici.UserID.Equals(username) && kullanici.Password.Equals(pass)) { this.Hide(); Windows.Window1 window1 = new Windows.Window1(this); window1.Show(); } } }
public MainWindow(Windows.Window1 window1) { InitializeComponent(); string ConnectionString = ConfigurationManager.ConnectionStrings["dataConnection"].ConnectionString; connection = new SqlConnection(ConnectionString); this.window1 = window1; }