100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > c#语言管理员系统代码 【.04.13改】c#学生管理系统三层架构(源码)

c#语言管理员系统代码 【.04.13改】c#学生管理系统三层架构(源码)

时间:2018-09-19 22:23:48

相关推荐

c#语言管理员系统代码 【.04.13改】c#学生管理系统三层架构(源码)

本帖最后由 凌凌壹 于 -4-13 11:08 编辑

噔噔噔 .04.13改链接:/ibbjg9g

在学习的路上一去不返,今日将这几天学习的一点点内容上传,望大佬赐教。

这次做成了三层架构,内含数据库。由于目前想不到太多的功能只做了增删改查询。各个模块功能也大体一致,所以只做了管理员的。

下面贴上一部分源码:

using System;

using System.Collections.Generic;

using ponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using Bill;

using Model;

namespace StudentManagement.Admin

{

public partial class SubjectManagement : Form

{

#region 常量变量

public Subject subject = new Subject();

private SubjectManager subManager = new SubjectManager();

private TeacherManager teatManager = new TeacherManager();

private GradeManager graManager = new GradeManager();

#endregion

public SubjectManagement()

{

InitializeComponent();

}

//窗体初始化

private void CourseManagement_Load(object sender, EventArgs e)

{

//初始化使能

comboBoxCredit.Enabled = false;

comboBoxTime.Enabled = false;

comboBoxNo.Enabled = false;

comboBoxName.Enabled = false;

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

BindCombox();

}

#region 按钮事件

//单击添加按钮事件

private void toolStripButtonAdd_Click(object sender, EventArgs e)

{

//初始化使能

comboBoxCredit.Enabled = true;

comboBoxTime.Enabled = true;

comboBoxNo.Enabled = true;

comboBoxName.Enabled = true;

buttonFunction.Text = "保存添加";

}

//单击删除按钮

private void toolStripButtonDelete_Click(object sender, EventArgs e)

{

DialogResult r = MessageBox.Show("请确认是否删除选中信息", "提示", MessageBoxButtons.YesNo);

if (r == DialogResult.Yes)

{

int result;

string subNo = dataGridView1.SelectedCells[0].Value.ToString();

result = subManager.DeleteSubject(subNo);

if (result > 0)

{

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

BindCombox();

MessageBox.Show("已删除课程号为" + subNo + "的课程");

}

else

{

MessageBox.Show("删除课程号为" + subNo + "的课程失败");

}

}

}

//单击修改按钮事件

private void toolStripButtonChange_Click(object sender, EventArgs e)

{

//初始化使能

comboBoxCredit.Enabled = true;

comboBoxTime.Enabled = true;

//comboBoxNo.Enabled = true;

comboBoxName.Enabled = true;

buttonFunction.Text = "保存修改";

SelectedRows();

}

//单击搜索按钮事件

private void toolStripButtonSearch_Click(object sender, EventArgs e)

{

//初始化使能

comboBoxCredit.Enabled = false;

comboBoxTime.Enabled = false;

comboBoxNo.Enabled = false;

comboBoxName.Enabled = false;

buttonFunction.Text = "查询";

BindCombox();

}

//单击刷新按钮

private void toolStripButtonRefresh_Click(object sender, EventArgs e)

{

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

BindCombox();

}

//单击保存/查询按钮事件

private void buttonFunction_Click(object sender, EventArgs e)

{

if (buttonFunction.Text == "保存添加")

{

if (CheckNullValue())

{

subManager.AddSubject(subject);

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

BindCombox();

}

}

else if (buttonFunction.Text == "保存修改")

{

if (CheckNullValue())

{

subManager.UpdateSubject(subject);

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

BindCombox();

}

}

else

{

QueryFunction();

}

}

#endregion

#region 获取选中行

///

/// 获取选中行

///

private void SelectedRows()

{

comboBoxNo.Text = this.dataGridView1.SelectedCells[0].Value.ToString();

comboBoxName.Text = this.dataGridView1.SelectedCells[1].Value.ToString();

comboBoxCredit.Text = this.dataGridView1.SelectedCells[2].Value.ToString();

comboBoxTime.Text = this.dataGridView1.SelectedCells[3].Value.ToString();

comboBoxTeacher.Text = this.dataGridView1.SelectedCells[4].Value.ToString();

comboBoxGrade.Text = this.dataGridView1.SelectedCells[5].Value.ToString();

}

#endregion

#region 查询功能

///

/// 查询功能

///

private void QueryFunction()

{

if (comboBoxTeacher.Text != "")

{

if (comboBoxGrade.Text != "")

{

this.dataGridView1.DataSource = subManager.GetSujectByTeacherNameAndGradeName(comboBoxTeacher.Text.Trim(), comboBoxGrade.Text.Trim());//数据绑定

}

else

{

this.dataGridView1.DataSource = subManager.GetSujectByTeacherName(comboBoxTeacher.Text.Trim());//数据绑定

}

}

else

{

if (comboBoxGrade.Text != "")

{

this.dataGridView1.DataSource = subManager.GetSujectByGradeName(comboBoxGrade.Text.Trim());//数据绑定

}

else

{

this.dataGridView1.DataSource = subManager.GetSujectData();//数据绑定

MessageBox.Show("查询条件为空,请输入查询条件。");

}

}

}

#endregion

#region 非空验证

///

/// 非空验证

///

public bool CheckNullValue()

{

bool flag = false;

if (comboBoxNo.Text == "")

{ MessageBox.Show("课程代号为空"); }

else if (comboBoxName.Text == "")

{ MessageBox.Show("课程名称为空"); }

else if (comboBoxCredit.Text == "")

{ MessageBox.Show("课程学分为空"); }

else if (comboBoxTime.Text == "")

{ MessageBox.Show("课程学时为空"); }

else if (comboBoxTeacher.Text == "")

{ MessageBox.Show("授课教师为空"); }

else if (comboBoxGrade.Text == "")

{ MessageBox.Show("课程班级为空"); }

else

{

subject.SubNo = boBoxNo.Text.Trim();

subject.SubName = boBoxName.Text.Trim();

subject.SubCredit = boBoxCredit.Text.Trim();

subject.SubTimes = boBoxTime.Text.Trim();

subject.TeaName = boBoxTeacher.Text.Trim();

subject.GraName = boBoxGrade.Text.Trim();

flag = true;

}

return flag;

}

#endregion

#region Combox数据源绑定

///

/// Combox数据源绑定

///

public void BindCombox()

{

boBoxNo.DataSource = subManager.GetSujectData();

boBoxNo.DisplayMember = "subNo";//绑定到课程号

boBoxName.DataSource = subManager.GetSujectData();

boBoxName.DisplayMember = "subName";//绑定到课程名

boBoxCredit.DataSource = subManager.GetSubjectCredit();//Model.Subject

boBoxCredit.DisplayMember = "subCredit";//绑定到课程学分

boBoxTime.DataSource = subManager.GetSubjectTimes();

boBoxTime.DisplayMember = "subTimes";//绑定到课程学时

boBoxTeacher.DataSource = teatManager.GetTeacherData();

boBoxTeacher.DisplayMember = "TeaName";//绑定到授课教师

boBoxGrade.DataSource = graManager.GetGradeData();

boBoxGrade.DisplayMember = "graName";//绑定到班级名

//绑定后显示为空

boBoxNo.Text = null;

boBoxName.Text = null;

boBoxCredit.Text = null;

boBoxTime.Text = null;

boBoxTeacher.Text = null;

boBoxGrade.Text = null;

}

#endregion

}

}

.03改链接: /s/1PUF5b5lZRaqfCUekeR7jRg

提取码: p6rg

加入打印功能,新建的数据库,所以内容跟图片表格中的内容不一致。

对于线程问题还未考虑,有大神亦可赐教。作为初学者做个小作品,大神勿喷,更希望大神可以指导。

附部分界面(备注:需连接数据库内部并不含数据库仅有界面,并不能直接运行)

登陆界面.png (134.96 KB, 下载次数: 1)

主界面

-3-14 14:46 上传

系统界面.png (36.89 KB, 下载次数: 1)

管理员界面

-3-14 14:46 上传

修改.png (71.39 KB, 下载次数: 1)

修改操作

-3-14 14:46 上传

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。