📄 frmusermanagement.cs
字号:
this.txtEmpName.TabIndex = 3;
this.txtEmpName.Text = "";
this.txtEmpName.MouseHover += new System.EventHandler(this.txtEmpName_MouseHover);
//
// txtUsrId
//
this.txtUsrId.Location = new System.Drawing.Point(134, 26);
this.txtUsrId.Name = "txtUsrId";
this.txtUsrId.Size = new System.Drawing.Size(120, 21);
this.txtUsrId.TabIndex = 2;
this.txtUsrId.Text = "";
this.txtUsrId.MouseHover += new System.EventHandler(this.txtUsrId_MouseHover);
//
// lblEmployee
//
this.lblEmployee.Location = new System.Drawing.Point(10, 69);
this.lblEmployee.Name = "lblEmployee";
this.lblEmployee.Size = new System.Drawing.Size(120, 25);
this.lblEmployee.TabIndex = 1;
this.lblEmployee.Text = "职员姓名";
this.lblEmployee.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblUsrId
//
this.lblUsrId.Location = new System.Drawing.Point(10, 26);
this.lblUsrId.Name = "lblUsrId";
this.lblUsrId.Size = new System.Drawing.Size(67, 25);
this.lblUsrId.TabIndex = 0;
this.lblUsrId.Text = "用户标识";
this.lblUsrId.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblPriority
//
this.lblPriority.Location = new System.Drawing.Point(10, 112);
this.lblPriority.Name = "lblPriority";
this.lblPriority.Size = new System.Drawing.Size(120, 25);
this.lblPriority.TabIndex = 1;
this.lblPriority.Text = "优先级";
this.lblPriority.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblPwd
//
this.lblPwd.Location = new System.Drawing.Point(19, 224);
this.lblPwd.Name = "lblPwd";
this.lblPwd.Size = new System.Drawing.Size(120, 25);
this.lblPwd.TabIndex = 1;
this.lblPwd.Text = "密码";
this.lblPwd.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblEmailId
//
this.lblEmailId.Location = new System.Drawing.Point(19, 258);
this.lblEmailId.Name = "lblEmailId";
this.lblEmailId.Size = new System.Drawing.Size(120, 25);
this.lblEmailId.TabIndex = 1;
this.lblEmailId.Text = "电子邮件标识";
this.lblEmailId.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblHeading
//
this.lblHeading.Location = new System.Drawing.Point(0, 0);
this.lblHeading.Name = "lblHeading";
this.lblHeading.TabIndex = 0;
//
// btnNew
//
this.btnNew.Location = new System.Drawing.Point(451, 388);
this.btnNew.Name = "btnNew";
this.btnNew.Size = new System.Drawing.Size(90, 26);
this.btnNew.TabIndex = 3;
this.btnNew.Text = "新建(&N)";
this.btnNew.Click += new System.EventHandler(this.btnNew_Click);
this.btnNew.MouseHover += new System.EventHandler(this.btnNew_MouseHover);
//
// btnUpdate
//
this.btnUpdate.Location = new System.Drawing.Point(557, 388);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(90, 24);
this.btnUpdate.TabIndex = 3;
this.btnUpdate.Text = "更新(&U)";
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
this.btnUpdate.MouseHover += new System.EventHandler(this.btnUpdate_MouseHover);
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(662, 388);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(90, 24);
this.btnPrint.TabIndex = 3;
this.btnPrint.Text = "打印(&P)";
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
this.btnPrint.MouseHover += new System.EventHandler(this.btnPrint_MouseHover);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(768, 439);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(90, 25);
this.btnExit.TabIndex = 3;
this.btnExit.Text = "退出";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// grpLine
//
this.grpLine.Location = new System.Drawing.Point(10, 420);
this.grpLine.Name = "grpLine";
this.grpLine.Size = new System.Drawing.Size(864, 9);
this.grpLine.TabIndex = 4;
this.grpLine.TabStop = false;
//
// errEmp
//
this.errEmp.ContainerControl = this;
//
// hlpUsrMgmt
//
this.hlpUsrMgmt.HelpNamespace = "D:\\Project10102004\\HTM_FILES_FOR_HELP\\SUPERMARKETHELP.CHM";
//
// ppdlgUser
//
this.ppdlgUser.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.ppdlgUser.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.ppdlgUser.ClientSize = new System.Drawing.Size(400, 300);
this.ppdlgUser.Document = this.pDocUser;
this.ppdlgUser.Enabled = true;
this.ppdlgUser.Icon = ((System.Drawing.Icon)(resources.GetObject("ppdlgUser.Icon")));
this.ppdlgUser.Location = new System.Drawing.Point(630, 20);
this.ppdlgUser.MinimumSize = new System.Drawing.Size(375, 250);
this.ppdlgUser.Name = "ppdlgUser";
this.hlpUsrMgmt.SetShowHelp(this.ppdlgUser, false);
this.ppdlgUser.TransparencyKey = System.Drawing.Color.Empty;
this.ppdlgUser.Visible = false;
//
// pDocUser
//
this.pDocUser.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pDocUser_PrintPage);
//
// tipUsrMgmt
//
this.tipUsrMgmt.AutomaticDelay = 150;
//
// btnPrintPreview
//
this.btnPrintPreview.Enabled = false;
this.btnPrintPreview.Location = new System.Drawing.Point(768, 388);
this.btnPrintPreview.Name = "btnPrintPreview";
this.btnPrintPreview.Size = new System.Drawing.Size(96, 24);
this.btnPrintPreview.TabIndex = 5;
this.btnPrintPreview.Text = "打印预览(&R)";
this.btnPrintPreview.Click += new System.EventHandler(this.btnPrintPreview_Click);
//
// pdlgUser
//
this.pdlgUser.Document = this.pDocUser;
//
// frmUserManagement
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(883, 470);
this.Controls.Add(this.btnPrintPreview);
this.Controls.Add(this.grpLine);
this.Controls.Add(this.btnNew);
this.Controls.Add(this.grpUsrDet);
this.Controls.Add(this.dbgDispEmp);
this.Controls.Add(this.grpSearch);
this.Controls.Add(this.btnUpdate);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.btnExit);
this.Name = "frmUserManagement";
this.Text = "用户管理";
this.Closing += new System.ComponentModel.CancelEventHandler(this.frmUserManagement_Closing);
this.Load += new System.EventHandler(this.frmUserManagement_Load);
this.grpSearch.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dbgDispEmp)).EndInit();
this.grpUsrDet.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
//Method for calculating Cumulative priority
public void CalculateCumPriority()
{
this.cumPriorVal = 0;
// Cheking the total items in the CheckedListBox chlPrior
for(int ctr = 0; ctr<=this.chlPrior.Items.Count-1;ctr++)
{
//Checking the Selected Items in the CheckedListBox
if(this.chlPrior.GetItemChecked(ctr))
{
this.cumPriorVal += this.arrPrior[ctr];
}
}
}
// Method for Collecting Data from the form to the structure
private void CollectEmployeeData()
{
stEmp.UsrId = this.txtUsrId.Text;
stEmp.Passwd = this.txtPwd.Text;
stEmp.PriorityId = this.cumPriorVal;
stEmp.EmpName = this.txtEmpName.Text;
stEmp.EmpStatus = this.EmpStatus;
stEmp.EmailId = this.txtEmailId.Text;
}
private void btnNew_Click(object sender, System.EventArgs e)
{
//Creating an object of frmNewUser class
frmNewUser fnw = new frmNewUser();
fnw.ShowDialog();
}
private void frmUserManagement_Load(object sender, System.EventArgs e)
{
//Disable And Enable
this.btnUpdate.Enabled = false;
this.btnPrint.Enabled= false;
this.grpUsrDet.Enabled = false;
// Loading the fields PriorityId and priority
int ctr =0;
DataConnection.commnd.CommandText="select priorityid,priority from priority";
try
{
reader = DataConnection.commnd.ExecuteReader();
while(reader.Read())
{
//Loading the Priority Value to the CheckedListBox
this.chlPrior.Items.Add(reader.GetString(1));
//Storing the priorityId to the array arrPrior
arrPrior[ctr] = reader.GetInt32(0);
ctr++;
}
reader.Close();
}
catch(OleDbException myException)
{
MessageBox.Show(myException.Message);
this.Close();
}
//Populate combobox with the UsrID values from the table - cboUId
DataConnection.commnd.CommandText="select UsrId from Employees";
reader = DataConnection.commnd.ExecuteReader();
while(reader.Read())
{
this.cboUId.Items.Add(reader.GetString(0));
}
reader.Close();
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
//Calling the method CalculateCumPriority
this.CalculateCumPriority();
//Checking if any values changed in the textbox with respect to datagrid
if ((this.cumPriorVal != Convert.ToInt32(this.dbgDispEmp[this.dbgDispEmp.CurrentRowIndex,2])) || (this.txtEmpName.Text != this.dbgDispEmp[this.dbgDispEmp.CurrentRowIndex,3].ToString()) || (this.chkEmpStat.Checked != Convert.ToBoolean(this.dbgDispEmp[this.dbgDispEmp.CurrentRowIndex,4])) || (this.txtPwd.Text != this.dbgDispEmp[this.dbgDispEmp.CurrentRowIndex,1].ToString()) || (this.txtEmailId.Text != this.dbgDispEmp[this.dbgDispEmp.CurrentRowIndex,5].ToString()))
{
//if changed, call the CollectEmployeeData method
this.CollectEmployeeData();
//Creating an Object of UserManagement class and
// Calling the ModifyEmployee method by passing the structure variable stEmp
UserManagement UAdminMgmt = new UserManagement();
UAdminMgmt.ModifyEmployee(stEmp);
this.btnUpdate.Enabled=false;
this.txtUsrId.Enabled= true;
this.txtPwd.Enabled = true;
this.btnNew.Enabled = true;
this.btnSearch.Enabled = true;
this.btnPrint.Enabled = false;
this.btnPwd.Enabled = false;
this.pwdStat = false;
//Calling the btnSearch_Click method to update the datagrid
this.btnSearch_Click(sender,e);
//Calling the ClearDetails method to clear the values in fields
this.ClearDetails();
//disabling the user details group box
this.grpUsrDet.Enabled = false;
this.btnSearch.Focus();
}
}
//Method to clear the fields
private void ClearDetails()
{
this.txtUsrId.Text = "";
this.txtEmpName.Text="";
this.txtPwd.Text="";
this.chkEmpStat.Checked=false;
this.txtEmailId.Text="";
//Calling the ClearPriorities method -
// to clear the priority values from screen
this.ClearPriorities();
}
//Method to clear the priority values from screen
private void ClearPriorities()
{
//Clearing items in the CheckedListBox
int ctr= 0;
while(ctr < this.chlPrior.Items.Count)
{
this.chlPrior.SetItemChecked(ctr,false);
ctr++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -