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

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. 数字化婚姻配对尝试问题(C++实现)

    问题描述:一.标题: 数字化婚姻配对尝试 二.题目: 建立一个模型,来模拟推导社会男女择偶过程. 为了模型简化,一个人的特性指标有三个,这里假设为财富.样貌.品格,每个指标均可取值1-100之间任意数 ...

  2. iptables详解(2):iptables实际操作之规则查询

    所属分类:IPtables  Linux基础 在阅读这篇文章之前,请确保你已经阅读了如下文章,如下文章总结了iptables的相关概念,是阅读这篇文章的基础. 图文并茂理解iptables 如果你是一 ...

  3. LNMP动态网站架构及web应用部署,搭建discuz论坛

    1)部署Nginx 实验tar安装包可找本人拿记得点+关注,感谢亲们支持,评论拿包 systemctl stop firewalld iptables -F setenforce 0 1)安装支持软件 ...

  4. is_NaN的使用

    原生js中使用判断某个值是否是数值,有且只有一个方法就是is_NaN. 原理:这个函数使用了Number() 去转换需要判断的值.Number() 去转换值,如果有任意非数值字符存在则就不是一个数值. ...

  5. Use emcli to delete obsolete agent targets in Oracle EM Cloud Control 12c

    [oracle@oem ~]$ cd /oem/oms/oms/bin   登录到oms中 [oracle@oem bin]$ ./emcli login -username=sysman Enter ...

  6. Atcoder Code Festival 2017 qual C 10.22 D题题解

    [题意概述] 给出一个只有小写字母的序列,问最少把序列分成几段可以满足每一段可以通过变换成为回文串.变换指的是交换子序列中的字母的位置. [题解] 我们把a~z分别设为2^0~2^25,每个子序列满足 ...

  7. Spring整合Junit框架进行单元测试Demo

    一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...

  8. mysql的一些高级查询

     1,查出学生详情表性别为男,并同时年龄大于18的  2,根据上述的结果,查出学生表对应的姓名,年龄,性别,address  3,查出学生的(姓名,年龄,性别,所属学院) 还可以添加注释

  9. 【codeforces 510D】Fox And Jumping

    [题目链接]:http://codeforces.com/contest/510/problem/D [题意] 你可以买n种卡片; 每种卡片的花费对应c[i]; 当你拥有了第i种卡片之后; 你可以在任 ...

  10. 【[Offer收割]编程练习赛13 C】 一人麻将

    [题目链接]:http://hihocoder.com/problemset/problem/1503 [题意] [题解] 一直在纠结如果没胡的话要扔掉哪一个麻将; 但其实可不用扔的,全部存起来就好了 ...