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

📄 faqsdb.cs

📁 FAQs for Rainbow Portal
💻 CS
字号:
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

using Rainbow.Configuration;


namespace Rainbow.DesktopModules 
{

	/// <summary>
	/// IBS Portal FAQ module
	/// (c)2002 by Christopher S Judd, CDP & Horizons, LLC
	/// Moved into Rainbow by Jakob Hansen, hansen3000@hotmail.com
	/// </summary>
	public class FAQsDB
	{

		// *******************************************************
		// 
		//  The AddFAQ function is used to ADD FAQs to the Database
		// 
		// *******************************************************
        public int AddFAQ(int moduleId, int itemId,  String question, String answer) 
		{
            //  Create Instance of Connection and Command Object
			SqlConnection myConnection = PortalSettings.SqlConnectionString;
			SqlCommand myCommand = new SqlCommand("AddFAQ", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            //  Add Parameters to SPROC
            SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4);
            parameterItemID.Direction = ParameterDirection.Output;
            myCommand.Parameters.Add(parameterItemID);

            SqlParameter parameterModuleID = new SqlParameter("@ModuleID", SqlDbType.Int, 4);
            parameterModuleID.Value = moduleId;
            myCommand.Parameters.Add(parameterModuleID);

            SqlParameter parameterQuestion = new SqlParameter("@Question", SqlDbType.NText);
            parameterQuestion.Value = question;
            myCommand.Parameters.Add(parameterQuestion);

            SqlParameter parameterAnswer = new SqlParameter("@Answer", SqlDbType.NText);
            parameterAnswer.Value = answer;
            myCommand.Parameters.Add(parameterAnswer);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();

            return Convert.ToInt32(parameterItemID.Value);
        }


		// *******************************************************
		// 
		//  The GetFAQ function is used to get all the FAQs in the module
		// 
		// *******************************************************
        public DataSet GetFAQ(int moduleId) 
		{
            //  Create Instance of Connection and Command Object
			SqlConnection myConnection = PortalSettings.SqlConnectionString;
			SqlDataAdapter myCommand = new SqlDataAdapter("GetFAQ", myConnection);
            myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;

            //  Add Parameters to SPROC
            SqlParameter parameterModuleId = new SqlParameter("@ModuleId", SqlDbType.Int, 4);
            parameterModuleId.Value = moduleId;
            myCommand.SelectCommand.Parameters.Add(parameterModuleId);

            //  Create and Fill the DataSet
            DataSet myDataSet = new DataSet();
            myCommand.Fill(myDataSet);

            //  return the DataSet
            return myDataSet;
        }


		// *******************************************************
		// 
		//  The GetSingleFAQ function is used to Get a single FAQ
		//	from the database for display/edit
		// 
		// *******************************************************
        public SqlDataReader GetSingleFAQ(int itemId) 
		{

            //  Create Instance of Connection and Command Object
			SqlConnection myConnection = PortalSettings.SqlConnectionString;
			SqlCommand myCommand = new SqlCommand("GetSingleFAQ", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            //  Add Parameters to SPROC
            SqlParameter parameterItemId = new SqlParameter("@ItemId", SqlDbType.Int, 4);
            parameterItemId.Value = itemId;
            myCommand.Parameters.Add(parameterItemId);

            //  Execute the command
            myConnection.Open();
            SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            //  return the datareader 
            return result;
        }


		// *******************************************************
		// 
		//  The DeleteFAQ function is used to remove FAQs from the Database
		// 
		// *******************************************************
        public void DeleteFAQ(int itemID)
		{
            //  Create Instance of Connection and Command Object
			SqlConnection myConnection = PortalSettings.SqlConnectionString;
			SqlCommand myCommand = new SqlCommand("DeleteFAQ", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            //  Add Parameters to SPROC
            SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4);
            parameterItemID.Value = itemID;
            myCommand.Parameters.Add(parameterItemID);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }


		// *******************************************************
		// 
		//  The UpdateFAQ function is used to update changes to the FAQs
		// 
		// *******************************************************
        public void UpdateFAQ(int moduleId, int itemId, String question, String answer)
		{
            //  Create Instance of Connection and Command Object
			SqlConnection myConnection = PortalSettings.SqlConnectionString;
			SqlCommand myCommand = new SqlCommand("UpdateFAQ", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            //  Add Parameters to SPROC
            SqlParameter parameterItemID = new SqlParameter("@ItemID", SqlDbType.Int, 4);
            parameterItemID.Value = itemId;
            myCommand.Parameters.Add(parameterItemID);

            SqlParameter parameterQuestion = new SqlParameter("@Question", SqlDbType.NText);
            parameterQuestion.Value = question;
            myCommand.Parameters.Add(parameterQuestion);

            SqlParameter parameterAnswer = new SqlParameter("@Answer", SqlDbType.NText);
            parameterAnswer.Value = answer;
            myCommand.Parameters.Add(parameterAnswer);
            
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }


	}
}

⌨️ 快捷键说明

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