项目实战:C/S 和B/S双架构开发"学生-教师管理系统"

项目实战: C/S 和 B/S 双架构开发 "学生-教师 管理系统"分工维护开发

目录

项目实战:C/S 和B/S双架构开发"学生-教师管理系统"  分工维护开发

编辑环境:

项目简介:

其他:

新的醍醐:

       项目运行效果[部分效果]

<1 C/S架构开发的>

<2 B/S架构开发的>

3.项目思路分析:

4.项目主要源码部分:

5.项目源码:


编辑环境:

win10_x64 /PowerBuild12.5/VS2015/ SqlServer2012

项目简介:

花了一天时间,一个小的Deam,采用C/S和B/S架构同时开发,这次就称“学生-教师管理系统”。这个其中它们是公用一个数据库的,主要程序是功能,教师在C/S端进行学生的成绩录入,课程的修改等,而学生在B/S端登陆之后进行注册和查看分数等。当然罗,它们都是具备一些基本的的增删改查的功能的。在这里是第一次采用同这两种架构模式的模式对一个数据库进行维护。源码也会在文章结束的时候发布出来。

其他

双架构开发 C/S 和B/S架构分工维护开发这次由于时间比较短,所以有一些界面的部分就做的比较简单,当然感兴趣的也可以自己把它继续完善下来。这次采用PowerBuild12.5编写C/S架构的部分,主要是负责教师部分。然后采用VS2015来写asp.net的项目,负责B/S架构的部分,主要是负责学生的部分。其中asp.net可以采用动态代码生成器生成简单地MVC模式的简单三层模式部分,然后结合自己的需要,适当的进行增删改查的综合,在业务层进行整理,实现一些复杂的功能的实现。且前端的设计部分(没有编码的时候)也可以采用AxureRP-Setup8.1来做一下,看是否满足客户的需求。用户需求是一个项目设计的最主要的标准。界面等,和功能等,都要以客户为准,但是也不能够一昧无节制的满足客户需求。这个部分就涉及到了需求工程部分,暂时不做说明(其实是我的水平还没有达到。瓜子都吓掉了。hhhh)

 

新的醍醐:

最近一段时间都是采用PowerDesigner15.1来设计数据库,首先自己是设计概念模型,然后生成物理模型,同时设置主键自增长、唯一等,看是否合理。在紧接着生成.sql文件,(注意生成Oracle 11g代码的时候,表名不能够打""号, 需要设置更改一下;生成SQL代码则没有这个问题)。然后配置链接数据库等,就可以正式的编码了。

 

==================================================================

 

1.项目运行效果[部分效果]

==================================================================

<1 C/S架构开发的>

 

 

 

<2 B/S架构开发的>

==================================================================

3.项目思路分析:

==================================================================

这次也算是大三这一两个月的一次学习检测,看看是否自己真的掌握了。其中的的需求如下(因为是按这和写的):

==================================================================

4.项目主要源码部分:

==================================================================

感觉这次代码比较简单,没有什么很是困难的部分,也有可能是没有一些特别比较困难的部分尝试吧.源码就放在下面,【带数据库,源码】

==================================================================

5.项目源码:

==================================================================

C/S 和B/S双架构开发"学生-教师管理系统"

  • 21
    点赞
  • 118
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 20
    评论
学生信息管理系统是一个常见的应用系统,使用C#语言采用三层架构进行开发,可以提高系统的可维护性、可扩展性、可重用性和可测试性等方面的优势。 三层架构是一个比较经典的软件架构,它将应用程序划分为三个主要的部分:表示层、业务逻辑层和数据访问层。每一层都有不同的职责,但它们又协同工作,为应用程序提供了良好的结构和可维护性。 下面我来介绍一下如何使用C#语言来开发一个学生信息管理系统。 一、需求分析 首先,我们需要对学生信息管理系统进行需求分析,明确系统的功能和需求,例如: 1. 学生信息的录入、修改、删除和查询功能。 2. 学生信息的显示和打印功能。 3. 学生信息的统计和分析功能。 4. 具有管理员和普通用户两种角色,管理员可以对学生信息进行管理,而普通用户只能浏览学生信息。 二、设计数据库 接下来,我们需要设计数据库,为系统提供数据存储和管理。在这里,我们可以使用SQL Server数据库管理系统来创建一个名为“Student”的数据库,其中包含一个名为“StudentInfo”的表,用于存储学生信息。 表的结构如下: |字段名称|字段类型|字段长度|是否允许空值| |:----:|:----:|:----:|:----:| |StudentID|nvarchar|10|否| |Name|nvarchar|20|否| |Sex|nvarchar|4|否| |Age|int|4|否| |Class|nvarchar|20|否| |Address|nvarchar|50|是| |Phone|nvarchar|20|是| 在这个表中,我们设置了一个主键StudentID,用于唯一标识每一个学生。 三、设计架构 在这里,我们采用三层架构来设计学生信息管理系统。 1. 表示层:表示层是系统与用户之间的接口,主要负责用户交互和数据展示的工作。在这里,我们使用Windows Forms技术来实现用户界面。 2. 业务逻辑层:业务逻辑层是系统的核心部分,它负责处理系统的业务逻辑,将用户的请求转化为对数据访问层的请求,并将处理结果返回给用户。在这里,我们将业务逻辑层封装为一个名为“StudentBLL”的类。 3. 数据访问层:数据访问层是系统与数据库之间的接口,主要负责对数据库进行访问和操作。在这里,我们将数据访问层封装为一个名为“StudentDAL”的类。 四、编写代码 1. 表示层代码 在表示层中,我们需要实现用户界面和事件响应等功能。在这里,我们使用Windows Forms技术来实现用户界面,例如: ```csharp // MainForm.cs public partial class MainForm : Form { private StudentBLL studentBLL = new StudentBLL(); public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { RefreshData(); } private void RefreshData() { dgvStudent.DataSource = studentBLL.GetAllStudents(); } private void btnAdd_Click(object sender, EventArgs e) { AddStudentForm addStudentForm = new AddStudentForm(); if (addStudentForm.ShowDialog() == DialogResult.OK) { Student student = new Student(); student.StudentID = addStudentForm.txtStudentID.Text; student.Name = addStudentForm.txtName.Text; student.Sex = addStudentForm.cboSex.Text; student.Age = Convert.ToInt32(addStudentForm.txtAge.Text); student.Class = addStudentForm.txtClass.Text; student.Address = addStudentForm.txtAddress.Text; student.Phone = addStudentForm.txtPhone.Text; if (studentBLL.AddStudent(student)) { MessageBox.Show("添加成功!"); RefreshData(); } else { MessageBox.Show("添加失败,请检查输入信息!"); } } } private void btnEdit_Click(object sender, EventArgs e) { if (dgvStudent.CurrentRow != null) { EditStudentForm editStudentForm = new EditStudentForm(); editStudentForm.txtStudentID.Text = dgvStudent.CurrentRow.Cells["StudentID"].Value.ToString(); editStudentForm.txtName.Text = dgvStudent.CurrentRow.Cells["Name"].Value.ToString(); editStudentForm.cboSex.Text = dgvStudent.CurrentRow.Cells["Sex"].Value.ToString(); editStudentForm.txtAge.Text = dgvStudent.CurrentRow.Cells["Age"].Value.ToString(); editStudentForm.txtClass.Text = dgvStudent.CurrentRow.Cells["Class"].Value.ToString(); editStudentForm.txtAddress.Text = dgvStudent.CurrentRow.Cells["Address"].Value.ToString(); editStudentForm.txtPhone.Text = dgvStudent.CurrentRow.Cells["Phone"].Value.ToString(); if (editStudentForm.ShowDialog() == DialogResult.OK) { Student student = new Student(); student.StudentID = editStudentForm.txtStudentID.Text; student.Name = editStudentForm.txtName.Text; student.Sex = editStudentForm.cboSex.Text; student.Age = Convert.ToInt32(editStudentForm.txtAge.Text); student.Class = editStudentForm.txtClass.Text; student.Address = editStudentForm.txtAddress.Text; student.Phone = editStudentForm.txtPhone.Text; if (studentBLL.UpdateStudent(student)) { MessageBox.Show("修改成功!"); RefreshData(); } else { MessageBox.Show("修改失败,请检查输入信息!"); } } } else { MessageBox.Show("请先选择一条记录!"); } } private void btnDelete_Click(object sender, EventArgs e) { if (dgvStudent.CurrentRow != null) { string studentID = dgvStudent.CurrentRow.Cells["StudentID"].Value.ToString(); if (MessageBox.Show("确定要删除学号为" + studentID + "的学生信息吗?", "删除确认", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (studentBLL.DeleteStudent(studentID)) { MessageBox.Show("删除成功!"); RefreshData(); } else { MessageBox.Show("删除失败!"); } } } else { MessageBox.Show("请先选择一条记录!"); } } private void btnSearch_Click(object sender, EventArgs e) { string keyword = txtKeyword.Text.Trim(); dgvStudent.DataSource = studentBLL.SearchStudents(keyword); } private void btnPrint_Click(object sender, EventArgs e) { PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == DialogResult.OK) { PrintDocument printDocument = new PrintDocument(); printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage); printDocument.PrinterSettings = printDialog.PrinterSettings; printDocument.Print(); } } private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { Font font = new Font("宋体", 12, FontStyle.Regular); Brush brush = new SolidBrush(Color.Black); int x = e.MarginBounds.Left; int y = e.MarginBounds.Top; int rowHeight = dgvStudent.Rows[0].Height; int columnCount = dgvStudent.Columns.Count; for (int i = 0; i < columnCount; i++) { e.Graphics.DrawString(dgvStudent.Columns[i].HeaderText, font, brush, x, y); x += dgvStudent.Columns[i].Width; } y += rowHeight; for (int i = 0; i < dgvStudent.Rows.Count; i++) { x = e.MarginBounds.Left; for (int j = 0; j < columnCount; j++) { e.Graphics.DrawString(dgvStudent.Rows[i].Cells[j].Value.ToString(), font, brush, x, y); x += dgvStudent.Columns[j].Width; } y += rowHeight; } } } ``` 2. 业务逻辑层代码 在业务逻辑层中,我们需要实现系统的业务逻辑,例如: ```csharp // StudentBLL.cs public class StudentBLL { private StudentDAL studentDAL = new StudentDAL(); public DataTable GetAllStudents() { return studentDAL.GetAllStudents(); } public bool AddStudent(Student student) { if (studentDAL.GetStudentByID(student.StudentID) == null) { return studentDAL.AddStudent(student); } else { return false; } } public bool UpdateStudent(Student student) { if (studentDAL.GetStudentByID(student.StudentID) != null) { return studentDAL.UpdateStudent(student); } else { return false; } } public bool DeleteStudent(string studentID) { if (studentDAL.GetStudentByID(studentID) != null) { return studentDAL.DeleteStudent(studentID); } else { return false; } } public DataTable SearchStudents(string keyword) { return studentDAL.SearchStudents(keyword); } } ``` 3. 数据访问层代码 在数据访问层中,我们需要实现对数据库的访问和操作,例如: ```csharp // StudentDAL.cs public class StudentDAL { private string connectionString = ConfigurationManager.ConnectionStrings["Student"].ConnectionString; public DataTable GetAllStudents() { string sql = "SELECT StudentID, Name, Sex, Age, Class, Address, Phone FROM StudentInfo"; return SqlHelper.ExecuteDataTable(connectionString, CommandType.Text, sql); } public Student GetStudentByID(string studentID) { string sql = "SELECT StudentID, Name, Sex, Age, Class, Address, Phone FROM StudentInfo WHERE StudentID = @StudentID"; SqlParameter[] parameters = new SqlParameter[]{ new SqlParameter("@StudentID", studentID) }; DataTable dataTable = SqlHelper.ExecuteDataTable(connectionString, CommandType.Text, sql, parameters); if (dataTable.Rows.Count == 1) { Student student = new Student(); student.StudentID = dataTable.Rows[0]["StudentID"].ToString(); student.Name = dataTable.Rows[0]["Name"].ToString(); student.Sex = dataTable.Rows[0]["Sex"].ToString(); student.Age = Convert.ToInt32(dataTable.Rows[0]["Age"]); student.Class = dataTable.Rows[0]["Class"].ToString(); student.Address = dataTable.Rows[0]["Address"].ToString(); student.Phone = dataTable.Rows[0]["Phone"].ToString(); return student; } else { return null; } } public bool AddStudent(Student student) { string sql = "INSERT INTO StudentInfo(StudentID, Name, Sex, Age, Class, Address, Phone) VALUES(@StudentID, @Name, @Sex, @Age, @Class, @Address, @Phone)"; SqlParameter[] parameters = new SqlParameter[]{ new SqlParameter("@StudentID", student.StudentID), new SqlParameter("@Name", student.Name), new SqlParameter("@Sex", student.Sex), new SqlParameter("@Age", student.Age), new SqlParameter("@Class", student.Class), new SqlParameter("@Address", student.Address), new SqlParameter("@Phone", student.Phone) }; return SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, parameters) == 1; } public bool UpdateStudent(Student student) { string sql = "UPDATE StudentInfo SET Name = @Name, Sex = @Sex, Age = @Age, Class = @Class, Address = @Address, Phone = @Phone WHERE StudentID = @StudentID"; SqlParameter[] parameters = new SqlParameter[]{ new SqlParameter("@StudentID", student.StudentID), new SqlParameter("@Name", student.Name), new SqlParameter("@Sex", student.Sex), new SqlParameter("@Age", student.Age), new SqlParameter("@Class", student.Class), new SqlParameter("@Address", student.Address), new SqlParameter("@Phone", student.Phone) }; return SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, parameters) == 1; } public bool DeleteStudent(string studentID) { string sql = "DELETE FROM StudentInfo WHERE StudentID = @StudentID"; SqlParameter[] parameters = new SqlParameter[]{ new SqlParameter("@StudentID", studentID) }; return SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, sql, parameters) == 1; } public DataTable SearchStudents(string keyword) { string sql = "SELECT StudentID, Name, Sex, Age, Class, Address, Phone FROM StudentInfo WHERE StudentID LIKE '%' + @Keyword + '%' OR Name LIKE '%' + @Keyword + '%'"; SqlParameter[] parameters = new SqlParameter[]{ new SqlParameter("@Keyword", keyword) }; return SqlHelper.ExecuteDataTable(connectionString, CommandType.Text, sql, parameters); } } ``` 五、总结 通过以上的介绍,我们可以看到,采用C#语言和三层架构开发学生信息管理系统可以提高系统的可维护性、可扩展性、可重用性和可测试性等方面的优势,同时也可以有效地分离业务逻辑和数据访问层,使系统的结构更加清晰和易于维护。
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

偕臧x

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值