Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        id = Session["id"].ToString().Trim();
        //Response.Write(id);
        ConnMySql       connMySql = new ConnMySql();
        string          sql       = "select score from stuScore where id='" + id + "' and courseNo='" + c1 + "'";
        MySqlDataReader myDR      = connMySql.GetData(sql);

        if (myDR.Read())
        {
            math.Text = myDR[0].ToString();
        }
        sql  = "select score from stuScore where id='" + id + "' and courseNo='" + c2 + "'";
        myDR = connMySql.GetData(sql);
        if (myDR.Read())
        {
            computer.Text = myDR[0].ToString();
        }
        sql  = "select score from stuScore where id='" + id + "' and courseNo='" + c3 + "'";
        myDR = connMySql.GetData(sql);
        if (myDR.Read())
        {
            english.Text = myDR[0].ToString();
        }
        sql  = "select score from stuScore where id='" + id + "' and courseNo='" + c4 + "'";
        myDR = connMySql.GetData(sql);
        if (myDR.Read())
        {
            pe.Text = myDR[0].ToString();
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        id = Session["id"].ToString().Trim();

        ConnMySql       connMySql = new ConnMySql();
        string          sql       = "select name,gender,age,department,address,ps from stuInfor where id='" + id + "'";
        MySqlDataReader myDR      = connMySql.GetData(sql);

        if (myDR.Read())
        {
            name       = myDR[0].ToString().Trim();
            gender     = myDR[1].ToString().Trim();
            age        = myDR[2].ToString().Trim();
            department = myDR[3].ToString().Trim();
            address    = myDR[4].ToString().Trim();
            ps         = myDR[5].ToString().Trim();

            idVal.Text   = id;
            nameVal.Text = name;
            //if (gender == "1")
            //{

            //    genderVal.Text = "男";
            //}
            //else if(gender == "0"){
            //    genderVal.Text = "女";
            //}
            genderVal.Text     = gender;
            ageVal.Text        = age;
            departmentVal.Text = department;
            addressVal.Text    = address;
            psVal.Text         = ps;
        }
    }
Ejemplo n.º 3
0
    protected void Login_Click(object sender, EventArgs e)
    {
        //MySqlCommand sqlcmd = new MySqlCommand();
        //sqlcmd.Parameters.AddWithValue("@id", nameVal.Text.ToString());
        ConnMySql connMySql = new ConnMySql();
        string    sql       = "select password from account where id='";

        sql += nameVal.Text.ToString() + "'";
        MySqlDataReader myDR = connMySql.GetData(sql);

        if (myDR.Read())
        {
            if (myDR[0].ToString() == passwordVal.Text.ToString())
            {
                Session["id"]       = nameVal.Text.ToString().Trim();
                Session["password"] = passwordVal.Text.ToString().Trim();
                Server.Transfer("home.aspx");
                Response.Redirect("home.aspx");
            }
            else
            {
                //MessageBox.Show("","");
                Response.Write("<script>alert(" + "'Wrong password.'" + ");</script>");
            }
        }
        else
        {
            Response.Write("<script>alert(" + "'ID does not exist.'" + ");</script>");
        }
    }
Ejemplo n.º 4
0
    protected void submit_Click(object sender, EventArgs e)
    {
        ConnMySql connMySql = new ConnMySql();
        string    sql       = "update stuInfor set name='" + this.nameVal.Text + "',gender='" + genderVal.Text + "',age=" + int.Parse(ageVal.Text) + ",department='" + departmentVal.Text + "',address='" + addressVal.Text + "',ps='" + psVal.Text + "' where id='" + id + "'";

        MySqlDataReader myDR = connMySql.GetData(sql);

        //Response.Write(ageVal.Text);
        Response.Write("<script>alert(" + "'Successful operation." + "');</script>");
    }
Ejemplo n.º 5
0
    protected void submit_Click(object sender, EventArgs e)
    {
        string name       = nameVal.Text.ToString().Trim();
        string gender     = genderVal.Text.ToString().Trim();
        string age        = ageVal.Text.ToString().Trim();
        string department = departmentVal.Text.ToString().Trim();
        string address    = addressVal.Text.ToString().Trim();
        string ps         = psVal.Text.ToString().Trim();
        string password   = passwordVal.Text.ToString().Trim();

        string id   = "";
        int    agei = int.Parse(age);

        if (name.Length > 6 || gender.Length > 1 || age.Length > 3 || department.Length > 10 || address.Length > 20 || ps.Length > 40 || password.Length > 20)
        {
            Response.Write("<script>alert(" + "'Data is illegal.'" + ");</script>");
        }
        else
        {
            ConnMySql connMySql = new ConnMySql();
            string    sql       = "select max(id) from account";

            MySqlDataReader myDR = connMySql.GetData(sql);
            if (myDR.Read())
            {
                id = myDR[0].ToString().Trim();
                id = (int.Parse(id) + 1).ToString();
            }

            sql  = "insert into stuInfor(id,name,gender,age,department,address,ps) values('" + id + "','" + name + "','" + gender + "'," + age + ",'" + department + "','" + address + "','" + ps + "')";
            myDR = connMySql.GetData(sql);
            sql  = "insert into account(id,password) values('" + id + "','" + password + "')";
            myDR = connMySql.GetData(sql);
            Response.Write("<script>alert(" + "'Registrantion success.User ID:" + id + "');</script>");
        }
    }
Ejemplo n.º 6
0
 protected void psBtn_Click(object sender, EventArgs e)
 {
     ConnMySql       connMySql = new ConnMySql();
     string          sql       = "update stuInfor set ps='' where id='" + id + "'";
     MySqlDataReader myDR      = connMySql.GetData(sql);
 }