Exemplo n.º 1
0
    // ADD Course
    protected void Confirm_Click(object sender, EventArgs e)
    {
        TextBox CID    = FindControl("CID") as TextBox;
        string  cid    = CID.Text;
        string  std_id = myFunc.Get_ID("Select std_ID from Student where Session_ID = '" + (string)Session["ID"] + "'", 1);
        string  pro_id = myFunc.Get_ID("Select pro_ID from Courses where CID= '" + cid + "';", 2);
        string  adm_id = myFunc.Get_ID("Select adm_ID from Courses where CID='" + cid + "';", 3);

        // 重複選課問題
        if (myFunc.Is_Course_Choosed(cid, std_id))
        {
            Response.Write("<script>alert('已選過該課程')</script>");
            return;
        }

        if (!myFunc.Is_Course_Exist(cid))
        {
            Response.Write("<script>alert('查無此課程 ')</script>");
            return;
        }

        if (std_id == null || pro_id == null || adm_id == null)
        {
            Response.Write("<script>alert('資料庫發生錯誤 歹勢啦')</script>");
            return;
        }

        // 確定人數是否已滿
        if (myFunc.Is_Course_Full(cid))
        {
            Response.Write("<script>alert('該課人數已滿')</script>");
            return;
        }
        else
        {
            myFunc.Course_Amount_Plus(cid);
        }


        if (myFunc.Is_Course_Conflict(std_id, cid))
        {
            Response.Write("<script>alert('該課程與其他已有課程衝堂')</script>");
            CID.Text = "";
            return;
        }
        // 學生:課程:教授 放入 課程池
        string command = "INSERT INTO [dbo].[Course_Pool] ([std_ID] ,[pro_ID] ,[CID] ,[adm_ID]) VALUES('" + std_id + "','" + pro_id + "','" + cid + "','" + adm_id + "');";

        SQL_cmd(command);


        myFunc.UPDATE_Total_Credit(std_id, cid, true);

        Response.Write("<script>alert('成功加入!')</script>");

        CID.Text = "";

        Response.Redirect("Select.aspx");
    }