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 ...
随机推荐
- opencv 图像各方向旋转
1. 简介 计算机图形学中的应用非常广泛的变换是一种称为仿射变换的特殊变换,在仿射变换中的基本变换包括平移.旋转.缩放.剪切这几种.本文以及接下来的几篇文章重点介绍一下关于旋转的变换,包括二维旋转变换 ...
- 洛谷——P1759 通天之潜水
P1759 通天之潜水 题目背景 直达通天路·小A历险记第三篇 题目描述 在猴王的帮助下,小A终于走出了这篇荒山,却发现一条波涛汹涌的河拦在了自己的面前.河面上并没有船,但好在小A有n个潜水工具. ...
- [luogu4054 JSOI2009] 计数问题(2D BIT)
传送门 Solution 2D BIT模板 Code //By Menteur_Hxy #include <cmath> #include <cstdio> #include ...
- Linux:SSH连接原理
1,SSH开启 2,执行:ssh username@ip地址 例如ssh root@10.1.1.1 3,查看cat ./ssh/kown_hosts 里面就保存了10.1.1.1的公钥了 4,对比一 ...
- defer, panic, recover使用总结
1. defer : 延迟调用.多个defer,依次入栈,在函数即将退出时,依次出栈调用 package main import "fmt" func main() { defer ...
- 00.用 yield 实现 Python 协程
来源:Python与数据分析 链接: https://mp.weixin.qq.com/s/GrU6C-x4K0WBNPYNJBCrMw 什么是协程 引用官方的说法: 协程是一种用户态的轻量级线程,协 ...
- nlogn求LIS(树状数组)
之前一直是用二分 但是因为比较难理解,写的时候也容易忘记怎么写. 今天比赛讲评的时候讲了一种用树状数组求LIS的方法 (1)好理解,自然也好写(但代码量比二分的大) (2)扩展性强.这个解法顺带求出以 ...
- 获取当前日期,或指定日期的农历js代码
时间不早了,直接上代码啦-- var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲乙丙丁戊己庚辛壬癸& ...
- 赛门铁克扩展验证EV SSL证书
申请EV SSL证书,将接受最严格验证企业域名所有权和企业身份信息,属于最高信任级别扩展验证(EV)的 EV SSL证书,最高达256位自适应加密.Symantec不仅提供先进的SSL加密技术,同 ...
- [APIO2014] [Uoj103] [Bzoj3676] Palindromes回文串 [Manacher,后缀数组]
用Manacher算法枚举回文子串,每次在后缀数组排序后的后缀数组中二分,因为用某一后缀和其他子串分别求匹配的长度,匹配长度在排序后该后缀的两侧具有单调性(匹配长度为min{H[x]|i<=x& ...