基本信息
源码名称:C# 学生信息管理系统 源码
源码大小:3.49M
文件格式:.zip
开发语言:C#
更新时间:2016-12-26
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
首先附加数据库,
管理员账号 admin 密码 00000
教师账号 t001 密码 12345
学生账号 SunPeng 密码 12345
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;
//下载自:好例子网 http://www.haolizi.net
namespace 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;//默认选择第一项
}
}
}