/// <summary> /// 得到一个对象实体 /// </summary> public Model.Pgame DataRowToModel(DataRow row) { Model.Pgame model = new Model.Pgame(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["version"] != null) { model.version = row["version"].ToString(); } if (row["Platform"] != null) { model.Platform = row["Platform"].ToString(); } if (row["Status"] != null) { model.Status = row["Status"].ToString(); } if (row["UpdateType"] != null) { model.UpdateType = row["UpdateType"].ToString(); } if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "") { model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString()); } if (row["OnTime"] != null && row["OnTime"].ToString() != "") { model.OnTime = DateTime.Parse(row["OnTime"].ToString()); } if (row["FirstLetter"] != null) { model.FirstLetter = row["FirstLetter"].ToString(); } if (row["IsLock"] != null && row["IsLock"].ToString() != "") { if ((row["IsLock"].ToString() == "1") || (row["IsLock"].ToString().ToLower() == "true")) { model.IsLock = true; } else { model.IsLock = false; } } if (row["Bak1"] != null) { model.Bak1 = row["Bak1"].ToString(); } if (row["Bak2"] != null) { model.Bak2 = row["Bak2"].ToString(); } if (row["Bak3"] != null) { model.Bak3 = row["Bak3"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Pgame GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,Name,version,Platform,Status,UpdateType,UpdateDate,OnTime,FirstLetter,IsLock,Bak1,Bak2,Bak3 from Pgame "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; Model.Pgame model = new Model.Pgame(); DataSet ds = DbHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }