⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentbll.cs

📁 连接数据库的基本操作,可以作为入门的学习参考
💻 CS
字号:
using System;
using System.Data;
using DALFactory.Dxs;
using IDAL.Dxs;
using SQLServerDAL.Dxs;
using Model.Dxs;

namespace BLL.Dxs
{
	/// <summary>
	/// StudentBLL 的摘要说明。
	/// </summary>
	public class StudentBLL
	{
		/// <summary>
		/// 获得学生信息接口
		/// </summary>
		/// <returns></returns>
		private IStudent GetStudentDAL()
		{
			IStudent studentDAL=StudentFactory.Create();
			return studentDAL;
		}

		/// <summary>
		/// 由学生编号获得学生信息
		/// </summary>
		/// <param name="studentId"></param>
		/// <returns></returns>
		public Student GetStudentById(int studentId)
		{
			IStudent studentDAL=this.GetStudentDAL();
			Student student=studentDAL.GetStudentInfoById(studentId);
			return student;
		}

		/// <summary>
		/// 获得所有学生的信息
		/// </summary>
		/// <returns></returns>
		public DataTable GetStudentAll()
		{
			IStudent studentDAL=this.GetStudentDAL();
			DataTable dt=studentDAL.GetAll();
			return dt;
		}

		/// <summary>
		/// 添加一条学生信息
		/// </summary>
		/// <param name="student"></param>
		/// <returns></returns>
		public bool AddStudent(Student student)
		{
			IStudent studentDAL=this.GetStudentDAL();
			return studentDAL.InsertStudentInfo(student);
		}

		public bool AddStudent(string name,string age,string height)
		{
			Student student=new Student();
			student.Name=name;
			student.Age=age;
			student.Height=height;
			return this.AddStudent(student);
		}

		/// <summary>
		/// 更新一条学生信息
		/// </summary>
		/// <param name="student"></param>
		/// <returns></returns>
		public bool UpdateStudent(Student student)
		{
			IStudent studentDAL=this.GetStudentDAL();
			return studentDAL.UpdateStudentInfo(student);
		}

		public bool UpdateStudent(int id,string name,string age,string height)
		{
			Student student=new Student();
			student.ID=id;
			student.Name=name;
			student.Age=age;
			student.Height=height;
			return this.UpdateStudent(student);
		}

		/// <summary>
		/// 删除一条学生信息
		/// </summary>
		/// <param name="student"></param>
		/// <returns></returns>
		public bool DeleteStudent(Student student)
		{
			IStudent studentDAL=this.GetStudentDAL();
			return studentDAL.DeleteStudentInfo(student);
		}

		public bool DeleteStudent(int id)
		{
			Student student=new Student();
			student.ID=id;
			return this.DeleteStudent(student);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -