12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data;
- using System.Data.SqlClient;
- namespace DAL
- {
- public class MonthKpiItemService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<MonthKpiItem> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<MonthKpiItem>.excuteSql(new MonthKpiItem(), "MonthKpiItem", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- MonthKpiItem excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<MonthKpiItem> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// 根据Id查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public MonthKpiItem GetMonthKpiItemByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from MonthKpiItem where Id = @id and IsDel = 0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据string查询信息
- /// </summary>
- /// <returns>返回空或者对象集合</returns>
- public List<MonthKpiItem> GetMonthKpiItem(string name)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from MonthKpiItem where Name like '%" + name + "%'");
- }
-
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <returns></returns>
- public List<MonthKpiItem> GetAll()
- {
- return excuteSql("select * from MonthKpiItem where IsDel=0", null);
- }
- }
- }
|