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

    /// <summary>
          /// 用户信息类
          /// </summary>
            private string email;

            public string Email
            {
                get { return email; }
                set { email = value; }
            }
            private int id;

            public int 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; }
            }

    /// <summary>
            /// 用户信息验证及登陆功能实现
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btnLogin_Click(object sender, EventArgs e)
            {
               
                if (txtEmail.Text.Trim() == "" || txtPwd.Text.Trim() == "")
                {
                    MessageBox.Show("用户名和密码不允许为空!");


                }
                else
                {
                    string username = txtEmail.Text;
                    string pwd = txtPwd.Text;
                    bool isOk = false;
                    foreach (LoginInfo item in array)
                    {
                        if (item != null)
                        {
                            if (item.Email == username && item.Password == pwd)
                            {
                                isOk = true;
                                FrmMain frm = new FrmMain();

                                frm.lblNames.Text = "欢迎," + item.Name;
                                frm.Show();
                                break;

                            }
                        }
                    }
                    if (isOk == false)
                    {
                        txtPwd.Text = "";
                        txtEmail.Focus();
                    }
                }
               
            }
          
            private void label2_Click(object sender, EventArgs e)
            {
                //创建注册窗体对象
                FrmRegist frm = new FrmRegist();
                frm.fl = this;
                frm.Show();
                this.Hide();//登陆隐藏窗体
            }

            private void pictureBox2_Click(object sender, EventArgs e)
            {

            }
            public LoginInfo[] array;//存储登录用户信息的对象数组
            private void FrmLogin_Load(object sender, EventArgs e)
            {
                //初始用户信息
                array = new LoginInfo[10];

               
            }

     /// <summary>
          /// 登陆窗体对象
          /// </summary>
          /// <param name="sender"></param>
          /// <param name="e"></param>
            private void btnMian_Click(object sender, EventArgs e)
            {
                LoginInfo info = new LoginInfo();
                info.Name = txtName.Text;
                info.Id = Convert.ToInt32(txtMa.Text);
                info.Email = txtEmail.Text;
                info.Email = txtEmails.Text;
                info.Password = txtPwd.Text;
                info.Password = txtPwds.Text;
                if (this.txtName.Text.Trim()=="")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtName.Focus();

                }
                else if (this.txtMa.Text.Trim() == "")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtMa.Focus();

                }
                else if (this.txtEmail.Text.Trim() == "")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtEmail.Focus();

                }
                else if (this.txtEmails.Text.Trim() == "")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtEmails.Focus();

                }
                else if (this.txtPwd.Text.Trim() == "")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtPwd.Focus();

                }
                else if (this.txtPwds.Text.Trim() == "")
                {
                    MessageBox.Show("信息不能为空!");
                    this.txtPwd.Focus();

                }
                else
                {  
                    MessageBox.Show("注册成功!");
                    for (int i = 0; i < fl.array.Length; i++)
                    {
                        if(fl.array[i]==null)
                        {
                            fl.array[i] = info;
                            break;
                        }
                    }

                    fl.Visible = true;
                    this.Close();
                }
              

      

  • 相关阅读:
    启动Django项目报错:django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
    vue基础
    创建django项目出现AttrbuteError module 'pip' has no attribute 'main'解决方法
    ipython基本使用方法
    JavaScript(一)
    Spring 框架的设计理念与设计模式
    深入Java网络编程与NIO(三)
    深入Java网络编程与NIO(一)
    Code Jam Kickstart 2018 Round H 题解
    从TiDB学习分布式数据库
  • 原文地址:https://www.cnblogs.com/aaaaliling/p/8677434.html
Copyright © 2011-2022 走看看