protected void btn_updateUni_Click(object sender, EventArgs e)
        {
            EditPlanDAO   ep  = new EditPlanDAO();
            SqlConnection con = new DBManager().getConnection();
            int           count;
            string        id  = ep.getSchID(Session["uniName"].ToString());
            string        sql = "UPDATE dbo.PathPlan SET uniID=@uniID WHERE accountID=@accountID";
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@uniID", id);
            cmd.Parameters.AddWithValue("@accountID", Session["accountID"].ToString());
            con.Open();
            count = Convert.ToInt32(cmd.ExecuteScalar());
            //update: count == 0
            if (count == 0)
            {
                alert_placeholder.Visible             = true;
                alert_placeholder.Attributes["class"] = "alert alert-success alert-dismissable";
                alertText.Text = "Successfully updated! Redirecting to View Own Plan page...";
                Response.AddHeader("REFRESH", "1;URL=ViewOwnPlan.aspx");
                con.Close();
                con.Dispose();
            }
            else
            {
                con.Close();
                con.Dispose();
                Response.Redirect("Error.aspx");
            }
        }
Ejemplo n.º 2
0
        protected void btn_updateTertiary_Click(object sender, EventArgs e)
        {
            EditPlanDAO   ep  = new EditPlanDAO();
            SqlConnection con = new DBManager().getConnection();
            int           count;

            if (radioSelectITEPolyJC.SelectedItem.Text == "Junior College")
            {
                string     id  = ep.getSchID(Session["JCName"].ToString());
                string     sql = "UPDATE dbo.PathPlan SET jcID=@jcID WHERE accountID=@accountID";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@jcID", id);
                cmd.Parameters.AddWithValue("@accountID", Session["accountID"].ToString());
                con.Open();
                count = Convert.ToInt32(cmd.ExecuteScalar());
                //update: count == 0
                if (count == 0)
                {
                    alert_placeholder.Visible             = true;
                    alert_placeholder.Attributes["class"] = "alert alert-success alert-dismissable";
                    alertText.Text = "Successfully updated! Redirecting to View Own Plan page...";
                    Response.AddHeader("REFRESH", "1;URL=ViewOwnPlan.aspx");
                    con.Close();
                    con.Dispose();
                }
                else
                {
                    con.Close();
                    con.Dispose();
                    Response.Redirect("Error.aspx");
                }
            }
            else if (radioSelectITEPolyJC.SelectedItem.Text == "Polytechnic")//selected is poly
            {
                string     id     = ep.getSchID(Session["POLYName"].ToString());
                string     course = Session["PolyCourse"].ToString();
                string     sql    = "UPDATE dbo.PathPlan SET polyID=@polyID, polyCourse=@polyCourse WHERE accountID=@accountID";
                SqlCommand cmd    = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@polyID", id);
                cmd.Parameters.AddWithValue("@polyCourse", course);
                cmd.Parameters.AddWithValue("@accountID", Session["accountID"].ToString());
                con.Open();
                count = Convert.ToInt32(cmd.ExecuteScalar());
                //update: count == 0
                if (count == 0)
                {
                    alert_placeholder.Visible             = true;
                    alert_placeholder.Attributes["class"] = "alert alert-success alert-dismissable";
                    alertText.Text = "Successfully updated! Redirecting to View Own Plan page...";
                    Response.AddHeader("REFRESH", "1;URL=ViewOwnPlan.aspx");
                    con.Close();
                    con.Dispose();
                }
                else
                {
                    con.Close();
                    con.Dispose();
                    Response.Redirect("Error.aspx");
                }
            }
            else //for ite
            {
                string     id  = ep.getSchID(Session["ITEName"].ToString());
                string     sql = "UPDATE dbo.PathPlan SET ITEID=@ITEID WHERE accountID=@accountID";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@ITEID", id);
                cmd.Parameters.AddWithValue("@accountID", Session["accountID"].ToString());
                con.Open();
                count = Convert.ToInt32(cmd.ExecuteScalar());
                //update: count == 0
                if (count == 0)
                {
                    alert_placeholder.Visible             = true;
                    alert_placeholder.Attributes["class"] = "alert alert-success alert-dismissable";
                    alertText.Text = "Successfully updated! Redirecting to View Own Plan page...";
                    Response.AddHeader("REFRESH", "1;URL=ViewOwnPlan.aspx");
                    con.Close();
                    con.Dispose();
                }
                else
                {
                    con.Close();
                    con.Dispose();
                    Response.Redirect("Error.aspx");
                }
            }
        }