private void OnLoad(object sender, RoutedEventArgs e) { try { selectedGc = GlobalVars.UserGc[index]; PageTitle.DataContext = selectedGc.Course; CreditsHolder.DataContext = String.Concat("Credits Registered: ", selectedGc.Credits.ToString()); GradeHolder.DataContext = selectedGc.Grade.ToString(); } catch { MessageBox.Show("Sorry, the page you are trying to access has expired. Maybe you had deleted something."); NavigationService.GoBack(); } }
private void OnLoad(object sender, RoutedEventArgs e) { try { if (index != -1) { PageTitle.DataContext = "edit course"; using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { List<Gradecard> temp = new List<Gradecard>(); if (myIsolatedStorage.FileExists("Gradecards.xml")) { using (IsolatedStorageFileStream stream1 = new IsolatedStorageFileStream("Gradecards.xml", FileMode.Open, FileAccess.Read, myIsolatedStorage)) { XmlSerializer serializer = new XmlSerializer(typeof(List<Gradecard>)); temp = (List<Gradecard>)serializer.Deserialize(stream1); } using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("Point.txt", FileMode.Open, FileAccess.Read, myIsolatedStorage)) { StreamReader rd = new StreamReader(stream); string[] tmp = rd.ReadLine().Split(','); GlobalVars.SGPA = Double.Parse(tmp[0]); GlobalVars.CGPA = Double.Parse(tmp[1]); } ToEdit = temp[index]; if (firstload) { CourseAddTbx.Text = ToEdit.Course; CreditsTbx.Text = ToEdit.Credits.ToString(); GradeTbx.Text = ToEdit.Grade; UpdSPGATbx.Text = GlobalVars.SGPA.ToString(); UpdCPGATbx.Text = GlobalVars.CGPA.ToString(); firstload = false; } } } } else PageTitle.DataContext = "new course"; } catch { MessageBox.Show("Oops! Something went wrong. You might have deleted the item on this page."); NavigationService.GoBack(); } }