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 { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new MonthKpiItemScore(), "MonthKpiItemScore", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 MonthKpiItemScore excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } /// /// 根据uid,yearmonth查询 /// 主要是为判空用 /// /// 返回空或者对象集合 public List GetScoreByUidYm(int uid, string ym) { return excuteSql("select * from MonthKpiItemScore where IsDel=0 and Uid=" + uid + " and YearMonth='" + ym + "'"); } /// /// 根据uid,yearmonth,itemid查询 /// 主要是为repeater赋分用 /// /// 返回空或者对象集合 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 + "'"); } /// /// 增加 /// /// /// 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); } /// /// 编辑 /// /// /// 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; } } }