private void Button_Click(object sender, RoutedEventArgs e) { var Username = new SqlParameter("@username", (username.Text)); var Password = new SqlParameter("@password", (password.Text)); var result = context.Database.SqlQuery <string>(" exec pLogin @username, @password ", Username, Password).FirstOrDefault(); if (string.Compare(result, "Manager") == 0) { var query = (from I in context.Instructors from U in context.Users where I.UserID == U.ID where U.Name == username.Text && U.Password == password.Text select I.ID).FirstOrDefault(); ManagerWindow managerWindow = new ManagerWindow(query); managerWindow.Show(); this.Close(); } else if (string.Compare(result, "Instructor") == 0) { var query = (from I in context.Instructors from U in context.Users where I.UserID == U.ID where U.Name == username.Text && U.Password == password.Text select I.ID).FirstOrDefault(); InstructorWin homeWindow = new InstructorWin(query); homeWindow.Show(); this.Close(); } else if (string.Compare(result, "Student") == 0) { var query = (from I in context.Students from U in context.Users where I.UserID == U.ID where U.Name == username.Text && U.Password == password.Text select I.ID).FirstOrDefault(); StudentWindow studentWindow = new StudentWindow(query); studentWindow.Show(); } else { MessageWindow message = new MessageWindow("Not Valid User"); message.Show(); } }
private void Button_Click(object sender, RoutedEventArgs e) { InstructorWin instructorWin = new InstructorWin(INStructorId); instructorWin.Show(); }