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 ...
随机推荐
- react typescript 父组件调用子组件
//父组件import * as React from 'react'import { Input } from 'antd'const Search = Input.Searchimport &qu ...
- js 简单模板引擎
代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...
- codevs 1160 蛇形矩阵
1160 蛇形矩阵 传送门 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题解 题目描述 Description 小明玩一个数字游戏,取个n行 ...
- Navicat premium连接Oracle报ORA-28547错误
1:ORA-28547 原因:navicate Primium版本的OCi和本地数据库的OCI版本不一致. 解决方法: 1:把navicate Primium版本自带oci.dll替换本地Oracle ...
- 【codeforces 701C】They Are Everywhere
[题目链接]:http://codeforces.com/contest/701/problem/C [题意] 让你选择一段最短的区间; 使得这段区间里面包含所有种类的字符; [题解] 之前都是用二分 ...
- 【LeetCode Weekly Contest 26 Q2】Longest Uncommon Subsequence II
[题目链接]:https://leetcode.com/contest/leetcode-weekly-contest-26/problems/longest-uncommon-subsequence ...
- Windows学习总结(7)——学会CMD命令提示符的重要性
作为普通电脑用户,大家接触最多的应该 是可视的操作系统界面.可是如果想真正学好计算机,学习好命令提示符可就是必不可少的.它可以更高效的帮助我们处理问题. 命令提示符是在操作系统中,提示进行命令输入的一 ...
- 允许MS SqlServer远程连接
实际问题: 服务器192.168.0.103上的SQL Express数据库实例,局域网内其余机器的Sql Server Management Studio都无法连接. 在本机上,可以用“.\SqlE ...
- hdu 1569 最大权独立集
/*最大点权独立集=sum-最小点权覆盖*/ #include<stdio.h> #include<string.h> #include<queue> using ...
- 洛谷 P1481 魔族密码
P1481 魔族密码 题目描述 风之子刚走进他的考场,就…… 花花:当当当当~~偶是魅力女皇——花花!!^^(华丽出场,礼炮,鲜花) 风之子:我呕……(杀死人的眼神)快说题目!否则……-_-### 花 ...