账号密码的登录程序

账号密码的登录程序: Class1 ck=new Class1(); bool

Assert.AreEqual(true,result);

public class Class1

{ private const int MaxNum = 35; private string[] m_Acoount, m_Password; public Class1()

result=ck.Check("2011494011","1");

{ m_Acoount = new string[MaxNum]; result=ck.Check("[1**********]","35");

m_Password = new string[MaxNum];

for (int i = 0; i

m_Acoount[i] = "201149401" + (i + 1).ToString();

m_Password[i] =

(i

+

1).ToString(); }

public bool Check(string account,string password) {

for (int i = 0; i

i++)

{ if ((string.Compare(account,

m_Acoount[i]) == 0)

&& (string.Compare(password, m_Password[i]) == 0))

return true;

else if ((string.Compare(account, m_Acoount[i]) != 0)

&& (string.Compare(password, m_Password[i]) == 0))

return false;

else if ((string.Compare(account, m_Acoount[i]) == 0)

&& (string.Compare(password, m_Password[i]) != 0))

return false; }

return false;

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 上述程序的调试代码:public class TestCheck {[Test] public void TestCheck1() {

// TODO: Add your test.

Assert.AreEqual(true,result);

result=ck.Check("[1**********]","10");

Assert.AreEqual(true,result);

result=ck.Check("[1**********]","36");

Assert.AreEqual(false,result);

result=ck.Check("2011494010","0");

Assert.AreEqual(false,result);

}........................................................................................

注册代码的类代码。。。 class Classcreat : Interfacedenglu {

string file = @"D:\z.txt";

public int zhuce(string account, string password, string s_password,string name) {

FileInfo f1 = new FileInfo(file); FileStream read_zhuce

=

f1.OpenRead(); byte[] datar

=

new

byte[(int)f1.Length];

read_zhuce.Read(datar, 0,

(int)f1.Length); string

value

=

System.Text.Encoding.ASCII.GetString(datar); string[] array = value.Split(' '); read_zhuce.Close(); int i;

for (i = 0; i

StreamWriter write

= f1.AppendText();

write.Write (account + " " + password + " "+name+" "); write.Flush(); write.Close(); return i; } else

return -1; }

public int denglu(string m_account, string m_password) {

FileInfo f2 = new FileInfo(file); FileStream read_denglu

=

f2.OpenRead(); byte[] datar1

=

new

byte[(int)f2.Length];

read_denglu.Read(datar1, 0,

(int)f2.Length); string

read

=

System.Text.Encoding.ASCII.GetString(datar1); string[] array = read.Split(' '); read_denglu.Close();

int i;///0账号错1都对2密码错 for (i = 0; i

return i; else

return -2; return-1;

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

注册界面各控件的代码:

private void button1_Click(object sender, EventArgs e) {

Interfacedenglu creat

=

new Classcreat(); int a

=

creat.zhuce(textBox1 .Text ,textBox2 .Text,textBox3.

Text,textBox4 .Text );

if (textBox1.Text == "" ||

textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")

{ MessageBox.Show("请填好你的信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

textBox1.Focus(); return; } if (a>=0)

DialogResult = MessageBox.Show("恭喜注册成功请登录","提示",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

if(DialogResult ==

DialogResult .OK )

this.Close (); if(a==-1) DialogResult = MessageBox.Show("输入密码不统一,请确认后再输

","

",MessageBoxButtons .OK ,MessageBoxIcon.Error );

if (DialogResult

== DialogResult.OK)

textBox2.Text =

"";

textBox3.Text = "";

textBox2.Focus(); if (a == -3) DialogResult =

MessageBox.Show("你所输入的账号已存在,请更换账号再进行注册", "提示",

MessageBoxButtons.OK, MessageBoxIcon.Error );

if (DialogResult

==

DialogResult.OK)

textBox1.Text =

""; textBox2.Text = ""; textBox3.Text = ""; textBox1.Focus(); private void

button2_Click(object

sender, EventArgs e) {

DialogResult = MessageBox.Show("确定要退出注册吗?", "提示",

MessageBoxButtons.YesNo,

MessageBoxIcon.Question);

if (DialogResult == DialogResult.Yes) 

this.Close(); }}}} 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

登录和登录时储存账户密码的文档代码 private

void

btn_denglu_Click(object

sender,

EventArgs e) {

Form form8 = new Form8(this); string file = @"D:\z.txt"; FileInfo f1 = new FileInfo(file); FileStream read_zhuce

= f1.OpenRead(); byte[] datar

=

new byte[(int)f1.Length];

read_zhuce.Read(datar, 0, (int)f1.Length); string

value

=

System.Text.Encoding.ASCII .GetString(datar); string[] array = value.Split(' '); read_zhuce.Close(); if (textBox1.Text

==

""

||

textBox2.Text == "")

{

MessageBox.Show("请输入账号密码",

"提示", MessageBoxButtons.OK,

MessageBoxIcon.Stop);

textBox1.Focus(); return; } int c;

Interfacedenglu dl = new Classcreat(); c =

dl.denglu(textBox1.Text,

textBox2.Text);

if (c == -1)

{ DialogResult = MessageBox.Show("账号不存在,请重新输入","提示",MessageBoxButtons .OK ,MessageBoxIcon.Stop );

if (DialogResult

==

DialogResult.OK)

textBox2.Text = ""; textBox1.Text = "";

textBox1.Focus(); }

else if (c >=0)

{DialogResult =MessageBox.Show("恭喜"+array[c+2]+"成功登录系统", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk ); if (DialogResult

==

DialogResult.OK)

this.Hide();

Form form3 = new Form3(); form3.Show();

form8.Show(); }

else if (c == -2)

{ MessageBox.Show("密码错误,请确认后再次尝试登录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);

if (DialogResult

==

DialogResult.OK)

textBox2.Text = ""; textBox2.Focus();

} private void

label3_Click(object

sender,

EventArgs e) {

Form form2 = new Form2(); form2.Show();

} private void Form1_Load(object sender, EventArgs e) {

string file = @"D:\z.txt"; if (File.Exists(file))

MessageBox.Show("你的信息将存

z.txt

","

",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

else

MessageBox.Show("发现不存在z.txt,将自动帮你新建","提示

",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

FileInfo f2 = new FileInfo(file); StreamWriter write = f2.AppendText();

write.Close(); }

private void btn_tuichu_Click(object sender, EventArgs e) {

DialogResult = MessageBox.Show("确定要退出登录系统吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (DialogResult == DialogResult.Yes) } } }

this.Close();

账号密码的登录程序: Class1 ck=new Class1(); bool

Assert.AreEqual(true,result);

public class Class1

{ private const int MaxNum = 35; private string[] m_Acoount, m_Password; public Class1()

result=ck.Check("2011494011","1");

{ m_Acoount = new string[MaxNum]; result=ck.Check("[1**********]","35");

m_Password = new string[MaxNum];

for (int i = 0; i

m_Acoount[i] = "201149401" + (i + 1).ToString();

m_Password[i] =

(i

+

1).ToString(); }

public bool Check(string account,string password) {

for (int i = 0; i

i++)

{ if ((string.Compare(account,

m_Acoount[i]) == 0)

&& (string.Compare(password, m_Password[i]) == 0))

return true;

else if ((string.Compare(account, m_Acoount[i]) != 0)

&& (string.Compare(password, m_Password[i]) == 0))

return false;

else if ((string.Compare(account, m_Acoount[i]) == 0)

&& (string.Compare(password, m_Password[i]) != 0))

return false; }

return false;

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 上述程序的调试代码:public class TestCheck {[Test] public void TestCheck1() {

// TODO: Add your test.

Assert.AreEqual(true,result);

result=ck.Check("[1**********]","10");

Assert.AreEqual(true,result);

result=ck.Check("[1**********]","36");

Assert.AreEqual(false,result);

result=ck.Check("2011494010","0");

Assert.AreEqual(false,result);

}........................................................................................

注册代码的类代码。。。 class Classcreat : Interfacedenglu {

string file = @"D:\z.txt";

public int zhuce(string account, string password, string s_password,string name) {

FileInfo f1 = new FileInfo(file); FileStream read_zhuce

=

f1.OpenRead(); byte[] datar

=

new

byte[(int)f1.Length];

read_zhuce.Read(datar, 0,

(int)f1.Length); string

value

=

System.Text.Encoding.ASCII.GetString(datar); string[] array = value.Split(' '); read_zhuce.Close(); int i;

for (i = 0; i

StreamWriter write

= f1.AppendText();

write.Write (account + " " + password + " "+name+" "); write.Flush(); write.Close(); return i; } else

return -1; }

public int denglu(string m_account, string m_password) {

FileInfo f2 = new FileInfo(file); FileStream read_denglu

=

f2.OpenRead(); byte[] datar1

=

new

byte[(int)f2.Length];

read_denglu.Read(datar1, 0,

(int)f2.Length); string

read

=

System.Text.Encoding.ASCII.GetString(datar1); string[] array = read.Split(' '); read_denglu.Close();

int i;///0账号错1都对2密码错 for (i = 0; i

return i; else

return -2; return-1;

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

注册界面各控件的代码:

private void button1_Click(object sender, EventArgs e) {

Interfacedenglu creat

=

new Classcreat(); int a

=

creat.zhuce(textBox1 .Text ,textBox2 .Text,textBox3.

Text,textBox4 .Text );

if (textBox1.Text == "" ||

textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")

{ MessageBox.Show("请填好你的信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

textBox1.Focus(); return; } if (a>=0)

DialogResult = MessageBox.Show("恭喜注册成功请登录","提示",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

if(DialogResult ==

DialogResult .OK )

this.Close (); if(a==-1) DialogResult = MessageBox.Show("输入密码不统一,请确认后再输

","

",MessageBoxButtons .OK ,MessageBoxIcon.Error );

if (DialogResult

== DialogResult.OK)

textBox2.Text =

"";

textBox3.Text = "";

textBox2.Focus(); if (a == -3) DialogResult =

MessageBox.Show("你所输入的账号已存在,请更换账号再进行注册", "提示",

MessageBoxButtons.OK, MessageBoxIcon.Error );

if (DialogResult

==

DialogResult.OK)

textBox1.Text =

""; textBox2.Text = ""; textBox3.Text = ""; textBox1.Focus(); private void

button2_Click(object

sender, EventArgs e) {

DialogResult = MessageBox.Show("确定要退出注册吗?", "提示",

MessageBoxButtons.YesNo,

MessageBoxIcon.Question);

if (DialogResult == DialogResult.Yes) 

this.Close(); }}}} 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

登录和登录时储存账户密码的文档代码 private

void

btn_denglu_Click(object

sender,

EventArgs e) {

Form form8 = new Form8(this); string file = @"D:\z.txt"; FileInfo f1 = new FileInfo(file); FileStream read_zhuce

= f1.OpenRead(); byte[] datar

=

new byte[(int)f1.Length];

read_zhuce.Read(datar, 0, (int)f1.Length); string

value

=

System.Text.Encoding.ASCII .GetString(datar); string[] array = value.Split(' '); read_zhuce.Close(); if (textBox1.Text

==

""

||

textBox2.Text == "")

{

MessageBox.Show("请输入账号密码",

"提示", MessageBoxButtons.OK,

MessageBoxIcon.Stop);

textBox1.Focus(); return; } int c;

Interfacedenglu dl = new Classcreat(); c =

dl.denglu(textBox1.Text,

textBox2.Text);

if (c == -1)

{ DialogResult = MessageBox.Show("账号不存在,请重新输入","提示",MessageBoxButtons .OK ,MessageBoxIcon.Stop );

if (DialogResult

==

DialogResult.OK)

textBox2.Text = ""; textBox1.Text = "";

textBox1.Focus(); }

else if (c >=0)

{DialogResult =MessageBox.Show("恭喜"+array[c+2]+"成功登录系统", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk ); if (DialogResult

==

DialogResult.OK)

this.Hide();

Form form3 = new Form3(); form3.Show();

form8.Show(); }

else if (c == -2)

{ MessageBox.Show("密码错误,请确认后再次尝试登录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);

if (DialogResult

==

DialogResult.OK)

textBox2.Text = ""; textBox2.Focus();

} private void

label3_Click(object

sender,

EventArgs e) {

Form form2 = new Form2(); form2.Show();

} private void Form1_Load(object sender, EventArgs e) {

string file = @"D:\z.txt"; if (File.Exists(file))

MessageBox.Show("你的信息将存

z.txt

","

",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

else

MessageBox.Show("发现不存在z.txt,将自动帮你新建","提示

",MessageBoxButtons .OK ,MessageBoxIcon.Asterisk );

FileInfo f2 = new FileInfo(file); StreamWriter write = f2.AppendText();

write.Close(); }

private void btn_tuichu_Click(object sender, EventArgs e) {

DialogResult = MessageBox.Show("确定要退出登录系统吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (DialogResult == DialogResult.Yes) } } }

this.Close();


相关文章

  • 怎样设置开机密码?忘记电脑密码了怎么办?
  • 怎样设置开机密码? 忘记电脑密码了怎么办? 怎样设置开机密码? 在开始-设置-控制面版-用户账户-创建或点击你现在的用户,上面有设置密码的选项 或者可以通过设置bios 开机的时候狂按del健,在里头可以找到password字样的东西,设置 ...查看


  • 密码破解3
  • [replyview]2000 xp管理员密码破解实战 Rock2000 一.删除SAM文件,清除Administrator账号密码 二.从SAM文件中 查找密码 三.用密码重设盘设新密码 四.修改屏保文件法 五.使用软件修改密码 Wind ...查看


  • 游戏账号注册登录系统
  • Venus账号注册登录 一.设计目的 简便操作的登陆方式. 将登陆.注册.充值为一体的登陆方式. 二.登陆界面 2.1 准备界面 进入应用后的LOGO界面: 玩家点击设备桌面的游戏图标后经过资源加载后进入账号登陆界面,账号登陆界面中包含注册 ...查看


  • 系统软件用户手册
  • 用户手册(软件使用说明书) 1引言 ...................................................................................................... ...查看


  • 数据库课程设计之留言板
  • 目 录 目 录................................................................................................................. ...查看


  • 支票打印软件使用说明
  • 支票打印软件使用说明  简介 支票打印软件是一款适用各种打印机型的专用支票套打软件,具有操作简单,使用快捷的特点. 本软件代替手工填写支票,小写金额自动软换大写金额,基本资料保存后重复使用,减少工作量,并避免手写失误造成废票与银行退票,节 ...查看


  • 网络安全实验一
  • 网络安全实验报告 学号: 姓名: 班级: 实验项目编号: B031120501 实验项目名称: 钓鱼式攻击手法 一.实验目的: 1. 了解钓鱼攻击的概念和实现原理. 2. 了解钓鱼网站和正常网站的区别. 3. 提高抵御钓鱼攻击的能力. 二. ...查看


  • 网络诈骗的常见招式破解
  • 文章来源:http://www.yunfalv.com/Content-7654.htm免费发布法律 咨询请 点击http://www.yunfalv.com/tiwen.htm 云法律网拥有万名专业律师3-5分钟快速解决您的法律问题 网络 ...查看


  • 安卓3g手机操作题目详解
  • 操作比赛题目详解 1.设置手机壁纸为动态"线性光幕效果",添加"窗口小部件""模拟时钟"到桌面主页的正上方. 操作过程:1.按紧桌面的空位,弹出对话框选择"壁纸" ...查看


热门内容