Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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();
        }