Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Input;
- using System.Linq;
- using System.Data.Linq;
- using System.Collections;
- namespace Assignment_7
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- static string conString = "Data Source=tod112.hib.no,1443;Initial Catalog=tod112;Persist Security Info=True;User ID=tod112;Password=tod112";
- static DataClasses1DataContext database = new DataClasses1DataContext(conString);
- static IQueryable<course> allCourses = from a in database.GetTable<course>() select a;
- static IQueryable<student> allStudents = from a in database.GetTable<student>() select a;
- static IQueryable<grade> allGrades = from a in database.GetTable<grade>() select a;
- public MainWindow()
- {
- InitializeComponent();
- // var allStudents = from a in database.GetTable<student>() select a;
- listView1.ItemsSource = allStudents;
- // listBoxCourses.ItemsSource = courses;
- //listBoxCourses.DisplayMemberPath = "coursename";
- //Binds the different fields in the gridview to the collumnames in the DB.
- gridViewID.DisplayMemberBinding = new Binding("id");
- gridViewName.DisplayMemberBinding = new Binding("studentname");
- gridViewAge.DisplayMemberBinding = new Binding("studentage");
- gridViewGrade.DisplayMemberBinding = new Binding("");
- // var allCourses = from a in database.GetTable<course>() select a;
- courseListView.ItemsSource = allCourses;
- courseID.DisplayMemberBinding = new Binding("coursecode");
- courseName.DisplayMemberBinding = new Binding("coursename");
- courseSemester.DisplayMemberBinding = new Binding("semester");
- courseTeacher.DisplayMemberBinding = new Binding("teacher");
- }
- private void buttonSearch_Click(object sender, RoutedEventArgs e)
- {
- string searchString = textBoxSearch.Text;
- var searching = from a in allStudents where a.studentname.StartsWith(searchString) select a;
- listView1.ItemsSource = searching;
- }
- private void button_Click(object sender, RoutedEventArgs e)
- {
- // TODO
- }
- private void listBoxCourses_MouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- // TODO: Sender is listboxviewitem
- ListBoxItem item = sender as ListBoxItem;
- }
- private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (courseListView.SelectedItems.Count>0) {
- var itemSelected = e.AddedItems;
- var queryAllStudentInSelectedCourse = from stud in allStudents
- from course in allCourses
- select a;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement