private async void RBT_Student_CheckedChangedAsync(object sender, EventArgs e) { if (((RadioButton)sender).Checked) { // 保存配置 Config.NetType = 0; // 判断切换是否合法 PNL_Student.Visible = RBT_Student.Checked; PNL_Teacher.Visible = RBT_Teacher.Checked; if (Config.StudentNet.SettingCertify.Enable == false || string.IsNullOrEmpty(Config.StudentNet.SettingCertify.UserId) || string.IsNullOrEmpty(Config.StudentNet.SettingCertify.Password)) { var f = new FrmCertify(); if (f.ShowDialog() != DialogResult.Yes) { RBT_Teacher.Checked = true; Config.NetType = 1; } } else { await SrLinkService.RegisterSchoolNetAsync(Config.StudentNet.SettingCertify.UserId, Config.StudentNet.SettingCertify.Password, 1); } ConfigService.SaveConfig(ref Config); ReFreshUi(); } }
private void 切换网络ToolStripMenuItem_Click(object sender, EventArgs e) { switch (Config.NetType) { case 0: TryLinkTeacher(); break; case 1: Config.NetType = 0; if (Config.StudentNet.SettingCertify.Enable == false || string.IsNullOrEmpty(Config.StudentNet.SettingCertify.UserId) || string.IsNullOrEmpty(Config.StudentNet.SettingCertify.Password)) { var f = new FrmCertify(); if (f.ShowDialog() != DialogResult.Yes) { Config.NetType = 1; } } else { //SrLinkService.RegisterSchoolNet(Config.StudentNet.SettingCertify.UserId, // Config.StudentNet.SettingCertify.Password); TryLinkStudent(true); } break; } TMR_SrLink.Enabled = (Config.NetType == 0 && Config.StudentNet.AutoLink); ConfigService.SaveConfig(ref Config); }