public void fromTable_Teacher() { //从Selection页面获取静态数据 if (Selection.arg == "fromInfo") //从学生信息表中查询数据 { //跳转页面,传递参数 StudentInfo si = new StudentInfo(); si.Getstring(arg); this.NavigationService.Navigate(si); } else if (Selection.arg == "fromAch") { //跳转页面,传递参数 StudentAchievement sa = new StudentAchievement(); sa.Getstring(arg); this.NavigationService.Navigate(sa); } else if (Selection.arg == "fromFile") { //跳转页面,传递参数 StudentFile sf = new StudentFile(); sf.Getstring(arg); this.NavigationService.Navigate(sf); } }
private void File_Click(object sender, RoutedEventArgs e) { StudentFile sf = new StudentFile(); Selection sl = new Selection(); sl.Getstring("fromFile"); //向页面传递参数 //查询登陆的用户是否为教师用户 DataClassesDataContext db = new DataClassesDataContext(); //查询“临时用户表”中登录的用户名 string lastuser = db.临时用户管理表.AsEnumerable().Last().用户名; //查询“用户管理表”用户名 var query = from n in db.用户管理表 where n.用户名 == lastuser select n.是否为教师账户; foreach (var m in query) { if (String.Compare(m, "y") != 0) //如果用户名不是教师账户 { this.Frame.Content = sf; } else { this.Frame.NavigationService.Navigate(sl); } } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //获取数据模板中元素的值 Table tl = listBox.SelectedItem as Table; ListBox ls = sender as ListBox; ListBoxItem lstitem = ls.ItemContainerGenerator.ContainerFromItem(ls.SelectedItem) as ListBoxItem; var m = ((学生学籍管理系统.查询结果存储表)(lstitem.Content)).学号; MainWindow.num = m; if (Selection.arg == "fromInfo") { StudentInfo si = new StudentInfo(); //第一次初始化,StudentInfo中的Getstring()方法并未被赋值 si.Getstring(m); //所以需要第二次初始化,以得到正确结果 StudentInfo si1 = new StudentInfo(); this.NavigationService.Navigate(si1); } else if (Selection.arg == "fromAch") { StudentAchievement sa = new StudentAchievement(); sa.Getstring(m); StudentAchievement sa1 = new StudentAchievement(); this.NavigationService.Navigate(sa1); } else if (Selection.arg == "fromFile") { StudentFile sf = new StudentFile(); sf.Getstring(m); StudentFile sf1 = new StudentFile(); this.NavigationService.Navigate(sf1); } }
//打印 public void Print_Click(object sender, RoutedEventArgs e) { var control = Selection.arg; if (control == "fromInfo") { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StudentInfo si = new StudentInfo(); dialog.PrintVisual(si.canvas, "Print Test"); } } else if (control == "fromAch") { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StudentAchievement sa = new StudentAchievement(); dialog.PrintVisual(sa.canvas, "Print Test"); } } else if (control == "fromFile") { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StudentFile sf = new StudentFile(); dialog.PrintVisual(sf.canvas, "Print Test"); } } else { PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { Select_Result sr = new Select_Result(); dialog.PrintVisual(sr.canvas, "Print Test"); } } }