123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 权限关联表数据访问类
- /// </summary>
- public class CompetenceService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<Competence> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<Competence>.excuteSql(new Competence(), "Competence", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- Competence excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<Competence> cList = excuteSql(sql, param);
- //判断集合是否为空
- if (cList == null || cList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return cList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public Competence GetCompetenceByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from Competence where Id = @id", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="Stable"></param>
- /// <returns></returns>
- public List<Competence> GetAll(int Stable)
- {
- return excuteSql("select * from Competence where STable = @STable", new SqlParameter("@STable", Stable));
- }
- /// <summary>
- /// 查询单个对象
- /// </summary>
- /// <param name="Stable"></param>
- /// <returns></returns>
- public Competence GetAll(int uid,int sid ,int Stable)
- {
- return excuteType("select * from Competence where UId = @UId and SId = @SId and STable = @STable", new SqlParameter("@UId", uid),new SqlParameter("@SId", sid),new SqlParameter("@STable", Stable));
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="c"></param>
- public bool AddCompetence(Competence c)
- {
- string sql = "insert into Competence values(@Uid,@Sid,@STable)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Uid",c.Uid),
- new SqlParameter("@Sid",c.Sid),
- new SqlParameter("@STable",c.STable)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelCompetence(int uid, int STable)
- {
- if (SqlHelper.ExecuteNonQuery("delete Competence where Uid =@Uid and STable = @STable", CommandType.Text, new SqlParameter("@Uid", uid), new SqlParameter("@STable",STable)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="sid"></param>
- /// <param name="STable"></param>
- /// <returns></returns>
- public bool DelCompetenceBySid(int sid,int STable)
- {
- if (SqlHelper.ExecuteNonQuery("delete Competence where Sid =@Sid and STable = @STable", CommandType.Text, new SqlParameter("@Sid", sid), new SqlParameter("@STable",STable)) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除用户对应页面权限
- /// </summary>
- /// <param name="sid"></param>
- /// <param name="STable"></param>
- /// <returns></returns>
- public bool DelCompetenceByUIdAndSIdAndSTable(int uid,int sid,int stable)
- {
- if (SqlHelper.ExecuteNonQuery("delete Competence where UId =@UId and SId = @SId and STable=@STable", CommandType.Text, new SqlParameter("@UId", uid), new SqlParameter("@SId", sid), new SqlParameter("@STable", stable)) > 0)
- return true;
- return false;
- }
- }
- }
|