コード例 #1
0
ファイル: jc_Public.cs プロジェクト: rdzzg/SHMetroTestSystem
        public void AddTestDetails(string testLogGuid, string subjectNo, int libraryNo,string paperLog)
        {
            SHMetroTestSysModel.jc_TestDetails testDetail=new SHMetroTestSysModel.jc_TestDetails();
            string[] strArray = paperLog.Split(new char[] { '`' });
            string paperType = "";
            string paperUserAnswers = "";
            string paperId = "";
            string userAnswer = "";
            for (int i = 0; i < strArray.Length; i++)
            {
                string[] strArray2 = strArray[i].Split(new char[] { '-' });
                if (strArray2.Length == 2)
                {
                    paperType = strArray2[0];
                    //26^|34^|35^|36^|37^|38^|56^|
                    paperUserAnswers = strArray2[1];
                    string[] strArray3 = paperUserAnswers.Split(new char[] { '|' });
                    for (int j = 0; j < strArray3.Length; j++)
                    {
                        string[] strArray4 = strArray3[j].Split(new char[] { '^' });
                        if (strArray4.Length == 2)
                        {
                            paperId = strArray4[0];
                            userAnswer = strArray4[1];
                        }
                        else if (strArray4.Length == 1)
                        {
                            paperId = strArray4[0];
                            userAnswer = "";
                        }
                        if (!string.IsNullOrEmpty(paperId))
                        {
                            testDetail.LibraryNo = libraryNo;
                            testDetail.PaperId =int.Parse(paperId) ;
                            testDetail.PaperType = paperType;
                            testDetail.SubjectNo = subjectNo;
                            testDetail.TestLogGuid = testLogGuid;
                            testDetail.UserAnswer = userAnswer;
                            testDetailsbll.Add(testDetail);
                        }
                    }
                }

            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SHMetroTestSysModel.jc_TestDetails DataRowToModel(DataRow row)
 {
     SHMetroTestSysModel.jc_TestDetails model=new SHMetroTestSysModel.jc_TestDetails();
     if (row != null)
     {
         if(row["TestDetailsNo"]!=null && row["TestDetailsNo"].ToString()!="")
         {
             model.TestDetailsNo=int.Parse(row["TestDetailsNo"].ToString());
         }
         if(row["TestLogGuid"]!=null)
         {
             model.TestLogGuid=row["TestLogGuid"].ToString();
         }
         if(row["SubjectNo"]!=null)
         {
             model.SubjectNo=row["SubjectNo"].ToString();
         }
         if(row["LibraryNo"]!=null && row["LibraryNo"].ToString()!="")
         {
             model.LibraryNo=int.Parse(row["LibraryNo"].ToString());
         }
         if(row["PaperId"]!=null && row["PaperId"].ToString()!="")
         {
             model.PaperId=int.Parse(row["PaperId"].ToString());
         }
         if(row["PaperType"]!=null)
         {
             model.PaperType=row["PaperType"].ToString();
         }
         if(row["UserAnswer"]!=null)
         {
             model.UserAnswer=row["UserAnswer"].ToString();
         }
     }
     return model;
 }
コード例 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SHMetroTestSysModel.jc_TestDetails GetModel(int TestDetailsNo)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 TestDetailsNo,TestLogGuid,SubjectNo,LibraryNo,PaperId,PaperType,UserAnswer from jc_TestDetails ");
            strSql.Append(" where TestDetailsNo=@TestDetailsNo");
            SqlParameter[] parameters = {
                    new SqlParameter("@TestDetailsNo", SqlDbType.Int,4)
            };
            parameters[0].Value = TestDetailsNo;

            SHMetroTestSysModel.jc_TestDetails model=new SHMetroTestSysModel.jc_TestDetails();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }