• 魔兽争霸系统


    首先我们先编写魔兽系统中的用户信息类(LoginInfo)用来存放属性

    封装属性代码:  

    //电子邮箱 private string email;         public string Email         {             get { return email; }             set { email = value; }         }         //身份证号码 private string id;

            public string Id         {             get { return id; }             set { id = value; }         }         //姓名 private string name;

            public string Name         {             get { return name; }             set { name = value; }         }         //密码 private string password;

            public string Password         { get { return password; } set { password = value; }         }

    登录界面

    代码:

    public static LoginInfo[] array; //创建对象数组

    #region 窗体 private void FrmLogin_Load(object sender, EventArgs e)         {             //初始化用户信息               array = new LoginInfo[20];   LoginInfo infol = new LoginInfo();   infol.Name = "孙丽丽";   infol.Id = "120185198005088521";   infol.Email = "lili@sohu.com";   infol.Password = "lili1980";   array[0] = infol;

      this.lblValidation.Visible = false;         }         #endregion

            #region 登录验证 private void butLogin_Click(object sender, EventArgs e)         {   if (txtEmail.Text.Trim() == "" || txtpass.Text.Trim() == "")   {     MessageBox.Show("用户名或密码不能为空!", "提示");   }   else   {     string userName = txtEmail.Text;     string pwd = txtpass.Text;     bool isOK = false;     foreach (LoginInfo item in array)     {       if (item != null)       {         if (item.Email == userName && item.Password == pwd)         {           isOK = true;           FrmMain fm = new FrmMain();           fm.lblname.Text = "欢迎," + item.Name;           fm.Show();           this.Hide();           break;         }       }     }     if (isOK == false)     {       this.lblValidation.Visible = true;       lblValidation.Text = "用户或密码错误!";     }   }

            }         #endregion 

            #region 注册 private void linkLabel1_Click(object sender, EventArgs e)         {   FrmRegist fr = new FrmRegist();   fr.ShowDialog();         }         #endregion

            #region 关闭 private void pnlExit_Click(object sender, EventArgs e)         {   Application.Exit();         }         #endregion

            #region 窗体移动 int frmPlayX ;         int frmPlayY;         private void timer1_Tick(object sender, EventArgs e)         {   this.Location = new Point(MousePosition.X - frmPlayX, MousePosition.Y - frmPlayY);         }         private void panel1_MouseDown(object sender, MouseEventArgs e)         {   frmPlayX = e.X;   frmPlayY = e.Y;

      timer1.Enabled = true;         }         private void panel1_MouseUp(object sender, MouseEventArgs e)         {   timer1.Enabled = false;         }         #endregion

    主窗体

    把Lable的Modifiers改成Public直接接受登录成功以后传的值就行

    注册页面

    代码:

    #region 注册 private void butzhuc_Click(object sender, EventArgs e)         {
      if (Bijiao()==true)   {     LoginInfo info = new LoginInfo();     info.Name = txtname.Text;     info.Id = txtId.Text;     info.Password = txtpassWord.Text;     info.Email = txtEmails.Text;

        for (int i = 1; i <= FrmLogin.array.Length; i++)     {        if (FrmLogin.array[i] == null)        {           FrmLogin.array[i] = info;           break;        }     }     this.Close(); //关闭本窗体               }         }

  • 相关阅读:
    Perl的运算符号字符
    windows xp 使用远程桌面时的关机/重新启动方法
    抵御TCP的洪水
    远程桌面连接中的常见问题 连接上就断开
    批量kill mysql进程
    Linux如何查看硬盘型号和缓存
    Apache Rewrite 规则详解
    nginx 内置变量大全
    大数据量分页存储过程效率测试附代码
    ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
  • 原文地址:https://www.cnblogs.com/ainiaiwo/p/5325011.html
Copyright © 2020-2023  润新知