/// <summary> /// 获得数据列表 /// </summary> public List<Model.Class_TraningCommentResult> DataTableToList(DataTable dt) { List<Model.Class_TraningCommentResult> modelList = new List<Model.Class_TraningCommentResult>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Class_TraningCommentResult model; for (int n = 0; n < rowsCount; n++) { model = new Model.Class_TraningCommentResult(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Verson = dt.Rows[n]["Verson"].ToString(); if (dt.Rows[n]["ClassId"].ToString() != "") { model.ClassId = int.Parse(dt.Rows[n]["ClassId"].ToString()); } if (dt.Rows[n]["Score"].ToString() != "") { model.Score = int.Parse(dt.Rows[n]["Score"].ToString()); } if (dt.Rows[n]["AccountId"].ToString() != "") { model.AccountId = int.Parse(dt.Rows[n]["AccountId"].ToString()); } if (dt.Rows[n]["Delflag"].ToString() != "") { if ((dt.Rows[n]["Delflag"].ToString() == "1") || (dt.Rows[n]["Delflag"].ToString().ToLower() == "true")) { model.Delflag = true; } else { model.Delflag = false; } } if (dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Class_TraningCommentResult GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Verson, ClassId, Score, AccountId, Delflag, CreateDate "); strSql.Append(" from Class_TraningCommentResult "); strSql.Append(" where "); strSql.Append(" Id = @Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; Model.Class_TraningCommentResult model = new Model.Class_TraningCommentResult(); DataSet ds = MSEntLibSqlHelper.ExecuteDataSetBySql(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()); } model.Verson = ds.Tables[0].Rows[0]["Verson"].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]["Score"].ToString() != "") { model.Score = int.Parse(ds.Tables[0].Rows[0]["Score"].ToString()); } if (ds.Tables[0].Rows[0]["AccountId"].ToString() != "") { model.AccountId = int.Parse(ds.Tables[0].Rows[0]["AccountId"].ToString()); } if (ds.Tables[0].Rows[0]["Delflag"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Delflag"].ToString() == "1") || (ds.Tables[0].Rows[0]["Delflag"].ToString().ToLower() == "true")) { model.Delflag = true; } else { model.Delflag = false; } } if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } return model; } else { return null; } }