不多废话,直接上效果图:

1录窗体

对应的代码:

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 Game
{
public partial class FrmLogin : Form
{
public FrmLogin()
{
InitializeComponent();
}
//点击x按钮触发的事件
private void btnclose_Click(object sender, EventArgs e)
{
//退出整个应用
Application.Exit();
} //点击注册按钮触发的事件
private void lblregister_Click(object sender, EventArgs e)
{
//隐藏当前窗体
this.Hide();
FrmRegist frm = new FrmRegist();
frm.fl = this;
frm.Show();
} //点击登录按钮触发的事件
private void btnlogin_Click(object sender, EventArgs e)
{
if (ProvingInfo()==true)
{
//定义变量接收文本框中的值
string email = txtemail.Text;
string password = txtpassword.Text;
bool happy = false;
foreach (LoginInfo item in LoginInfo.array)
{
if(item!=null)
{
if (item.Email.Equals(email) && item.Password.Equals(password))
{
happy = true;
//关闭当前窗体
this.Hide();
//显示主窗体
FrmMain frm = new FrmMain();
frm.loginame = item.Name;
frm.Show();
break;
} }
}
if(happy==false)
{
MessageBox.Show("登录失败!请检查邮箱和密码是否正确");
}
} }
//验证填写信息
public bool ProvingInfo()
{
if(txtemail.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请填写email");
this.txtemail.Focus();
return false;
}
else if (txtpassword.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请填写密码");
this.txtpassword.Focus();
return false;
}
else
{ return true;
} } //Load事件
private void FrmLogin_Load(object sender, EventArgs e)
{ LoginInfo info1 = new LoginInfo();
info1.Name = "泪洒星辰";
info1.Id = "";
info1.Email = "lsxc@163.com";
info1.Password = "pwd@123";
for (int i = ; i < LoginInfo.array.Length; i++)
{
if (LoginInfo.array[i] == null)
{
LoginInfo.array[i] = info1;
break;
}
} } }
}

2册窗体

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 Game
{
public partial class FrmRegist : Form
{
public FrmRegist()
{
InitializeComponent();
} private void textBox3_TextChanged(object sender, EventArgs e)
{ } private void label6_Click(object sender, EventArgs e)
{ }
//点击取消触发的事件
private void btnclose_Click(object sender, EventArgs e)
{
//关闭当前窗体
this.Close();
//显示上一级窗体
FrmLogin fl = new FrmLogin();
fl.Show(); } private void FrmRegist_Load(object sender, EventArgs e)
{ }
//定义窗体对象保存logininfo窗体传过来的值
public FrmLogin fl;
//点击注册触发的事件
private void btnregin_Click(object sender, EventArgs e)
{ if (ProvingInfo() == true)
{
//获取文本框中对应的值
string name = txtname.Text;
string email = txtemail.Text;
string cid = txtcid.Text;
string password = txtpassword.Text;
LoginInfo info = new LoginInfo();
info.Name = name;
info.Id = cid;
info.Email = email;
info.Password = password;
MessageBox.Show("注册成功!");
for (int i = ; i < LoginInfo.array.Length; i++)
{
if (LoginInfo.array[i] == null)
{
LoginInfo.array[i] = info;
break;
}
}
}
}
//验证填写信息
public bool ProvingInfo()
{
if(txtname.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请填写姓名");
this.txtname.Focus();
return false;
}
else if(txtcid.Text.Trim().Equals(string .Empty))
{
MessageBox.Show("请填身份证号码");
this.txtcid.Focus();
return false; }
else if (txtemail.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请填身份证号码");
this.txtemail.Focus();
return false; }
else if (txtpassword.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请填写密码");
this.txtpassword.Focus();
return false; }
else if (txtone.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请确认邮箱输入");
this.txtone.Focus();
return false; }
else if (txtokone.Text.Trim().Equals(string.Empty))
{
MessageBox.Show("请确认密码输入");
this.txtokone.Focus();
return false; }
else if (!txtemail.Text.Equals(txtone.Text))
{
MessageBox.Show("两次输入的邮箱不一致");
return false;
}
else if(!txtpassword.Text.Equals(txtokone.Text))
{
MessageBox.Show("两次输入的密码不一致");
return false;
}
else
{
return true;
} }
}
}

3.主界面

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 Game
{
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
}
//定义变量保存窗体传过来的值
public string loginame;
//Load事件
private void FrmMain_Load(object sender, EventArgs e)
{
//给label控件赋值
lblloginname.Text = "欢迎" + loginame + "来到魔兽世界";
}
}
}

其实,并不复杂,关键是你的思路,一定要清晰明了。

C#之仿魔兽登录的更多相关文章

  1. 项目<<魔兽登录系统>>

    创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体   (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...

  2. 深入.NET框架 项目《魔兽登录系统》

    创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体   (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...

  3. 深入.NET框架 项目--魔兽登录系统

    创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体   (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...

  4. 很酷的CSS3仿Facebook登录表单

    原文:很酷的CSS3仿Facebook登录表单 今天看到一款很不错的CSS3登录表单,外观是仿Facebook的登录表单,还挺不错的,另外也支持简单的表单输入框验证.下图是表单的效果图: 我们也可以在 ...

  5. Android仿QQ登录下拉历史列表

    demo中包含了Sqlite数据库增删改查,对存储的账号进行按照最新的时间排序,限制了最多存储5条数据. 效果图: 1.首先创建MyHelper建表: public class MyHelper ex ...

  6. WPF开发实例——仿QQ登录界面

    原文:WPF开发实例--仿QQ登录界面 版权声明:本文为博主原创文章,如需转载请标明转载地址 http://blog.csdn.net/u013981858 https://blog.csdn.net ...

  7. 编写Java程序,使用Swing布局管理器和常用控件,实现仿QQ登录界面

    返回本章节 返回作业目录 需求说明: 使用Swing布局管理器和常用控件,实现仿QQ登录界面 实现思路: 创建登录界面的类QQLogin,该类继承父类JFrame,在该类中创建无参数的构造方法,在构造 ...

  8. .net 写魔兽登录

    代码如下: 登录页面: public partial class FrmLogin : Form { public FrmLogin() { InitializeComponent(); } priv ...

  9. 零基础~仿qq登录界面

    html代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...

随机推荐

  1. Android—修改button属性

    一般安卓里的普通按钮控件灰灰的,比较单调,我们可以给按钮加上背景图片,或者自定义按钮的圆角,颜色等属性. 下面用代码举例: <Button android:id="@+id/reset ...

  2. CentOS 7 不能连接网路的解决方法

    ---恢复内容开始--- 刚安装的CentOS7 是不能连接网络的,更不能使用yum 进行应用的安装 (1)通过ip addr或者是 ifconfig获取需要编辑的文件名 (2)vi /etc/sys ...

  3. Cent os常见操作命令

    1.查看防火墙状态:firewall-cmd –-state 2.关闭防火墙:systemctl stop firewalld.service 3.禁止防火墙开机启动:systemctl disabl ...

  4. JavaScript学习笔记之对象

    目录 1.自定义对象 2.Array 3.Boolean 4.Date 5.Math 6.Number 7.String 8.RegExp 9.Function 10.Event 在 JavaScri ...

  5. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

  6. [置顶] Java基础学习总结(34)——HTTP协议详解

    一.什么是HTTP协议 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的 ...

  7. N天学习一个linux命令之ping

    用途 检测主机是否可到达,也就是说,目标主机是否可以联网,还可以用于检测网速.通过发送ICMP ECHO_REQUEST数据包检测. 用法 ping [options] destination 常用选 ...

  8. N天学习一个Linux命令之mkdir

    前言 暂无 用途 用于新建目录 常用参数 1.设置目录权限-m, --mode=MODE 2.递归创建目录(父目录不存在时,也创建)-p, --parents 3.其它-v, --verbose pr ...

  9. What you can talk

    data buffer who locked the account hash join cost memory and nested loop do not. How to make it hash ...

  10. POJ-2201-Cartesian Tree(笛卡尔树)

    Description Let us consider a special type of a binary search tree, called a cartesian tree. Recall ...