ViewWageService.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 工资多表联查数据访问类
  12. /// </summary>
  13. public class ViewWageService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<ViewWage> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<ViewWage>.excuteSql(new ViewWage(), "ViewWage", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 获取单个对象
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回空或者单个对象</returns>
  31. ViewWage excuteType(string sql, params SqlParameter[] param)
  32. {
  33. //查询结果放入对象集合
  34. List<ViewWage> vwList = excuteSql(sql, param);
  35. //判断集合是否为空
  36. if (vwList == null || vwList.Count == 0)
  37. //返回null
  38. return null;
  39. //返回单个对象
  40. return vwList[0];
  41. }
  42. /// <summary>
  43. /// 根据编号查询对象信息
  44. /// </summary>
  45. /// <param name="id">对象编号</param>
  46. /// <returns>返回空或者对象信息</returns>
  47. public List<ViewWage> GetByIdStr(string idStr,int company,int company2)
  48. {
  49. //调用获取单个对象的方法
  50. return excuteSql("select REPLACE (w.YearMonth,'-','') as YearMonth,SUBSTRING(w.StartDate,9,10) + '-' + SUBSTRING(w.EndDate,9,10) as Date,u.Number as UserNumber,u.CnName as UserName,w.Basic,w.Floats,w.PostAllowance,w.GarmentWashSubsidies,w.CommunicationSubsidies,w.TrafficSubsidies,w.InformationSecurityFee,w.OperationBonus,w.SpecialAllowance,w.OtherSubsidies,w.Should,w.WithholdingInsurance,w.SickLeave,w.SomethingFalse,w.LateTo,w.LeaveEarly,w.NotPunch,w.Absenteeism,w.OtherDeductions,w.TotalDeductions,w.TotalRealHair,u.Company,w.Mealsupplement,w.Tax,w.AfterTax,w.Gongjijin,w.GroupCost from Wage w join Users u on w.UserId = u.Id where w.Id in (" + idStr + ") and u.Company <> " + company + " and u.Company <> " + company2 + "");
  51. }
  52. }
  53. }