using System; using System.Collections.Generic; using System.Linq; using System.Text; using Models; using System.Data.SqlClient; using System.Data; namespace DAL { /// /// 应收款项报表数据访问类 /// public class ViewDelegationInfoAndForeignReceivablesService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new ViewDelegationInfoAndForeignReceivables(), "ViewDelegationInfoAndForeignReceivables", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 ViewDelegationInfoAndForeignReceivables excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List adList = excuteSql(sql, param); //判断集合是否为空 if (adList == null || adList.Count == 0) //返回null return null; //返回单个对象 return adList[0]; } /// /// 根据出访日期获取数据集合 /// /// /// /// public List GetByTime(string startTime, string endTime) { //return excuteSql("select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from ForeignReceivables fr join DelegationInfo di on fr.DIID = di.id where di.VisitDate between '" + startTime + "' and '" + endTime + "' and issure=1 and di.isdel=0 "); return excuteSql("select distinct fr.diid,di.TeamName,di.ClientUnit,di.VisitDate from ForeignReceivables fr join DelegationInfo di on fr.DIID = di.id where di.VisitDate between '" + startTime + "' and '" + endTime + "' and di.isdel=0 order by di.VisitDate asc"); } /// /// /// /// /// /// (团组收入,会务收入,赛事项目收入,其他非团组收入) /// public List GetByTimeAndType(string startTime, string endTime,string Type) { string sql = string.Empty; switch (Type) { case "团组收入": sql = $@"select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(38,39,40) and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 "; break; case "会务收入": sql = $@"select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(691) and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 "; break; case "赛事项目收入": sql = $@" select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c where a.TeamDid = b.Id and a.Id = c.DIId and b.id in(762) and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 "; break; case "其他非团组收入": sql = $@" select distinct a.Id as diid,a.TeamName,a.ClientUnit,a.VisitDate from DelegationInfo a,SetData b ,ForeignReceivables c where a.TeamDid = b.Id and a.Id = c.DIId and b.id not in(762,691,38,39,40) and a.VisitDate between '{startTime}' and '{endTime}' and a.IsDel = 0 "; break; } if (string.IsNullOrEmpty(sql)) { return new List(); } return excuteSql(sql); } } }