Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StatusCheck.loginStatusCheck(Session, Response, "student");

            if (Request["id"] != null)
            {
                if (Request["cancel"] != null && Request["cancel"].Equals("1"))
                {
                    //取消报名
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());
                    String        sql        = "UPDATE dotnetexp.dbo.seminar_student SET is_deleted=1 WHERE is_deleted=0 AND seminar_id=" + Request["id"] + " AND student_id=" + Session["cur_id"] + ";";
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    SqlCommand cmd = new SqlCommand(sql, connection);
                    object     obj = cmd.ExecuteNonQuery();
                    if (obj != null)
                    {
                        //Success
                    }
                    else
                    {
                        //Fail
                    }
                    Response.Redirect("seminar.aspx");
                }
                else
                {
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());

                    String sql = "INSERT INTO dotnetexp.dbo.seminar_student(seminar_id, student_id, enroll_time, is_deleted) VALUES('" + Request["id"] + "'," + Session["cur_id"] + ", GETDATE(), 0);";
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    SqlCommand cmd = new SqlCommand(sql, connection);
                    object     obj = cmd.ExecuteNonQuery();
                    if (obj != null)
                    {
                        //Success
                    }
                    else
                    {
                        //Fail
                    }
                    Response.Redirect("seminar.aspx");
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StatusCheck.loginStatusCheck(Session, Response, "student");

            if (Session["cur_id"] == null || Session["cur_type"] == null)
            {
                Response.Redirect("/login.aspx");
            }
            else if (!Session["cur_type"].Equals("student"))
            {
                Response.Status = "404 Not Found";
                Response.End();
            }
            else if (Session["cur_activate"] != null)
            {
                Response.Redirect("/activateAccount.aspx");
            }

            List <String[]> seminarList = new List <string[]>();
            SqlConnection   connection  = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());
            string          sql         = "SELECT seminar.id, seminar.name sname, course.[name] cname, CONVERT(varchar, seminar.time, 120 ) " +
                                          "FROM dotnetexp.dbo.seminar, dotnetexp.dbo.course WHERE course.[no]=seminar.[course_no] AND seminar.is_deleted=0;";
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
            DataSet        dataSet = new DataSet();

            adapter.Fill(dataSet, "seminar");
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                string[] seminarRow = new string[dataSet.Tables[0].Rows[i].ItemArray.Length + 1];
                for (int j = 0; j < dataSet.Tables[0].Rows[i].ItemArray.Length; j++)
                {
                    seminarRow[j] = (dataSet.Tables[0].Rows[i].ItemArray[j].ToString());
                }
                connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());
                sql        = "SELECT * from dotnetexp.dbo.seminar_student WHERE seminar_id=" + seminarRow[0] + " AND student_id=" + Session["cur_id"] + " AND is_deleted=0;";
                adapter    = new SqlDataAdapter(sql, connection);
                DataSet enrollDataSet = new DataSet();
                adapter.Fill(enrollDataSet, "seminarEnroll");
                if (enrollDataSet.Tables[0].Rows.Count > 0)
                {
                    seminarRow[dataSet.Tables[0].Rows[i].ItemArray.Length] = "1";
                }
                else
                {
                    seminarRow[dataSet.Tables[0].Rows[i].ItemArray.Length] = "0";
                }
                seminarList.Add(seminarRow);
            }
            Session["seminarList"] = seminarList;
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StatusCheck.loginStatusCheck(Session, Response, "student");

            if (Request["Request_Method"] == "POST")
            {
                if (Request["id"] != null)
                {
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());
                    String        question   = Request["question"];

                    String sql = "UPDATE dotnetexp.dbo.seminar_student SET question='" + question + "' WHERE is_deleted=0 AND seminar_id=" + Request["id"] + " AND student_id=" + Session["cur_id"] + ";";
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    SqlCommand cmd = new SqlCommand(sql, connection);
                    object     obj = cmd.ExecuteNonQuery();
                    if (obj != null)
                    {
                        //Success
                    }
                    else
                    {
                        //Fail
                    }
                }
                Response.Redirect("seminar.aspx");
            }
            if (Request["Request_Method"] == "GET")
            {
                if (Request["id"] != null)
                {
                    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ToString());

                    String         sql     = "SELECT question from dotnetexp.dbo.seminar_student WHERE is_deleted=0 AND seminar_id=" + Request["id"] + " AND student_id=" + Session["cur_id"] + ";";
                    SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
                    DataSet        dataSet = new DataSet();
                    adapter.Fill(dataSet, "question");
                    Session["question"] = dataSet.Tables[0].Rows[0].ItemArray[0].ToString();
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     StatusCheck.loginStatusCheck(Session, Response, "student");
 }