/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "HQ_PhotoGroup"; * parameters[1].Value = "PhotoID"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod public List <ResultMallPhotoGroup> GetPhotoGroupList(int customerId) { List <ResultMallPhotoGroup> list = null; string sql = string.Format(@"select PhotoID,PhotoName,FatherID,Photo_Customer_ID,Photo_Cover,Photo_Time,FilePath, (select COUNT(Callery_ID) from HQ_Gallery where Callery_Customer_ID={0} and Photo_FatherID=b.PhotoID) as counts from HQ_PhotoGroup as b where Photo_Customer_ID={0} order by Photo_Time desc", customerId); DataTable dt = DbHelperSQL.Query(sql).Tables[0]; if (dt != null && dt.Rows.Count > 0) { list = new List <ResultMallPhotoGroup>(); list.Add(new ResultMallPhotoGroup() { name = "未分组", count = this.GetPhotoGroupByNOGroup(customerId), id = 0 }); foreach (DataRow row in dt.Rows) { ResultMallPhotoGroup model = DataRowToResultModel(row); list.Add(model); } } else { list = new List <ResultMallPhotoGroup>(); list.Add(new ResultMallPhotoGroup() { name = "未分组", count = this.GetPhotoGroupByNOGroup(customerId), id = 0 }); } return(list); }
/// <summary> /// 得到一个对象实体 /// </summary> public ResultMallPhotoGroup DataRowToResultModel(DataRow row) { ResultMallPhotoGroup model = new ResultMallPhotoGroup(); if (row != null) { if (row["PhotoID"] != null && row["PhotoID"].ToString() != "") { model.id = int.Parse(row["PhotoID"].ToString()); } if (row["PhotoName"] != null) { model.name = row["PhotoName"].ToString(); } if (row["FatherID"] != null && row["FatherID"].ToString() != "") { model.parentId = int.Parse(row["FatherID"].ToString()); } if (row["Photo_Customer_ID"] != null && row["Photo_Customer_ID"].ToString() != "") { model.customerId = int.Parse(row["Photo_Customer_ID"].ToString()); } if (row["Photo_Cover"] != null) { model.thumb = row["Photo_Cover"].ToString(); } if (row["Photo_Time"] != null && row["Photo_Time"].ToString() != "") { model.createTime = DateTime.Parse(row["Photo_Time"].ToString()); } if (row["FilePath"] != null && row["FilePath"].ToString() != "") { model.path = row["FilePath"].ToString(); } if (row["counts"] != null && row["counts"].ToString() != "") { model.count = Convert.ToInt32(row["counts"].ToString()); } } return(model); }