深入.NET平台和C#编程第一章上机2-4代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 上机练习2
{
   public  class LoginInfo
    {
        private string _Name;
        private string _Id;
        private string _Email;
        private string _Passworld;


        public string Name
        {
            get
            {
                return _Name;
            }

            set
            {
                _Name = value;
            }
        }

        public string Id
        {
            get
            {
                return _Id;
            }

            set
            {
                _Id = value;
            }
        }

        public string Email
        {
            get
            {
                return _Email;
            }

            set
            {
                _Email = value;
            }
        }

        public string Passworld
        {
            get
            {
                return _Passworld;
            }



            set
            {
                _Passworld = value;
            }
        }
    }
}


 
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 上机练习2
{
    public partial class FrmLogin : Form
    {
        public LoginInfo[] array;
        public FrmLogin()
        {
            InitializeComponent();
        }

        private void label4_Click(object sender, EventArgs e)
        {
            FrmRegist r = new FrmRegist();
            r.Parent = this.Parent;
            r.Show();
            this.Hide();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "" && textBox2.Text.Trim() == "")
            {
                MessageBox.Show("电子邮件和密码不能为空!", "提示");
            }
            else
            {
                string userNmae = textBox1.Text;
                string pwd = textBox2.Text;
                bool isOk = false;
                foreach (LoginInfo item in array)
                {
                    if (item!=null)
                    {
                        if (item.Email==userNmae&&item.Passworld==pwd)
                        {
                            lblValidation.Visible = false;
                            isOk = true;
                            FrmMain fm = new FrmMain();
                            fm.label1.Text = "欢迎," + item.Name;
                            fm.Show();
                          
                            break;
                        }
                    }

                }
                if (isOk == false)
                {
                    lblValidation.Visible = true;
                    textBox1.Text = "";
                    textBox2.Text = "";
                }

            }
        }

        private void FrmLogin_Load(object sender, EventArgs e)
        {
            //初始化信息
            array = new LoginInfo[10];
            LoginInfo INFO1 = new LoginInfo();
            INFO1.Name = "孙丽丽";
            INFO1.Id = "12018519805088521";
            INFO1.Email = "lili@sohu.com";
            INFO1.Passworld="lili1980";
            array[0] = INFO1;

            //省略其他初始用户信息的代码
            //初始时将验证提示信息隐藏
            lblValidation.Visible = false;

        }
    }

  
    }

 

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 上机练习2
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}

 

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 上机练习2
{
    public partial class FrmRegist : Form
    {
        public FrmRegist()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
        public FrmLogin fl;
        private LoginInfo info;

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1 != null && textBox2 != null && textBox3 != null && textBox4 != null && textBox5 == textBox3 && textBox6 == textBox4)
            {
                FrmLogin l = new FrmLogin();
                l.Parent = this.Parent;
                l.Show();
            }
            else
            {
                MessageBox.Show("恭喜,通过验证!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                for (int i = 0; i < fl.array.Length; i++)
                {
                    if (fl.array[i]==null)
                    {
                        fl.array[i] = info;
                        break;
                    }
                }
                fl.Visible = true;
                this.Close();
            }
        }
    }
}

 
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值