📄 frmusermanagement.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;
using System.Drawing.Printing;
namespace SupermarketProject
{
/// <summary>
/// Summary description for UserManagement.
/// </summary>
public class frmUserManagement : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox grpSearch;
private System.Windows.Forms.Label lblEName;
private System.Windows.Forms.Label lblUId;
private System.Windows.Forms.TextBox txtEName;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.DataGrid dbgDispEmp;
private System.Windows.Forms.GroupBox grpUsrDet;
private System.Windows.Forms.Label lblUsrId;
private System.Windows.Forms.Label lblEmployee;
private System.Windows.Forms.Label lblPriority;
private System.Windows.Forms.Label lblPwd;
private System.Windows.Forms.TextBox txtUsrId;
private System.Windows.Forms.TextBox txtEmpName;
private System.Windows.Forms.CheckedListBox chlPrior;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.CheckBox chkEStat;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.CheckBox chkEmpStat;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.GroupBox grpLine;
private System.Windows.Forms.TextBox txtEmailId;
private System.Windows.Forms.Label lblEmailId;
private System.Windows.Forms.ComboBox cboUId;
private System.Windows.Forms.Button btnPwd;
private System.Windows.Forms.Button btnNew;
private System.Windows.Forms.HelpProvider hlpUsrMgmt;
private System.Windows.Forms.ToolTip tipUsrMgmt;
private System.ComponentModel.IContainer components;
//variable for printing heading on printout
private System.Windows.Forms.Label lblHeading;
//variable to read from database
private OleDbDataReader reader;
private DataGridPrinter dataGridPrinter = null;
//Variable for storing the cumulative priority value
public int cumPriorVal;
//Integer Array for storing the priority value from the Table
public int[] arrPrior = new int[4];
//Structure variable
public stEmployee stEmp;
//Search Value variable for passing the values of fields
public string[] searchValue;
//Variable for storing the Employee status CheckBox field
public bool EmpStatus;
//Declare DataTable for setting DataGrid source
public DataTable dtab;
public string errorMsg;
public bool pwdStat;
private System.Windows.Forms.Button btnPrintPreview;
private System.Windows.Forms.PrintDialog pdlgUser;
private System.Windows.Forms.PrintPreviewDialog ppdlgUser;
private System.Drawing.Printing.PrintDocument pDocUser;
private System.Windows.Forms.ErrorProvider errEmp;
public bool stat = true;
private Settings settings;
public frmUserManagement()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
settings =new Settings();
this.hlpUsrMgmt.HelpNamespace=settings.uiDirectory+ @"\HELP\SupermarketHelp.chm";
//
// TODO: Add any constructor code after InitializeComponent call
// Initializing the variable searchValue
searchValue = new string[3];
//Initializing a variable of Struct stEmployee
//stEmp = new stEmployee();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
[STAThread]
static void Main()
{
Application.Run(new frmUserManagement());
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmUserManagement));
this.grpSearch = new System.Windows.Forms.GroupBox();
this.cboUId = new System.Windows.Forms.ComboBox();
this.chkEStat = new System.Windows.Forms.CheckBox();
this.btnSearch = new System.Windows.Forms.Button();
this.lblUId = new System.Windows.Forms.Label();
this.lblEName = new System.Windows.Forms.Label();
this.txtEName = new System.Windows.Forms.TextBox();
this.dbgDispEmp = new System.Windows.Forms.DataGrid();
this.grpUsrDet = new System.Windows.Forms.GroupBox();
this.btnPwd = new System.Windows.Forms.Button();
this.txtEmailId = new System.Windows.Forms.TextBox();
this.chkEmpStat = new System.Windows.Forms.CheckBox();
this.chlPrior = new System.Windows.Forms.CheckedListBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.txtEmpName = new System.Windows.Forms.TextBox();
this.txtUsrId = new System.Windows.Forms.TextBox();
this.lblEmployee = new System.Windows.Forms.Label();
this.lblUsrId = new System.Windows.Forms.Label();
this.lblPriority = new System.Windows.Forms.Label();
this.lblPwd = new System.Windows.Forms.Label();
this.lblEmailId = new System.Windows.Forms.Label();
this.lblHeading = new System.Windows.Forms.Label();
this.btnNew = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.btnPrint = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.grpLine = new System.Windows.Forms.GroupBox();
this.errEmp = new System.Windows.Forms.ErrorProvider();
this.hlpUsrMgmt = new System.Windows.Forms.HelpProvider();
this.ppdlgUser = new System.Windows.Forms.PrintPreviewDialog();
this.pDocUser = new System.Drawing.Printing.PrintDocument();
this.tipUsrMgmt = new System.Windows.Forms.ToolTip(this.components);
this.btnPrintPreview = new System.Windows.Forms.Button();
this.pdlgUser = new System.Windows.Forms.PrintDialog();
this.grpSearch.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dbgDispEmp)).BeginInit();
this.grpUsrDet.SuspendLayout();
this.SuspendLayout();
//
// grpSearch
//
this.grpSearch.Controls.Add(this.cboUId);
this.grpSearch.Controls.Add(this.chkEStat);
this.grpSearch.Controls.Add(this.btnSearch);
this.grpSearch.Controls.Add(this.lblUId);
this.grpSearch.Controls.Add(this.lblEName);
this.grpSearch.Controls.Add(this.txtEName);
this.grpSearch.Location = new System.Drawing.Point(10, 9);
this.grpSearch.Name = "grpSearch";
this.grpSearch.Size = new System.Drawing.Size(825, 51);
this.grpSearch.TabIndex = 0;
this.grpSearch.TabStop = false;
this.grpSearch.Text = "选择一个或多个参数进行搜索";
//
// cboUId
//
this.cboUId.Location = new System.Drawing.Point(346, 17);
this.cboUId.Name = "cboUId";
this.cboUId.Size = new System.Drawing.Size(124, 20);
this.cboUId.TabIndex = 6;
this.cboUId.MouseHover += new System.EventHandler(this.cboUId_MouseHover);
//
// chkEStat
//
this.chkEStat.Location = new System.Drawing.Point(557, 17);
this.chkEStat.Name = "chkEStat";
this.chkEStat.Size = new System.Drawing.Size(125, 26);
this.chkEStat.TabIndex = 5;
this.chkEStat.Text = "活动";
this.chkEStat.MouseHover += new System.EventHandler(this.chkEStat_MouseHover);
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(720, 17);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(96, 26);
this.btnSearch.TabIndex = 4;
this.btnSearch.Text = "搜索";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// lblUId
//
this.lblUId.Location = new System.Drawing.Point(288, 17);
this.lblUId.Name = "lblUId";
this.lblUId.Size = new System.Drawing.Size(58, 25);
this.lblUId.TabIndex = 1;
this.lblUId.Text = "用户标识";
this.lblUId.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblEName
//
this.lblEName.Location = new System.Drawing.Point(10, 17);
this.lblEName.Name = "lblEName";
this.lblEName.Size = new System.Drawing.Size(105, 25);
this.lblEName.TabIndex = 0;
this.lblEName.Text = "职员姓名";
this.lblEName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtEName
//
this.txtEName.Location = new System.Drawing.Point(134, 17);
this.txtEName.Name = "txtEName";
this.txtEName.Size = new System.Drawing.Size(120, 21);
this.txtEName.TabIndex = 2;
this.txtEName.Text = "";
this.txtEName.MouseHover += new System.EventHandler(this.txtEName_MouseHover);
//
// dbgDispEmp
//
this.dbgDispEmp.DataMember = "";
this.dbgDispEmp.Enabled = false;
this.dbgDispEmp.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dbgDispEmp.Location = new System.Drawing.Point(10, 78);
this.dbgDispEmp.Name = "dbgDispEmp";
this.dbgDispEmp.ReadOnly = true;
this.dbgDispEmp.Size = new System.Drawing.Size(432, 301);
this.dbgDispEmp.TabIndex = 1;
this.dbgDispEmp.DoubleClick += new System.EventHandler(this.dbgDispEmp_DoubleClick);
//
// grpUsrDet
//
this.grpUsrDet.Controls.Add(this.btnPwd);
this.grpUsrDet.Controls.Add(this.txtEmailId);
this.grpUsrDet.Controls.Add(this.chkEmpStat);
this.grpUsrDet.Controls.Add(this.chlPrior);
this.grpUsrDet.Controls.Add(this.txtPwd);
this.grpUsrDet.Controls.Add(this.txtEmpName);
this.grpUsrDet.Controls.Add(this.txtUsrId);
this.grpUsrDet.Controls.Add(this.lblEmployee);
this.grpUsrDet.Controls.Add(this.lblUsrId);
this.grpUsrDet.Controls.Add(this.lblPriority);
this.grpUsrDet.Controls.Add(this.lblPwd);
this.grpUsrDet.Controls.Add(this.lblEmailId);
this.grpUsrDet.Location = new System.Drawing.Point(451, 78);
this.grpUsrDet.Name = "grpUsrDet";
this.grpUsrDet.Size = new System.Drawing.Size(423, 301);
this.grpUsrDet.TabIndex = 2;
this.grpUsrDet.TabStop = false;
this.grpUsrDet.Text = "用户详细信息";
//
// btnPwd
//
this.btnPwd.Enabled = false;
this.btnPwd.Location = new System.Drawing.Point(278, 224);
this.btnPwd.Name = "btnPwd";
this.btnPwd.Size = new System.Drawing.Size(135, 26);
this.btnPwd.TabIndex = 8;
this.btnPwd.Text = "修改密码";
this.btnPwd.Click += new System.EventHandler(this.btnPwd_Click);
//
// txtEmailId
//
this.txtEmailId.Location = new System.Drawing.Point(134, 258);
this.txtEmailId.Name = "txtEmailId";
this.txtEmailId.Size = new System.Drawing.Size(120, 21);
this.txtEmailId.TabIndex = 7;
this.txtEmailId.Text = "";
this.txtEmailId.Validating += new System.ComponentModel.CancelEventHandler(this.txtEmailId_Validating);
this.txtEmailId.Validated += new System.EventHandler(this.txtEmailId_Validated);
this.txtEmailId.MouseHover += new System.EventHandler(this.txtEmailId_MouseHover);
//
// chkEmpStat
//
this.chkEmpStat.Location = new System.Drawing.Point(307, 26);
this.chkEmpStat.Name = "chkEmpStat";
this.chkEmpStat.Size = new System.Drawing.Size(106, 26);
this.chkEmpStat.TabIndex = 6;
this.chkEmpStat.Text = "活动";
this.chkEmpStat.CheckedChanged += new System.EventHandler(this.chkEmpStat_CheckedChanged);
//
// chlPrior
//
this.chlPrior.Location = new System.Drawing.Point(125, 103);
this.chlPrior.Name = "chlPrior";
this.chlPrior.Size = new System.Drawing.Size(144, 84);
this.chlPrior.TabIndex = 5;
this.chlPrior.Leave += new System.EventHandler(this.chlPrior_Leave);
this.chlPrior.MouseHover += new System.EventHandler(this.chlPrior_MouseHover);
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(134, 224);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(120, 21);
this.txtPwd.TabIndex = 4;
this.txtPwd.Text = "";
this.txtPwd.MouseHover += new System.EventHandler(this.txtPwd_MouseHover);
//
// txtEmpName
//
this.txtEmpName.Location = new System.Drawing.Point(134, 69);
this.txtEmpName.Name = "txtEmpName";
this.txtEmpName.Size = new System.Drawing.Size(120, 21);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -