学生信息管理系统是针对学校学生处的大量业务处理工作而开发的管理软件,主要用于学校学生信息管理,总体任务是实现学生、老师、班级等信息关系的系统化、科学化、规范化和自动化,其主要任务是用计算机对学生各种信息进行日常管理,如查询、修改、增加、删除等,另外还考虑到学生选课、成绩等,针对这些要求设计了学生信息管理系统。推行学校信息管理系统的应用是进一步推进学生学籍管理规范化、电子化、控制辍学和提高义务教育水平的重要举措。
开发环境: Visual Studio 2022
数据库环境: SQL Server 2008 R2
目标框架: .NET Framework 4.8
项目结构: Client / Server Winform 窗体程序
登录部分代码:
private void btnLogin_Click(object sender, EventArgs e)
{
string strErr = "";
string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;
Manage.Login.Login objLogin = new Manage.Login.Login(strConnection);
if (rabAdmin.Checked == true)
{
Model.Users.Users objUsers = new Model.Users.Users();
objUsers.UserNo= txtUserNo.Text.Replace("'", "''");
objUsers.UserNo = objUsers.UserNo.Trim();
objUsers.PassWord = txtPassWord.Text.Replace("'", "''");
objUsers.PassWord = objUsers.PassWord.Trim();
if (txtUserNo.Text == "admin" && txtPassWord.Text == "123")
{
objUsers.Rights = 1;
MainForm objEnter = new MainForm(objUsers.UserNo, objUsers.PassWord, objUsers.Rights);
this.Visible = false;
objEnter.Show();
}
else
{
MessageBox.Show("您输入的账号或密码错误,请重新输入!");
txtUserNo.Text = "";
txtPassWord.Text = "";
return;
}
}
else if (rabTea.Checked == true)
{
Model.Users.Users objUsers = new Model.Users.Users();
objUsers.UserNo = txtUserNo.Text.Replace("'", "''");
objUsers.UserNo = objUsers.UserNo.Trim();
objUsers.UserNo = objUsers.UserNo.Replace("%", @"\%");
objUsers.PassWord = txtPassWord.Text.Replace("'", "''");
objUsers.PassWord = objUsers.PassWord.Trim();
objUsers.PassWord = objUsers.PassWord.Replace("%", @"\%");
objUsers.Rights = 2;
int iRent = objLogin.JudgeExist(objUsers.UserNo, objUsers.PassWord,objUsers.Rights, out strErr);
if (iRent == 1)
{
MainForm objEnter = new MainForm(objUsers.UserNo, objUsers.PassWord, objUsers.Rights);
objEnter.Show();
this.Visible = false;
}
else
{
MessageBox.Show("您输入的账号或密码错误,请重新输入!");
txtUserNo.Text = "";
txtPassWord.Text = "";
return;
}
}
else
{
Model.Users.Users objUsers = new Model.Users.Users();
objUsers.UserNo = txtUserNo.Text.Replace("'", "''");
objUsers.UserNo = objUsers.UserNo.Trim();
objUsers.PassWord = txtPassWord.Text.Replace("'", "''");
objUsers.PassWord = objUsers.PassWord.Trim();
objUsers.Rights = 3;
int iRent = objLogin.JudgeExist(objUsers.UserNo, objUsers.PassWord, objUsers.Rights, out strErr);
if (iRent == 1)
{
MainForm objEnter = new MainForm(objUsers.UserNo, objUsers.PassWord, objUsers.Rights);
objEnter.Show();
this.Visible = false;
}
else
{
MessageBox.Show("您输入的账号或密码错误,请重新输入!");
txtUserNo.Text = "";
txtPassWord.Text = "";
return;
}
}
}
学生管理部分代码:
private void btnSave_Click(object sender, EventArgs e)
{
string strErr = "";
Model.Student.Student objStudent = new Model.Student.Student();
string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;
Manage.Student.Student objStu = new Manage.Student.Student(strConnection);
int Ar = objStu.JudgeClassExist();
if (Ar == 0)
{
MessageBox.Show("不存在班级,将不能添加学生");
}
else
{
objStudent.StuNo = txtStuNo.Text.Replace("'", "''");
objStudent.StuNo = objStudent.StuNo.Trim();
objStudent.StuName = txtStuName.Text.Replace("'", "''");
objStudent.StuName = objStudent.StuName.Trim();
if (objStudent.StuNo == "" || objStudent.StuName == "")
{
MessageBox.Show("请将信息填写完整!");
}
else
{
if (rabWoman.Checked == true)
{
objStudent.Sex = "女";
}
else
{
objStudent.Sex = "男";
}
objStudent.BirthDate = dtpBirthDate.Value;
objStudent.EntranceTime = dtpEntranceTime.Value;
//objStudent.StuTel = txtStuTel.Text.ToString();
//objStudent.StuTel = txtStuTel.Text.Replace("'", "''");
if (this.txtStuTel.Text != "")
{
string patten = @"(13\d{9}(;13\d{9})*)|(15\d{9}(;15\d{9})*)|(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}(;(\(\d{3,4}\)|\d{3,4}-)?\d{7,8})*";
Regex r = new Regex(patten);
Match m = r.Match(txtStuTel.Text);
if (!m.Success)
{
MessageBox.Show("请输入正确的电话号码");
this.txtStuTel.Text = "";
this.txtStuTel.Focus();
return;
}
else
{
objStudent.StuTel = txtStuTel.Text.ToString();
}
}
objStudent.StuAddress = txtAddress.Text.Replace("'", "''");
objStudent.Remark = txtRemark.Text.Replace("'", "''");
objStudent.ClassId = int.Parse(cmbClassId.SelectedValue.ToString());
//int Ar= objStu. JudgeClassExist();
int iExist = objStu.JudgeStuNo(objStudent.StuNo);
int R = objStu.JudgeStuNoLikeTeaNo(objStudent.StuNo);
if (iExist == 1)
{
MessageBox.Show("此编号的学生已经存在,请重新为此学生编号");
}
else if (R == 1)
{
MessageBox.Show("存在一个此编号的教师,学生编号不能和教师编号相同");
}
else
{
int iRent = objStu.AddStu(objStudent, out strErr);
if (iRent == 0)
{
MessageBox.Show(strErr);
return;
}
else
{
MessageBox.Show("添加学生信息成功,同时系统为此学生创建账号成功");
this.Visible = false;
}
}
}
}
}
项目编号: 20220509001
默认登录账号密码: admin / 123
下载地址: 【 20220509001】基于 C#+SQLServer2008 学生管理系统的设计与实现(源码+数据库+设计文档).rar