From 2db653beeb4d100b9b8741f9b9d740c07a451c4b Mon Sep 17 00:00:00 2001 From: Zhou Xuebin Date: Mon, 12 Mar 2018 19:38:13 +0800 Subject: [PATCH] fixed issue #2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复同一课程和教师在多个上课时间情况下,错误使用首个上课时间进行选课的bug --- FuckJW2005/Form1.Designer.cs | 14 +++++++------- FuckJW2005/Form1.cs | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/FuckJW2005/Form1.Designer.cs b/FuckJW2005/Form1.Designer.cs index 3713d60..e25aa39 100644 --- a/FuckJW2005/Form1.Designer.cs +++ b/FuckJW2005/Form1.Designer.cs @@ -195,16 +195,16 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(11, 171); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(95, 12); + this.label6.Size = new System.Drawing.Size(53, 12); this.label6.TabIndex = 1; - this.label6.Text = "课程名称/代号 *"; + this.label6.Text = "课程名称"; // // courseName // this.courseName.FormattingEnabled = true; - this.courseName.Location = new System.Drawing.Point(112, 168); + this.courseName.Location = new System.Drawing.Point(75, 168); this.courseName.Name = "courseName"; - this.courseName.Size = new System.Drawing.Size(154, 20); + this.courseName.Size = new System.Drawing.Size(219, 20); this.courseName.TabIndex = 6; this.courseName.SelectedIndexChanged += new System.EventHandler(this.courseName_SelectedIndexChanged); this.courseName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.courseName_KeyPress); @@ -240,10 +240,10 @@ private void InitializeComponent() // // teacher // - this.teacher.Location = new System.Drawing.Point(112, 199); + this.teacher.Location = new System.Drawing.Point(75, 199); this.teacher.Name = "teacher"; this.teacher.ReadOnly = true; - this.teacher.Size = new System.Drawing.Size(154, 21); + this.teacher.Size = new System.Drawing.Size(219, 21); this.teacher.TabIndex = 7; this.teacher.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.teacher_KeyPress); // @@ -261,7 +261,7 @@ private void InitializeComponent() // // courseTime // - this.courseTime.Location = new System.Drawing.Point(112, 228); + this.courseTime.Location = new System.Drawing.Point(75, 228); this.courseTime.Name = "courseTime"; this.courseTime.ReadOnly = true; this.courseTime.Size = new System.Drawing.Size(219, 21); diff --git a/FuckJW2005/Form1.cs b/FuckJW2005/Form1.cs index 61daf65..a0b4ce5 100644 --- a/FuckJW2005/Form1.cs +++ b/FuckJW2005/Form1.cs @@ -580,6 +580,11 @@ private bool submit_course_data(string course_id) try { ns.HttpPost(url, post_data, NetStream.DEFAULT_CONTENT_TYPE_PARAM, header); + if (ns.HTTP_Response.StatusCode != System.Net.HttpStatusCode.OK) + { + debug_output("HTTP错误:服务器返回" + (int)ns.HTTP_Response.StatusCode + "(" + ns.HTTP_Response.StatusDescription + ")"); + return false; //status check + } var response_str = ns.ReadResponseString(Encoding.Default); return check_course_selected(response_str.Replace("\r", "").Replace("\n", "")); } @@ -598,13 +603,15 @@ private void select_course_callback() try { //init - string course_name = "", teacher_name = ""; + string course_name = "", teacher_name = "", course_time = ""; Invoke(new ThreadStart(delegate { courseName.Enabled = false; teacher.Enabled = false; + courseTime.Enabled = false; course_name = courseName.Text; teacher_name = teacher.Text; + course_time = courseTime.Text; goFuck.Enabled = true; goFuck.Text = "不干"; })); @@ -617,7 +624,7 @@ private void select_course_callback() //getting course_name courses course = course_list.Find((courses obj) => { - return (obj.Name == course_name && obj.Teacher == teacher_name); + return (obj.Name == course_name && obj.Teacher == teacher_name && obj.Time == course_time); }); if (!string.IsNullOrEmpty(course.CheckBoxStr)) @@ -630,6 +637,10 @@ private void select_course_callback() Thread.Sleep(3000); } while (!suc); } + else + { + debug_output("未找到相关课程,大概是个bug吧"); + } } catch (ThreadAbortException) { } catch (Exception ex) @@ -643,6 +654,7 @@ private void select_course_callback() { courseName.Enabled = true; teacher.Enabled = true; + courseTime.Enabled = true; goFuck.Text = "开干"; threadUsing = false; }));