예제 #1
0
 private void LoadStudents()
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         IQueryable <Student> StudentList  = from Students in context.Students select Students;
         List <Student>       StudentItems = StudentList.ToList();
         StudentListBox.ItemsSource = StudentItems;
     }
 }
예제 #2
0
 private void LoadStudents()
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         IQueryable<Student> StudentList = from Students in context.Students select Students;
         List<Student> StudentItems = StudentList.ToList();
         StudentListBox.ItemsSource = StudentItems;
     }
 }
예제 #3
0
 private void Submit(object sender, EventArgs e)
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         Student st = new Student() { ID = Int32.Parse(ID_text.Text), Name = Name_text.Text, LastName = LastName_text.Text };
         context.Students.InsertOnSubmit(st);
         context.SubmitChanges();
         MessageBox.Show("Student Added Successfully");
     }
 }
 private void Submit(object sender, EventArgs e)
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         Student st = new Student()
         {
             ID = Int32.Parse(ID_text.Text), Name = Name_text.Text, LastName = LastName_text.Text
         };
         context.Students.InsertOnSubmit(st);
         context.SubmitChanges();
         MessageBox.Show("Student Added Successfully");
     }
 }
예제 #5
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         var StudentLoaded = (from Stud in context.Students where Stud.ID == Int32.Parse(ID_txt.Text) select Stud).FirstOrDefault();
         if (StudentLoaded != null)
         {
             StudentLoaded.Name = Name_txt.Text;
             StudentLoaded.LastName = LastName_txt.Text;
             context.SubmitChanges();
         }
     }
 }
예제 #6
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         var StudentLoaded = (from Stud in context.Students where Stud.ID == Int32.Parse(ID_txt.Text) select Stud).FirstOrDefault();
         if (StudentLoaded != null)
         {
             StudentLoaded.Name     = Name_txt.Text;
             StudentLoaded.LastName = LastName_txt.Text;
             context.SubmitChanges();
         }
     }
 }
예제 #7
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     String id = NavigationContext.QueryString["id"];
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         var StudentLoaded = (from Stud in context.Students where Stud.ID == Int32.Parse(id) select Stud).FirstOrDefault();
         if (StudentLoaded!=null)
         {
             ID_txt.Text = StudentLoaded.ID.ToString();
             Name_txt.Text = StudentLoaded.Name;
             LastName_txt.Text = StudentLoaded.LastName;
         }
     }
 }
예제 #8
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            String id = NavigationContext.QueryString["id"];

            using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
            {
                var StudentLoaded = (from Stud in context.Students where Stud.ID == Int32.Parse(id) select Stud).FirstOrDefault();
                if (StudentLoaded != null)
                {
                    ID_txt.Text       = StudentLoaded.ID.ToString();
                    Name_txt.Text     = StudentLoaded.Name;
                    LastName_txt.Text = StudentLoaded.LastName;
                }
            }
        }
예제 #9
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         if (!context.DatabaseExists())
         {
             context.CreateDatabase();
             MessageBox.Show("University Database created successfully");
         }
         else
         {
             MessageBox.Show("University already Exists");
         }
     }
 }
예제 #10
0
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
     {
         if (!context.DatabaseExists())
         {
             context.CreateDatabase();
             MessageBox.Show("University Database created successfully");
         }
         else
         {
             MessageBox.Show("University already Exists");
         }
     }
 }
예제 #11
0
 private void DeleteRegister(object sender, EventArgs e)
 {
     if (StudentListBox.SelectedIndex!=-1)
     {
         Student st = (Student)StudentListBox.SelectedItem;
         using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
         {
             context.Students.Attach(st);
             context.Students.DeleteOnSubmit(st);
             context.SubmitChanges();
             MessageBox.Show("Student Deleted Successfully");
             StudentListBox.ItemsSource = null;
             LoadStudents();
         }
     }
     else
     {
         MessageBox.Show("A Student must be selected in order to delete it!");
     }
 }
예제 #12
0
 private void DeleteRegister(object sender, EventArgs e)
 {
     if (StudentListBox.SelectedIndex != -1)
     {
         Student st = (Student)StudentListBox.SelectedItem;
         using (UniversityDataContext context = new UniversityDataContext(App.UniversityconnectionString))
         {
             context.Students.Attach(st);
             context.Students.DeleteOnSubmit(st);
             context.SubmitChanges();
             MessageBox.Show("Student Deleted Successfully");
             StudentListBox.ItemsSource = null;
             LoadStudents();
         }
     }
     else
     {
         MessageBox.Show("A Student must be selected in order to delete it!");
     }
 }