private void btnSend_Click(object sender, EventArgs e) { if (AccessOperation.Exists("Select * From Login where UserName = '******'") == false) { MessageBox.Show("该用户不存在!"); txtUser.Text = ""; txtEmail.Text = ""; return; } if (AccessOperation.Exists("Select * From Login where UserName = '******' and Email = '" + txtEmail.Text + "'") == false) { MessageBox.Show("邮箱未与该用户绑定!"); txtEmail.Text = ""; return; } try { string sendName = "*****@*****.**"; string sendPass = "******"; string reciveName = txtEmail.Text; string title = "电影爱好者平台验证码"; Random rd = new Random(); code1 = rd.Next(100000, 999999); string content = code1.ToString(); SendEmail(sendName, sendPass, reciveName, title, content, "smtp.qq.com"); timer1.Start(); t = 60; } catch { MessageBox.Show("验证码发送失败!"); } }
private void btnPost_Click(object sender, EventArgs e) { if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'") == false) { MessageBox.Show("原密码错误!"); txtps1.Text = ""; txtps2.Text = ""; txtps3.Text = ""; return; } if (txtps1.Text == "" || txtps2.Text == "" || txtps3.Text == "") { MessageBox.Show("更改密码所需信息不能为空!"); return; } Regex pattern_password = new Regex(@"[\da-zA-Z0-9]{6,15}"); if (!pattern_password.IsMatch(txtps2.Text)) { MessageBox.Show("密码应为6到15位字母或数字!"); txtps2.Text = ""; txtps3.Text = ""; return; } if (!txtps2.Text.Equals(txtps3.Text)) { MessageBox.Show("两次输入的新密码不同!"); txtps2.Text = ""; txtps3.Text = ""; return; } try { AccessOperation.ExecuteNonQuery("Update [Login] Set [Password]='" + txtps2.Text + "' Where [UserName]='" + username + "'"); MessageBox.Show("修改完成!"); }catch { MessageBox.Show("修改失败!"); } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtPwd.Text.Length == 0 || cbUser.Text.Length == 0) { MessageBox.Show("用户名或密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (AccessOperation.Exists("Select * From Login where UserName='******'") == false) { MessageBox.Show("用户不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'") == false) { MessageBox.Show("密码错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where Password = '******' and UserName = '******'")) { username = cbUser.Text; MessageBox.Show("欢迎使用电影爱好者平台!"); if (!AccessOperation.Exists("Select * From UsedUser where UserName = '******'")) { try { AccessOperation.ExecuteNonQuery("Insert Into [UsedUser] VALUES('" + cbUser.Text + "')"); }catch { MessageBox.Show("未能插入本次登陆记录"); } } this.Hide(); this.skinEngine1.SkinFile = @"Skins\" + AccessOperation.ExecuteScalar("Select Style From Messages where UserName = '******'"); new Main(username).Show(); return; } }
private void btnRegister_Click(object sender, EventArgs e) { Regex pattern_email = new Regex(@"^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$"); Regex pattern_username = new Regex(@"[\da-zA-Z0-9]{2,10}"); Regex pattern_password = new Regex(@"[\da-zA-Z0-9]{6,15}"); if (txtUser.Text.Length == 0) { MessageBox.Show("用户名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtEmail.Text.Length == 0) { MessageBox.Show("邮箱不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtPwd.Text.Length == 0) { MessageBox.Show("密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AccessOperation.Exists("Select * From Login where UserName='******'") != false) { MessageBox.Show("用户名重复!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUser.Text = ""; return; } if (!pattern_username.IsMatch(txtUser.Text)) { MessageBox.Show("用户名应为2到10位字母或数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUser.Text = ""; return; } if (AccessOperation.Exists("Select * From Login where Email='" + txtEmail.Text + "'")) { MessageBox.Show("邮箱已使用!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Text = ""; return; } if (!pattern_email.IsMatch(txtEmail.Text)) { MessageBox.Show("邮箱格式错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Text = ""; return; } if (!pattern_password.IsMatch(txtUser.Text)) { MessageBox.Show("密码应为6到15位字母或数字!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPwd.Text = ""; txtRepeat.Text = ""; return; } if (txtRepeat.Text.Equals(txtPwd.Text) == false) { MessageBox.Show("密码两次输入不相同!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPwd.Text = ""; txtRepeat.Text = ""; return; } AccessOperation.ExecuteNonQuery("Insert Into [Login] ([UserName], [Password], [Email]) VALUES('" + txtUser.Text + "', '" + txtPwd.Text + "', '" + txtEmail.Text + "')"); MessageBox.Show("注册成功!"); this.Hide(); new InputMessages(txtUser.Text).Show(); return; }