惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - chenglingr

C#三层ATM-12.资产查询 C#三层ATM-13.ATM开户 C#三层ATM-10.改密码 C#三层ATM-11.查看交易信息 C#三层ATM-9.转账功能设计 C#三层ATM-7.挂失 C#三层ATM-8.存款、取款功能设计 C#三层ATM-6.查询账户基本信息 C#三层ATM-4.ATM界面设计 C#三层ATM-3.编写数据库访问类 C#三层ATM-2.编写Model项目实体类 C#三层ATM-1.搭建三层ATM项目框架 C#三层ATM-0.数据表设计 MVC系列15-首页 MVC系列-13.前台文章显示页 MVC系列14-后台我的文章页 MVC系列-12.项目的重新规划 MVC系列-11.两表联合-发表文章 - chenglingr MVC系列-10.用户验证-导航条改造
C#三层ATM-5.登陆功能设计
chenglingr · 2016-06-06 · via 博客园 - chenglingr

登录功能设计

1.三层结构基本文件准备

1)在DAL项目里创建三个类文件,分别是cardinfo.cs、transInfo.cs、userInfo.cs

2)在BLL项目里同样创建三个类文件,分别是cardinfo.cs、transInfo.cs、userInfo.cs

3)把这些新添加的类都设置为公有的--public

wps875D.tmpwps879C.tmp

4)打开BLL项目里的cardinfo.cs添加类的只读私有字段。

private readonly DAL.cardinfo dal=new DAL.cardinfo();

如下:

wps87AD.tmpwps87BD.tmp

5)打开BLL项目里的transInfo.cs添加类的只读私有字段。

private readonly DAL.transInfo dal=new DAL.transInfo();

6)打开BLL项目里的userInfo.cs添加类的只读私有字段。

private readonly DAL.userInfo dal=new DAL.userInfo();

2.编写查询用户名密码是否存在的方法---DAL项目

1)打开DAL项目--cardinfo.cs文件,增加一个Exists方法

2)编写代码

wps87CE.tmp

3.编写BLL项目代码

1)打开BLL项目--cardinfo.cs文件,增加一个Exists方法

2)编写代码

wps87CF.tmp

4.打开winF项目下的登陆窗口Login

1)双击登录按钮,产生代码。

private void button1_Click(object sender, EventArgs e)

2)双击取消按钮,产生代码:

private void button2_Click(object sender, EventArgs e)

3)为login窗体类,添加字段,表示卡号,用于数据传递。

public string CardID;

4)编写button1_Click方法

label3.Text = "";

string name = textBox1.Text;

string pwd = textBox2.Text;

            BLL.cardinfo bll = new BLL.cardinfo();//创建bll层对象

if (bll.Exists(name, pwd))  //调用方法

            {

                CardID = textBox1.Text;//保存卡号到字段

this.DialogResult = DialogResult.OK;//表示登陆成功

            }

else

            { label3.Text = "用户名密码错误!请重试"; }//显示错误信息

5)编写button2_Click方法

this.DialogResult = DialogResult.Cancel ;//表示登录不成功

整体代码如下:

wps87EF.tmp

5.打开main窗口,编写代码

1)为main窗体类添加卡号字段

public string CardID;

2)编写登录菜单项代码

wps87F0.tmp

3)编写退出账户菜单项、退出系统菜单的代码

wps8801.tmp