123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- 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 InvitationOfficialActivitiesService
- {
- /// <summary>
- /// 查询所有
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回集合</returns>
- List<InvitationOfficialActivities> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<InvitationOfficialActivities>.excuteSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", sql, CommandType.Text, param);
- }
- /// <summary>
- /// 获取单个对象
- /// </summary>
- /// <param name="sql">sql语句</param>
- /// <param name="param">可变参数数组</param>
- /// <returns>返回空或者单个对象</returns>
- InvitationOfficialActivities excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<InvitationOfficialActivities> ioaList = excuteSql(sql, param);
- //判断集合是否为空
- if (ioaList == null || ioaList.Count == 0)
- //返回null
- return null;
- //返回单个对象
- return ioaList[0];
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public InvitationOfficialActivities GetInvitationOfficialActivitiesByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from InvitationOfficialActivities where Id = @id and isdel=0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public InvitationOfficialActivities GetInvitationOfficialActivitiesAndDiId(int diid,string Inviter)
- {
- //调用获取单个对象的方法
- return excuteType("select * from InvitationOfficialActivities where DIId = @diid and Inviter="+Inviter+" and isdel=0", new SqlParameter("@diid", diid));
- }
- public List<InvitationOfficialActivities> GetIByDiid(int diid)
- {
- //调用获取单个对象的方法
- return excuteSql("select * from InvitationOfficialActivities where DIId = @diid and isdel=0", new SqlParameter("@diid", diid));
- }
- /// <summary>
- /// 获取全部 - 分页
- /// </summary>
- /// <returns></returns>
- public List<InvitationOfficialActivities> GetInvitationOfficialActivities(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string inviter, string startTime, string endTime, string arrayUsersId)
- {
- string sqlwhere = "IsDel = 0 and DIId = '" + tourCode + "' and Inviter like '%" + inviter + "%' and Operator in (" + arrayUsersId + ")";
- if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
- sqlwhere += " and (InviteTime Between '" + startTime + "' and '" + endTime + "')";
- return PageBase<InvitationOfficialActivities>.excutePageSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", "InvitationOfficialActivities", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <returns></returns>
- public bool AddInvitationOfficialActivities(InvitationOfficialActivities ioa, out int id)
- {
- string sql = "insert into InvitationOfficialActivities values(@DIId,@InviterArea,@Inviter,@InviteTime,@Attachment,@InviteCosts,@Currency," +
- "@SendCost,@IsGoOfficialBusiness,@Remark,@Operator,@OperatorDate,@IsDel,@EventsCost,@TranslateCost,@SendCurrency,@EventsCurrency,@TranslateCurrency);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",ioa.DIId),
- new SqlParameter("@InviterArea",ioa.InviterArea),
- new SqlParameter("@Inviter",ioa.Inviter),
- new SqlParameter("@InviteTime",ioa.InviteTime),
- new SqlParameter("@Attachment",ioa.Attachment),
- new SqlParameter("@InviteCosts",ioa.InviteCosts),
- new SqlParameter("@Currency",ioa.Currency),
- new SqlParameter("@SendCost",ioa.SendCost),
- new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
- new SqlParameter("@Remark",ioa.Remark),
- new SqlParameter("@Operator",ioa.Operators),
- new SqlParameter("@OperatorDate",ioa.OperatorsDate),
- new SqlParameter("@IsDel",ioa.IsDel),
- new SqlParameter("@EventsCost",ioa.EventsCost),
- new SqlParameter("@TranslateCost",ioa.TranslateCost),
- new SqlParameter("@SendCurrency",ioa.SendCurrency),
- new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
- new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
- };
- int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
- if (obj > 0)
- {
- id = obj;
- return true;
- }
- id = 0;
- return false;
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public bool EditInvitationOfficialActivities(InvitationOfficialActivities ioa)
- {
- string sql = "update InvitationOfficialActivities set DIId = @DIId,InviterArea = @InviterArea,Inviter = @Inviter,InviteTime = @InviteTime," +
- "Attachment = @Attachment,InviteCosts = @InviteCosts,Currency = @Currency,SendCost = @SendCost," +
- "IsGoOfficialBusiness = @IsGoOfficialBusiness,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,EventsCost=@EventsCost," +
- " TranslateCost=@TranslateCost,SendCurrency=@SendCurrency,EventsCurrency=@EventsCurrency,TranslateCurrency=@TranslateCurrency where Id = @Id";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@DIId",ioa.DIId),
- new SqlParameter("@InviterArea",ioa.InviterArea),
- new SqlParameter("@Inviter",ioa.Inviter),
- new SqlParameter("@InviteTime",ioa.InviteTime),
- new SqlParameter("@Attachment",ioa.Attachment),
- new SqlParameter("@InviteCosts",ioa.InviteCosts),
- new SqlParameter("@Currency",ioa.Currency),
- new SqlParameter("@SendCost",ioa.SendCost),
- new SqlParameter("@IsGoOfficialBusiness",ioa.IsGoOfficaiaBussiness),
- new SqlParameter("@Remark",ioa.Remark),
- new SqlParameter("@Operator",ioa.Operators),
- new SqlParameter("@OperatorDate",ioa.OperatorsDate),
- new SqlParameter("@Id",ioa.Id),
- new SqlParameter("@EventsCost",ioa.EventsCost),
- new SqlParameter("@TranslateCost",ioa.TranslateCost),
- new SqlParameter("@SendCurrency",ioa.SendCurrency),
- new SqlParameter("@EventsCurrency",ioa.EventsCurrency),
- new SqlParameter("@TranslateCurrency",ioa.TranslateCurrency),
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool DelInvitationOfficialActivities(int id)
- {
- if (SqlHelper.ExecuteNonQuery("update InvitationOfficialActivities set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
- return true;
- return false;
- }
- }
- }
|