using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using System.Data.SqlClient;
using System.Data;
using System.Runtime.InteropServices;
namespace DAL
{
///
/// 付款信息数据访问类
///
public class CreditCardPaymentService
{
///
/// 查询所有
///
/// sql语句
/// 可变参数数组
/// 返回集合
List excuteSql(string sql, params SqlParameter[] param)
{
return ServiceBase.excuteSql(new CreditCardPayment(), "CreditCardPayment", sql, CommandType.Text, param);
}
///
/// 获取单个对象
///
/// sql语句
/// 可变参数数组
/// 返回空或者单个对象
CreditCardPayment excuteType(string sql, params SqlParameter[] param)
{
//查询结果放入对象集合
List ccpList = excuteSql(sql, param);
//判断集合是否为空
if (ccpList == null || ccpList.Count == 0)
//返回null
return null;
//返回单个对象
return ccpList[0];
}
///
/// 根据编号查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CreditCardPayment GetCreditCardPaymentByID(int id, int ispay)
{
string sql = "select * from CreditCardPayment where Id = @id and isdel=0";
//ispay=2为不查询ispay
if (ispay != 2)
{
sql = sql + " and isPay=" + ispay;
}
//调用获取单个对象的方法
return excuteType(sql, new SqlParameter("@id", id));
}
///
/// 根据编号CId,Ctable查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CreditCardPayment GetCreditCardPaymentByCid(int cid,int cTable)
{
string sql = "select * from CreditCardPayment where cid = @cid and cTable=" + cTable;
//调用获取单个对象的方法
return excuteType(sql, new SqlParameter("@cid", cid));
}
///
/// 根据ID集合查询数据
///
///
///
public List GetByIdList(string idlist)
{
//调用获取单个对象的方法
return excuteSql("select * from CreditCardPayment where Isdel=0 and Id in (" + idlist + ")");
}
///
/// 根据查询对象信息
///
/// 对象编号
/// 返回空或者单个对象信息
public CreditCardPayment GetCreditCardPaymentByCIDAndDIIDAndCTable(int cid, int diid, int ctable)
{
//调用获取单个对象的方法
return excuteType("select * from CreditCardPayment where CId = @CId and DIId = @DIId and CTable = @CTable", new SqlParameter("@CId", cid), new SqlParameter("@DIId", diid), new SqlParameter("@CTable", ctable));
}
///
/// 查询ctable中的cid
///
/// cid集合
/// ctable
///
public List GetCreditCardPaymentByCIDSAndCTable(List cids , int ctable)
{
string sql = $@"select * from CreditCardPayment
where isdel = 0 and cid in ({string.Join(",",cids).TrimEnd(',')}) and ctable = {ctable} ";
return excuteSql(sql);
}
///
/// 查询对象集合
///
/// 标识
/// 团组主键编号
///
public List GetByInCTableAndDIID(string CTable, int DIID)
{
return excuteSql("select * from CreditCardPayment where isdel=0 and CTable in (" + CTable + ") and DIID = " + DIID + "");
}
///
/// 新增
///
/// 对象
public bool AddCreditCardPayment(CreditCardPayment ccp)
{
string sql = "insert into CreditCardPayment values(@PayDId,@ConsumptionPatterns,@ConsumptionDate,@CTDId,@BankNo,@CardholderName,@PayMoney,@PaymentCurrency,@DayRate,@CompanyBankNo,@OtherBankName,@OtherSideNo,@OtherSideName,@Remark,@Operator,@OperatorDate,@MFOperator,@MFOperatorDate,@IsAuditDM,@AuditDMOperate,@AuditDMDate,@IsAuditMF,@AuditMFOperate,@AuditMFDate,@IsAuditGM,@AuditGMOperate,@AuditGMDate,@IsPay,@DIId,@CId,@CTable,@IsDel,@PayPercentage,@PayThenMoney,@PayPercentageOld,@PayThenMoneyOld,@UpdateDate,@Payee,@RMBPrice,@OrbitalPrivateTransfer,@ExceedBudget,@IsMatchCreditCard)";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@PayDId",ccp.PayDId),
new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
new SqlParameter("@CTDId",ccp.CTDId),
new SqlParameter("@BankNo",ccp.BankNo),
new SqlParameter("@CardholderName",ccp.CardholderName),
new SqlParameter("@PayMoney",ccp.PayMoney),
new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
new SqlParameter("@DayRate",ccp.DayRate),
new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
new SqlParameter("@OtherBankName",ccp.OtherBankName),
new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
new SqlParameter("@OtherSideName",ccp.OtherSideName),
new SqlParameter("@Remark",ccp.Remark),
new SqlParameter("@Operator",ccp.Operators),
new SqlParameter("@OperatorDate",ccp.OperatorsDate),
new SqlParameter("@MFOperator",ccp.MFOperators),
new SqlParameter("@MFOperatorDate",ccp.MFOperatorsDate),
new SqlParameter("@IsAuditDM",ccp.IsAuditDM),
new SqlParameter("@AuditDMOperate",ccp.AuditDMOperate),
new SqlParameter("@AuditDMDate",ccp.AuditDMDate),
new SqlParameter("@IsAuditMF",ccp.IsAuditMF),
new SqlParameter("@AuditMFOperate",ccp.AuditMFOperate),
new SqlParameter("@AuditMFDate",ccp.AuditMFDate),
new SqlParameter("@IsAuditGM",ccp.IsAuditGM),
new SqlParameter("@AuditGMOperate",ccp.AuditGMOperate),
new SqlParameter("@AuditGMDate",ccp.AuditGMDate),
new SqlParameter("@IsPay",ccp.IsPay),
new SqlParameter("@DIId",ccp.DIId),
new SqlParameter("@CId",ccp.CId),
new SqlParameter("@CTable",ccp.CTable),
new SqlParameter("@IsDel",ccp.IsDel),
new SqlParameter("@PayPercentage",ccp.PayPercentage),
new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
new SqlParameter("@PayPercentageOld",ccp.PayPercentage),
new SqlParameter("@PayThenMoneyOld",ccp.PayThenMoney),
new SqlParameter("@UpdateDate",ccp.UpdateDate),
new SqlParameter("@Payee",ccp.Payee),
new SqlParameter("@RMBPrice",ccp.RMBPrice),
new SqlParameter("@OrbitalPrivateTransfer",ccp.OrbitalPrivateTransfer),
new SqlParameter("@ExceedBudget",ccp.ExceedBudget),
new SqlParameter("@IsMatchCreditCard","0")
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 编辑
///
/// 对象
public bool EditCreditCardPayment(CreditCardPayment ccp)
{
string sql = "update CreditCardPayment set PayThenMoneyOld=PayThenMoney,PayPercentageOld=PayPercentage,UpdateDate=OperatorDate,PayDId = @PayDId,ConsumptionPatterns = @ConsumptionPatterns,ConsumptionDate = @ConsumptionDate,CTDId = @CTDId,BankNo = @BankNo,CardholderName=@CardholderName,PayMoney=@PayMoney,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,CompanyBankNo = @CompanyBankNo,OtherBankName = @OtherBankName,OtherSideNo = @OtherSideNo,OtherSideName = @OtherSideName,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,PayPercentage = @PayPercentage,PayThenMoney = @PayThenMoney,IsAuditGM = 0,AuditGMOperate=0,AuditGMDate='',Payee=@Payee,RMBPrice=@RMBPrice,OrbitalPrivateTransfer=@OrbitalPrivateTransfer,ExceedBudget=@ExceedBudget where DIId = @DIId and CId = @CId and ID = @ID";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@PayDId",ccp.PayDId),
new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
new SqlParameter("@CTDId",ccp.CTDId),
new SqlParameter("@BankNo",ccp.BankNo),
new SqlParameter("@CardholderName",ccp.CardholderName),
new SqlParameter("@PayMoney",ccp.PayMoney),
new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
new SqlParameter("@DayRate",ccp.DayRate),
new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
new SqlParameter("@OtherBankName",ccp.OtherBankName),
new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
new SqlParameter("@OtherSideName",ccp.OtherSideName),
new SqlParameter("@Remark",ccp.Remark),
new SqlParameter("@Operator",ccp.Operators),
new SqlParameter("@OperatorDate",ccp.OperatorsDate),
new SqlParameter("@PayPercentage",ccp.PayPercentage),
new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
new SqlParameter("@DIId",ccp.DIId),
new SqlParameter("@CId",ccp.CId),
new SqlParameter("@Payee",ccp.Payee),
new SqlParameter("@RMBPrice",ccp.RMBPrice),
new SqlParameter("@OrbitalPrivateTransfer",ccp.OrbitalPrivateTransfer),
new SqlParameter("@ExceedBudget",ccp.ExceedBudget),
new SqlParameter("@Id",ccp.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
public bool EditCreditCardPaymentByHotelID(CreditCardPayment ccp)
{
string sql = "update CreditCardPayment set PayMoney=@PayMoney,PaymentCurrency=@PaymentCurrency,DayRate=@DayRate,Operator=@Operator,OperatorDate=@OperatorDate,PayThenMoney=@PayThenMoney,PayThenMoneyOld=@PayThenMoneyOld,RMBPrice=@RMBPrice, IsAuditGM = @IsAuditGM,AuditGMDate=@AuditGMDate where Id = @Id ";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@PayMoney",ccp.PayMoney),
new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
new SqlParameter("@DayRate",ccp.DayRate),
new SqlParameter("@Operator",ccp.Operators),
new SqlParameter("@OperatorDate",ccp.OperatorsDate),
new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
new SqlParameter("@PayThenMoneyOld",ccp.PayThenMoneyOld),
new SqlParameter("@RMBPrice",ccp.RMBPrice),
new SqlParameter("@IsAuditGM",ccp.IsAuditGM),
new SqlParameter("@AuditGMDate",ccp.AuditGMDate),
new SqlParameter("@Id",ccp.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 编辑
///
/// 对象
public bool EditCreditCardPaymentByID(CreditCardPayment ccp)
{
string sql = "update CreditCardPayment set PayDId = @PayDId,ConsumptionPatterns = @ConsumptionPatterns,ConsumptionDate = @ConsumptionDate,CTDId = @CTDId,BankNo = @BankNo,CardholderName=@CardholderName,PayMoney=@PayMoney,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,CompanyBankNo = @CompanyBankNo,OtherBankName = @OtherBankName,OtherSideNo = @OtherSideNo,OtherSideName = @OtherSideName,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,IsPay = 1 where Id = @Id";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@PayDId",ccp.PayDId),
new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
new SqlParameter("@CTDId",ccp.CTDId),
new SqlParameter("@BankNo",ccp.BankNo),
new SqlParameter("@CardholderName",ccp.CardholderName),
new SqlParameter("@PayMoney",ccp.PayMoney),
new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
new SqlParameter("@DayRate",ccp.DayRate),
new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
new SqlParameter("@OtherBankName",ccp.OtherBankName),
new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
new SqlParameter("@OtherSideName",ccp.OtherSideName),
new SqlParameter("@Remark",ccp.Remark),
new SqlParameter("@Operator",ccp.Operators),
new SqlParameter("@OperatorDate",ccp.OperatorsDate),
new SqlParameter("@Id",ccp.Id)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 编辑 - 价格、货币、汇率
///
/// 对象
public bool EditCreditCardPaymentByMoneyAndCurrencyAndDayRate(CreditCardPayment ccp)
{
string sql = "update CreditCardPayment set PayMoney=@PayMoney,RMBPrice=@RMBPrice,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,Operator = @Operator,OperatorDate = @OperatorDate ,IsAuditGM = 0,AuditGMOperate=0,AuditGMDate='' where DIId = @DIId and CId = @CId";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@PayMoney",ccp.PayMoney),
new SqlParameter("@RMBPrice",ccp.RMBPrice),
new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
new SqlParameter("@DayRate",ccp.DayRate),
new SqlParameter("@Operator",ccp.Operators),
new SqlParameter("@OperatorDate",ccp.OperatorsDate),
new SqlParameter("@DIId",ccp.DIId),
new SqlParameter("@CId",ccp.CId)
};
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
return true;
return false;
}
///
/// 更改人民币金额和汇率
///
///
///
public bool EditPayMoneyAndDayRate(int id, string payMoney, string dayRate, string RMBPrice)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set PayMoney = @PayMoney,DayRate = @DayRate,RMBPrice=@RMBPrice where Id = @Id", CommandType.Text, new SqlParameter("@PayMoney", payMoney), new SqlParameter("@DayRate", dayRate), new SqlParameter("@RMBPrice", RMBPrice), new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 删除
///
///
///
public bool DelCreditCardPayment(int cid, int diid)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsDel = 1 where CId = @CId and DIId = @DIId", CommandType.Text, new SqlParameter("@CId", cid), new SqlParameter("DIId", diid)) > 0)
return true;
return false;
}
///
/// 更改已付款状态
///
///
///
public bool UpdateCreditCardPaymentIsPay(int cid, int diid)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsPay = 1 where CId = @CId and DIId = @DIId", CommandType.Text, new SqlParameter("@CId", cid), new SqlParameter("DIId", diid)) > 0)
return true;
return false;
}
///
/// 更改审核通过状态 2021-01-11
///
///
///
public bool UpdateAudit(int id, int IsAuditGM, int auditGMOperate, string auditGMDate, float exceedbudget)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = @IsAuditGM,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate ,ExceedBudget=@ExceedBudget where Id = @Id",
CommandType.Text,
new SqlParameter("@IsAuditGM", IsAuditGM),
new SqlParameter("@AuditGMOperate", auditGMOperate),
new SqlParameter("@AuditGMDate", auditGMDate),
new SqlParameter("@ExceedBudget", exceedbudget),
new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 更改审核通过状态
///
///
///
public bool UpdateCreditCardPaymentIsAudit(int id, int auditGMOperate, string auditGMDate)
{
//CreditCardPayment ccp = GetCreditCardPaymentByID(id, 0);
//if (ccp != null)
// if(ccp.CTable==76 || ccp.CTable==85)
// UpdateCreditCardPaymentIsPay(id);
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 1,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
public bool UpdateCreditCardPaymentIsAuditMF(int id, int AuditMFOperate, string AuditMFDate)
{
//CreditCardPayment ccp = GetCreditCardPaymentByID(id, 0);
//if (ccp != null)
// if(ccp.CTable==76 || ccp.CTable==85)
// UpdateCreditCardPaymentIsPay(id);
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditMF = 1,AuditMFOperate = @AuditMFOperate , AuditMFDate = @AuditMFDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditMFOperate", AuditMFOperate), new SqlParameter("@AuditMFDate", AuditMFDate)
, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 审核不通过
///
///
///
public bool UpdateCreditCardPaymentIsReAudit(int id, int auditGMOperate, string auditGMDate)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 3,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
public List GetCreditCardPaymentByCTableAndIsPay(int CTable, int IsPay)
{
//调用获取单个对象的方法
return excuteSql("select * from creditCardPayment where IsDel = 0 and CTable = @CTable and IsPay = @IsPay", new SqlParameter("@CTable", CTable), new SqlParameter("@IsPay", IsPay));
}
///
/// 根据类别和支付状态查询信用卡表数据
/// 分页
/// 20210910 贾文滔
///
///
///
///
public List GetDataByCTableAndIsPay(int pageIndex, out int sumPage, out int totalRecord, int CTable, int IsPay)
{
string sqlwhere = "Isdel=0 and CTable=" + CTable+ " and IsPay=" + IsPay;
return PageBase.excutePageSql(new CreditCardPayment(), "CreditCardPayment", "CreditCardPayment", "*", "id desc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord);
}
///
/// 经理审核
///
///
public List GetOPListByDIID(string diid, int isAuditGM)
{
return excuteSql("select * from creditCardPayment where diid = " + diid + " and IsAuditGM = " + isAuditGM + " and isDel = 0 and Operator > 0 and Operator is not null");
}
///
/// 更改审核通过状态
///
///
///
public bool UpdateCreditCardPaymentIsAuditByNo(int id, int auditGMOperate, string auditGMDate)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 2,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 查询付款集合
///
///
public List GetOPIsPayListByDIID(string diid, int isPay)
{
return excuteSql("select * from creditCardPayment where diid = " + diid + " and IsPay = " + isPay + " and IsAuditGM = 1");
}
///
/// 付款申请书 - 旧版2016-05-10
///
///
//public List GetOPIsPaymentApplicationReport(string startTime,string endTime)
//{
// return excuteSql("select * from creditCardPayment where isDel = 0 and IsPay = 0 and IsAuditGM = 1 and (auditGMDate between '" + startTime + "' and '" + endTime + "')");
//}
///
/// 付款申请书
///
///
public List GetOPIsPaymentApplicationReport(string startTime, string endTime)
{
return excuteSql("select * from creditCardPayment where isDel = 0 and IsPay = 0 and IsAuditGM = 1 and (auditGMDate between '" + startTime + "' and '" + endTime + "')");
}
///
/// 更改已付款状态
///
///
///
public bool UpdateCreditCardPaymentIsPay(int id)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsPay = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 更改已付款状态
///
///
///
public bool UpdateCreditCardPaymentIsPay(int id, string DayRate, string RMBPrice)
{
string sql = "update CreditCardPayment set IsPay = 1";
if (DayRate != "")
{
sql = sql + " ,DayRate=" + DayRate;
}
if (RMBPrice != "")
sql = sql + " ,RMBPrice=" + RMBPrice;
sql = sql + " where id=@Id";
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 修改信用卡匹配状态
///
///
///
///
public bool UpdateCreditCardPaymentIsMatchCreditCard(string[] ids, int IsMatchCreditCard = 1)
{
if (ids != null && ids.Length > 0)
{
string sql = $"update CreditCardPayment set IsMatchCreditCard = {IsMatchCreditCard} where isdel = 0 and id in ({string.Join(",", ids).TrimEnd(',')})";
if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text) > 0)
return true;
}
return false;
}
///
/// 获取团组总费用
///
///
///
public double GetSumByDIID(int diid)
{
Object obj = SqlHelper.ExecuteScalar("select sum(PayMoney) from CreditCardPayment where diid = " + diid + " and isDel = 0 and isPay = 1", CommandType.Text);
if (obj == null || string.IsNullOrEmpty(obj.ToString()))
{
return 0.0;
}
else
{
return (double)(obj);
}
}
public decimal GetRBMSumByDiid(int diid)
{
Object obj = SqlHelper.ExecuteScalar("select SUM(RMBPrice) from CreditCardPayment where diid = " + diid + " and isDel = 0 and isPay = 1", CommandType.Text);
if (obj == null || string.IsNullOrEmpty(obj.ToString()))
{
return 0.00M;
}
else
{
return Convert.ToDecimal(obj);
}
}
///
/// 根据团组业务类型获取收款方
///
/// 团组业务类型
///
public List GetPayee(int Ctable, string payee)
{
List List = new List();
using (SqlDataReader dr = SqlHelper.ExcuteReader("select Distinct(payee) from CreditCardPayment where CTable = " + Ctable + " AND Ispay=1 and Isdel=0 and payee like '%" + payee + "%' ", CommandType.Text))
{
if (dr != null)
{
string str = "";
while (dr.Read())
{
str = dr["payee"].ToString();
List.Add(str);
}
}
}
return List;
}
///
/// 获取非团组总费用
///
///
///
public double GetSumOfNotTeamByDIID(int diid)
{
return (double)(SqlHelper.ExecuteScalar("select sum(PayMoney) from CreditCardPayment where diid <> " + diid + "", CommandType.Text));
}
///
/// 更改团组是否操作完成状态
///
///
///
public bool EditCreditCardPaymentByDiid(int id)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsSure = 1,SureTime=" + DateTime.Now + " where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
return true;
return false;
}
///
/// 根据信用卡账单修改酒店付款金额
///
///
///
public bool UpdateCreditCardPaymentMoney(int diid, string hotelName, int payMoney)
{
if (SqlHelper.ExecuteNonQuery("update T set T.PayThenMoneyOld=T.PayThenMoney,T.UpdateDate=T.OperatorDate,T.paymoney = " + payMoney + " from CreditCardPayment T inner join HotelReservations H on T.diid=H.diid where T.diid=" + diid + " and h.isdel=0 and t.isdel=0 and t.CTABLE = 76 and t.cid = h.id and h.hotelName ='" + hotelName + "'", CommandType.Text, null) > 0)
return true;
return false;
}
///
/// 根据信用卡账单修改机票付款金额
///
///
///
public bool UpdateCreditCardPaymentMoneyForAirTick(int diid, int payMoney)
{
if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set PayThenMoneyOld=paymoney,UpdateDate=OperatorDate,paymoney = " + payMoney + " where diid=" + diid + " and ctable=85 and isdel=0", CommandType.Text, null) > 0)
return true;
return false;
}
///
/// 根据团组编号查询该团组的付款信息
///
///
///
public List GetOPIsPayListByDIID(int diid, int ispay)
{
string sql = "select * from creditCardPayment where diid = " + diid + " and isdel=0 and IsAuditGM=1";
if (ispay != 2)
sql += " and ispay=" + ispay;
return excuteSql(sql);
}
///
/// 根据团组编号查询该团组的付款信息 notIsPsy
///
///
///
public List GetByDIIDNotIsPay(int diid)
{
string sql = "select * from creditCardPayment where diid = " + diid + " and isdel = 0 and IsAuditGM <> 2 ";
return excuteSql(sql);
}
///
/// 根据团组编号查询该团组的付款信息
///
///
///
public List GetListByDIID(int diid)
{
string sql = "select * from creditCardPayment where diid = " + diid + " and isdel = 0 and isPay = 1";
return excuteSql(sql);
}
///
/// 根据团组编号查询该团组的付款信息
///
///
///
public List GetListByID(int id)
{
string sql = "select * from creditCardPayment where id = " + id + " and isdel=0";
return excuteSql(sql);
}
///
/// 查询团组所有的付款信息
///
///
public List GetOPListByDIID(string diid, string startTime, string endTime)
{
return excuteSql("select * from creditCardPayment where diid = " + diid + " and isDel = 0 and VisitDate between '" + startTime + "' and '" + endTime + "'");
}
///
/// 经理审核
///
///
public List GetOPListByDIID(int isAuditGM)
{
return excuteSql("select * from creditCardPayment where IsPay = 0 and IsAuditGM = " + isAuditGM + " and isDel = 0");
}
///
/// 根据条件查询条件获取 - 分页
///
///
///
///
///
///
///
public DataTable GetAll(int pageIndex, int pageSize, out int sumPage, out int totalRecord, int isAuditGM, string teamName, string tourCode, string clientName, string clientUnit)
{
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@pageIndex",pageIndex),
new SqlParameter("@pageSize",pageSize),
new SqlParameter("@isAuditGM",isAuditGM),
new SqlParameter("@teamName",teamName),
new SqlParameter("@tourCode",tourCode),
new SqlParameter("@clientName",clientName),
new SqlParameter("@clientUnit",clientUnit)
};
SqlParameter[] parameter1 = new SqlParameter[]{
new SqlParameter("@isAuditGM",isAuditGM),
new SqlParameter("@teamName",teamName),
new SqlParameter("@tourCode",tourCode),
new SqlParameter("@clientName",clientName),
new SqlParameter("@clientUnit",clientUnit)
};
string sqlC = "select count(1) from creditCardPayment T join DelegationInfo D on T.diid=D.id join setData S on T.Cid=S.ID join setData S1 on T.CTable=S1.ID where T.isdel=0 and isAuditGM=@isAuditGM and TeamName like '%" + teamName + "%' and TourCode like '%" + tourCode + "%' and ClientName like '%" + clientName + "%' and clientUnit like '%" + clientUnit + "%'";
object result = SqlHelper.ExecuteScalar(sqlC, CommandType.Text, parameter1);
if (result != null)
{
totalRecord = Convert.ToInt32(result.ToString());
//计算出总页数
sumPage = totalRecord % 10 == 0 ? totalRecord / 10 : totalRecord / 10 + 1;
}
else
{
totalRecord = 0;
//计算出总页数
sumPage = 1;
}
return SqlHelper.TransferProcedure("exec_creditCardPayment", CommandType.StoredProcedure, parameter);
}
//签证费用审核过不能删除
public bool isAduitByaVisa(int diid, int cid)
{
string sql = "select * from creditCardPayment WHERE DIId= @diid AND CId=@cid AND (IsAuditDM=1 OR IsAuditGM = 1 OR IsAuditMF = 1)";
SqlParameter[] parameter = new SqlParameter[]{
new SqlParameter("@diid",diid),
new SqlParameter("@cid",cid)
};
object result = SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter);
if (result != null)
{
return true;
}
else
{
return false;
}
}
///
/// 获取全部 - 分页 + 条件
///
/// 分页当前页数
/// 分页总页数
/// 一共多少条数据
/// 信用卡类型
/// 日期类型
/// 开始时间
/// 结束时间
/// 经手人
///
public List GetALL(int pageIndex, out int sumPage, out int totalRecord, int TypeId, int dateType, string startTime, string endTime, string HandlersOper)
{
//消费类型 不匹配 财付通,京东,微信支付,淘宝
string sqlwhere = "charindex('财付通',ConsumptionPatterns) = 0 " +
"and charindex('京东',ConsumptionPatterns) = 0 " +
"and charindex('微信支付',ConsumptionPatterns) = 0 " +
"and charindex('淘宝',ConsumptionPatterns) = 0 ";
//信用卡类型
if (TypeId == 0)
sqlwhere += " and IsDel = 0 and CTDId != 0 ";
else
sqlwhere += " and IsDel = 0 and CTDId != 0 and CTDId =" + TypeId;
//时间类型
if (dateType == 0 && startTime != "")
{
if (endTime != "")
sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
else
{
endTime = DateTime.Now.ToString("yyyy-MM-dd");
sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
}
}
else if (dateType == 1 && startTime != "")
{
if (endTime != "")
sqlwhere += " and MFOperatorsDate between '" + startTime + "' and '" + endTime + "'";
else
{
endTime = DateTime.Now.ToString("yyyy-MM-dd");
sqlwhere += " and MFOperatorsDate between '" + startTime + "' and '" + endTime + "'";
}
}
//经手人
if (HandlersOper != "")
sqlwhere += " and Operator=" + HandlersOper;
return PageBase.excutePageSql(new CreditCardPayment(), "CreditCardPayment", "CreditCardPayment", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
}
public List GetALL(string OperType,int size ,int page,out int total,string Queryname,string groupName)
{
string QuerySql = string.Empty;
string sql = $"select top {size} * from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null ";
total = 0 ;
if (!string.IsNullOrWhiteSpace(Queryname))
{
UsersService usersService = new UsersService();
var queryUserId = usersService.GetAll().FindAll(x => x.CnName.Contains(Queryname)).Select(x => x.Id);
if (queryUserId.Count() > 0)
{
QuerySql += $" and Operator in ({string.Join(",", queryUserId).TrimEnd(',')}) ";
}
else
{
QuerySql += $" and Operator in (0) ";
}
}
if (!string.IsNullOrWhiteSpace(groupName))
{
DelegationInfoService Dele = new DelegationInfoService();
var deleId = Dele.getByName(groupName).Select(x => x.Id);
if (deleId.Count() > 0)
{
QuerySql += $" and DIId in ({string.Join(",", deleId).TrimEnd(',')}) ";
}
else
{
QuerySql += $" and DIId in (0) ";
}
}
sql += QuerySql;
if (OperType == "finance")
{
sql += $@" and IsAuditMF = 0 and IsAuditGM = 0 and Id not in (
select top {(page-1)*size} Id from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null
and IsAuditMF = 0 and IsAuditGM = 0 {QuerySql}
order by DIId desc
)";
total = (int)SqlHelper.ExecuteScalar($@"select count(*) from creditCardPayment where isdel = 0 and Operator > 0
and Operator is not null and IsAuditMF = 0 and IsAuditGM = 0 " + QuerySql, CommandType.Text);
}
else if (OperType == "GM")
{
sql += $@" and IsAuditMF = 1 and IsAuditGM = 0 and Id not in (
select top {(page - 1) * size} Id from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null
and IsAuditMF = 1 and IsAuditGM = 0 {QuerySql}
order by DIId desc
)";
total = (int)SqlHelper.ExecuteScalar($@"select count(*) from creditCardPayment where isdel = 0 and Operator > 0
and Operator is not null and IsAuditMF = 1 and IsAuditGM = 0 " + QuerySql, CommandType.Text);
}
sql += " order by DIId desc ";
return excuteSql(sql);
}
///
/// excel导出查询
///
/// 信用卡类型
/// 开始时间
/// 结束时间
///
public List GetDownExcelSelelct(int TypeId, string startTime, string endTime)
{
string sqlwhere = "select * from creditCardPayment where ";
//信用卡类型
if (TypeId == 0)
sqlwhere += "IsDel = 0 and CTDId != 0 ";
else
sqlwhere += "IsDel = 0 and CTDId != 0 and CTDId =" + TypeId;
sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
return excuteSql(sqlwhere);
}
}
}