MonthKpiItemScoreService.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. namespace DAL
  9. {
  10. public class MonthKpiItemScoreService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<MonthKpiItemScore> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<MonthKpiItemScore>.excuteSql(new MonthKpiItemScore(), "MonthKpiItemScore", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. MonthKpiItemScore excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<MonthKpiItemScore> hdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (hdList == null || hdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return hdList[0];
  38. }
  39. /// <summary>
  40. /// 根据uid,yearmonth查询
  41. /// 主要是为判空用
  42. /// </summary>
  43. /// <returns>返回空或者对象集合</returns>
  44. public List<MonthKpiItemScore> GetScoreByUidYm(int uid, string ym)
  45. {
  46. return excuteSql("select * from MonthKpiItemScore where IsDel=0 and Uid=" + uid + " and YearMonth='" + ym + "'");
  47. }
  48. /// <summary>
  49. /// 根据uid,yearmonth,itemid查询
  50. /// 主要是为repeater赋分用
  51. /// </summary>
  52. /// <returns>返回空或者对象集合</returns>
  53. public MonthKpiItemScore GetScoreByUidYmIid(int uid, string ym,string ItemId)
  54. {
  55. //调用获取单个对象的方法
  56. return excuteType("select * from MonthKpiItemScore where IsDel=0 and Uid=" + uid + " and YearMonth='" + ym + "' and ItemId='" + ItemId + "'");
  57. }
  58. /// <summary>
  59. /// 增加
  60. /// </summary>
  61. /// <param name="cd"></param>
  62. /// <returns></returns>
  63. public bool AddMKIS(MonthKpiItemScore MKIS)
  64. {
  65. string sql = "insert into MonthKpiItemScore values(@Uid,@YearMonth,@ItemId,@ItemLeaderScore,@ItemManaScore,@ItemEmployScore,@IsDel)";
  66. SqlParameter[] parameter = new SqlParameter[]{
  67. new SqlParameter("@Uid",MKIS.Uid),
  68. new SqlParameter("@YearMonth",MKIS.YearMonth),
  69. new SqlParameter("@ItemId",MKIS.ItemId),
  70. new SqlParameter("@ItemLeaderScore",MKIS.ItemLeaderScore),
  71. new SqlParameter("@ItemManaScore",MKIS.ItemManaScore),
  72. new SqlParameter("@ItemEmployScore",MKIS.ItemEmployScore),
  73. new SqlParameter("@IsDel",MKIS.IsDel),
  74. };
  75. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  76. return true;
  77. return false;
  78. }
  79. public MonthKpiItemScore EditMkisbyUidYmIid(int uid, string ym,string ItemId,float ls,float ms,float es)
  80. {
  81. return excuteType("update MonthKpiItemScore set ItemLeaderScore=" + ls + " ItemManaScore=" + ms + " ItemEmployScore=" + es + " where Uid=" + uid + " and YearMonth='" + ym + "' and ItemId=" + ItemId);
  82. }
  83. /// <summary>
  84. /// 编辑
  85. /// </summary>
  86. /// <param name="sdt"></param>
  87. /// <returns></returns>
  88. public bool EditMKIS(MonthKpiItemScore MKIS)
  89. {
  90. string sql = "update MonthKpiItemScore set Uid=@Uid,YearMonth = @YearMonth,ItemId = @ItemId,ItemLeaderScore=@ItemLeaderScore,ItemManaScore = @ItemManaScore,ItemEmployScore = @ItemEmployScore,IsDel = @IsDel where Id = @Id";
  91. SqlParameter[] parameter = new SqlParameter[]{
  92. new SqlParameter("@Uid",MKIS.Uid),
  93. new SqlParameter("@YearMonth",MKIS.YearMonth),
  94. new SqlParameter("@ItemId",MKIS.ItemId),
  95. new SqlParameter("@ItemLeaderScore",MKIS.ItemLeaderScore),
  96. new SqlParameter("@ItemManaScore",MKIS.ItemManaScore),
  97. new SqlParameter("@ItemEmployScore",MKIS.ItemEmployScore),
  98. new SqlParameter("@IsDel",MKIS.IsDel),
  99. new SqlParameter("@Id",MKIS.Id)
  100. };
  101. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  102. return true;
  103. return false;
  104. }
  105. }
  106. }