private void EnterButton_Click(object sender, RoutedEventArgs e) { LoginResult lr = af.Login(this.number.Text, this.password.Password); if (lr != null) { if (lr.code == "200") { if (AccountUtil.IsRole(AccountUtil.ADMIN, lr.data.roles)) { CacheService.Instance.AdminToken = lr.token; ConfigWindow configWindow = new ConfigWindow(); configWindow.Show(); configWindow.Owner = this.Owner; this.Close(); } else { LSMessageBox.Show("登录异常", "当前角色不是管理员"); } } else { LSMessageBox.Show("登录错误", lr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { LoginResult lr = af.Login(this.number.Text, this.password.Password); if (lr != null) { if (lr.code == "200") { if (AccountUtil.IsRole(AccountUtil.STUDENT, lr.data.roles)) { Student student = new Student() { Number = lr.data.account, Name = lr.data.name, Token = lr.token, Id = lr.data.id }; ReservationResult rr = rf.GetValidity(CacheService.Instance.Lab.id, student.Token); if (rr != null) { if (rr.code == "200") { try { if (rr.data.clazz == null) { student.ClassId = -1; CacheService.Instance.AddStuList(student); students.Add(student); this.studentList.Items.Refresh(); } else { student.ClassId = rr.data.clazz.id; //LSMessageBox.Show("班级ID", rr.data.clazz.id+""); CacheService.Instance.AddStuList(student); students.Add(student); this.studentList.Items.Refresh(); } } catch (ArgumentException) { LSMessageBox.Show("登陆异常", "已经存在该学生"); } this.experiment.Content = rr.data.experiment.name; CacheService.Instance.ExperimentId = rr.data.experiment.id; this.virtualExp = rr.data.experiment.virtual_exp_link; if (rr.data.experiment.virtual_exp_link == null || rr.data.experiment.virtual_exp_link == "") { this.virtualexp.IsEnabled = false; } else { this.virtualexp.IsEnabled = true; } } else { LSMessageBox.Show("登陆异常", rr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } } else { LSMessageBox.Show("登录异常", "当前角色不是学生"); } this.number.Clear(); this.password.Clear(); } else { LSMessageBox.Show("登录错误", lr.message); } } else { LSMessageBox.Show("网络错误", "网络异常"); } }