⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parentsectionutility.cs

📁 C#邮件代码库,用于邮件发送
💻 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 + -