private void btnSubmit_Click(object sender, EventArgs e) { if (txtUserName.Text.Trim() == "") { MessageBox.Show("用户名不能为空!"); return; } BLL.user_info userBll = new BLL.user_info(); if (userBll.GetModel(txtUserName.Text.Trim()) != null) { MessageBox.Show("用户名已存在!"); return; } if (txtUserPwd.Text == "") { MessageBox.Show("密码不能为空!"); return; } if (txtCrmPwd.Text != txtUserPwd.Text) { MessageBox.Show("两次输入的密码不相同!"); return; } Model.user_info userModel = new Model.user_info(); userModel.user_name = txtUserName.Text.Trim(); userModel.user_isadmin = rdBtnYes.Checked; userModel.user_pwd = Maticsoft.Common.PasswordEncrypt.EncryptDES(txtUserPwd.Text); userModel.user_tel = txtUserTel.Text.Trim(); userModel.user_email = txtUserEmail.Text.Trim(); userModel.user_remark = rchTxtUserRemark.Text.Trim(); userBll.Add(userModel); this.Close(); }
private void btnLogin_Click(object sender, EventArgs e) { BLL.user_info userBll = new BLL.user_info(); Model.user_info userModel = new Model.user_info(); string userName = txtUser.Text; string userPwd = txtPwd.Text; userModel = userBll.GetModel(userName); if (userModel == null) { MessageBox.Show("用户不存在!"); return; } if (Maticsoft.Common.PasswordEncrypt.EncryptDES(userPwd) == userModel.user_pwd) { cfa.AppSettings.Settings["lastUser"].Value = userName; if (chkbxRmbrPwd.Checked) { cfa.AppSettings.Settings["lastUserPwd"].Value = Maticsoft.Common.PasswordEncrypt.EncryptDES(userPwd); } else { cfa.AppSettings.Settings["lastUserPwd"].Value = ""; } cfa.Save(); constants.currentUser = userModel; this.Hide(); MainForm main = new MainForm(); main.Show(); } else { MessageBox.Show("密码错误!"); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (txtUserName.Text.Trim() == "") { MessageBox.Show("用户名不能为空!"); return; } BLL.user_info userBll = new BLL.user_info(); Model.user_info userModel = userBll.GetModel(txtUserName.Text.Trim()); if (userModel != null && userModel.user_id != this.editUser.user_id) { MessageBox.Show("用户名已存在!"); return; } editUser.user_name = txtUserName.Text.Trim(); editUser.user_tel = txtUserTel.Text.Trim(); editUser.user_isadmin = rdBtnYes.Checked; editUser.user_email = txtUserEmail.Text.Trim(); editUser.user_remark = rchTxtUserRemark.Text.Trim(); userBll.Update(editUser); MessageBox.Show("修改成功!"); this.Close(); }