//登录函数 private void login() { //判断输入是否为空 if (cmbRole.Text.Trim() == "") { ShowAlertMessage("请选择用户角色!"); return; } if (cmbUserName.Text.Trim() == "") { ShowAlertMessage("请输入用户名!"); return; } if (txtPassword.Text.Trim() == "") { ShowAlertMessage("请输入密码"); return; } //获取输入框中输入的数据 Employees employees = new Employees(); employees.EMPLOYEERIGHT = cmbRole.Text.Trim(); employees.EMPLOYEENAME = cmbUserName.Text.Trim(); employees.EMPLOYEEPASSWORD = txtPassword.Text.Trim(); DataTable dt = new DataTable(); //实例化登录控制类 EmployeesManage empM = new EmployeesManage(); try { if (empM.LoginUser(employees, out dt)) { this.ShowMessage("登录成功!"); //frmCrkmanage fck = new frmCrkmanage(); //fck.btnScanner.Enabled = true; string UpdateInfo = dt.Rows[0]["EmployeeDepart"].ToString() + " " + dt.Rows[0]["EmployeeName"].ToString(); TransfEvent(UpdateInfo);//触发事件 this.Close(); } else { this.ShowErrorMessage("登录失败!"); } } catch (Exception e) { throw e; } }
private void btnRegister_Click(object sender, EventArgs e) { Employees employees = new Employees(); { employees.EMPLOYEEDEPART = cmbDepart.Text.Trim(); employees.EMPLOYEERIGHT = cmbRight.Text.Trim(); employees.EMPLOYEENAME = txtUserName.Text.Trim(); employees.EMPLOYEEPASSWORD = txtPassword.Text.Trim(); } EmployeesManage empM = new EmployeesManage(); if (empM.Add(employees)) { this.ShowMessage("注册成功!"); this.Close(); } else { this.ShowErrorMessage("注册失败,请重新注册!"); } }