Example #1
0
        protected void btn_change_Click(object sender, EventArgs e)
        {
            Model.Score sc = new Model.Score()
            {
                StuId      = Convert.ToInt32(Request.Params["StuId"]),
                CourseId   = Convert.ToInt32(Request.Params["CourseId"]),
                ClassScore = float.Parse(new_ClassScore.Text.ToString().Trim()),
                MatchScore = float.Parse(new_MatchScore.Text.ToString().Trim()),
                FinalScore = float.Parse(new_FinalScore.Text.ToString().Trim()),
            };
            int res = new ScoreManage().ChangeScore(sc);

            if (res > 0)
            {
                Response.Write("<script>alert('修改成功!');history.go(-2)</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!');</script>");
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            float matchratio = float.Parse(TextBox2.Text.Trim());
            float classratio = float.Parse(TextBox1.Text.Trim());

            for (int i = 0; i < Repeater1.Items.Count; i++)
            {
                Model.Score sc = new Model.Score()
                {
                    StuId      = Convert.ToInt32(((Literal)Repeater1.Items[i].FindControl("StuId")).Text.Trim()),
                    CourseId   = Convert.ToInt32(Request.Params["CourseId"]),
                    MatchScore = float.Parse(((TextBox)(Repeater1.Items[i].Controls[0].FindControl("matchScore"))).Text),
                    ClassScore = float.Parse(((TextBox)(Repeater1.Items[i].FindControl("classScore"))).Text),
                    FinalScore = float.Parse(((TextBox)(Repeater1.Items[i].FindControl("matchScore"))).Text) * matchratio + float.Parse(((TextBox)(Repeater1.Items[i].FindControl("classScore"))).Text) * classratio
                };
                int result = new ScoreManage().addStuScore(sc);
                if (result == 0)
                {
                    Response.Write("<script>window.alert('成功添加了" + i + "名同学的成绩,第" + i + 1 + "位同学成绩添加失败!');</script>");
                    break;
                }
            }
            Response.Write("<script>window.alert('成功添加了" + Repeater1.Items.Count + "名同学的成绩');</script>");
        }