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

📄 eventutility.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace ASPNET.StarterKit.Communities.Events {

    using System;
    using System.Collections;
    using System.Web;
    using System.Data;
    using System.Data.SqlClient;
    using ASPNET.StarterKit.Communities;


    //*********************************************************************
    //
    // EventUtility Class
    //
    // Contains static utility methods used by the Events section. 
    //
    //*********************************************************************

    public class EventUtility {


        //*********************************************************************
        //
        // GetTotalRecords Method
        //
        // Returns the total number of visible events
        //
        //*********************************************************************
        
        public static int GetTotalRecords(int sectionID) {
            SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
            SqlCommand cmdGetTotal = new SqlCommand("Community_EventsGetTotalRecords", conPortal);
            cmdGetTotal.CommandType = CommandType.StoredProcedure;
            cmdGetTotal.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            cmdGetTotal.Parameters.Add("@sectionID", sectionID);
            conPortal.Open();
            cmdGetTotal.ExecuteNonQuery();
            int totalRecords = (int)cmdGetTotal.Parameters["@RETURN_VALUE"].Value;                      
            conPortal.Close();

            return totalRecords;  
        }
  


        //*********************************************************************
        //
        // GetTotalRecordsWithInvisible Method
        //
        // Returns the total number of visible and invisible events
        //
        //*********************************************************************
        
        public static int GetTotalRecordsWithInvisible(int sectionID) {
            SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
            SqlCommand cmdGetTotal = new SqlCommand("Community_EventsGetTotalRecordsWithInvisible", conPortal);
            cmdGetTotal.CommandType = CommandType.StoredProcedure;
            cmdGetTotal.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            cmdGetTotal.Parameters.Add("@sectionID", sectionID);
            conPortal.Open();
            cmdGetTotal.ExecuteNonQuery();
            int totalRecords = (int)cmdGetTotal.Parameters["@RETURN_VALUE"].Value;                      
            conPortal.Close();
          
            return totalRecords;  
        }
  




        //*********************************************************************
        //
        // GetTotalPastRecords Method
        //
        // Returns the total number of visible past events
        //
        //*********************************************************************
        
        public static int GetTotalPastRecords(int sectionID) {
            SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
            SqlCommand cmdGetTotal = new SqlCommand("Community_EventsGetTotalPastRecords", conPortal);
            cmdGetTotal.CommandType = CommandType.StoredProcedure;
            cmdGetTotal.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            cmdGetTotal.Parameters.Add("@sectionID", sectionID);
            conPortal.Open();
            cmdGetTotal.ExecuteNonQuery();
            int totalRecords = (int)cmdGetTotal.Parameters["@RETURN_VALUE"].Value;                      
            conPortal.Close();

            return totalRecords;  
        }
  


        //*********************************************************************
        //
        // GetTotalPastRecordsWithInvisible Method
        //
        // Returns the total number of past visible and invisible events
        //
        //*********************************************************************
        
        public static int GetTotalPastRecordsWithInvisible(int sectionID) {
            SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
            SqlCommand cmdGetTotal = new SqlCommand("Community_EventsGetTotalPastRecordsWithInvisible", conPortal);
            cmdGetTotal.CommandType = CommandType.StoredProcedure;
            cmdGetTotal.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            cmdGetTotal.Parameters.Add("@sectionID", sectionID);
            conPortal.Open();
            cmdGetTotal.ExecuteNonQuery();
            int totalRecords = (int)cmdGetTotal.Parameters["@RETURN_VALUE"].Value;                      
            conPortal.Close();
          
            return totalRecords;  
        }
  


    
        //*********************************************************************
        //
        // AddEvent Method
        //
        // Adds a new event to the database. 
        //
        //*********************************************************************

        public static int AddEvent
        (
            int sectionID, 
            string username,
            string eventTitle, 
            string eventLink,
            string eventBriefDescription, 
            string eventFullDescription, 
            string eventLocation,
            string eventSpeaker,
            string eventSpeakerBiography,
            DateTime eventDate,
            DateTime eventDateVisible,
            int topicID,
            int moderationStatus
        ){
            // Update Database with new Event
            SqlConnection conPortal = new SqlConnection(CommunityGlobals.ConnectionString);
            SqlCommand cmdAdd = new SqlCommand("Community_EventsAddEvent", conPortal);
            cmdAdd.CommandType = CommandType.StoredProcedure;
            
            cmdAdd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            cmdAdd.Parameters.Add("@communityID", CommunityGlobals.CommunityID);
            cmdAdd.Parameters.Add("@sectionID", sectionID);
            cmdAdd.Parameters.Add("@username", username);
            cmdAdd.Parameters.Add("@eventTitle", eventTitle);
            cmdAdd.Parameters.Add("@eventLink", eventLink);
            cmdAdd.Parameters.Add("@eventBriefDescription", eventBriefDescription);
			cmdAdd.Parameters.Add("@eventFullDescription", SqlDbType.NText);
			cmdAdd.Parameters["@eventFullDescription"].Value = eventFullDescription;
            cmdAdd.Parameters.Add("@eventLocation", eventLocation);
            cmdAdd.Parameters.Add("@eventSpeaker", eventSpeaker);
            cmdAdd.Parameters.Add("@eventSpeakerBiography", eventSpeakerBiography);
			cmdAdd.Parameters.Add("@eventMetaDescription", ContentPageUtility.CalculateMetaDescription(eventBriefDescription));
            cmdAdd.Parameters.Add("@eventMetaKeys", ContentPageUtility.CalculateMetaKeys(eventBriefDescription));
            cmdAdd.Parameters.Add("@eventDate", eventDate);
            cmdAdd.Parameters.Add("@eventDateVisible", eventDateVisible);
            cmdAdd.Parameters.Add("@topicID", topicID);
            cmdAdd.Parameters.Add("@moderationStatus", moderationStatus);

            conPortal.Open();
            cmdAdd.ExecuteNonQuery();
			int result = (int)cmdAdd.Parameters["@RETURN_VALUE"].Value;

            // Add Search Keys
            SearchUtility.AddSearchKeys(conPortal, sectionID, result, eventTitle, eventBriefDescription);


            conPortal.Close();
            
            return result;       
        }


        //*********************************************************************
        //
        // EditEvent Method
        //
        // Edits an existing event in the database. 
        //
        //*********************************************************************

        public static void EditEvent
        (
            string username,
            int sectionID,
            int contentPageID, 
            string eventTitle, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -