Exemple #1
0
        public void SaveUserScoreAlter()
        {
            //获得列表上用户从左至右的课程编号、用户编号、成绩及课程名称
            List <List <string> > scoreInfo = userView.GetScore();

            int    alterSuccessCount = 0;  //成功录入成绩的课程门数
            string hasAlter          = ""; //录入成功的课程名称
            int    isAlterOne        = 0;  //用来标记一门课是否成功录入成绩,==0表示不成功

            foreach (List <string> scoreItem in scoreInfo)
            {
                //检测输入是否为数字
                if (!CommonFunction.IsNumString(scoreItem[2], "decimal"))
                {
                    MessageBox.Show("请正确输入成绩!");
                    return;
                }
                string sqlUpdateScore = "update TD_Score set SOR_GRADE=" + scoreItem[2] + " where SOR_COUCODE='" +
                                        scoreItem[0] + "' and SOR_STUCODE='" + scoreItem[1] + "'";
                isAlterOne = CommonFunction.ExecuteSqlNonQuery(sqlUpdateScore);
                if (isAlterOne == 0)
                {
                    MessageBox.Show("成功录入" + alterSuccessCount + "门成绩:\n" + hasAlter + "\n其他成绩录入失败。");
                    return;
                }
                alterSuccessCount++;
                hasAlter += (scoreItem[3] + "  ");
            }
            MessageBox.Show("成功录入" + alterSuccessCount + "门成绩:\n" + hasAlter);
        }