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 GroupsDecreasePaymentsService { /// /// 查询所有 /// /// sql语句 /// 可变参数数组 /// 返回集合 List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new GroupsDecreasePayments(), "GroupsDecreasePayments", sql, CommandType.Text, param); } /// /// 获取单个对象 /// /// sql语句 /// 可变参数数组 /// 返回空或者单个对象 GroupsDecreasePayments excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List gdpList = excuteSql(sql, param); //判断集合是否为空 if (gdpList == null || gdpList.Count == 0) //返回null return null; //返回单个对象 return gdpList[0]; } /// /// 根据编号查询对象信息 /// /// 对象编号 /// 返回空或者单个对象信息 public GroupsDecreasePayments GetGroupsDecreasePaymentsByID(int id) { //调用获取单个对象的方法 return excuteType("select * from GroupsDecreasePayments where Id = @id and isdel=0", new SqlParameter("@id", id)); } /// /// 根据编号查询对象信息 - 多表-用于付款申请 /// /// 对象编号 /// 返回空或者单个对象信息 public GroupsDecreasePayments GetGroupsDecreasePaymentsByIDable(int id) { //调用获取单个对象的方法 //return excuteType("select * from GroupsDecreasePayments where Id = @id and isdel=0", new SqlParameter("@id", id)); return excuteType("select * from GroupsDecreasePayments gdp join dbo.DelegationInfo di on di.Id = gdp.DIID where (di.TeamDid <> 300 and di.TeamDid <> 320) and gdp.IsDel =0 and gdp.Id = @ID", new SqlParameter("@id", id)); } /// /// 获取全部 - 分页 /// /// public List GetGroupsDecreasePayments(int pageIndex, out int sumPage, out int totalRecord, string tourCode, string arrayUsersId) { string sqlwhere = "IsDel = 0 and DIId = " + tourCode + " and Operator in (" + arrayUsersId + ")"; return PageBase.excutePageSql(new GroupsDecreasePayments(), "GroupsDecreasePayments", "GroupsDecreasePayments", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } /// /// 获取增减款项表里的零用金数据 /// /// /// public List GetCashDataByDiid(int diid) { return excuteSql("select * from GroupsDecreasePayments where Diid = @diid and isdel=0 and PriceName like '%零用金%' ", new SqlParameter("@diid", diid)); } /// 增加 /// /// public bool AddGroupsDecreasePayments(GroupsDecreasePayments gpd, out int id) { string sql = "insert into GroupsDecreasePayments values(@DIID,@PriceName,@Price,@Currency,@FilePath,@Remark,@Operator,@OperatorDate,@IsDel,@PriceType,@coefficient,@PriceTypeDetail);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIId",gpd.DIID), new SqlParameter("@PriceName",gpd.PriceName), new SqlParameter("@Price",gpd.Price), new SqlParameter("@Currency",gpd.Currency), new SqlParameter("@FilePath",gpd.FilePath), new SqlParameter("@Remark",gpd.Remark), new SqlParameter("@Operator",gpd.Operators), new SqlParameter("@OperatorDate",gpd.OperatorsDate), new SqlParameter("@IsDel",gpd.IsDel), new SqlParameter("@PriceType",gpd.PriceType), new SqlParameter("@coefficient",gpd.coefficient), new SqlParameter("@PriceTypeDetail",gpd.PriceTypeDetail) }; int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter)); if (obj > 0) { id = obj; return true; } id = 0; return false; } /// /// 编辑 /// /// public bool EditGroupsDecreasePayments(GroupsDecreasePayments gpd) { string sql = "update GroupsDecreasePayments set DIID = @DIID,PriceName = @PriceName,Price = @Price,Currency = @Currency,FilePath = @FilePath,Remark = @Remark ,Operator = @Operator,OperatorDate = @OperatorDate,PriceType = @PriceType,coefficient= @coefficient,PriceTypeDetail=@PriceTypeDetail where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@DIId",gpd.DIID), new SqlParameter("@PriceName",gpd.PriceName), new SqlParameter("@Price",gpd.Price), new SqlParameter("@Currency",gpd.Currency), new SqlParameter("@FilePath",gpd.FilePath), new SqlParameter("@Remark",gpd.Remark), new SqlParameter("@Operator",gpd.Operators), new SqlParameter("@OperatorDate",gpd.OperatorsDate), new SqlParameter("@Id",gpd.Id), new SqlParameter("@PriceType",gpd.PriceType), new SqlParameter("@coefficient",gpd.coefficient), new SqlParameter("@PriceTypeDetail",gpd.PriceTypeDetail) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } /// /// 删除 /// /// public bool DelGroupsDecreasePayments(int id) { string sql = "update GroupsDecreasePayments set IsDel = 1 where Id = @Id"; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } } }