123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Models;
- namespace DAL
- {
- /// <summary>
- /// 团组附件下载统计数据访问层
- /// </summary>
- public class TeamAttachmentService
- {
- /// <summary>
- /// 查询所有数据
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<TeamAttachmentInfo> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<TeamAttachmentInfo>.excuteSql(new TeamAttachmentInfo(), "TeamAttachmentInfo", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- TeamAttachmentInfo excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<TeamAttachmentInfo> ctggdList = excuteSql(sql, param);
- //判断集合是否为空
- if (ctggdList == null || ctggdList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ctggdList[0];
- }
- //增Add
- public bool Add(TeamAttachmentInfo tai)
- {
- string sql = "insert into TeamAttachment values(@Diid,@AirNumber,@HotelNumber,@VisaNumber,@InvitedNumber,@OfficialNumber,@PickNumber,@Oper,@OperDate,@Isdel);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@Diid",tai.Diid),
- new SqlParameter("@AirNumber",tai.AirNumber),
- new SqlParameter("@HotelNumber",tai.HotelNumber),
- new SqlParameter("@VisaNumber",tai.VisaNumber),
- new SqlParameter("@InvitedNumber",tai.InvitedNumber),
- new SqlParameter("@OfficialNumber",tai.OfficialNumber),
- new SqlParameter("@PickNumber",tai.PickNumber),
- new SqlParameter("@Oper",tai.Oper),
- new SqlParameter("@OperDate",tai.OperDate),
- new SqlParameter("@Isdel",tai.Isdel)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- //删Delete
- public bool Del(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update TeamAttachment set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- //改Update
- public bool Edit(TeamAttachmentInfo tai)
- {
- string sql = "update TeamAttachment set AirNumber=@AirNumber,HotelNumber=@HotelNumber,VisaNumber=@VisaNumber,InvitedNumber=@InvitedNumber," +
- "OfficialNumber=@OfficialNumber,PickNumber=@PickNumber,Oper=@Oper,OperDate=@OperDate,Isdel=@Isdel where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@AirNumber",tai.AirNumber),
- new SqlParameter("@HotelNumber",tai.HotelNumber),
- new SqlParameter("@VisaNumber",tai.VisaNumber),
- new SqlParameter("@InvitedNumber",tai.InvitedNumber),
- new SqlParameter("@OfficialNumber",tai.OfficialNumber),
- new SqlParameter("@PickNumber",tai.PickNumber),
- new SqlParameter("@Oper",tai.Oper),
- new SqlParameter("@OperDate",tai.OperDate),
- new SqlParameter("@Isdel",tai.Isdel),
- new SqlParameter("@Id",tai.Id)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 根据团组id singer
- /// </summary>
- /// <param name="diid">团组id</param>
- /// <returns></returns>
- public TeamAttachmentInfo GetByDiid(int diid)
- {
- //调用获取单个对象的方法
- return excuteType("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
- }
- /// <summary>
- /// 根据团组id
- /// </summary>
- /// <param name="diid">团组id</param>
- /// <returns></returns>
- public List<TeamAttachmentInfo> GetByDiids(int diid)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from TeamAttachment where IsDel=0 and Diid=@diid ", new SqlParameter("@diid", diid));
- }
- }
- }
|