set |
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();
}
}
}
}