欢迎来到传世资源网!
加载中...
正在加载,请耐心等待...
本站为收藏、学习站,如有侵权,请联系管理员删除!

C# 学生信息管理系统 源码

介绍 评论 失效链接反馈

首先附加数据库,管理员账号 admin 密码 00000教师账号 t001 密码 12345学生账号 SunPeng 密码 12345C# 学生信息管理系统 源码 C#语言基础-第1张C# 学生信息管理系统 源码 C#语言基础-第2张C# 学生信息管理系统 源码 C#语言基础-第3张C# 学生信息管理系统 源码 C#语言基础-第4张C# 学生信息管理系统 源码 C#语言基础-第5张C# 学生信息管理系统 源码 C#语言基础-第6张C# 学生信息管理系统 源码 C#语言基础-第7张
C# 学生信息管理系统 源码 C#语言基础-第8张 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;//下载自:找例子网 https://www.5t6t.comnamespace LoginFrame{ public partial class LoginForm : Form { public LoginForm() { InitializeComponent(); } private void pictureBox2_Click(object sender, EventArgs e) { Application.Exit(); } private void pictureBox1_Click(object sender, EventArgs e) { if (ValidateInput()) { string userName = txtUserName.Text; string pwd = txtPwd.Text; try { string sql = ""; if (cbxUserStyle.Text == "教员") { sql =string.Format( "select count(*) from Teacher where LoginId='{0}' and LoginPwd='{1}'",userName,pwd); } else if (cbxUserStyle.Text == "管理员") { sql = string.Format("select count(*) from Admin where LoginId='{0}' and LoginPwd='{1}'",userName,pwd); } else {//学生 sql = string.Format("select count(*) from Student where LoginId='{0}' and LoginPwd='{1}'", userName, pwd); } SqlCommand command = new SqlCommand(sql,DbHelper.connection); DbHelper.connection.Open(); int i = (int)command.ExecuteScalar(); if (i > 0) { if (cbxUserStyle.Text == "教员") { SirForm sf = new SirForm(); sf.FormClosed = Sf_FormClosed; sf.Show(); this.Hide(); } else if (cbxUserStyle.Text == "管理员") { AdminForm af = new AdminForm(); af.FormClosed = Sf_FormClosed; af.Show(); this.Hide(); } else { StuForm sf = new StuForm(); sf.FormClosed = Sf_FormClosed; sf.Show(); this.Hide(); } MessageBox.Show("登陆成功!"); } else { MessageBox.Show("用户名或密码不正确!"); txtPwd.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { DbHelper.connection.Close(); } } } private void Sf_FormClosed(object sender, FormClosedEventArgs e) { Application.Exit(); } private bool ValidateInput() { if (txtUserName.Text.Trim() == "") { MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else if (txtPwd.Text.Trim() == "") { MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else if (cbxUserStyle.Text.Trim() == "") { MessageBox.Show("请选择用户类型!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; } private void LoginForm_Load(object sender, EventArgs e) { //string sql = "select * from UserType"; //DataSet dataSet = new DataSet(); //SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,DbHelper.connection); //try //{ // dataAdapter.Fill(dataSet, "UserType"); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); // return; //} //cbxUserStyle.DataSource = dataSet.Tables[0]; cbxUserStyle.SelectedIndex = 0;//默认选择第一项 } }}

下载声明:

本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。
相关推荐:

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复