C#之仿魔兽登录
不多废话,直接上效果图:
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#之仿魔兽登录的更多相关文章
- 项目<<魔兽登录系统>>
创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体 (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...
- 深入.NET框架 项目《魔兽登录系统》
创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体 (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...
- 深入.NET框架 项目--魔兽登录系统
创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体 (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...
- 很酷的CSS3仿Facebook登录表单
原文:很酷的CSS3仿Facebook登录表单 今天看到一款很不错的CSS3登录表单,外观是仿Facebook的登录表单,还挺不错的,另外也支持简单的表单输入框验证.下图是表单的效果图: 我们也可以在 ...
- Android仿QQ登录下拉历史列表
demo中包含了Sqlite数据库增删改查,对存储的账号进行按照最新的时间排序,限制了最多存储5条数据. 效果图: 1.首先创建MyHelper建表: public class MyHelper ex ...
- WPF开发实例——仿QQ登录界面
原文:WPF开发实例--仿QQ登录界面 版权声明:本文为博主原创文章,如需转载请标明转载地址 http://blog.csdn.net/u013981858 https://blog.csdn.net ...
- 编写Java程序,使用Swing布局管理器和常用控件,实现仿QQ登录界面
返回本章节 返回作业目录 需求说明: 使用Swing布局管理器和常用控件,实现仿QQ登录界面 实现思路: 创建登录界面的类QQLogin,该类继承父类JFrame,在该类中创建无参数的构造方法,在构造 ...
- .net 写魔兽登录
代码如下: 登录页面: public partial class FrmLogin : Form { public FrmLogin() { InitializeComponent(); } priv ...
- 零基础~仿qq登录界面
html代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...
随机推荐
- js 根据数组分组动态生成table(相同项合并)
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/ ...
- JavaScript day3(数据类型)
数据类型(data type) JavaScript提供七种不同的数据类型(data types),它们是string(字符串), symbol(符号), number(数字), undefined( ...
- OSI 7层模型和 TCP/IP 5层模型
网络协议通常分不同层次进行开发,每一层分别负责不同的通行功能. 两种参考模型 OSI 和 TCP/IP, OSI 先有模型后有协议,TCP/IP 则相反. OSI 7层模型 - 应用层 - 表示层 - ...
- Python编程时.py与.pyc文件的介绍
Python的程序中,是把原始程序代码放在.py文件里,而Python会在执行.py文件的时候.将.py形式的程序编译成中间式文件(byte-compiled)的.pyc文件,这么做的目的就是为了加快 ...
- Codeforces Round #412 (Div. 2)ABCD
tourist的剧毒contest,题干长到让人不想做... A.看不太懂题意直接看下面input output note n组里有两数不一样的一组就rated 否则单调不增为maybe,否则unra ...
- CDOJ 889 Battle for Silver
Battle for Silver Time Limit: 2999/999MS (Java/Others) Memory Limit: 65432/65432KB (Java/Others) ...
- Linux 下android环境的配置
Linux 下android环境的配置 1. JDK下载 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads- ...
- asciiflow
http://asciiflow.com/ https://maxiang.io/# http://www.jianshu.com/p/19432b5e3c60
- 动态配置 JBOSS ( eap 6.2 ) 数据源
操作环境 windows + jboss eap 6.2 + MyEclipse 10.0 项目用的是jboss eap 6.2,作为Red公司升级后的eap稳定版. 相比之前的 AS 系列,不管是安 ...
- 菜鸟学Java(二十二)——又一次认识泛型
泛型是Java SE 1.5的新特性,泛型的本质是參数化类型,也就是说所操作的数据类型被指定为一个參数.这样的參数类型能够用在类.接口和方法的创建中,分别称为泛型类.泛型接口.泛型方法. Java语言 ...