zoukankan      html  css  js  c++  java
  • 魔兽登录系统

    FrmLogin界面:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 
    11 namespace day01_0100魔兽登陆
    12 {
    13     public partial class FrmLogin : Form
    14     {
    15         public FrmLogin()
    16         {
    17             InitializeComponent();
    18         }
    19 
    20         private void label2_Click(object sender, EventArgs e)
    21         {
    22             FrmRegist fr = new FrmRegist();
    23             fr.fl = this;
    24             fr.Show();
    25             this.Hide();
    26         }
    27         //存储登录用户信息的对象数组
    28         public LoginInfo[] array;
    29         private void FrmLogin_Load(object sender, EventArgs e)
    30         {
    31             //初始用户信息
    32             array = new LoginInfo[10];
    33             LoginInfo info1 = new LoginInfo();
    34             info1.Name = "孙丽丽";
    35             info1.Id = "12345678";
    36             info1.Email = "123@qq.com";
    37             info1.Password = "123456";
    38             array[0] = info1;
    39         }
    40 
    41         private void btnLogin_Click(object sender, EventArgs e)
    42         {
    43             if (txtEmail.Text.Trim() == "" || txtPwd.Text.Trim() == "")
    44             {
    45                 MessageBox.Show("用户名密码不能为空", "提示");
    46             }
    47             else
    48             {
    49                 string userName = txtEmail.Text;
    50                 string pwd = txtPwd.Text;
    51                 bool isOK = false;
    52                 foreach (LoginInfo item in array)
    53                 {
    54                     if (item != null)
    55                     {
    56                         if (item.Email == userName && item.Password == pwd)
    57                         {
    58 
    59                             isOK = true;
    60                             FrmMain fm = new FrmMain();
    61                             fm.bt = "欢迎" + item.Name;
    62                             fm.Show();
    63                             break;
    64                         }
    65                     }
    66                 }
    67                 if (isOK == false)
    68                 {
    69                     lblPwd.Visible = true;
    70                     txtPwd.Text = "";
    71                     txtPwd.Focus();
    72                 }
    73             }
    74         }
    75     }
    76 }

     FrmRegist界面:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 
    11 namespace day01_0100魔兽登陆
    12 {
    13     public partial class FrmRegist : Form
    14     {
    15         public FrmRegist()
    16         {
    17             InitializeComponent();
    18         }
    19         public FrmLogin fl;
    20         private void btnRegist_Click(object sender, EventArgs e)
    21         {
    22             //LoginInfo info = new LoginInfo();
    23             MessageBox.Show("恭喜,通过验证!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    24             for (int i = 0; i < fl.array.Length; i++)
    25             {
    26                 if (fl.array[i] == null)
    27                 {
    28                     fl.array[i] = new LoginInfo();
    29                     fl.array[i].Name = textBox1.Text;
    30                     fl.array[i].Password = textBox4.Text;
    31                     fl.array[i].Email = textBox3.Text;
    32                     break;
    33                 }
    34             }
    35             fl.Visible = true;
    36             this.Close();
    37         }
    38     }
    39 }

    FrmMain界面:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 
    11 namespace day01_0100魔兽登陆
    12 {
    13     public partial class FrmMain : Form
    14     {
    15         public FrmMain()
    16         {
    17             InitializeComponent();
    18         }
    19         public string bt;
    20         private void FrmMain_Load(object sender, EventArgs e)
    21         {
    22             label1.Text=bt;
    23         }
    24     }
    25 }
  • 相关阅读:
    记录我发现的第一个关于 Google 的 Bug
    iOS 中的 Delayed Transition
    Appstore|IPA
    地图|定位
    开发者账号
    App跳转
    国际化
    短信|彩信
    闪光灯
    Cornerstone|SVN
  • 原文地址:https://www.cnblogs.com/liutao1122/p/7138092.html
Copyright © 2011-2022 走看看