日期:2014-05-17 浏览次数:21168 次
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 LoginForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")//判断是否输入的用户名
{
MessageBox.Show("用户名不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
if (textBox1.Text.ToLower() == "nb" && textBox2.Text == "nb")//判断用户名和密码是否正确
{
MessageBox.Show("登录成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show("用户名或密码错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox2.Text = "";//清空文本框
}
}
}
------解决方案--------------------