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

📄 powermanage.cs

📁 工作流引擎
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.button1.Size = new System.Drawing.Size(90, 24);
			this.button1.TabIndex = 5;
			this.button1.Text = "添加";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.SystemColors.Control;
			this.button2.Enabled = false;
			this.button2.Location = new System.Drawing.Point(296, 496);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(90, 24);
			this.button2.TabIndex = 5;
			this.button2.Text = "删除";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button4
			// 
			this.button4.BackColor = System.Drawing.SystemColors.Control;
			this.button4.Location = new System.Drawing.Point(416, 496);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(90, 24);
			this.button4.TabIndex = 5;
			this.button4.Text = "关闭";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// dataGrid2
			// 
			this.dataGrid2.CaptionVisible = false;
			this.dataGrid2.DataMember = "";
			this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid2.Location = new System.Drawing.Point(296, 32);
			this.dataGrid2.Name = "dataGrid2";
			this.dataGrid2.RowHeadersVisible = false;
			this.dataGrid2.Size = new System.Drawing.Size(320, 448);
			this.dataGrid2.TabIndex = 7;
			this.dataGrid2.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								  this.dataGridTableStyle2});
			// 
			// dataGridTableStyle2
			// 
			this.dataGridTableStyle2.DataGrid = this.dataGrid2;
			this.dataGridTableStyle2.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																												  this.dataGridTextBoxColumn4});
			this.dataGridTableStyle2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle2.MappingName = "t_admin";
			this.dataGridTableStyle2.ReadOnly = true;
			this.dataGridTableStyle2.RowHeadersVisible = false;
			// 
			// dataGridTextBoxColumn4
			// 
			this.dataGridTextBoxColumn4.Format = "";
			this.dataGridTextBoxColumn4.FormatInfo = null;
			this.dataGridTextBoxColumn4.HeaderText = "操作名称";
			this.dataGridTextBoxColumn4.MappingName = "functionname";
			this.dataGridTextBoxColumn4.NullText = "";
			this.dataGridTextBoxColumn4.ReadOnly = true;
			this.dataGridTextBoxColumn4.Width = 300;
			// 
			// button5
			// 
			this.button5.BackColor = System.Drawing.SystemColors.Control;
			this.button5.Location = new System.Drawing.Point(168, 496);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(90, 24);
			this.button5.TabIndex = 5;
			this.button5.Text = "修改";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// AccessManage
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.AliceBlue;
			this.ClientSize = new System.Drawing.Size(624, 526);
			this.Controls.Add(this.dataGrid2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button5);
			this.Name = "AccessManage";
			this.Text = "权限管理";
			this.Load += new System.EventHandler(this.AccessManage_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button4_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void AccessManage_Load(object sender, System.EventArgs e)
		{
			myCon= MainForm.getConnection();
			myAdapter = new SqlDataAdapter();
			myAdapter.TableMappings.Add("Table","t_adminuser");			
			ds=new DataSet();
			DataTable dt = new DataTable("t_adminuser");
			ds.Tables.Add(dt);
			this.dataGrid1.SetDataBinding(ds,"t_adminuser");
			//绑定dataGrid1的数据源为 名为"t_adminuser" 的DataSet 
			myAdapter1 = new SqlDataAdapter();
			myAdapter1.TableMappings.Add("Table","power");
			SqlCommand cmd1 = myCon.CreateCommand();
			myAdapter1.SelectCommand=cmd1;
			DataTable dt1 = new DataTable("power");
			ds.Tables.Add(dt1);
			this.dataGrid2.SetDataBinding(ds,"power");
            //绑定dataGrid2的数据源为 名为"power" 的DataSet 
			SqlCommand cmd = myCon.CreateCommand();
			cmd.CommandText="select autoid, userid,replace(name,null,'未知') realname, "+
				" (sum(superadmin)) superadmin, round(avg(supplyID),0) supplyid from t_user,"+
				" t_adminuser where t_user.autoid=t_adminuser.userautoid group by autoid,userid,name";
			myAdapter.SelectCommand=cmd;
			ds.Tables["t_adminuser"].Clear();
			myAdapter.Fill(ds, "t_adminuser");
            //左侧dataGrid1 显示所有管理员用户列表
			DataColumn dc = new DataColumn();
			dc.DataType = System.Type.GetType("System.String");
			dc.ColumnName = "shortname";
			ds.Tables["t_adminuser"].Columns.Add(dc);			
		}
		public void getAdminUser()
		{
			
		}
		//当在左侧管理员列表 单击某个用户时 右侧显示该用户的权限列表
		private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
		{
			this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
			if(this.dataGrid1[this.dataGrid1.CurrentRowIndex,0].ToString().Trim().Equals(""))
				return;
			myAdapter1.SelectCommand.CommandText = "select (functionname) functionname "+
				"from t_adminuser where userautoid="+this.dataGrid1[this.dataGrid1.CurrentRowIndex,0];
			ds.Tables["power"].Clear();
			myAdapter1.Fill(ds,"power");
			SqlCommand cmd = myCon.CreateCommand();
			cmd.CommandText="select dirid from t_adminuser where dirid>0 and userautoid="
				+this.dataGrid1[this.dataGrid1.CurrentRowIndex,0];
			SqlDataReader oread = cmd.ExecuteReader();
			while ( oread.Read())
			{
				int dirID = oread.GetInt32(0);
			}
			oread.Close();				
		}
        //单击【删除】按钮 从管理员表删除 选中用户
		private void button2_Click(object sender, System.EventArgs e)
		{
			SqlCommand cmd = new SqlCommand("delete from t_adminuser where userautoid="
				+this.dataGrid1[this.dataGrid1.CurrentRowIndex,0],myCon);
			cmd.ExecuteNonQuery();
			ds.Tables["power"].Clear();
			ds.Tables["t_adminuser"].Clear();
			myAdapter.Fill(ds, "t_adminuser");
		}
        //单击【添加】按钮 打开AddAdmin 添加管理员权限窗体
		private void button1_Click(object sender, System.EventArgs e)
		{
			AddAdmin aa = new AddAdmin(myCon);
			aa.MyForm=(MainForm)this.MdiParent;
			if ( aa.ShowDialog()==DialogResult.OK)
			{
				ds.Tables["power"].Clear();
				ds.Tables["t_adminuser"].Clear();
				myAdapter.Fill(ds, "t_adminuser");
				this.getAdminUser();
			}
		}
        //单击【修改】按钮 打开AddAdmin 添加管理员权限窗体
		private void button5_Click(object sender, System.EventArgs e)
		{
			AddAdmin aa = new AddAdmin(myCon);
			aa.MyForm=(MainForm)this.MdiParent;
			aa.UserAutoID=Int32.Parse(this.dataGrid1[this.dataGrid1.CurrentRowIndex,0].ToString());
			aa.UserID = this.dataGrid1[this.dataGrid1.CurrentRowIndex,1].ToString();
			if ( aa.ShowDialog()==DialogResult.OK)
			{
				ds.Tables["power"].Clear();
				ds.Tables["t_adminuser"].Clear();
				myAdapter.Fill(ds, "t_adminuser");
				this.getAdminUser();
			}
		}
	}
}

⌨️ 快捷键说明

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