Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SHMetroTestSysModel.jc_Library GetModel(int LibraryNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 LibraryNo,SubjectNo,LibraryType,LibraryProperties,LibraryName,LibraryIntroduction,LibraryLayout,Radio,More,Bool,Fill,QA,Total,RadioInfo,MoreInfo,BoolInfo,FillInfo,QAInfo,LibraryScore,PassingGrade,TotalScore,TestTime,fixedNo,Reexam,StartDate,EndDate from jc_Library ");
            strSql.Append(" where LibraryNo=@LibraryNo");
            SqlParameter[] parameters = {
                    new SqlParameter("@LibraryNo", SqlDbType.Int,4)
            };
            parameters[0].Value = LibraryNo;

            SHMetroTestSysModel.jc_Library model = new SHMetroTestSysModel.jc_Library();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SHMetroTestSysModel.jc_Library DataRowToModel(DataRow row)
 {
     SHMetroTestSysModel.jc_Library model = new SHMetroTestSysModel.jc_Library();
     if (row != null)
     {
         if (row["LibraryNo"] != null && row["LibraryNo"].ToString() != "")
         {
             model.LibraryNo = int.Parse(row["LibraryNo"].ToString());
         }
         if (row["SubjectNo"] != null)
         {
             model.SubjectNo = row["SubjectNo"].ToString();
         }
         if (row["LibraryType"] != null)
         {
             model.LibraryType = row["LibraryType"].ToString();
         }
         if (row["LibraryProperties"] != null)
         {
             model.LibraryProperties = row["LibraryProperties"].ToString();
         }
         if (row["LibraryName"] != null)
         {
             model.LibraryName = row["LibraryName"].ToString();
         }
         if (row["LibraryIntroduction"] != null)
         {
             model.LibraryIntroduction = row["LibraryIntroduction"].ToString();
         }
         if (row["LibraryLayout"] != null)
         {
             model.LibraryLayout = row["LibraryLayout"].ToString();
         }
         if (row["Radio"] != null && row["Radio"].ToString() != "")
         {
             model.Radio = int.Parse(row["Radio"].ToString());
         }
         if (row["More"] != null && row["More"].ToString() != "")
         {
             model.More = int.Parse(row["More"].ToString());
         }
         if (row["Bool"] != null && row["Bool"].ToString() != "")
         {
             model.Bool = int.Parse(row["Bool"].ToString());
         }
         if (row["Fill"] != null && row["Fill"].ToString() != "")
         {
             model.Fill = int.Parse(row["Fill"].ToString());
         }
         if (row["QA"] != null && row["QA"].ToString() != "")
         {
             model.QA = int.Parse(row["QA"].ToString());
         }
         if (row["Total"] != null && row["Total"].ToString() != "")
         {
             model.Total = int.Parse(row["Total"].ToString());
         }
         if (row["RadioInfo"] != null)
         {
             model.RadioInfo = row["RadioInfo"].ToString();
         }
         if (row["MoreInfo"] != null)
         {
             model.MoreInfo = row["MoreInfo"].ToString();
         }
         if (row["BoolInfo"] != null)
         {
             model.BoolInfo = row["BoolInfo"].ToString();
         }
         if (row["FillInfo"] != null)
         {
             model.FillInfo = row["FillInfo"].ToString();
         }
         if (row["QAInfo"] != null)
         {
             model.QAInfo = row["QAInfo"].ToString();
         }
         if (row["LibraryScore"] != null)
         {
             model.LibraryScore = row["LibraryScore"].ToString();
         }
         if (row["PassingGrade"] != null && row["PassingGrade"].ToString() != "")
         {
             model.PassingGrade = int.Parse(row["PassingGrade"].ToString());
         }
         if (row["TotalScore"] != null && row["TotalScore"].ToString() != "")
         {
             model.TotalScore = int.Parse(row["TotalScore"].ToString());
         }
         if (row["TestTime"] != null && row["TestTime"].ToString() != "")
         {
             model.TestTime = int.Parse(row["TestTime"].ToString());
         }
         if (row["fixedNo"] != null)
         {
             model.fixedNo = row["fixedNo"].ToString();
         }
         if (row["Reexam"] != null && row["Reexam"].ToString() != "")
         {
             if ((row["Reexam"].ToString() == "1") || (row["Reexam"].ToString().ToLower() == "true"))
             {
                 model.Reexam = true;
             }
             else
             {
                 model.Reexam = false;
             }
         }
         if (row["StartDate"] != null && row["StartDate"].ToString() != "")
         {
             model.StartDate = DateTime.Parse(row["StartDate"].ToString());
         }
         if (row["EndDate"] != null && row["EndDate"].ToString() != "")
         {
             model.EndDate = DateTime.Parse(row["EndDate"].ToString());
         }
     }
     return model;
 }