?? parentsectionutility.cs
字號:
namespace ASPNET.StarterKit.Communities.ParentSection {
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
//*********************************************************************
//
// ParentSectionUtility Class
//
// Contains static utility methods for working with
// parent sections and their children.
//
//*********************************************************************
public class ParentSectionUtility {
//*********************************************************************
//
// GetTotalRecords Method
//
// Returns the total number of child sections.
//
//*********************************************************************
public static int GetTotalRecords(string username, int sectionID) {
SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
SqlCommand cmdGet = new SqlCommand("Community_ParentSectionGetTotalRecords", conPortal);
cmdGet.CommandType = CommandType.StoredProcedure;
cmdGet.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
cmdGet.Parameters.Add("@communityID", CommunityGlobals.CommunityID);
cmdGet.Parameters.Add("@username", username);
cmdGet.Parameters.Add("@sectionID", sectionID);
conPortal.Open();
cmdGet.ExecuteNonQuery();
int result = (int)cmdGet.Parameters["@RETURN_VALUE"].Value;
conPortal.Close();
return result;
}
//*********************************************************************
//
// GetChildSections Method
//
// Returns a list of child sections.
//
//*********************************************************************
public static ArrayList GetChildSections(string username, int sectionID, int pageSize, int pageIndex, string sortOrder) {
ArrayList colParentSectionInfo = new ArrayList();
SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
SqlCommand cmdGet = new SqlCommand("Community_ParentSectionGetChildSections", conPortal);
cmdGet.CommandType = CommandType.StoredProcedure;
cmdGet.Parameters.Add("@communityID", CommunityGlobals.CommunityID);
cmdGet.Parameters.Add("@username", username);
cmdGet.Parameters.Add("@sectionID", sectionID);
cmdGet.Parameters.Add("@pageSize", pageSize);
cmdGet.Parameters.Add("@pageIndex", pageIndex);
conPortal.Open();
SqlDataReader dr = cmdGet.ExecuteReader();
while (dr.Read())
colParentSectionInfo.Add(PopulateParentSectionInfoFromSqlDataReader(dr));
conPortal.Close();
return colParentSectionInfo;
}
//*********************************************************************
//
// PopulateParentSectionInfoFromSqlDataReader Method
//
// Creates a ParentSectionInfo object from a SqlDataReader.
//
//*********************************************************************
private static ParentSectionInfo PopulateParentSectionInfoFromSqlDataReader(SqlDataReader dr) {
ParentSectionInfo parentSectionInfo = new ParentSectionInfo();
parentSectionInfo.ID = (int)dr["section_id"];
parentSectionInfo.Title = (string)dr["section_title"];
parentSectionInfo.Description = (string)dr["section_description"];
parentSectionInfo.Path = SectionUtility.GetSectionPath(parentSectionInfo.ID);
parentSectionInfo.IsPublic = (bool)dr["isPublic"];
return parentSectionInfo;
}
//*********************************************************************
//
// ParentSectionUtility Constructor
//
// Use private constructor for a class with static methods.
//
//*********************************************************************
private ParentSectionUtility() {}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -