用c#语言编写学生管理系统,C#实现简单学生信息管理系统.pdf

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)

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值