123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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 MonthKpiItemScoreService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<MonthKpiItemScore> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<MonthKpiItemScore>.excuteSql(new MonthKpiItemScore(), "MonthKpiItemScore", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- MonthKpiItemScore excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<MonthKpiItemScore> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// 根据uid,yearmonth查询
- /// 主要是为判空用
- /// </summary>
- /// <returns>返回空或者对象集合</returns>
- public List<MonthKpiItemScore> GetScoreByUidYm(int uid, string ym)
- {
-
- return excuteSql("select * from MonthKpiItemScore where IsDel=0 and Uid=" + uid + " and YearMonth='" + ym + "'");
- }
- /// <summary>
- /// 根据uid,yearmonth,itemid查询
- /// 主要是为repeater赋分用
- /// </summary>
- /// <returns>返回空或者对象集合</returns>
- public MonthKpiItemScore GetScoreByUidYmIid(int uid, string ym,string ItemId)
- {
- //调用获取单个对象的方法
- return excuteType("select * from MonthKpiItemScore where IsDel=0 and Uid=" + uid + " and YearMonth='" + ym + "' and ItemId='" + ItemId + "'");
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="cd"></param>
- /// <returns></returns>
- public bool AddMKIS(MonthKpiItemScore MKIS)
- {
- string sql = "insert into MonthKpiItemScore values(@Uid,@YearMonth,@ItemId,@ItemLeaderScore,@ItemManaScore,@ItemEmployScore,@IsDel)";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Uid",MKIS.Uid),
- new SqlParameter("@YearMonth",MKIS.YearMonth),
- new SqlParameter("@ItemId",MKIS.ItemId),
- new SqlParameter("@ItemLeaderScore",MKIS.ItemLeaderScore),
- new SqlParameter("@ItemManaScore",MKIS.ItemManaScore),
- new SqlParameter("@ItemEmployScore",MKIS.ItemEmployScore),
- new SqlParameter("@IsDel",MKIS.IsDel),
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- public MonthKpiItemScore EditMkisbyUidYmIid(int uid, string ym,string ItemId,float ls,float ms,float es)
- {
- return excuteType("update MonthKpiItemScore set ItemLeaderScore=" + ls + " ItemManaScore=" + ms + " ItemEmployScore=" + es + " where Uid=" + uid + " and YearMonth='" + ym + "' and ItemId=" + ItemId);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sdt"></param>
- /// <returns></returns>
- public bool EditMKIS(MonthKpiItemScore MKIS)
- {
- string sql = "update MonthKpiItemScore set Uid=@Uid,YearMonth = @YearMonth,ItemId = @ItemId,ItemLeaderScore=@ItemLeaderScore,ItemManaScore = @ItemManaScore,ItemEmployScore = @ItemEmployScore,IsDel = @IsDel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Uid",MKIS.Uid),
- new SqlParameter("@YearMonth",MKIS.YearMonth),
- new SqlParameter("@ItemId",MKIS.ItemId),
- new SqlParameter("@ItemLeaderScore",MKIS.ItemLeaderScore),
- new SqlParameter("@ItemManaScore",MKIS.ItemManaScore),
- new SqlParameter("@ItemEmployScore",MKIS.ItemEmployScore),
- new SqlParameter("@IsDel",MKIS.IsDel),
- new SqlParameter("@Id",MKIS.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- }
- }
|