protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeSelect") { int row; try { row = System.Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { Response.Write(ex.Message); row = -1; } string course_schedule_id = GridView2.Rows[row].Cells[0].Text; string stu_id = Session["account_user_id"].ToString(); bool isChanged = CourseSelectDBUtil.Delete(course_schedule_id + stu_id); if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "退选成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "退选失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); } }
protected void Button_Delete_Click(object sender, EventArgs e) { string course_select_id = Input_Delete_Course_Select_ID.Text; bool isChanged = CourseSelectDBUtil.Delete(course_select_id); if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "删除选课信息成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "删除选课信息失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int row; try { row = System.Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { Response.Write(ex.Message); row = -1; } string course_schedule_id = GridView1.Rows[row].Cells[0].Text; string stu_id = Session["account_user_id"].ToString(); string sql = "SELECT course_schedule.course_schedule_capacity - course_selected_count.selected_count FROM course_schedule INNER JOIN course_selected_count ON course_schedule.course_schedule_id = course_selected_count.course_schedule_id WHERE course_schedule.course_schedule_id = '" + course_schedule_id + "'"; if (!(Int32.Parse(DBUtil.GetSingle(sql).ToString()) > 0)) { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "当前课程容量已满。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); Data_Bind(); return; } bool isChanged = CourseSelectDBUtil.Add(course_schedule_id + stu_id, stu_id, course_schedule_id, "0", "0"); if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "选课成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "选课失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); } }
protected void Button_Score_Entry_Click(object sender, EventArgs e) { course_schedule_id = Input_Course_Schedule_ID.Text; string stu_id = Input_Student_ID.Text; string score = Input_Course_Select_Score.Text; bool isChanged = CourseSelectDBUtil.UpdateScore(course_schedule_id + stu_id, score); if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "录入成绩成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "录入成绩失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); }
protected void Button_Update_Click(object sender, EventArgs e) { string course_select_id = Input_Update_Course_Select_ID.Text; string update_item_select = Input_Update_Item_Select.Value.ToString(); string update_value = Input_Update_Value.Text; bool isChanged = false; switch (update_item_select) { case "选课编号": isChanged = CourseSelectDBUtil.UpdateID(course_select_id, update_value); break; case "学生编号": isChanged = CourseSelectDBUtil.UpdateStudentID(course_select_id, update_value); break; case "课程安排编号": isChanged = CourseSelectDBUtil.UpdateCourseScheduleID(course_select_id, update_value); break; case "成绩": isChanged = CourseSelectDBUtil.UpdateScore(course_select_id, update_value); break; case "选课状态": isChanged = CourseSelectDBUtil.UpdateStatus(course_select_id, update_value); break; } if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "修改选课信息成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "修改选课信息失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); }
protected void Button_Add_Click(object sender, EventArgs e) { string course_select_id = Input_Add_Course_Select_ID.Text; string student_id = Input_Add_Student_ID.Text; string course_schedule_id = Input_Add_Course_Schedule_ID.Text; string course_select_score = Input_Add_Course_Select_Score.Text; string course_select_status = Input_Add_Course_Select_Status.Text; bool isChanged = CourseSelectDBUtil.Add(course_select_id, student_id, course_schedule_id, course_select_score, course_select_status); if (isChanged) { string toastrScript = ToastrHelper.GetToastrScript("success", "提示", "添加选课信息成功。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } else { string toastrScript = ToastrHelper.GetToastrScript("danger", "提示", "添加选课信息失败。"); ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "script", toastrScript, true); } Data_Bind(); }