/// <summary> /// 得到一个对象实体 /// </summary> public SHMetroTestSysModel.jc_ExerciseLog DataRowToModel(DataRow row) { SHMetroTestSysModel.jc_ExerciseLog model=new SHMetroTestSysModel.jc_ExerciseLog(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["LxType"]!=null) { model.LxType=row["LxType"].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["UserIdCard"]!=null) { model.UserIdCard=row["UserIdCard"].ToString(); } if(row["StartLxTime"]!=null && row["StartLxTime"].ToString()!="") { model.StartLxTime=DateTime.Parse(row["StartLxTime"].ToString()); } if(row["EndLxTime"]!=null && row["EndLxTime"].ToString()!="") { model.EndLxTime=DateTime.Parse(row["EndLxTime"].ToString()); } if(row["ExerciseLong"]!=null && row["ExerciseLong"].ToString()!="") { model.ExerciseLong=int.Parse(row["ExerciseLong"].ToString()); } if(row["Score"]!=null && row["Score"].ToString()!="") { model.Score=decimal.Parse(row["Score"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public SHMetroTestSysModel.jc_ExerciseLog GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,LxType,SubjectNo,LibraryNo,UserIdCard,StartLxTime,EndLxTime,ExerciseLong,Score from jc_ExerciseLog "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; SHMetroTestSysModel.jc_ExerciseLog model=new SHMetroTestSysModel.jc_ExerciseLog(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }