Пример #1
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Score GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,MScore,ClassID,StudentID,StudentName,StudentCode,CourseID,CourseName,Score_Op,Score_Pre,Score_Ex,Score_Percent,ProjectCourseID,ClassItemID from Score ");
            strSql.Append(" where [email protected] ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.Score model=new LabMS.Model.Score();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["MScore"].ToString()!="")
                {
                    model.MScore=int.Parse(ds.Tables[0].Rows[0]["MScore"].ToString());
                }
                if(ds.Tables[0].Rows[0]["ClassID"].ToString()!="")
                {
                    model.ClassID=int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["StudentID"].ToString()!="")
                {
                    model.StudentID=int.Parse(ds.Tables[0].Rows[0]["StudentID"].ToString());
                }
                model.StudentName=ds.Tables[0].Rows[0]["StudentName"].ToString();
                model.StudentCode=ds.Tables[0].Rows[0]["StudentCode"].ToString();
                if(ds.Tables[0].Rows[0]["CourseID"].ToString()!="")
                {
                    model.CourseID=int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString());
                }
                model.CourseName=ds.Tables[0].Rows[0]["CourseName"].ToString();
                if(ds.Tables[0].Rows[0]["Score_Op"].ToString()!="")
                {
                    model.Score_Op=int.Parse(ds.Tables[0].Rows[0]["Score_Op"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Score_Pre"].ToString()!="")
                {
                    model.Score_Pre=int.Parse(ds.Tables[0].Rows[0]["Score_Pre"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Score_Ex"].ToString()!="")
                {
                    model.Score_Ex=int.Parse(ds.Tables[0].Rows[0]["Score_Ex"].ToString());
                }
                model.Score_Percent=ds.Tables[0].Rows[0]["Score_Percent"].ToString();
                if(ds.Tables[0].Rows[0]["ProjectCourseID"].ToString()!="")
                {
                    model.ProjectCourseID=int.Parse(ds.Tables[0].Rows[0]["ProjectCourseID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["ClassItemID"].ToString()!="")
                {
                    model.ClassItemID=int.Parse(ds.Tables[0].Rows[0]["ClassItemID"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #2
0
        //保存成绩
        protected void Save_OnClick(object sender, EventArgs e)
        {
            List<LabMS.Model.Score> list = new List<LabMS.Model.Score>();
            string[] str = new string[4];

            int count = ScoreGridView.Rows.Count;
            if (count == 0)
            {
                return;
            }
            int[] iarray = new int[count];
            for (int i = 0; i < count; i++)
            {
                LabMS.Model.Score scoreModel = new LabMS.Model.Score();
                TextBox optb = (TextBox)ScoreGridView.Rows[i].FindControl("OpScoreTBX");
                TextBox pretb = (TextBox)ScoreGridView.Rows[i].FindControl("PreScoreTBX");
                TextBox extb = (TextBox)ScoreGridView.Rows[i].FindControl("ExScoreTBX");
                TextBox stb = (TextBox)ScoreGridView.Rows[i].FindControl("ScoreTBX");
                int IsScore;

                scoreModel.ProjectCourseID = GetProCourseIDByProID(int.Parse(SubjectDDL.SelectedValue), int.Parse(IDHF.Value));
                scoreModel.StudentID = int.Parse(ScoreGridView.DataKeys[i]["StudentID"].ToString());

                IsScore = CheckIsScore(scoreModel.ProjectCourseID, scoreModel.StudentID);

                if (IsScore>0)//更新
                {
                    iarray[i] = 1;
                    int iOut;
                    if(optb.Text.Trim() != "")
                    {
                        if (int.TryParse(optb.Text.Trim(), out iOut))
                            scoreModel.Score_Op = iOut;
                    }
                    if(pretb.Text.Trim() != "")
                    {
                        if (int.TryParse(pretb.Text.Trim(), out iOut))
                            scoreModel.Score_Pre = iOut;
                    }
                    if (extb.Text.Trim() != "")
                    {
                        if (int.TryParse(extb.Text.Trim(), out iOut))
                            scoreModel.Score_Ex = iOut;
                    }
                    if (stb.Text.Trim() != "")
                    {
                        if (int.TryParse(stb.Text.Trim(), out iOut))
                            scoreModel.MScore = iOut;
                    }
                    scoreModel.ID = IsScore;
                    list.Add(scoreModel);
                }
                else//插入
                {
                    iarray[i] = 0;
                    int iOut;
                    if (optb.Text.Trim() != "")
                    {
                        if (int.TryParse(optb.Text.Trim(), out iOut))
                            scoreModel.Score_Op = iOut;
                    }
                    if (pretb.Text.Trim() != "")
                    {
                        if (int.TryParse(pretb.Text.Trim(), out iOut))
                            scoreModel.Score_Pre = iOut;
                    }
                    if (extb.Text.Trim() != "")
                    {
                        if (int.TryParse(extb.Text.Trim(), out iOut))
                            scoreModel.Score_Ex = iOut;
                    }
                    if (stb.Text.Trim() != "")
                    {
                        if (int.TryParse(stb.Text.Trim(), out iOut))
                            scoreModel.MScore = iOut;
                    }
                    if (IDHF.Value != "0")
                    {
                        scoreModel.CourseID = int.Parse(IDHF.Value);
                    }
                    scoreModel.CourseName = CourseNameTBX.Text.Trim();
                    if (ClassDDL.SelectedValue != "")
                    {
                        if (int.TryParse(ClassDDL.SelectedValue, out iOut))
                            scoreModel.ClassID = iOut;
                    }
                    //scoreModel.ProjectCourseID = GetProCourseIDByProID(int.Parse(SubjectDDL.SelectedValue), int.Parse(IDHF.Value));
                    scoreModel.ClassItemID = GetCouClaIDByClaID(int.Parse(ClassDDL.SelectedValue), int.Parse(IDHF.Value));
                    scoreModel.Score_Percent = "";
                    scoreModel.StudentCode = ScoreGridView.Rows[i].Cells[0].Text;
                    //scoreModel.StudentID = int.Parse(ScoreGridView.DataKeys[i]["StudentID"].ToString());
                    //scoreModel.ID = int.Parse(ScoreGridView.DataKeys[i]["ID"].ToString());
                    scoreModel.StudentName = ScoreGridView.Rows[i].Cells[1].Text;
                    list.Add(scoreModel);
                }
            }
            ExtendBLL.Score scoreExt = new ExtendBLL.Score();
            try
            {
                scoreExt.AddScore(iarray, list);
                LabMS.Common.JShelper.JSAlert(Page, "script", "添加成功!");
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "script", "添加失败!");
            }
        }