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

📄 operatorlist.aspx.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 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;
using BusObjectForum;
using SampleForum.SetData;
namespace SampleForum.SysManage
{
	/// <summary>
	/// OperatorList 的摘要说明。
	/// </summary>
	public class OperatorList : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
		protected System.Web.UI.WebControls.CheckBoxList Checkboxlist1;
		protected System.Web.UI.WebControls.DataGrid dgrOperator;
		protected System.Web.UI.WebControls.Label labCurrentPage;
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack)
				InitList();
			this.dgrOperator.Columns[0].Visible = false;
			
		}
		public static string CONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.OLEDBConnectionString;
			}
		}
		public static string SQLCONNSTRING
		{
			get
			{
				connect_strings oConn = new connect_strings();
				return oConn.SqlConnectionString;
			}
		}
		public void InitList()
		{
			InnerFunction oFunction = new InnerFunction();
			string ErrDesc="";
			dgrOperator.PageSize =int.Parse(oFunction.getUserParaByName(CONNSTRING,"Forum_ListPageNO",out ErrDesc));
			dgrOperator.PagerStyle.Mode=PagerMode.NumericPages;
			ErrDesc = "";
			AdminC oAdmin = new AdminC();
			DataSet oDataSet = oAdmin.getOperatorList(CONNSTRING,out ErrDesc);
			if(ErrDesc=="")
			{
				this.dgrOperator.DataSource = oDataSet.Tables["T_Function"].DefaultView;
				this.dgrOperator.DataBind();
			}
			else
			{
				Response.Write ("取参数列表发生错误:"+ErrDesc);
				Response.End();
			}
			
		}
		//初始化功能权限列表
		public void InitFunctionList(object oSource, System.EventArgs e)
		{
			string ErrDesc="";
			ForumC oForum = new ForumC();
			DataSet oDataSet = oForum.getForumList(CONNSTRING,out ErrDesc);
			CheckBoxList chkListFunction = (CheckBoxList)oSource;
			ListItem oListItem ;

			string strOperatorID="";
			try
			{
				strOperatorID = Session["selectOPID"].ToString();
			}
			catch(NullReferenceException exp)
			{
				strOperatorID = "";
			}

			DataSet oDataSetRight = oForum.getFunctionByOperatorID(CONNSTRING,strOperatorID,out ErrDesc);
			for(int i=0;i<=oDataSet.Tables[0].Rows.Count-1;i++)
			{
				oListItem = new ListItem(oDataSet.Tables[0].Rows[i].ItemArray[1].ToString(),oDataSet.Tables[0].Rows[i].ItemArray[0].ToString());
				bool blnCheck = false;
				for(int j=0;j<=oDataSetRight.Tables[0].Rows.Count-1;j++)
				{
					if(oDataSet.Tables[0].Rows[i].ItemArray[0].ToString()==oDataSetRight.Tables[0].Rows[j].ItemArray[2].ToString())
					{
						blnCheck=true;
					}
				}
				oListItem.Selected = blnCheck;
				chkListFunction.Items.Add(oListItem);
			}
		}

		public void DoItemEdit(object oSource,DataGridCommandEventArgs oArgs)
		{
			this.dgrOperator.EditItemIndex = oArgs.Item.ItemIndex;
			Session["selectOPID"] = oArgs.Item.Cells[0].Text;
			InitList();
		}
		public void OperatorUpdate(object oSource,DataGridCommandEventArgs oArgs)
		{
			string ErrDesc="";
			string strOperatorId = oArgs.Item.Cells[0].Text;
			string strCheck = oArgs.Item.Cells[2].Text;
			DropDownList oIsPower = (DropDownList)oArgs.Item.FindControl("selIsPower");
			DropDownList oIsAdmin = (DropDownList)oArgs.Item.FindControl("selIsAdmin");
			DropDownList oIsNoUsed = (DropDownList)oArgs.Item.FindControl("selIsNoUsed");
			CheckBoxList oCheckListFunction = (CheckBoxList)oArgs.Item.FindControl("chkListFunction");
			string strSelFunction="";			//当前选择的功能权限
			for(int i=0;i<=oCheckListFunction.Items.Count-1;i++)
			{
				if(oCheckListFunction.Items[i].Selected==true)
				{
					strSelFunction += oCheckListFunction.Items[i].Value+",";
				}
				
			}
			strSelFunction = strSelFunction.Substring(0,strSelFunction.Length-1);
			char sepSign=',';
			string[] arrSelFunction = strSelFunction.Split(sepSign);
			AdminC oAdmin = new AdminC();
			if(oAdmin.UpdateOperatorAdminState(SQLCONNSTRING,oIsPower.SelectedValue,oIsAdmin.SelectedValue,oIsNoUsed.SelectedValue,strOperatorId,arrSelFunction,out ErrDesc))
			{
				Response.Write ("更新操作员状态成功!");
			}
			else
			{
				Response.Write ("发生错误:"+ErrDesc);
			}
		}
		public void ChangePage(object oSender,DataGridPageChangedEventArgs objArgs)
		{
			dgrOperator.CurrentPageIndex = objArgs.NewPageIndex;
			InitList();
			labCurrentPage.Text = (dgrOperator.CurrentPageIndex+1).ToString();
		}
		public void OperatorCancel(object oSource,DataGridCommandEventArgs oArgs)
		{
			this.dgrOperator.EditItemIndex = -1;
			this.InitList();
		}
		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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