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

📄 admin_systemsetup.aspx.cs

📁 网上自动答疑系统(C#)
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace dayi
{
	/// <summary>
	/// admin_systemSetup 的摘要说明。
	/// </summary>
	public class admin_systemSetup : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox txtCountBeforeFullText;
		protected System.Web.UI.WebControls.DropDownList listWordbookType;
		protected System.Web.UI.WebControls.TextBox txtAfficheCount;
		protected System.Web.UI.WebControls.Button btnSetup;
		protected System.Web.UI.WebControls.DropDownList listWordbookAllow;
		protected System.Web.UI.WebControls.DropDownList listSearchType;
		protected System.Web.UI.WebControls.Button btnDefault;
		protected System.Web.UI.WebControls.DropDownList listLockRegister;
		protected System.Web.UI.WebControls.DropDownList listAutoType;
		protected System.Web.UI.WebControls.TextBox txtAddToWordbookCount;
		protected System.Web.UI.WebControls.TextBox txtHotRecordCount;
	
		dayi.controlDatabase cd=new controlDatabase();

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!this.IsPostBack)
			{
				if(Session["userType"].ToString()!="admin")
				{
					//确认身份
					Response.Redirect("err.aspx?err=没有权限");
				}
				try
				{
					if(Session["userType"].ToString()!="admin" || Session["userName"].ToString()=="")
					{
						//Response.Redirect("err.aspx?err=没有权限");
					}
					this.txtAfficheCount.Text=cd.getSystemPara("afficheCount").ToString();
					this.txtCountBeforeFullText.Text=cd.getSystemPara("countBeforeFullText").ToString();
					this.listWordbookAllow.SelectedValue=(bool)cd.getSystemPara("wordbookAllow")?"true":"false";
					this.listWordbookType.SelectedValue=cd.getSystemPara("wordbookType").ToString();
					this.listSearchType.SelectedValue=cd.getSystemPara("searchType").ToString();
					this.listLockRegister.SelectedValue=cd.getSystemPara("lockRegister").ToString();
					this.listAutoType.SelectedValue=cd.getSystemPara("autoAnswerType").ToString();
					this.txtAddToWordbookCount.Text=cd.getSystemPara("addToWordbookCount").ToString();
					this.txtHotRecordCount.Text=cd.getSystemPara("hotRecordCount").ToString().Trim();
				}
				catch(Exception ee)
				{
					//Response.Redirect("err.aspx?err="+Server.HtmlEncode(ee.Message));
					Response.Write(ee.ToString()+"<br>"+cd.ErrorString);
				}
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnSetup.Click += new System.EventHandler(this.btnSetup_Click);
			this.btnDefault.Click += new System.EventHandler(this.btnDefault_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSetup_Click(object sender, System.EventArgs e)
		{
			//设置系统参数
			try
			{
				string countBeforeFullText=this.txtCountBeforeFullText.Text.Trim();
				string wordbookAllow=this.listWordbookAllow.SelectedValue;
				string wordbookType=this.listWordbookType.SelectedValue;
				string afficheCount=this.txtAfficheCount.Text.Trim();
				string searchType=this.listSearchType.SelectedValue;
				string lockRegister=this.listLockRegister.SelectedValue;
				string autoType=this.listAutoType.SelectedValue;
				string addToWordbookCount=this.txtAddToWordbookCount.Text.Trim();
				string hotRecordCount=this.txtHotRecordCount.Text.Trim();

				string sql="update [systemPara] set paraValue='"+countBeforeFullText+"' where paraName='countBeforeFullText'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+wordbookAllow+"' where paraName='wordbookAllow'";
			    cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+wordbookType+"' where paraName='wordbookType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+afficheCount+"' where paraName='afficheCount'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+searchType+"' where paraName='searchType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+lockRegister+"' where paraName='lockRegister'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+autoType+"' where paraName='autoAnswerType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+addToWordbookCount+"' where paraName='addToWordbookCount'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='"+hotRecordCount+"' where paraName='hotRecordCount'";
				cd.updateDatabase(sql);

			}
			catch(Exception ee)
			{
				Response.Write(ee.ToString());
			}
		}

		private void btnDefault_Click(object sender, System.EventArgs e)
		{
			//设为默认
			try
			{
				string sql="update [systemPara] set paraValue='5' where paraName='countBeforeFullText'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='true' where paraName='wordbookAllow'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='subject' where paraName='wordbookType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='10' where paraName='afficheCount'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='matching' where paraName='searchType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='none' where paraName='lockRegister'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='all' where paraName='autoAnswerType'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='20' where paraName='addToWordbookCount'";
				cd.updateDatabase(sql);

				sql="update [systemPara] set paraValue='10' where paraName='hotRecordCount'";
				cd.updateDatabase(sql);

				this.txtAfficheCount.Text=cd.getSystemPara("afficheCount").ToString();
				this.txtCountBeforeFullText.Text=cd.getSystemPara("countBeforeFullText").ToString();
				this.listWordbookAllow.SelectedValue=(bool)cd.getSystemPara("wordbookAllow")?"true":"false";
				this.listWordbookType.SelectedValue=cd.getSystemPara("wordbookType").ToString();
				this.listSearchType.SelectedValue=cd.getSystemPara("searchType").ToString();
				this.listLockRegister.SelectedValue=cd.getSystemPara("lockRegister").ToString();
				this.listAutoType.SelectedValue="all";
				this.txtAddToWordbookCount.Text="20";
				this.txtHotRecordCount.Text="10";
			}
			catch(Exception ee)
			{
				Response.Write(ee.ToString());
			}
		}
	}
}

⌨️ 快捷键说明

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