示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Rebecca - If not logged in, or user is not a student, redirect to default page
        if (Session["user"] == null || (Convert.ToInt32(Session["typeID"]) != 5))
        {
            Response.Redirect("../Default.aspx");
        }
        else
        {
            //Otherwise assign session to username field
            string user = Session["user"].ToString();
        }

        //It is not a postback / on page load / do not perform when save button pressed
        if (!IsPostBack)
        {
            //Getting userID from URL
            int userID = Convert.ToInt32(Request.QueryString["UserID"]);

            //RMU - DB Connection:
            string connectionString = WebConfigurationManager.ConnectionStrings
                                      ["dbconnect"].ConnectionString;

            SqlConnection myConnection = new SqlConnection(connectionString);

            myConnection.Open();

            string query = "SELECT * FROM SIS_FINANCE WHERE studentID=@Id";


            SqlCommand myCommand = new SqlCommand(query, myConnection);


            myCommand.Parameters.AddWithValue("@Id", userID);

            SqlDataReader rdr = myCommand.ExecuteReader();

            while (rdr.Read())
            {
                string other = rdr["other"].ToString();
                Other.Text = other;
                bool sfni = Convert.ToBoolean(rdr["SFNI"]);
                SFNIBox.Checked = sfni;
                bool othermethod = Convert.ToBoolean(rdr["otherPaymentMethod"]);
                OtherBox.Checked = othermethod;
            }

            Other.DataBind();
            SFNIBox.DataBind();
            OtherBox.DataBind();

            myConnection.Close();
        }
    }