/**烟台大学计算机学院学生
*All right reserved.
*文件名称:C#-—登陆界面
*作者:杨飞
*完成日期:2014年9月2日
*版本号:v1.0
*对任务及求解方法的描述部分:C#-—登陆界面
*我的程序:*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
// this.BackgroundImage = Image.FromFile(@"D://Water lilies.jpg");
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox2.Text != "123456")
{
MessageBox.Show("密码错误,请重新输入");
textBox2.Clear();
textBox2.Focus();
}
else
{
Form2 m = new Form2();
m.Show();
this.Hide();
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
textBox2.PasswordChar = '*';
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (textBox2.Text == "123456")
{
Form2 m = new Form2();
m.Show();
this.Hide();
}
else {
MessageBox.Show("密码错误,请重新输入");
textBox2.Clear();
textBox2.Focus();
}
}
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (textBox1.Text == "19950603"&&textBox2.Text=="liuyi")
{
Form2 m = new Form2();
m.Show();
this.Hide();
}
else
{
MessageBox.Show("你输入错误,请重新输入");
textBox1.Clear();
textBox1.Focus();
textBox2.Clear();
textBox2.Focus();
}
}
}
}
}
运行结果;
心得体会;呵呵