第二步:
在 Form1.cs 中完成以下代码
using Dome16_三次锁定.service;
using Dome16_三次锁定.service.serviceimpl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace Dome16_三次锁定
{public partial class Form1 : Form{private userService userService;public Form1(){InitializeComponent();userService = new userServiceimpl();}private void button1_Click(object sender, EventArgs e){string name = UserName.Text.Trim();string pwd = UserPwd.Text.Trim();if (userService.IsLock(name)) // 在15分钟内 是否连接输入错误3次{MessageBox.Show("当前账号已经锁定, 请15分钟之后重试");}else{if (userService.IsLoginSuccess(name,pwd)){MessageBox.Show("登入成功");userService.UpdateErrorTime(name); // 次数归零}else{MessageBox.Show("登入失败");userService.UpdateLoginTime_ErrorTime(name);}}}private void button2_Click(object sender, EventArgs e){string name = RegName.Text.Trim();string pwd = RegPwd.Text.Trim();if(userService.IsRegister(name, pwd)){MessageBox.Show("注册成功");}else{MessageBox.Show("用户已经存在!");}}}
}
最后就得完成数据库的表