/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.StorePictures DataRowToModel(DataRow row) { Maticsoft.Model.StorePictures model = new Maticsoft.Model.StorePictures(); if (row != null) { if (row["StorePicturesID"] != null) { model.StorePicturesID = row["StorePicturesID"].ToString(); } if (row["BusPhotoAlbumID"] != null) { model.BusPhotoAlbumID = row["BusPhotoAlbumID"].ToString(); } if (row["BusinessID"] != null) { model.BusinessID = row["BusinessID"].ToString(); } if (row["UsersID"] != null) { model.UsersID = row["UsersID"].ToString(); } if (row["PictureAddress"] != null) { model.PictureAddress = row["PictureAddress"].ToString(); } if (row["PicName"] != null) { model.PicName = row["PicName"].ToString(); } if (row["IsUserUpload"] != null && row["IsUserUpload"].ToString() != "") { if ((row["IsUserUpload"].ToString() == "1") || (row["IsUserUpload"].ToString().ToLower() == "true")) { model.IsUserUpload = true; } else { model.IsUserUpload = false; } } if (row["PicState"] != null && row["PicState"].ToString() != "") { model.PicState = int.Parse(row["PicState"].ToString()); } if (row["UploadTime"] != null && row["UploadTime"].ToString() != "") { model.UploadTime = DateTime.Parse(row["UploadTime"].ToString()); } if (row["NickName"] != null) { model.NickName = row["NickName"].ToString(); } if (row["IsSetTop"] != null && row["IsSetTop"].ToString() != "") { if ((row["IsSetTop"].ToString() == "1") || (row["IsSetTop"].ToString().ToLower() == "true")) { model.IsSetTop = true; } else { model.IsSetTop = false; } } if (row["LikeCount"] != null && row["LikeCount"].ToString() != "") { model.LikeCount = int.Parse(row["LikeCount"].ToString()); } if (row["ShareCount"] != null && row["ShareCount"].ToString() != "") { model.ShareCount = int.Parse(row["ShareCount"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.StorePictures GetModel(string StorePicturesID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 StorePicturesID,BusPhotoAlbumID,BusinessID,UsersID,PictureAddress,PicName,IsUserUpload,PicState,UploadTime,NickName,IsSetTop,LikeCount,ShareCount from StorePictures "); strSql.Append(" where StorePicturesID=@StorePicturesID "); SqlParameter[] parameters = { new SqlParameter("@StorePicturesID", SqlDbType.NVarChar,50) }; parameters[0].Value = StorePicturesID; Maticsoft.Model.StorePictures model = new Maticsoft.Model.StorePictures(); DataSet ds = ServerDbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }