学习了用VS2012制作了程序的登陆界面
代码块
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 shaochao2017270402
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndex = 1;
}
private void button1_Click(object sender, EventArgs e)
{
if (this.textBox2.Text == "" || this.textBox1.Text == "")
{
MessageBox.Show("用户名密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (this.comboBox1.SelectedItem.ToString() == "收银员")
{
if (this.textBox1.Text == "111111" && this.textBox1.Text == "111111"
|| this.textBox1.Text == "123456" && this.textBox2.Text == "123456")
{
//MessageBox.Show("收银员登录成功");
this.Hide();
Form2 fm2 = new Form2();
fm2.userName = this.textBox1.Text.ToString();
//fm2.MdiParent = this;
fm2.Show();
}
else
{
MessageBox.Show("用户名或者密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else if (this.comboBox1.SelectedItem.ToString() == "库管员")
{
if (this.textBox1.Text == "1" && this.textBox2.Text == "1")
{
//MessageBox.Show("库管员登录成功");
this.Hide();
Form3 fm2 = new Form3();
fm2.userName = this.textBox1.Text.ToString();
//fm2.MdiParent = this;
fm2.Show();
}
else
{
MessageBox.Show("用户名或者密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MessageBox.Show("请联系管理员", "提示", MessageBoxButtons.OK);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
this.button1_Click(sender, e);
}
}
private void textBox1_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
private void textBox2_Enter(object sender, EventArgs e)
{
((TextBox)sender).SelectAll();
}
}
}
网友评论