You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1252 lines
78 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Data;
using System.Data.SqlClient;
using WebSqlHelper;
using DSWeb.Models;
using System.Collections;
using System.Collections.Generic;
namespace DSWeb.EntityDA
{
public class FeeDoDA
{
private string PARM_FEE_DO_GID = "@gid";
private string PARM_FEE_DO_BILL_NO = "@bill_no";
private string PARM_FEE_DO_BSNO = "@bsno";
private string PARM_FEE_DO_MBL_NO = "@mbl_no";
private string PARM_FEE_DO_HBL_NO = "@nbl_no";
private string PARM_FEE_DO_CUSTOMER_NAME = "@customer_name";
private string PARM_FEE_DO_BSTYPE = "@bs_type";
private string PARM_FEE_DO_FEE_ID = "@fee_id";
private string PARM_FEE_DO_FEE_NAME = "@fee_name";
private string PARM_FEE_DO_CURRENCY = "@currency";
private string PARM_FEE_DO_AMOUNT = "@amount";
private string PARM_FEE_DO_DO_AMOUNT = "@do_amount";
private string PARM_FEE_DO_FEE_TYPE = "@fee_type";
private string PARM_FEE_DO_CATEGORY = "@category";
private string PARM_FEE_DO_BILL_STATUS = "@bill_status";
private string PARM_FEE_DO_REMARK = "@remark";
//private string PARM_FEE_DO_IS_DELETE = "@is_delete";
//private string PARM_FEE_DO_DELETE_USER = "@delete_user";
//private string PARM_FEE_DO_DELETE_TIME = "@delete_time";
private string PARM_FEE_DO_INVOICE_SETTLE_NO = "@invoice_settle_no";
private string PARM_FEE_SETTLEMENT_GID = "@gid";
private string PARM_FEE_SETTLEMENT_BILL_NO = "@bill_no";
//private string PARM_FEE_SETTLEMENT_BILL_DATE = "@bill_date";
private string PARM_FEE_SETTLEMENT_SETTLE_MODE = "@settle_mode";
private string PARM_FEE_SETTLEMENT_CUSTOMER_NAME = "@customer_name";
private string PARM_FEE_SETTLEMENT_SETTLE_TYPE = "@settle_type";
private string PARM_FEE_SETTLEMENT_AMOUNT_RMB = "@amount_rmb";
private string PARM_FEE_SETTLEMENT_ACCOUNT_RMB = "@account_rmb";
private string PARM_FEE_SETTLEMENT_RATE = "@rate";
private string PARM_FEE_SETTLEMENT_AMOUNT_USD = "@amount_usd";
private string PARM_FEE_SETTLEMENT_ACCOUNT_USD = "@account_usd";
private string PARM_FEE_SETTLEMENT_BILL_TYPE = "@bill_type";
private string PARM_FEE_SETTLEMENT_VOUCHER_NO = "@voucher_no";
private string PARM_FEE_SETTLEMENT_SETTLE_USER = "@settle_user";
//private string PARM_FEE_SETTLEMENT_SETTLE_TIME = "@settle_time";
//private string PARM_FEE_SETTLEMENT_AUDIT_USER = "@audit_user";
//private string PARM_FEE_SETTLEMENT_AUDIT_TIME = "@audit_time";
private string PARM_FEE_SETTLEMENT_IS_EXPORT = "@is_export";
private string PARM_FEE_SETTLEMENT_FINANCIAL_VOUCHER = "@financial_voucher";
private string PARM_FEE_SETTLEMENT_BILL_STATUS = "@bill_status";
private string PARM_FEE_SETTLEMENT_REMARK = "@remark";
//private string PARM_FEE_GID = "@gid";
//private string PARM_FEE_STATUS = "@fee_status";
private string PARM_FEE_SETTLEMENT = "@settlement";
private string PARM_FEE_CHEQUE_NUM = "@cheque_num";
//ch_fee_invoice
private const string PARM_INVOICE_GID = "@gid";
private const string PARM_INVOICE_IS_NEED_FEE = "@is_need_fee";
//ch_fee_recvamount
private const string PARM_RECEIVE_AMOUNT_GID = "@gid";
private const string PARM_RECEIVE_AMOUNT_DO_AMOUNT = "@do_amount";
private const string PARM_RECEIVE_AMOUNT_SETTLE_USER = "@settle_user";
//ch_fee_verification
private const string PARM_VERIFICATION_GID = "@gid";
private const string PARM_VERIFICATION_BILL_NO = "@bill_no";
private const string PARM_VERIFICATION_SETTLE_TIME = "@settle_time";
private const string PARM_VERIFICATION_RECV_AMOUNT_ID = "@recvamount_id";
private const string PARM_VERIFICATION_SETTLE_USER = "@settle_user";
//private string SQL_SELECT_FEE_DO = "";
private string SQL_SELECT_GETDATE = "SELECT GETDATE()";
private string SQL_INSERT_FEE_DO = " INSERT INTO ch_fee_do(GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,REMARK,INVOICESETTLENO) "
+ " VALUES(@gid,@bill_no,@bsno,@mbl_no,@nbl_no,@customer_name,@bs_type,@fee_id,@fee_name,@currency,@amount,@do_amount,@fee_type,@category,@bill_status,@remark,@invoice_settle_no) ";
private string SQL_SELECT_FEE_DO_BY_BILLNO = "SELECT GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,REMARK,ORIGCURRENCY,EXCHANGERATE,ISDELETED,INVOICESETTLENO,COMPANYID,ORIGAMOUNT FROM ch_fee_do WHERE BILLNO = @bill_no AND CATEGORY <> 7 order by bsno,feename";//申请发票
private string SQL_SELECT_FEE_DO_BY_BILLNO2 = "SELECT GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,REMARK,ORIGCURRENCY,EXCHANGERATE,ISDELETED,INVOICESETTLENO,COMPANYID,ORIGAMOUNT FROM ch_fee_do WHERE BILLNO = @bill_no AND CATEGORY = 7";//自由发票
//private string SQL_UPDATE_FEE = "UPDATE ch_fee SET SETTLEMENT = @settlement,FEESTATUS = @fee_status WHERE GID = @gid";
private string SQL_UPDATE_FEE = " UPDATE ch_fee SET ch_fee.SETTLEMENT = ch_fee.SETTLEMENT+@settlement,ch_fee.FEESTATUS = C.FEESTATUS,ch_fee.CHEQUENUM = @cheque_num "
+ " FROM "
+ " (SELECT A.GID,CASE WHEN B.AMOUNT < A.AMOUNT THEN CASE WHEN B.AMOUNT+A.SETTLEMENT = A.AMOUNT THEN 9 ELSE 8 END ELSE "
+ " CASE WHEN B.AMOUNT = A.AMOUNT THEN 9 END END as FEESTATUS FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID WHERE B.GID = @gid) as C "
+ " WHERE C.GID = ch_fee.GID ";
private string SQL_UPDATE_INVOICE = "UPDATE ch_fee_invoice SET ISNEEDFEE = @is_need_fee WHERE GID = @gid";
private string SQL_UPDATE_RECEIVE_AMOUNT = " UPDATE ch_fee_recvamount SET DOAMOUNT = ISNULL(DOAMOUNT,0)+@do_amount,SETTLETIME = GETDATE(),SETTLEUSER = @settle_user WHERE GID = @gid ";
private string SQL_UPDATE_RECEIVE_AMOUNT_FINISH = " UPDATE ch_fee_recvamount SET ISFINISH = A.ISFINISH FROM (SELECT GID,CASE WHEN ISNULL(RECVAMOUNT,0) = ISNULL(DOAMOUNT,0) THEN 1 ELSE 0 END AS ISFINISH "
+ " FROM ch_fee_recvamount WHERE GID = @gid) as A WHERE ch_fee_recvamount.GID = A.GID ";
private string SQL_INSERT_CH_FEE_VERIFICATION = " INSERT INTO ch_fee_verification(GID,BILLNO,SETTLETIME,RECVAMOUNTID,SETTLEUSER) VALUES(@gid,@bill_no,GETDATE(),@recvamount_id,@settle_user)";
public DateTime getServerDateTime()
{
DateTime nowDateTime = new DateTime();
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_GETDATE, null))
{
try
{
while (sqlRead.Read())
{
if (!sqlRead.IsDBNull(0))
{
nowDateTime = sqlRead.GetDateTime(0);
}
}
}
catch (Exception execError)
{
throw execError;
}
}
return nowDateTime;
}
public DataSet GetExcuteSql(string strSql)
{
DataSet tempSet = new DataSet();
tempSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return tempSet;
}
/// <summary>
/// 去掉已结算的chFeeDo
/// </summary>
/// <param name="tempBillNO"></param>
/// <returns></returns>
public IList<FeeDoEntity> GetFeeDoByBillNO_DelCRDR(string tempBillNO)
{
//初始化返回变量
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
string SQL_SELECT_FEE_DO_BY_BILLNO_DelCRDR = "SELECT GID,BILLNO,BSNO,MBLNO,HBLNO,CUSTOMERNAME,BSTYPE,FEEID,FEENAME,CURRENCY,AMOUNT,DOAMOUNT,FEETYPE,CATEGORY,BILLSTATUS,REMARK,ORIGCURRENCY,EXCHANGERATE,ISDELETED,INVOICESETTLENO,COMPANYID,ORIGAMOUNT FROM ch_fee_do WHERE BILLNO = '" + tempBillNO + "' AND CATEGORY <> 7 "
//+ " and feeid not in (select feeid from ch_fee_do where (billno like '%CR%' or billno like '%DR%') and (ISDELETED is null or ISDELETED=0) and AMOUNT=DOAMOUNT) "
+ " and feeid not in (select f.gid from (select feeid,sum(AMOUNT) as AMOUNT from (select feeid,AMOUNT from ch_fee_do where (billno like '%CR%' or billno like '%DR%') and (ISDELETED is null or ISDELETED=0) and AMOUNT=DOAMOUNT ) as a group by a.feeid) as d LEFT OUTER JOIN ch_fee as f on f.gid=d.feeid where f.AMOUNT=d.AMOUNT) "//2014-03-03修改
+ " order by bsno,feename";//申请发票
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_DO_BY_BILLNO_DelCRDR, null))
{
try
{
//读取字段值
while (sqlRead.Read())
{
FeeDoEntity feeDoEntity = new FeeDoEntity();
if (!sqlRead.IsDBNull(0))
{
feeDoEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeDoEntity.BillNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeDoEntity.BSNO = sqlRead.GetString(2);
}
if (!sqlRead.IsDBNull(3))
{
feeDoEntity.MBLNO = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeDoEntity.HBLNO = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeDoEntity.CustomerName = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeDoEntity.BSType = sqlRead.GetInt32(6);
}
if (!sqlRead.IsDBNull(7))
{
feeDoEntity.FeeID = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeDoEntity.FeeName = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeDoEntity.Currency = sqlRead.GetString(9);
}
if (!sqlRead.IsDBNull(10))
{
feeDoEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeDoEntity.DoAmount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeDoEntity.FeeType = sqlRead.GetInt32(12);
}
if (!sqlRead.IsDBNull(13))
{
feeDoEntity.Category = sqlRead.GetInt32(13);
}
if (!sqlRead.IsDBNull(14))
{
feeDoEntity.BillStatus = sqlRead.GetInt32(14);
}
if (!sqlRead.IsDBNull(15))
{
feeDoEntity.Remark = sqlRead.GetString(15);
}
if (!sqlRead.IsDBNull(16))
{
feeDoEntity.OrigCurrency = sqlRead.GetString(16);
}
if (!sqlRead.IsDBNull(17))
{
feeDoEntity.ExchangeRate = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeDoEntity.IsDeleted = sqlRead.GetBoolean(18);
}
if (!sqlRead.IsDBNull(19))
{
feeDoEntity.InvoiceSettleNO = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeDoEntity.CompanyID = sqlRead.GetString(20);
}
if (!sqlRead.IsDBNull(21))
{
feeDoEntity.OriginalFeeCSTL = sqlRead.GetDecimal(21);//ORIGAMOUNT
}
//,DELETEUSER,DELETETIME,,
feeDoEntities.Add(feeDoEntity);
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return feeDoEntities;
}
public IList<FeeDoEntity> GetFeeDoByBillNO(string tempBillNO)
{
//初始化返回变量
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
//初始化参数并赋值
SqlParameter parm = new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar, 20);
parm.Value = tempBillNO;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_DO_BY_BILLNO, parm))
{
try
{
//读取字段值
while (sqlRead.Read())
{
FeeDoEntity feeDoEntity = new FeeDoEntity();
if (!sqlRead.IsDBNull(0))
{
feeDoEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeDoEntity.BillNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeDoEntity.BSNO = sqlRead.GetString(2);
}
if (!sqlRead.IsDBNull(3))
{
feeDoEntity.MBLNO = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeDoEntity.HBLNO = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeDoEntity.CustomerName = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeDoEntity.BSType = sqlRead.GetInt32(6);
}
if (!sqlRead.IsDBNull(7))
{
feeDoEntity.FeeID = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeDoEntity.FeeName = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeDoEntity.Currency = sqlRead.GetString(9);
}
if (!sqlRead.IsDBNull(10))
{
feeDoEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeDoEntity.DoAmount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeDoEntity.FeeType = sqlRead.GetInt32(12);
}
if (!sqlRead.IsDBNull(13))
{
feeDoEntity.Category = sqlRead.GetInt32(13);
}
if (!sqlRead.IsDBNull(14))
{
feeDoEntity.BillStatus = sqlRead.GetInt32(14);
}
if (!sqlRead.IsDBNull(15))
{
feeDoEntity.Remark = sqlRead.GetString(15);
}
if (!sqlRead.IsDBNull(16))
{
feeDoEntity.OrigCurrency = sqlRead.GetString(16);
}
if (!sqlRead.IsDBNull(17))
{
feeDoEntity.ExchangeRate = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeDoEntity.IsDeleted = sqlRead.GetBoolean(18);
}
if (!sqlRead.IsDBNull(19))
{
feeDoEntity.InvoiceSettleNO = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeDoEntity.CompanyID = sqlRead.GetString(20);
}
if (!sqlRead.IsDBNull(21))
{
feeDoEntity.OriginalFeeCSTL = sqlRead.GetDecimal(21);//ORIGAMOUNT
}
//,DELETEUSER,DELETETIME,,
feeDoEntities.Add(feeDoEntity);
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return feeDoEntities;
}
public IList<FeeDoEntity> GetFeeDoByBillNO2(string tempBillNO)
{
//初始化返回变量
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
//初始化参数并赋值
SqlParameter parm = new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar, 20);
parm.Value = tempBillNO;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_DO_BY_BILLNO2, parm))
{
try
{
//读取字段值
while (sqlRead.Read())
{
FeeDoEntity feeDoEntity = new FeeDoEntity();
if (!sqlRead.IsDBNull(0))
{
feeDoEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeDoEntity.BillNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeDoEntity.BSNO = sqlRead.GetString(2);
}
if (!sqlRead.IsDBNull(3))
{
feeDoEntity.MBLNO = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeDoEntity.HBLNO = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeDoEntity.CustomerName = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeDoEntity.BSType = sqlRead.GetInt32(6);
}
if (!sqlRead.IsDBNull(7))
{
feeDoEntity.FeeID = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeDoEntity.FeeName = sqlRead.GetString(8);
}
if (!sqlRead.IsDBNull(9))
{
feeDoEntity.Currency = sqlRead.GetString(9);
}
if (!sqlRead.IsDBNull(10))
{
feeDoEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeDoEntity.DoAmount = sqlRead.GetDecimal(11);
}
if (!sqlRead.IsDBNull(12))
{
feeDoEntity.FeeType = sqlRead.GetInt32(12);
}
if (!sqlRead.IsDBNull(13))
{
feeDoEntity.Category = sqlRead.GetInt32(13);
}
if (!sqlRead.IsDBNull(14))
{
feeDoEntity.BillStatus = sqlRead.GetInt32(14);
}
if (!sqlRead.IsDBNull(15))
{
feeDoEntity.Remark = sqlRead.GetString(15);
}
if (!sqlRead.IsDBNull(16))
{
feeDoEntity.OrigCurrency = sqlRead.GetString(16);
}
if (!sqlRead.IsDBNull(17))
{
feeDoEntity.ExchangeRate = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeDoEntity.IsDeleted = sqlRead.GetBoolean(18);
}
if (!sqlRead.IsDBNull(19))
{
feeDoEntity.InvoiceSettleNO = sqlRead.GetString(19);
}
if (!sqlRead.IsDBNull(20))
{
feeDoEntity.CompanyID = sqlRead.GetString(20);
}
if (!sqlRead.IsDBNull(21))
{
feeDoEntity.OriginalFeeCSTL = sqlRead.GetDecimal(21);//ORIGAMOUNT
}
//,DELETEUSER,DELETETIME,,
feeDoEntities.Add(feeDoEntity);
}
}
catch (Exception exceError)
{
//抛出异常
throw exceError;
}
}
return feeDoEntities;
}
public int InsertFeeDo(IList<FeeDoEntity> tempFeeDoEntities, IList<FeeSettlementEntity> tempFeeSettlementEntities)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (FeeDoEntity feeDoEntity in tempFeeDoEntities)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSNO, SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_MBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_HBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSTYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_CATEGORY,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_REMARK,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_INVOICE_SETTLE_NO,SqlDbType.VarChar,20)
};
parms[0].Value = feeDoEntity.GID;
parms[1].Value = feeDoEntity.BillNO;
parms[2].Value = feeDoEntity.BSNO;
parms[3].Value = feeDoEntity.MBLNO;
parms[4].Value = feeDoEntity.HBLNO;
parms[5].Value = feeDoEntity.CustomerName;
parms[6].Value = feeDoEntity.BSType;
parms[7].Value = feeDoEntity.FeeID;
parms[8].Value = feeDoEntity.FeeName;
parms[9].Value = feeDoEntity.Currency;
parms[10].Value = feeDoEntity.OriginalFeeCSTL;
parms[11].Value = feeDoEntity.DoAmount;
parms[12].Value = feeDoEntity.FeeType;
parms[13].Value = feeDoEntity.Category;
parms[14].Value = feeDoEntity.BillStatus;
parms[15].Value = feeDoEntity.Remark;
parms[16].Value = "";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
SqlParameter[] feeParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CHEQUE_NUM,SqlDbType.VarChar,200)
};
feeParms[0].Value = feeDoEntity.GID;
feeParms[1].Value = feeDoEntity.OriginalFeeCSTL;
feeParms[2].Value = tempFeeSettlementEntities[0].ChequeNo;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE, feeParms);
}
foreach (FeeSettlementEntity tempFeeSettlementEntity in tempFeeSettlementEntities)
{
SqlParameter[] settleParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_SETTLEMENT_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_MODE, SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_RMB,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_RMB,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_USD,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_USD,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_VOUCHER_NO,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_IS_EXPORT,SqlDbType.Bit),
new SqlParameter(PARM_FEE_SETTLEMENT_FINANCIAL_VOUCHER,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_REMARK,SqlDbType.VarChar,100),
new SqlParameter("@ACCOUNTS_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ACCOUNTS_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ACCOUNTS_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@PREPAY_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@AHSR_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@FINANCIAL_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ADVANCE_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_MONEY", SqlDbType.Decimal,9)
};
settleParms[0].Value = tempFeeSettlementEntity.GID;
settleParms[1].Value = tempFeeSettlementEntity.BillNO;
settleParms[2].Value = tempFeeSettlementEntity.SettleMode;
settleParms[3].Value = tempFeeSettlementEntity.CustomerName;
settleParms[4].Value = tempFeeSettlementEntity.SettleType;
settleParms[5].Value = tempFeeSettlementEntity.AmountRMB;
settleParms[6].Value = tempFeeSettlementEntity.AccountRMB;
settleParms[7].Value = tempFeeSettlementEntity.Rate;
settleParms[8].Value = tempFeeSettlementEntity.AmountUSD;
settleParms[9].Value = tempFeeSettlementEntity.AccountUSD;
settleParms[10].Value = tempFeeSettlementEntity.BillType;
settleParms[11].Value = tempFeeSettlementEntity.VoucherNO;
settleParms[12].Value = tempFeeSettlementEntity.SettleUser;
settleParms[13].Value = tempFeeSettlementEntity.IsExport;
settleParms[14].Value = tempFeeSettlementEntity.FinancialVoucher;
settleParms[15].Value = tempFeeSettlementEntity.BillStatus;
settleParms[16].Value = tempFeeSettlementEntity.Remark;
settleParms[17].Value = tempFeeSettlementEntity.ACCOUNTS_CURRENCY;//记账资料_币别
settleParms[18].Value = tempFeeSettlementEntity.ACCOUNTS_RATE;//记账资料_汇率
settleParms[19].Value = tempFeeSettlementEntity.ACCOUNTS_MONEY;//记账资料_金额
settleParms[20].Value = tempFeeSettlementEntity.PREPAY_CURRENCY;//预付支资料_币别
settleParms[21].Value = tempFeeSettlementEntity.PREPAY_RATE;//预付支资料_汇率
settleParms[22].Value = tempFeeSettlementEntity.PREPAY_MONEY;//预付支资料_金额
settleParms[23].Value = tempFeeSettlementEntity.AHSR_CURRENCY;//实付支资料_币别
settleParms[24].Value = tempFeeSettlementEntity.AHSR_RATE;//实付支资料_汇率
settleParms[25].Value = tempFeeSettlementEntity.AHSR_MONEY;//实付支资料_金额
settleParms[26].Value = tempFeeSettlementEntity.FINANCIAL_CURRENCY;//财务费用_币别
settleParms[27].Value = tempFeeSettlementEntity.FINANCIAL_RATE;//财务费用_汇率
settleParms[28].Value = tempFeeSettlementEntity.FINANCIAL_MONEY;//财务费用_金额
settleParms[29].Value = tempFeeSettlementEntity.ADVANCE_CURRENCY;//预付支取用资料_币别
settleParms[30].Value = tempFeeSettlementEntity.ADVANCE_RATE;//预付支取用资料_汇率
settleParms[31].Value = tempFeeSettlementEntity.ADVANCE_MONEY;//预付支取用资料_金额
//settleParms[17].Value = tempFeeSettlementEntity.SettleTime;
string SETTLETIME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "getdate()," : "'" + tempFeeSettlementEntity.SettleTime.ToString() + "',";
string SETTLETIME_NAME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "SETTLETIME," : "SETTLETIME,";
string SQL_INSERT_FEE_SETTLEMENT = string.Format("INSERT INTO ch_fee_settlement(GID, BILLNO, BILLDATE, SETTLEMODE, CUSTOMERNAME, SETTLETYPE, AMOUNTRMB, ACCOUNTRMB, RATE, AMOUNTUSD, ACCOUNTUSD, BILLTYPE, VOUCHERNO, SETTLEUSER, {0} ISEXPORT, FINANCIALVOUCHER, BILLSTATUS, REMARK,ACCOUNTS_CURRENCY,ACCOUNTS_RATE,ACCOUNTS_MONEY,PREPAY_CURRENCY,PREPAY_RATE,PREPAY_MONEY,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,FINANCIAL_CURRENCY,FINANCIAL_RATE,FINANCIAL_MONEY,ADVANCE_CURRENCY,ADVANCE_RATE,ADVANCE_MONEY)"
+ " VALUES(@gid,@bill_no,GETDATE(),@settle_mode,@customer_name,@settle_type,@amount_rmb,@account_rmb,@rate,@amount_usd,@account_usd,@bill_type,@voucher_no,@settle_user,{1}@is_export,@financial_voucher,@bill_status,@remark,@ACCOUNTS_CURRENCY,@ACCOUNTS_RATE,@ACCOUNTS_MONEY,@PREPAY_CURRENCY,@PREPAY_RATE,@PREPAY_MONEY,@AHSR_CURRENCY,@AHSR_RATE,@AHSR_MONEY,@FINANCIAL_CURRENCY,@FINANCIAL_RATE,@FINANCIAL_MONEY,@ADVANCE_CURRENCY,@ADVANCE_RATE,@ADVANCE_MONEY)", SETTLETIME_NAME, SETTLETIME);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_SETTLEMENT, settleParms);
}
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
public int DoVerifyRecvAmountByRecvSettle(IList<FeeDoEntity> tempFeeDoEntities, IList<FeeSettlementEntity> tempFeeSettlementEntities, IList<ReceiveAmountEntity> recvAmountEntities, IList<VerificationEntity> verificationEntities)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (FeeDoEntity feeDoEntity in tempFeeDoEntities)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSNO, SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_MBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_HBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSTYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_CATEGORY,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_REMARK,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_INVOICE_SETTLE_NO,SqlDbType.VarChar,20)
};
parms[0].Value = feeDoEntity.GID;
parms[1].Value = feeDoEntity.BillNO;
parms[2].Value = feeDoEntity.BSNO;
parms[3].Value = feeDoEntity.MBLNO;
parms[4].Value = feeDoEntity.HBLNO;
parms[5].Value = feeDoEntity.CustomerName;
parms[6].Value = feeDoEntity.BSType;
parms[7].Value = feeDoEntity.FeeID;
parms[8].Value = feeDoEntity.FeeName;
parms[9].Value = feeDoEntity.Currency;
parms[10].Value = feeDoEntity.OriginalFeeCSTL;
parms[11].Value = feeDoEntity.DoAmount;
parms[12].Value = feeDoEntity.FeeType;
parms[13].Value = feeDoEntity.Category;
parms[14].Value = feeDoEntity.BillStatus;
parms[15].Value = feeDoEntity.Remark;
parms[16].Value = "";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
SqlParameter[] feeParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CHEQUE_NUM,SqlDbType.VarChar,200)
};
feeParms[0].Value = feeDoEntity.GID;
feeParms[1].Value = feeDoEntity.OriginalFeeCSTL;
feeParms[2].Value = tempFeeSettlementEntities[0].ChequeNo;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE, feeParms);
//实收核销FeeDo
parms[0].Value = Guid.NewGuid().ToString();
parms[1].Value = verificationEntities[0].BillNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
}
foreach (FeeSettlementEntity tempFeeSettlementEntity in tempFeeSettlementEntities)
{
SqlParameter[] settleParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_SETTLEMENT_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_MODE, SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_RMB,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_RMB,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_USD,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_USD,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_VOUCHER_NO,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_IS_EXPORT,SqlDbType.Bit),
new SqlParameter(PARM_FEE_SETTLEMENT_FINANCIAL_VOUCHER,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_REMARK,SqlDbType.VarChar,100),
new SqlParameter("@ACCOUNTS_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ACCOUNTS_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ACCOUNTS_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@PREPAY_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@AHSR_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@FINANCIAL_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ADVANCE_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_MONEY", SqlDbType.Decimal,9)
};
settleParms[0].Value = tempFeeSettlementEntity.GID;
settleParms[1].Value = tempFeeSettlementEntity.BillNO;
settleParms[2].Value = tempFeeSettlementEntity.SettleMode;
settleParms[3].Value = tempFeeSettlementEntity.CustomerName;
settleParms[4].Value = tempFeeSettlementEntity.SettleType;
settleParms[5].Value = tempFeeSettlementEntity.AmountRMB;
settleParms[6].Value = tempFeeSettlementEntity.AccountRMB;
settleParms[7].Value = tempFeeSettlementEntity.Rate;
settleParms[8].Value = tempFeeSettlementEntity.AmountUSD;
settleParms[9].Value = tempFeeSettlementEntity.AccountUSD;
settleParms[10].Value = tempFeeSettlementEntity.BillType;
settleParms[11].Value = tempFeeSettlementEntity.VoucherNO;
settleParms[12].Value = tempFeeSettlementEntity.SettleUser;
settleParms[13].Value = tempFeeSettlementEntity.IsExport;
settleParms[14].Value = tempFeeSettlementEntity.FinancialVoucher;
settleParms[15].Value = tempFeeSettlementEntity.BillStatus;
settleParms[16].Value = tempFeeSettlementEntity.Remark;
settleParms[17].Value = tempFeeSettlementEntity.ACCOUNTS_CURRENCY;//记账资料_币别
settleParms[18].Value = tempFeeSettlementEntity.ACCOUNTS_RATE;//记账资料_汇率
settleParms[19].Value = tempFeeSettlementEntity.ACCOUNTS_MONEY;//记账资料_金额
settleParms[20].Value = tempFeeSettlementEntity.PREPAY_CURRENCY;//预付支资料_币别
settleParms[21].Value = tempFeeSettlementEntity.PREPAY_RATE;//预付支资料_汇率
settleParms[22].Value = tempFeeSettlementEntity.PREPAY_MONEY;//预付支资料_金额
settleParms[23].Value = tempFeeSettlementEntity.AHSR_CURRENCY;//实付支资料_币别
settleParms[24].Value = tempFeeSettlementEntity.AHSR_RATE;//实付支资料_汇率
settleParms[25].Value = tempFeeSettlementEntity.AHSR_MONEY;//实付支资料_金额
settleParms[26].Value = tempFeeSettlementEntity.FINANCIAL_CURRENCY;//财务费用_币别
settleParms[27].Value = tempFeeSettlementEntity.FINANCIAL_RATE;//财务费用_汇率
settleParms[28].Value = tempFeeSettlementEntity.FINANCIAL_MONEY;//财务费用_金额
settleParms[29].Value = tempFeeSettlementEntity.ADVANCE_CURRENCY;//预付支取用资料_币别
settleParms[30].Value = tempFeeSettlementEntity.ADVANCE_RATE;//预付支取用资料_汇率
settleParms[31].Value = tempFeeSettlementEntity.ADVANCE_MONEY;//预付支取用资料_金额
//
string SETTLETIME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "getdate()," : "'" + tempFeeSettlementEntity.SettleTime.ToString() + "',";
string SETTLETIME_NAME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "SETTLETIME," : "SETTLETIME,";
//
string SQL_INSERT_FEE_SETTLEMENT = string.Format("INSERT INTO ch_fee_settlement(GID, BILLNO, BILLDATE, SETTLEMODE, CUSTOMERNAME, SETTLETYPE, AMOUNTRMB, ACCOUNTRMB, RATE, AMOUNTUSD, ACCOUNTUSD, BILLTYPE, VOUCHERNO, SETTLEUSER, {0} ISEXPORT, FINANCIALVOUCHER, BILLSTATUS, REMARK,ACCOUNTS_CURRENCY,ACCOUNTS_RATE,ACCOUNTS_MONEY,PREPAY_CURRENCY,PREPAY_RATE,PREPAY_MONEY,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,FINANCIAL_CURRENCY,FINANCIAL_RATE,FINANCIAL_MONEY,ADVANCE_CURRENCY,ADVANCE_RATE,ADVANCE_MONEY)"
+ " VALUES(@gid,@bill_no,GETDATE(),@settle_mode,@customer_name,@settle_type,@amount_rmb,@account_rmb,@rate,@amount_usd,@account_usd,@bill_type,@voucher_no,@settle_user,{1}@is_export,@financial_voucher,@bill_status,@remark,@ACCOUNTS_CURRENCY,@ACCOUNTS_RATE,@ACCOUNTS_MONEY,@PREPAY_CURRENCY,@PREPAY_RATE,@PREPAY_MONEY,@AHSR_CURRENCY,@AHSR_RATE,@AHSR_MONEY,@FINANCIAL_CURRENCY,@FINANCIAL_RATE,@FINANCIAL_MONEY,@ADVANCE_CURRENCY,@ADVANCE_RATE,@ADVANCE_MONEY)", SETTLETIME_NAME, SETTLETIME);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_SETTLEMENT, settleParms);
}
foreach (ReceiveAmountEntity recvAmountEntity in recvAmountEntities)
{
SqlParameter[] updateRecvParms = new SqlParameter[]{
new SqlParameter(PARM_RECEIVE_AMOUNT_DO_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_RECEIVE_AMOUNT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_RECEIVE_AMOUNT_GID,SqlDbType.VarChar,36)
};
updateRecvParms[0].Value = recvAmountEntity.DoAmount;
updateRecvParms[1].Value = recvAmountEntity.SettleUser;
updateRecvParms[2].Value = recvAmountEntity.GID;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_RECEIVE_AMOUNT, updateRecvParms);
SqlParameter[] updateRecvFinishParms = new SqlParameter[] {
new SqlParameter(PARM_RECEIVE_AMOUNT_GID,SqlDbType.VarChar,36)
};
updateRecvFinishParms[0].Value = recvAmountEntity.GID;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_RECEIVE_AMOUNT_FINISH, updateRecvFinishParms);
}
foreach (VerificationEntity verificationEntity in verificationEntities)
{
SqlParameter[] InsertVerificationParms = new SqlParameter[] {
new SqlParameter(PARM_VERIFICATION_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_VERIFICATION_BILL_NO,SqlDbType.VarChar,20),
new SqlParameter(PARM_VERIFICATION_RECV_AMOUNT_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_VERIFICATION_SETTLE_USER,SqlDbType.VarChar,36)
};
InsertVerificationParms[0].Value = verificationEntity.GID;
InsertVerificationParms[1].Value = verificationEntity.BillNO;
InsertVerificationParms[2].Value = verificationEntity.RecvAmountGID;
InsertVerificationParms[3].Value = verificationEntity.SettleUser;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_CH_FEE_VERIFICATION, InsertVerificationParms);
}
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
public int SettleInvoice(IList<FeeDoEntity> tempFeeDoEntities, IList<FeeSettlementEntity> tempFeeSettlementEntities,string tempInvoicID,string tempInvoiceNum)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (FeeDoEntity feeDoEntity in tempFeeDoEntities)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSNO, SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_MBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_HBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSTYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_CATEGORY,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_REMARK,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_INVOICE_SETTLE_NO,SqlDbType.VarChar,20)
};
parms[0].Value = feeDoEntity.GID;
parms[1].Value = feeDoEntity.BillNO;
parms[2].Value = feeDoEntity.BSNO;
parms[3].Value = feeDoEntity.MBLNO;
parms[4].Value = feeDoEntity.HBLNO;
parms[5].Value = feeDoEntity.CustomerName;
parms[6].Value = feeDoEntity.BSType;
parms[7].Value = feeDoEntity.FeeID;
parms[8].Value = feeDoEntity.FeeName;
parms[9].Value = feeDoEntity.Currency;
parms[10].Value = feeDoEntity.OriginalFeeCSTL;
parms[11].Value = feeDoEntity.DoAmount;
parms[12].Value = feeDoEntity.FeeType;
parms[13].Value = feeDoEntity.Category;
parms[14].Value = feeDoEntity.BillStatus;
parms[15].Value = feeDoEntity.Remark;
parms[16].Value = feeDoEntity.InvoiceSettleNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
SqlParameter[] feeParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CHEQUE_NUM,SqlDbType.VarChar,200)
};
feeParms[0].Value = feeDoEntity.GID;
feeParms[1].Value = feeDoEntity.OriginalFeeCSTL;
feeParms[2].Value = tempInvoiceNum;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE, feeParms);
}
foreach (FeeSettlementEntity tempFeeSettlementEntity in tempFeeSettlementEntities)
{
SqlParameter[] settleParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_SETTLEMENT_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_MODE, SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_RMB,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_RMB,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_USD,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_USD,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_VOUCHER_NO,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_IS_EXPORT,SqlDbType.Bit),
new SqlParameter(PARM_FEE_SETTLEMENT_FINANCIAL_VOUCHER,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_REMARK,SqlDbType.VarChar,100),
new SqlParameter("@ACCOUNTS_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ACCOUNTS_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ACCOUNTS_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@PREPAY_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@AHSR_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@FINANCIAL_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ADVANCE_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_MONEY", SqlDbType.Decimal,9)
};
settleParms[0].Value = tempFeeSettlementEntity.GID;
settleParms[1].Value = tempFeeSettlementEntity.BillNO;
settleParms[2].Value = tempFeeSettlementEntity.SettleMode;
settleParms[3].Value = tempFeeSettlementEntity.CustomerName;
settleParms[4].Value = tempFeeSettlementEntity.SettleType;
settleParms[5].Value = tempFeeSettlementEntity.AmountRMB;
settleParms[6].Value = tempFeeSettlementEntity.AccountRMB;
settleParms[7].Value = tempFeeSettlementEntity.Rate;
settleParms[8].Value = tempFeeSettlementEntity.AmountUSD;
settleParms[9].Value = tempFeeSettlementEntity.AccountUSD;
settleParms[10].Value = tempFeeSettlementEntity.BillType;
settleParms[11].Value = tempFeeSettlementEntity.VoucherNO;
settleParms[12].Value = tempFeeSettlementEntity.SettleUser;
settleParms[13].Value = tempFeeSettlementEntity.IsExport;
settleParms[14].Value = tempFeeSettlementEntity.FinancialVoucher;
settleParms[15].Value = tempFeeSettlementEntity.BillStatus;
settleParms[16].Value = tempFeeSettlementEntity.Remark;
settleParms[17].Value = tempFeeSettlementEntity.ACCOUNTS_CURRENCY;//记账资料_币别
settleParms[18].Value = tempFeeSettlementEntity.ACCOUNTS_RATE;//记账资料_汇率
settleParms[19].Value = tempFeeSettlementEntity.ACCOUNTS_MONEY;//记账资料_金额
settleParms[20].Value = tempFeeSettlementEntity.PREPAY_CURRENCY;//预付支资料_币别
settleParms[21].Value = tempFeeSettlementEntity.PREPAY_RATE;//预付支资料_汇率
settleParms[22].Value = tempFeeSettlementEntity.PREPAY_MONEY;//预付支资料_金额
settleParms[23].Value = tempFeeSettlementEntity.AHSR_CURRENCY;//实付支资料_币别
settleParms[24].Value = tempFeeSettlementEntity.AHSR_RATE;//实付支资料_汇率
settleParms[25].Value = tempFeeSettlementEntity.AHSR_MONEY;//实付支资料_金额
settleParms[26].Value = tempFeeSettlementEntity.FINANCIAL_CURRENCY;//财务费用_币别
settleParms[27].Value = tempFeeSettlementEntity.FINANCIAL_RATE;//财务费用_汇率
settleParms[28].Value = tempFeeSettlementEntity.FINANCIAL_MONEY;//财务费用_金额
settleParms[29].Value = tempFeeSettlementEntity.ADVANCE_CURRENCY;//预付支取用资料_币别
settleParms[30].Value = tempFeeSettlementEntity.ADVANCE_RATE;//预付支取用资料_汇率
settleParms[31].Value = tempFeeSettlementEntity.ADVANCE_MONEY;//预付支取用资料_金额
string SETTLETIME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "getdate()," : "'" + tempFeeSettlementEntity.SettleTime.ToString() + "',";
string SETTLETIME_NAME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "SETTLETIME," : "SETTLETIME,";
string SQL_INSERT_FEE_SETTLEMENT = string.Format("INSERT INTO ch_fee_settlement(GID, BILLNO, BILLDATE, SETTLEMODE, CUSTOMERNAME, SETTLETYPE, AMOUNTRMB, ACCOUNTRMB, RATE, AMOUNTUSD, ACCOUNTUSD, BILLTYPE, VOUCHERNO, SETTLEUSER, {0} ISEXPORT, FINANCIALVOUCHER, BILLSTATUS, REMARK,ACCOUNTS_CURRENCY,ACCOUNTS_RATE,ACCOUNTS_MONEY,PREPAY_CURRENCY,PREPAY_RATE,PREPAY_MONEY,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,FINANCIAL_CURRENCY,FINANCIAL_RATE,FINANCIAL_MONEY,ADVANCE_CURRENCY,ADVANCE_RATE,ADVANCE_MONEY)"
+ " VALUES(@gid,@bill_no,GETDATE(),@settle_mode,@customer_name,@settle_type,@amount_rmb,@account_rmb,@rate,@amount_usd,@account_usd,@bill_type,@voucher_no,@settle_user,{1}@is_export,@financial_voucher,@bill_status,@remark,@ACCOUNTS_CURRENCY,@ACCOUNTS_RATE,@ACCOUNTS_MONEY,@PREPAY_CURRENCY,@PREPAY_RATE,@PREPAY_MONEY,@AHSR_CURRENCY,@AHSR_RATE,@AHSR_MONEY,@FINANCIAL_CURRENCY,@FINANCIAL_RATE,@FINANCIAL_MONEY,@ADVANCE_CURRENCY,@ADVANCE_RATE,@ADVANCE_MONEY)", SETTLETIME_NAME, SETTLETIME);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_SETTLEMENT, settleParms);
}
SqlParameter[] updateInvoicParms = new SqlParameter[] {
new SqlParameter(PARM_INVOICE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_INVOICE_IS_NEED_FEE,SqlDbType.Bit)
};
updateInvoicParms[0].Value = tempInvoicID;
updateInvoicParms[1].Value = 1;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_INVOICE, updateInvoicParms);
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
public int SettleInvoiceForRecvAmount(IList<FeeDoEntity> tempFeeDoEntities, IList<FeeSettlementEntity> tempFeeSettlementEntities, string tempInvoicID, string tempInvoiceNum, IList<ReceiveAmountEntity> recviveAmountEntities, IList<VerificationEntity> verificationEntities)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (FeeDoEntity feeDoEntity in tempFeeDoEntities)
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSNO, SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_MBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_HBL_NO,SqlDbType.VarChar,30),
new SqlParameter(PARM_FEE_DO_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_BSTYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_FEE_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_DO_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_DO_AMOUNT,SqlDbType.Decimal,40),
new SqlParameter(PARM_FEE_DO_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_CATEGORY,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_DO_REMARK,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DO_INVOICE_SETTLE_NO,SqlDbType.VarChar,20)
};
parms[0].Value = feeDoEntity.GID;
parms[1].Value = feeDoEntity.BillNO;
parms[2].Value = feeDoEntity.BSNO;
parms[3].Value = feeDoEntity.MBLNO;
parms[4].Value = feeDoEntity.HBLNO;
parms[5].Value = feeDoEntity.CustomerName;
parms[6].Value = feeDoEntity.BSType;
parms[7].Value = feeDoEntity.FeeID;
parms[8].Value = feeDoEntity.FeeName;
parms[9].Value = feeDoEntity.Currency;
parms[10].Value = feeDoEntity.OriginalFeeCSTL;
parms[11].Value = feeDoEntity.DoAmount;
parms[12].Value = feeDoEntity.FeeType;
parms[13].Value = feeDoEntity.Category;
parms[14].Value = feeDoEntity.BillStatus;
parms[15].Value = feeDoEntity.Remark;
parms[16].Value = feeDoEntity.InvoiceSettleNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
SqlParameter[] feeParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_DO_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CHEQUE_NUM,SqlDbType.VarChar,200)
};
feeParms[0].Value = feeDoEntity.GID;
feeParms[1].Value = feeDoEntity.OriginalFeeCSTL;
feeParms[2].Value = tempInvoiceNum;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE, feeParms);
//实收核销FeeDo
parms[0].Value = Guid.NewGuid().ToString();
parms[1].Value = verificationEntities[0].BillNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_DO, parms);
}
foreach (FeeSettlementEntity tempFeeSettlementEntity in tempFeeSettlementEntities)
{
SqlParameter[] settleParms = new SqlParameter[]{
new SqlParameter(PARM_FEE_SETTLEMENT_GID, SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_NO, SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_MODE, SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_CUSTOMER_NAME,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_RMB,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_RMB,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_AMOUNT_USD,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_SETTLEMENT_ACCOUNT_USD,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_VOUCHER_NO,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_SETTLEMENT_IS_EXPORT,SqlDbType.Bit),
new SqlParameter(PARM_FEE_SETTLEMENT_FINANCIAL_VOUCHER,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_SETTLEMENT_BILL_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_SETTLEMENT_REMARK,SqlDbType.VarChar,100),
new SqlParameter("@ACCOUNTS_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ACCOUNTS_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ACCOUNTS_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@PREPAY_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@PREPAY_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@AHSR_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@AHSR_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@FINANCIAL_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@FINANCIAL_MONEY", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_CURRENCY", SqlDbType.VarChar,20) ,
new SqlParameter("@ADVANCE_RATE", SqlDbType.Decimal,9) ,
new SqlParameter("@ADVANCE_MONEY", SqlDbType.Decimal,9)
};
settleParms[0].Value = tempFeeSettlementEntity.GID;
settleParms[1].Value = tempFeeSettlementEntity.BillNO;
settleParms[2].Value = tempFeeSettlementEntity.SettleMode;
settleParms[3].Value = tempFeeSettlementEntity.CustomerName;
settleParms[4].Value = tempFeeSettlementEntity.SettleType;
settleParms[5].Value = tempFeeSettlementEntity.AmountRMB;
settleParms[6].Value = tempFeeSettlementEntity.AccountRMB;
settleParms[7].Value = tempFeeSettlementEntity.Rate;
settleParms[8].Value = tempFeeSettlementEntity.AmountUSD;
settleParms[9].Value = tempFeeSettlementEntity.AccountUSD;
settleParms[10].Value = tempFeeSettlementEntity.BillType;
settleParms[11].Value = tempFeeSettlementEntity.VoucherNO;
settleParms[12].Value = tempFeeSettlementEntity.SettleUser;
settleParms[13].Value = tempFeeSettlementEntity.IsExport;
settleParms[14].Value = tempFeeSettlementEntity.FinancialVoucher;
settleParms[15].Value = tempFeeSettlementEntity.BillStatus;
settleParms[16].Value = tempFeeSettlementEntity.Remark;
settleParms[17].Value = tempFeeSettlementEntity.ACCOUNTS_CURRENCY;//记账资料_币别
settleParms[18].Value = tempFeeSettlementEntity.ACCOUNTS_RATE;//记账资料_汇率
settleParms[19].Value = tempFeeSettlementEntity.ACCOUNTS_MONEY;//记账资料_金额
settleParms[20].Value = tempFeeSettlementEntity.PREPAY_CURRENCY;//预付支资料_币别
settleParms[21].Value = tempFeeSettlementEntity.PREPAY_RATE;//预付支资料_汇率
settleParms[22].Value = tempFeeSettlementEntity.PREPAY_MONEY;//预付支资料_金额
settleParms[23].Value = tempFeeSettlementEntity.AHSR_CURRENCY;//实付支资料_币别
settleParms[24].Value = tempFeeSettlementEntity.AHSR_RATE;//实付支资料_汇率
settleParms[25].Value = tempFeeSettlementEntity.AHSR_MONEY;//实付支资料_金额
settleParms[26].Value = tempFeeSettlementEntity.FINANCIAL_CURRENCY;//财务费用_币别
settleParms[27].Value = tempFeeSettlementEntity.FINANCIAL_RATE;//财务费用_汇率
settleParms[28].Value = tempFeeSettlementEntity.FINANCIAL_MONEY;//财务费用_金额
settleParms[29].Value = tempFeeSettlementEntity.ADVANCE_CURRENCY;//预付支取用资料_币别
settleParms[30].Value = tempFeeSettlementEntity.ADVANCE_RATE;//预付支取用资料_汇率
settleParms[31].Value = tempFeeSettlementEntity.ADVANCE_MONEY;//预付支取用资料_金额
//
string SETTLETIME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "getdate()," : "'" + tempFeeSettlementEntity.SettleTime.ToString() + "',";
string SETTLETIME_NAME = tempFeeSettlementEntity.SettleTime.ToString().IndexOf("0001") > -1 ? "SETTLETIME," : "SETTLETIME,";
//
string SQL_INSERT_FEE_SETTLEMENT = string.Format("INSERT INTO ch_fee_settlement(GID, BILLNO, BILLDATE, SETTLEMODE, CUSTOMERNAME, SETTLETYPE, AMOUNTRMB, ACCOUNTRMB, RATE, AMOUNTUSD, ACCOUNTUSD, BILLTYPE, VOUCHERNO, SETTLEUSER, {0} ISEXPORT, FINANCIALVOUCHER, BILLSTATUS, REMARK,ACCOUNTS_CURRENCY,ACCOUNTS_RATE,ACCOUNTS_MONEY,PREPAY_CURRENCY,PREPAY_RATE,PREPAY_MONEY,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,FINANCIAL_CURRENCY,FINANCIAL_RATE,FINANCIAL_MONEY,ADVANCE_CURRENCY,ADVANCE_RATE,ADVANCE_MONEY)"
+ " VALUES(@gid,@bill_no,GETDATE(),@settle_mode,@customer_name,@settle_type,@amount_rmb,@account_rmb,@rate,@amount_usd,@account_usd,@bill_type,@voucher_no,@settle_user,{1}@is_export,@financial_voucher,@bill_status,@remark,@ACCOUNTS_CURRENCY,@ACCOUNTS_RATE,@ACCOUNTS_MONEY,@PREPAY_CURRENCY,@PREPAY_RATE,@PREPAY_MONEY,@AHSR_CURRENCY,@AHSR_RATE,@AHSR_MONEY,@FINANCIAL_CURRENCY,@FINANCIAL_RATE,@FINANCIAL_MONEY,@ADVANCE_CURRENCY,@ADVANCE_RATE,@ADVANCE_MONEY)", SETTLETIME_NAME, SETTLETIME);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_SETTLEMENT, settleParms);
}
SqlParameter[] updateInvoicParms = new SqlParameter[] {
new SqlParameter(PARM_INVOICE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_INVOICE_IS_NEED_FEE,SqlDbType.Bit)
};
updateInvoicParms[0].Value = tempInvoicID;
updateInvoicParms[1].Value = 1;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_INVOICE, updateInvoicParms);
foreach (ReceiveAmountEntity recvAmountEntity in recviveAmountEntities)
{
SqlParameter[] updateRecvParms = new SqlParameter[]{
new SqlParameter(PARM_RECEIVE_AMOUNT_DO_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_RECEIVE_AMOUNT_SETTLE_USER,SqlDbType.VarChar,36),
new SqlParameter(PARM_RECEIVE_AMOUNT_GID,SqlDbType.VarChar,36)
};
updateRecvParms[0].Value = recvAmountEntity.DoAmount;
updateRecvParms[1].Value = recvAmountEntity.SettleUser;
updateRecvParms[2].Value = recvAmountEntity.GID;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_RECEIVE_AMOUNT, updateRecvParms);
SqlParameter[] updateRecvFinishParms = new SqlParameter[] {
new SqlParameter(PARM_RECEIVE_AMOUNT_GID,SqlDbType.VarChar,36)
};
updateRecvFinishParms[0].Value = recvAmountEntity.GID;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_RECEIVE_AMOUNT_FINISH, updateRecvFinishParms);
}
foreach (VerificationEntity verificationEntity in verificationEntities)
{
SqlParameter[] InsertVerificationParms = new SqlParameter[] {
new SqlParameter(PARM_VERIFICATION_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_VERIFICATION_BILL_NO,SqlDbType.VarChar,20),
new SqlParameter(PARM_VERIFICATION_RECV_AMOUNT_ID,SqlDbType.VarChar,36),
new SqlParameter(PARM_VERIFICATION_SETTLE_USER,SqlDbType.VarChar,36)
};
InsertVerificationParms[0].Value = verificationEntity.GID;
InsertVerificationParms[1].Value = verificationEntity.BillNO;
InsertVerificationParms[2].Value = verificationEntity.RecvAmountGID;
InsertVerificationParms[3].Value = verificationEntity.SettleUser;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_CH_FEE_VERIFICATION, InsertVerificationParms);
}
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
}
}