12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Models;
- using System.Data.SqlClient;
- using System.Data;
- namespace DAL
- {
- /// <summary>
- /// 工资多表联查数据访问类
- /// </summary>
- public class ViewWageService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<ViewWage> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<ViewWage>.excuteSql(new ViewWage(), "ViewWage", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- ViewWage excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<ViewWage> vwList = excuteSql(sql, param);
- //判断集合是否为空
- if (vwList == null || vwList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return vwList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者对象信息</returns>
- public List<ViewWage> GetByIdStr(string idStr,int company,int company2)
- {
- //调用获取单个对象的方法
- 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 + "");
- }
- }
- }
|