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 InvitationOfficialActivitiesService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 InvitationOfficialActivities excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List ioaList = excuteSql(sql, param); //判断集合是否为空 if (ioaList == null || ioaList.Count == 0) //返回null return null; //返回单个对象 return ioaList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public InvitationOfficialActivities GetInvitationOfficialActivitiesByID(int id) { //调用获取单个对象的方法 return excuteType("select * from InvitationOfficialActivities where Id = @id and isdel=0", new SqlParameter("@id", id)); } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 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 GetIByDiid(int diid) { //调用获取单个对象的方法 return excuteSql("select * from InvitationOfficialActivities where DIId = @diid and isdel=0", new SqlParameter("@diid", diid)); } /// /// 获取全部 - 分页 /// /// public List 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.excutePageSql(new InvitationOfficialActivities(), "InvitationOfficialActivities", "InvitationOfficialActivities", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } /// /// 增加 /// /// 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; } /// /// 编辑 /// /// 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; } /// /// 删除 /// /// /// 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; } } }