You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
437 lines
16 KiB
437 lines
16 KiB
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Stone.Common;
|
|
|
|
namespace Stone.User
|
|
{
|
|
/// <summary>
|
|
/// FUser 的摘要说明。
|
|
/// </summary>
|
|
public class frmUserManager : System.Windows.Forms.Form
|
|
{
|
|
private GroupBox groupBox2;
|
|
private Label label3;
|
|
private Label label1;
|
|
private TextBox t_username;
|
|
private GroupBox groupBox1;
|
|
private Button b_DelUser;
|
|
private ListView lst_User;
|
|
private ColumnHeader columnHeader1;
|
|
private Button b_AddUser;
|
|
private ColumnHeader columnHeader3;
|
|
private Label label4;
|
|
private TextBox t_usermemo;
|
|
private ColumnHeader columnHeader4;
|
|
private TextBox t_password;
|
|
private Button b_enabled1;
|
|
private Button b_enabled0;
|
|
private Button b_Authority;
|
|
/// <summary>
|
|
/// 必需的设计器变量。
|
|
/// </summary>
|
|
private System.ComponentModel.Container components = null;
|
|
|
|
public frmUserManager()
|
|
{
|
|
//
|
|
// Windows 窗体设计器支持所必需的
|
|
//
|
|
InitializeComponent();
|
|
|
|
//
|
|
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
|
|
//
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清理所有正在使用的资源。
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if(components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
base.Dispose( disposing );
|
|
}
|
|
|
|
#region Windows 窗体设计器生成的代码
|
|
/// <summary>
|
|
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
|
|
/// 此方法的内容。
|
|
/// </summary>
|
|
private void InitializeComponent()
|
|
{
|
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
|
this.t_password = new System.Windows.Forms.TextBox();
|
|
this.label4 = new System.Windows.Forms.Label();
|
|
this.t_usermemo = new System.Windows.Forms.TextBox();
|
|
this.b_AddUser = new System.Windows.Forms.Button();
|
|
this.label3 = new System.Windows.Forms.Label();
|
|
this.label1 = new System.Windows.Forms.Label();
|
|
this.t_username = new System.Windows.Forms.TextBox();
|
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
|
this.b_Authority = new System.Windows.Forms.Button();
|
|
this.b_enabled1 = new System.Windows.Forms.Button();
|
|
this.b_enabled0 = new System.Windows.Forms.Button();
|
|
this.b_DelUser = new System.Windows.Forms.Button();
|
|
this.lst_User = new System.Windows.Forms.ListView();
|
|
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
this.groupBox2.SuspendLayout();
|
|
this.groupBox1.SuspendLayout();
|
|
this.SuspendLayout();
|
|
//
|
|
// groupBox2
|
|
//
|
|
this.groupBox2.Controls.Add(this.t_password);
|
|
this.groupBox2.Controls.Add(this.label4);
|
|
this.groupBox2.Controls.Add(this.t_usermemo);
|
|
this.groupBox2.Controls.Add(this.b_AddUser);
|
|
this.groupBox2.Controls.Add(this.label3);
|
|
this.groupBox2.Controls.Add(this.label1);
|
|
this.groupBox2.Controls.Add(this.t_username);
|
|
this.groupBox2.Location = new System.Drawing.Point(16, 299);
|
|
this.groupBox2.Name = "groupBox2";
|
|
this.groupBox2.Size = new System.Drawing.Size(507, 166);
|
|
this.groupBox2.TabIndex = 1;
|
|
this.groupBox2.TabStop = false;
|
|
this.groupBox2.Text = "添加操作员";
|
|
//
|
|
// t_password
|
|
//
|
|
this.t_password.Location = new System.Drawing.Point(86, 52);
|
|
this.t_password.MaxLength = 20;
|
|
this.t_password.Name = "t_password";
|
|
this.t_password.Size = new System.Drawing.Size(278, 21);
|
|
this.t_password.TabIndex = 1;
|
|
//
|
|
// label4
|
|
//
|
|
this.label4.AutoSize = true;
|
|
this.label4.Location = new System.Drawing.Point(27, 86);
|
|
this.label4.Name = "label4";
|
|
this.label4.Size = new System.Drawing.Size(53, 12);
|
|
this.label4.TabIndex = 9;
|
|
this.label4.Text = "备 注:";
|
|
//
|
|
// t_usermemo
|
|
//
|
|
this.t_usermemo.Location = new System.Drawing.Point(86, 85);
|
|
this.t_usermemo.MaxLength = 20;
|
|
this.t_usermemo.Name = "t_usermemo";
|
|
this.t_usermemo.Size = new System.Drawing.Size(278, 21);
|
|
this.t_usermemo.TabIndex = 2;
|
|
//
|
|
// b_AddUser
|
|
//
|
|
this.b_AddUser.Location = new System.Drawing.Point(390, 54);
|
|
this.b_AddUser.Name = "b_AddUser";
|
|
this.b_AddUser.Size = new System.Drawing.Size(83, 59);
|
|
this.b_AddUser.TabIndex = 4;
|
|
this.b_AddUser.Text = "添加操作员";
|
|
this.b_AddUser.UseVisualStyleBackColor = true;
|
|
this.b_AddUser.Click += new System.EventHandler(this.b_AddUser_Click);
|
|
//
|
|
// label3
|
|
//
|
|
this.label3.AutoSize = true;
|
|
this.label3.Location = new System.Drawing.Point(27, 54);
|
|
this.label3.Name = "label3";
|
|
this.label3.Size = new System.Drawing.Size(53, 12);
|
|
this.label3.TabIndex = 4;
|
|
this.label3.Text = "密 码:";
|
|
//
|
|
// label1
|
|
//
|
|
this.label1.AutoSize = true;
|
|
this.label1.Location = new System.Drawing.Point(27, 22);
|
|
this.label1.Name = "label1";
|
|
this.label1.Size = new System.Drawing.Size(53, 12);
|
|
this.label1.TabIndex = 1;
|
|
this.label1.Text = "操作员:";
|
|
//
|
|
// t_username
|
|
//
|
|
this.t_username.Location = new System.Drawing.Point(86, 19);
|
|
this.t_username.MaxLength = 20;
|
|
this.t_username.Name = "t_username";
|
|
this.t_username.Size = new System.Drawing.Size(278, 21);
|
|
this.t_username.TabIndex = 0;
|
|
//
|
|
// groupBox1
|
|
//
|
|
this.groupBox1.Controls.Add(this.b_Authority);
|
|
this.groupBox1.Controls.Add(this.b_enabled1);
|
|
this.groupBox1.Controls.Add(this.b_enabled0);
|
|
this.groupBox1.Controls.Add(this.b_DelUser);
|
|
this.groupBox1.Controls.Add(this.lst_User);
|
|
this.groupBox1.Location = new System.Drawing.Point(16, 12);
|
|
this.groupBox1.Name = "groupBox1";
|
|
this.groupBox1.Size = new System.Drawing.Size(507, 272);
|
|
this.groupBox1.TabIndex = 0;
|
|
this.groupBox1.TabStop = false;
|
|
this.groupBox1.Text = "操作员列表";
|
|
//
|
|
// b_Authority
|
|
//
|
|
this.b_Authority.Location = new System.Drawing.Point(406, 217);
|
|
this.b_Authority.Name = "b_Authority";
|
|
this.b_Authority.Size = new System.Drawing.Size(83, 33);
|
|
this.b_Authority.TabIndex = 4;
|
|
this.b_Authority.Text = "操作员权限";
|
|
this.b_Authority.UseVisualStyleBackColor = true;
|
|
this.b_Authority.Click += new System.EventHandler(this.b_Authority_Click);
|
|
//
|
|
// b_enabled1
|
|
//
|
|
this.b_enabled1.Location = new System.Drawing.Point(276, 217);
|
|
this.b_enabled1.Name = "b_enabled1";
|
|
this.b_enabled1.Size = new System.Drawing.Size(83, 33);
|
|
this.b_enabled1.TabIndex = 3;
|
|
this.b_enabled1.Text = "允许操作员";
|
|
this.b_enabled1.UseVisualStyleBackColor = true;
|
|
this.b_enabled1.Click += new System.EventHandler(this.b_enabled1_Click);
|
|
//
|
|
// b_enabled0
|
|
//
|
|
this.b_enabled0.Location = new System.Drawing.Point(146, 217);
|
|
this.b_enabled0.Name = "b_enabled0";
|
|
this.b_enabled0.Size = new System.Drawing.Size(83, 33);
|
|
this.b_enabled0.TabIndex = 2;
|
|
this.b_enabled0.Text = "禁用操作员";
|
|
this.b_enabled0.UseVisualStyleBackColor = true;
|
|
this.b_enabled0.Click += new System.EventHandler(this.b_enabled0_Click);
|
|
//
|
|
// b_DelUser
|
|
//
|
|
this.b_DelUser.Location = new System.Drawing.Point(16, 217);
|
|
this.b_DelUser.Name = "b_DelUser";
|
|
this.b_DelUser.Size = new System.Drawing.Size(83, 33);
|
|
this.b_DelUser.TabIndex = 1;
|
|
this.b_DelUser.Text = "删除操作员";
|
|
this.b_DelUser.UseVisualStyleBackColor = true;
|
|
this.b_DelUser.Click += new System.EventHandler(this.b_DelUser_Click);
|
|
//
|
|
// lst_User
|
|
//
|
|
this.lst_User.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
|
this.columnHeader1,
|
|
this.columnHeader3,
|
|
this.columnHeader4});
|
|
this.lst_User.FullRowSelect = true;
|
|
this.lst_User.HideSelection = false;
|
|
this.lst_User.Location = new System.Drawing.Point(16, 24);
|
|
this.lst_User.Name = "lst_User";
|
|
this.lst_User.Size = new System.Drawing.Size(473, 187);
|
|
this.lst_User.TabIndex = 0;
|
|
this.lst_User.UseCompatibleStateImageBehavior = false;
|
|
this.lst_User.View = System.Windows.Forms.View.Details;
|
|
//
|
|
// columnHeader1
|
|
//
|
|
this.columnHeader1.Text = "操作员";
|
|
this.columnHeader1.Width = 111;
|
|
//
|
|
// columnHeader3
|
|
//
|
|
this.columnHeader3.Text = "状态";
|
|
this.columnHeader3.Width = 101;
|
|
//
|
|
// columnHeader4
|
|
//
|
|
this.columnHeader4.Text = "备注";
|
|
this.columnHeader4.Width = 138;
|
|
//
|
|
// frmUserManager
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
|
|
this.ClientSize = new System.Drawing.Size(537, 477);
|
|
this.Controls.Add(this.groupBox1);
|
|
this.Controls.Add(this.groupBox2);
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
|
this.Name = "frmUserManager";
|
|
this.ShowInTaskbar = false;
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
this.Text = "操作员管理";
|
|
this.Load += new System.EventHandler(this.FUser_Load);
|
|
this.groupBox2.ResumeLayout(false);
|
|
this.groupBox2.PerformLayout();
|
|
this.groupBox1.ResumeLayout(false);
|
|
this.ResumeLayout(false);
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void FUser_Load(object sender, EventArgs e)
|
|
{
|
|
UpdateListView();
|
|
}
|
|
|
|
private void UpdateListView()
|
|
{
|
|
try
|
|
{
|
|
DataSet dsUser = F_UserInfo.GetListAll();
|
|
|
|
this.lst_User.Items.Clear();
|
|
foreach (DataRow drUser in dsUser.Tables[0].Rows)
|
|
{
|
|
this.lst_User.Items.Add(
|
|
new System.Windows.Forms.ListViewItem(
|
|
new string[] {
|
|
drUser["Name"].ToString(),
|
|
drUser["Enabled"].ToString() == "0" ? "禁用" : "允许",
|
|
drUser["Memo"].ToString()
|
|
}, -1)
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void b_DelUser_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.lst_User.SelectedItems.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
string user_name = this.lst_User.SelectedItems[0].Text.Trim();
|
|
if (MyMessageBox.ShowQuestion("你确实要删除 " + user_name + "?"))
|
|
{
|
|
F_UserInfo.Del(user_name);
|
|
UpdateListView();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MyMessageBox.ShowInfoMessage("请选取要删除的操作员!");
|
|
}
|
|
}
|
|
|
|
private void b_AddUser_Click(object sender, EventArgs e)
|
|
{
|
|
string user_name = MyStrings.GetString(this.t_username.Text.Trim());
|
|
string user_memo = MyStrings.GetString(this.t_usermemo.Text.Trim());
|
|
string user_password = MyStrings.EncryptStr(this.t_password.Text.Trim());
|
|
|
|
|
|
if (user_name.Equals(string.Empty))
|
|
{
|
|
MessageBox.Show("操作员不能为空!");
|
|
this.t_username.Focus();
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
F_UserInfo.Add(user_name, user_password, user_memo);
|
|
|
|
UpdateListView();
|
|
|
|
MyMessageBox.ShowInfoMessage(user_name + " 添加成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
private void b_enabled0_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.lst_User.SelectedItems.Count > 0)
|
|
{
|
|
string user_name = this.lst_User.SelectedItems[0].Text.Trim();
|
|
|
|
if (user_name.Equals("admin"))
|
|
{
|
|
MessageBox.Show("admin 不能执行该操作!");
|
|
return;
|
|
}
|
|
|
|
if (MyMessageBox.ShowQuestion("是否要禁用 " + user_name + " ?"))
|
|
{
|
|
F_UserInfo.Edit(user_name, 0);
|
|
|
|
UpdateListView();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MyMessageBox.ShowErrorMessage("请选取要禁用的操作员!");
|
|
}
|
|
}
|
|
|
|
private void b_enabled1_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.lst_User.SelectedItems.Count > 0)
|
|
{
|
|
string user_name = this.lst_User.SelectedItems[0].Text.Trim();
|
|
|
|
if (user_name.Equals("admin"))
|
|
{
|
|
MessageBox.Show("admin 不能执行该操作!");
|
|
return;
|
|
}
|
|
|
|
if (MyMessageBox.ShowQuestion("是否要启用 " + user_name + " ?"))
|
|
{
|
|
F_UserInfo.Edit(user_name, 1);
|
|
UpdateListView();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MyMessageBox.ShowErrorMessage("请选取要启用的操作员!");
|
|
}
|
|
}
|
|
|
|
private void b_Authority_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.lst_User.SelectedItems.Count > 0)
|
|
{
|
|
string user_name = this.lst_User.SelectedItems[0].Text.Trim();
|
|
|
|
frmAuthority dialog = new frmAuthority();
|
|
dialog.Select_User_Name = user_name;
|
|
dialog.ShowDialog();
|
|
dialog.Dispose();
|
|
}
|
|
else
|
|
{
|
|
MyMessageBox.ShowInfoMessage("请先选取一个操作员!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MyMessageBox.ShowErrorMessage(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|