📄 insert.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace pwxt
{
public partial class insert : Form
{
private string adminname = "admin";
private string adminpasd = "1100";
public string username;
public string userpasd;
public insert()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
username = textBox1.Text;
userpasd = textBox2.Text;
if (username == adminname & userpasd == adminpasd)
{
MessageBox.Show("登录成功");
this.Visible = false;
menu_class();
this.Visible = true;
}
else
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionstring"]);
string strcmd="SELECT * FROM USertable WHERE name='"+username+"'AND pasd='"+userpasd+"'";
SqlCommand cmd = new SqlCommand(strcmd, conn);
conn.Open();
SqlDataReader odr = null;
odr = cmd.ExecuteReader();
if (odr.Read() == false)
{
MessageBox.Show("用户名错误或者密码错误");
this.Show();
}
else
{
MessageBox.Show("登录成功");
this.Visible = false;
menu_class();
this.Visible = true;
}
conn.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Visible = false;
try
{
zhuce zc = new zhuce();
if (zc.ShowDialog() == DialogResult.OK)
{
}
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}
this.Visible = true;
}
void menu_class()
{
try
{
menuclass mc = new menuclass();
if (username != adminname && userpasd != adminpasd)
{
mc.删除ToolStripMenuItem.Enabled = false;
mc.增加ToolStripMenuItem.Enabled = false;
}
else
mc.button1.Enabled = false;
if (mc.ShowDialog() == DialogResult.OK)
{
}
}
catch (Exception e2)
{
MessageBox.Show(e2.Message);
}
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -