C#实实现现简简单单学学生生信信息息管管理理系系统统
一、运行环境windows,使用vs编译软件
二、主要功能
登录、 加学生信息、修改学生信息、删除学生信息、查询学生信息
三、实现步骤
1、登陆界面功能实现
老规矩,先贴下主要代码:
//构造方法
public Login()
{
InitializeComponent();
this.label3.Parent = this;
this.label1. ackColor = Color.Transparent;
this.label2. ackColor = Color.Transparent;
this.label3. ackColor = Color.Transparent;
this.Form orderStyle = System.Windows.Forms.Form orderStyle.None;
}
//对登录按钮的事件实现代码
private void button1_Click(object sender, EventArgs e)
{
string ss = ConfigurationManager.ConnectionStrings["Stu"].ToString();
SqlConnection conn = new SqlConnection(ss);
try
{
//开启连接
conn.Open();
// Message ox.Show("数据库连接成功!");
}
catch (Exception)
{
//Message ox.Show("数据库连接失败!");
}
String uname = txtName.Text.Trim();
string pword = txtPass.Text.Trim();
if(uname == ""|| pword == "")
{
Message ox.Show("请输入用户名或密码!");
return;
}
else
{
SqlCommand cmd = conn.CreateCommand();
SqlDataAdapter adp = new SqlDataAdapter();
string sql2 = "select * from account where name='"+ uname + " 'and pass='" + pword + "
' ";
cmd.CommandText = sql2;
adp.SelectCommand = cmd;
DataSet dat = new DataSet();
adp.Fill(dat, "account");
if(dat.Tables["account"].Rows.Count == 0)
{
Message ox.Show("用户名或密码错误!");
return;
}
else
{
Form1.isLogin = true;
Form1.username = this.txtName.Text;
this.Close();
}
cmd.Clone();
}
conn.Close();
}
//实现按ESC键关闭该窗口
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Win
dows.Forms.Keys keyData)
{
switch (keyData)
{
case Keys.Escape:
this.Close();//esc关闭窗体
break;
}
return false;
}
//重置按钮清空文本框
private void button2_Click(object sender, EventArgs e)