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

📄 specialitymanager.cs

📁 C#2.0宝典源码,C#经典书籍,很多例子
💻 CS
字号:
using System;
using System.Data.OleDb;
using StudentsMIS.DataAccess;

namespace StudentsMIS.Business
{
	/// <summary>
	/// SpecialityManager 的摘要说明。
	/// </summary>
	public class SpecialityManager
	{
		public SpecialityManager()
		{
			
		}

    public int Insert(string specialityID,string specialityCollege,string specialityName)
    {
      OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select speciality_ID From speciality Where speciality_ID=@SpecialityID");
      objCommand.Parameters.Add("@SpecialityID",specialityID);
      if(objCommand.ExecuteReader().HasRows)
      {
        CommandCloser.CloseOleDbCommand(objCommand);
        return 0;
      }
      objCommand = CommandBuilder.BuildOleDbCommand("Select speciality_name From speciality Where speciality_name=@SpecialityName And speciality_college=@SpecialityCollege");
      objCommand.Parameters.Add("@SpecialityName",specialityName);
      objCommand.Parameters.Add("@SpecialityCollege",specialityCollege);
      if(objCommand.ExecuteReader().HasRows)
      {
        CommandCloser.CloseOleDbCommand(objCommand);
        return 1;
      }
      objCommand = CommandBuilder.BuildOleDbCommand("INSERT INTO speciality(speciality_ID,speciality_name,speciality_college) VALUES(@SpecialityID,@SpecialityName,@SpecialityCollege)");
      objCommand.Parameters.Add("@SpecialityID",specialityID);
      objCommand.Parameters.Add("@SpecialityName",specialityName);
      objCommand.Parameters.Add("@SpecialityCollege",specialityCollege);
      objCommand.ExecuteNonQuery();
      CommandCloser.CloseOleDbCommand(objCommand);
      return 2;
    }

    public void Delete(string specialityID)
    {
      OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Delete From speciality Where speciality_ID=@SpecialityID");
      objCommand.Parameters.Add("@SpecialityID",specialityID);
      objCommand.ExecuteNonQuery();
      CommandCloser.CloseOleDbCommand(objCommand);
    }

    public int Update(string specialityID,string specialityCollege,string specialityName)
    {
      OleDbCommand objCommand = CommandBuilder.BuildOleDbCommand("Select speciality_name From speciality Where speciality_name=@SpecialityName And speciality_college=@SpecialityCollege");
      objCommand.Parameters.Add("@SpecialityName",specialityName);
      objCommand.Parameters.Add("@SpecialityCollege",specialityCollege);
      if(objCommand.ExecuteReader().HasRows)
      {
        CommandCloser.CloseOleDbCommand(objCommand);
        return 0;
      }
      objCommand = CommandBuilder.BuildOleDbCommand("Update speciality Set speciality_name=@SpecialityName,speciality_college=@SpecialityCollege Where speciality_ID=@SpecialityID");
      objCommand.Parameters.Add("@SpecialityName",specialityName);
      objCommand.Parameters.Add("@SpecialityCollege",specialityCollege);
      objCommand.Parameters.Add("@SpecialityID",specialityID);
      objCommand.ExecuteNonQuery();
      CommandCloser.CloseOleDbCommand(objCommand);
      return 1;
    }
	}
}

⌨️ 快捷键说明

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