private void btnreg_Click(object sender, EventArgs e) { UserInfo userNew = new UserInfo(); userNew.UserName = txtName.Text; userNew.UserPwd =Encryption(txtPsw.Text); userNew.UserPhone = txtPho.Text; userNew.Flag = 0; userNew.UserDelFlag = 0; //给UserAccount赋值 由于UserAccount不能设置为自动增长,随机数又的检测重复,所以我再次只获取用户的数量,根据用户数量给用户设置登录账号 UserInfoBLL userBLL = new UserInfoBLL(); int userCount = userBLL.GetUserCountByUserDelFlag(0); userNew.UserAccount = GetUserAccountByUserCount(userCount); int msg = userBLL.InsertUserInfo(userNew);//1成功 0失败 //查看是否注册成功 成功:给用户返回登录账号,关闭注册窗体 失败:显示直接停留在注册窗体 if (msg==1) { MessageBox.Show("注册成功,请牢记您的登录账号:" + userNew.UserAccount); this.Close(); } else { MessageBox.Show("注册失败,请重新注册"); txtName.Text = ""; txtPho.Text = ""; txtPsw.Text = ""; } }
private void btnOk_Click(object sender, EventArgs e) { //获取输入内容 string account = txtAccount.Text; string name = txtName.Text; string phone = txtPhone.Text; //根据输入的内容,在数据库中查找有没有这条记录,有的话返回用户的id,修改密码(随机生成) UserInfoBLL userBLL = new UserInfoBLL(); string msg = userBLL.UpdatePwd(account, name, phone); MessageBox.Show(msg); txtPhone.Text = ""; txtName.Text = ""; txtAccount.Text = ""; }