namespace 工具箱测试
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0; //combobox索引显示为第一个
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
const string tid = "201966",tpwd="123asd";
const string sid = "201988",spwd="123qwe";
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)//登陆
{
string id = maskedTextBox1.Text;
string pwd = textBox1.Text;
if (id==""||pwd=="")
{
MessageBox.Show("请输入必填项");
return;
}
string selecttype = comboBox1.SelectedItem.ToString();
switch (selecttype)
{
case"老师":
if (tid.Equals(id)&&tpwd.Equals(pwd))
{
MessageBox.Show("登陆成功");
Main main = new Main();
main.Show();
this.Hide();
}
else
{
MessageBox.Show("用户名或者密码不正确");
}
break;
case"学生":
if (sid.Equals(id)&&spwd.Equals(pwd))
{
MessageBox.Show("登陆成功");
XS xues = new XS();
xues.Show();
this.Hide();
}
else
{
MessageBox.Show("用户名或者密码不正确");
}
break;
利用C#编写管理系统
最新推荐文章于 2022-07-28 20:54:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)