protected void OnAuthCancelled(object sender, EventArgs e) { AuthenticateForm authForm = (AuthenticateForm)sender; RecordPanel record = new RecordPanel(); record.StudentId = authForm.StudentId; record.Status = "取消"; recordLayout.Controls.Add(record); recordLayout.Controls.SetChildIndex(record, 0); }
protected void OnAuthCompleted(object sender, UploadValuesCompletedEventArgs e) { scanButton.Enabled = true; if (e.Cancelled) { return; } if (e.Error != null) { ApiError error = ApiClient.ParseError(e.Error); if (error == null) { Program.ShowError(this, e.Error, "驗證失敗"); } else { Program.ShowError(this, "無法完成驗證。(錯誤代碼:{0})", "驗證失敗", error.Code); } } else { // Create a new AuthenticateForm AuthenticateForm authForm = new AuthenticateForm(); // Parse and load the reply JObject entity = ApiClient.ParseJson(e.Result); string studentIdWithRev = (string)e.UserState; authForm.StudentId = studentIdWithRev.Substring(0, 9); authForm.Revision = studentIdWithRev.Substring(9); authForm.College = (string)entity["college"]; authForm.Department = (string)entity["department"]; authForm.BallotNames = String.Join("\n", from s in entity["ballots"] select(string) s); authForm.SessionKey = (string)entity["session_key"]; authForm.BoothAllocated += OnBoothAllocated; authForm.Cancelled += OnAuthCancelled; // Show the form authForm.ShowDialog(this); } }