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.

2878 lines
139 KiB
C#

using System;
using System.Data;
using System.Data.SqlClient;
using DSWeb.Models;
using WebSqlHelper;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace DSWeb.EntityDA
{
public class FeeDA
{
#region 费用参数
private const string PARM_FEE_GID = "@gid";
private const string PARM_FEE_BSNO = "@bsno";
private const string PARM_FEE_TYPE = "@fee_type";
private const string PARM_FEE_NAME = "@fee_name";
private const string PARM_FEE_DESCRIPTION = "@fee_description";
private const string PARM_FEE_CUSTOMER_TYPE = "@customer_type";
private const string PARM_FEE_CUSTOMER_NAME = "@customer_name";
private const string PARM_FEE_UNIT = "@unit";
private const string PARM_FEE_UNIT_PRICE = "@unit_price";
private const string PARM_FEE_QUANTITY = "@quantity";
private const string PARM_FEE_AMOUNT = "@amount";
private const string PARM_FEE_CURRENCY = "@currency";
private const string PARM_FEE_EXCHANGE_RATE = "@exchange_rate";
private const string PARM_FEE_REASON = "@reason";
private const string PARM_FEE_REMARK = "@remark";
private const string PARM_FEE_COMMISSION_RATE = "@comm_rate";
private const string PARM_FEE_SETTLEMENT = "@settlement";
private const string PARM_FEE_INVOICE = "@invoice";
private const string PARM_FEE_ORDER_AMOUNT = "@order_amount";
private const string PARM_FEE_ORDER_INVOCE = "@order_invoice";
private const string PARM_FEE_SUBMIT_DATE = "@submit_date";
private const string PARM_FEE_AUDIT_OPERATOR = "@audit_operator";
private const string PARM_FEE_AUDIT_DATE = "@audit_date";
private const string PARM_FEE_ENTER_OPERATOR = "@enter_operator";
private const string PARM_FEE_ENTER_DATE = "@enter_date";
private const string PARM_FEE_DEBITNO = "@debitno";
private const string PARM_FEE_ISDEBIT = "@is_debit";
private const string PARM_FEE_ISOPEN = "@is_open";
private const string PARM_FEE_ISADVANCEPAY = "@is_advance_pay";
private const string PARM_FEE_SORT = "@sort";
private const string PARM_FEE_ISINVOICE = "@is_invoice";
private const string PARM_FEE_STATUS = "@fee_status";
private const string PARM_FEE_FRT = "@fee_frt";
private const string PARM_FEE_AUDIT_STATUS = "@audit_status";
private const string PARM_FEE_AUDIT_WMSOUTBSNO = "@WMSOUTBSNO";
#endregion
#region 费用利润
//fee_gain
private const string PARM_FEEPROFIT_GID = "@gid";//惟一标识
private const string PARM_FEEPROFIT_BSNO = "@bsno";//委托编号
private const string PARM_FEEPROFIT_RMB_DR = "@rmb_dr";//应收人民币
private const string PARM_FEEPROFIT_USD_DR = "@usd_dr";//应收美元
private const string PARM_FEEPROFIT_OTHER_DR = "@other_dr";//应收其他币别
private const string PARM_FEEPROFIT_RMB_CR = "@rmb_cr";//应付人民币
private const string PARM_FEEPROFIT_USD_CR = "@usd_cr";//应付美元
private const string PARM_FEEPROFIT_OTHER_CR = "@other_cr";//应付其他币别
private const string PARM_FEEPROFIT_DR_TOTAL = "@dr_total";//应收合计
private const string PARM_FEEPROFIT_CR_TOTAL = "@cr_total";//应付合计
private const string PARM_FEEPROFIT_STL_DR_RMB = "@stl_dr_rmb";//应收RMB结算
private const string PARM_FEEPROFIT_STL_DR_USD = "@stl_dr_usd";//应收USB结算
private const string PARM_FEEPROFIT_STL_DR_OTHER = "@stl_dr_other";//应收其他币别结算
private const string PARM_FEEPROFIT_STL_CR_RMB = "@stl_cr_rmb";//应收RMB结算
private const string PARM_FEEPROFIT_STL_CR_USD = "@stl_cr_usd";//应收USB结算
private const string PARM_FEEPROFIT_STL_CR_OTHER = "@stl_cr_other";//应收其他币别结算
private const string PARM_FEEPROFIT_STL_DR_TOTAL = "@stl_dr_total";//应收结算合计
private const string PARM_FEEPROFIT_STL_CR_TOTAL = "@stl_cr_total";//应付结算合计
private const string PARM_FEEPROFIT_RMB_PROFIT = "@rmb_profit";//RMB利润
private const string PARM_FEEPROFIT_USD_PROFIT = "@usd_profit";//USD利润
private const string PARM_FEEPROFIT_OTHER_PROFIT = "@other_profit";//其他币别利润
private const string PARM_FEEPROFIT_PROFIT_TOTAL = "@profit_total";//合计利润
private const string PARM_FEEPROFIT_PROFIT_RATE = "@profit_rate";//利润率
private const string PARM_FEEPROFIT_CREATE_USER = "@create_user";//创建人
private const string PARM_FEEPROFIT_CREATE_TIME = "@create_time";//创建时间
private const string PARM_FEEPROFIT_MODIFIED_USER = "@modified_user";//最后一次更新操作人GID
private const string PARM_FEEPROFIT_MODIFIED_TIME = "@modified_time";//最后一次更新时间
private const string PARM_WORKFLOW_DO_AUDITOR = "@auditor";
#endregion
#region 通知消息
//通知消息
private const string PARM_MESSAGE_GID = "@gid";
private const string PARM_MESSAGE_NAME = "@name";
private const string PARM_MESSAGE_DESCRIPTION = "@description";
private const string PARM_MESSAGE_CREATE_TIME = "@create_time";
private const string PARM_MESSAGE_IS_READ = "@is_read";
private const string PARM_MESSAGE_READ_COUNT = "@read_count";
private const string PARM_MESSAGE_MESSAGE_CONTENT = "@message_content";
private const string PARM_MESSAGE_LAST_READ_TIME = "@last_readtime";
private const string PARM_MESSAGE_RECEIVER = "@receiver";
private const string PARM_MESSAGE_TYPE = "@type";
private const string PARM_MESSAGE_TASK_URL = "@task_url";
private const string PARM_MESSAGE_TASK_ID = "@task_id";
#endregion
private const string SQL_SELECT_FEE_ALL = " SELECT top 10 GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee";
private const string SQL_SELECT_FEE_BY_GID = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE GID = @gid ";
private const string SQL_SELECT_FEE_BY_WmsOutBsno = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE WMSOUTBSNO = @WMSOUTBSNO ";
private const string SQL_SELECT_FEE_BY_BSNO = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = @bsno ";
private const string SQL_SELECT_FEE_BY_BSNO_FEESTATUS = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = @bsno and FEETYPE=1 and FEESTATUS<>9 and CUSTOMERNAME=(select CUSTOMERNAME from op_seae where BSNO = @bsno)";
private const string SQL_SELECT_FEE_BY_BSNO_FEESTATUS1 = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = @bsno and FEETYPE=1 and FEESTATUS=9 and CUSTOMERNAME=(select CUSTOMERNAME from op_seae where BSNO = @bsno)";
private const string SQL_SELECT_FEE_BY_BSNO_AND_TYPE = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = @bsno AND FEETYPE like @fee_type";
private const string SQL_INSERT_FEE = " INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT ) "
+ " VALUES "
+ " (@gid,@bsno,@fee_type,@fee_name,@fee_description,@customer_type,@customer_name,@unit,@unit_price,@quantity,@amount,@currency, "
+ " @exchange_rate,@reason,@remark,@comm_rate,@settlement,@invoice,@order_amount,@order_invoice,@submit_date,@audit_operator, "
+ " @audit_date,@debitno,@is_debit,@is_open,@is_advance_pay,@sort,@is_invoice,@fee_status,@fee_frt)";
private const string SQL_SELECT_FEE_LIST = " SELECT top 10 GID, FEETYPE, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, COMMISSIONRATE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE,REMARK,FEEFRT "
+ " FROM ch_fee";
private const string SQL_DELETE_FEE_BY_GID = "DELETE FROM ch_fee WHERE GID = @gid";
private const string SQL_UPDATE_FEE_STATUS_BY_GID = "UPDATE ch_fee SET FEESTATUS = @fee_status WHERE GID = @gid";
private const string SQL_UPDATE_FEE_AUDITSTATUS = "UPDATE ch_fee SET AUDITSTATUS = @audit_status WHERE GID = @gid ";
private const string SQL_SELECT_FEE_IS_RUNNING = " SELECT COUNT(*) FROM ch_fee WHERE ORDERAMOUNT <> 0 OR ORDERINVOICE <> 0 AND GID = @gid ";
private const string SQL_INSERT_CH_FEE = " INSERT INTO ch_fee(GID,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,COMMISSIONRATE,AMOUNT,CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY,FEETYPE,BSNO,ENTEROPERATOR,ENTERDATE,FEESTATUS,WMSOUTBSNO,LINENUM) "
+ " VALUES(@gid,@fee_name,@customer_name,@unit,@unit_price,@quantity,@comm_rate,@amount,@currency,@exchange_rate,@fee_frt,@remark,@is_advance_pay,@fee_type,"
+ " @bsno,@enter_operator,GETDATE(),@fee_status,@WMSOUTBSNO,@LINENUM) ";
private const string SQL_UPDATE_CH_FE = " UPDATE ch_fee SET FEENAME = @fee_name,CUSTOMERNAME = @customer_name,UNIT = @unit,UNITPRICE = @unit_price,QUANTITY = @quantity,COMMISSIONRATE = @comm_rate,"
+ " AMOUNT = @amount,CURRENCY = @currency,EXCHANGERATE = @exchange_rate,FEEFRT = @fee_frt,REMARK = @remark,ISADVANCEDPAY = @is_advance_pay,LINENUM=@LINENUM WHERE GID = @gid ";//,WMSOUTBSNO=@WMSOUTBSNO
private const string SQL_SELECT_CH_FEE_STATUS = "SELECT FEESTATUS FROM ch_fee WHERE GID = @gid";
private const string SQL_SELECT_FEE_PROFIT_BY_BSNO = "SELECT BSNO FROM fee_gain WHERE BSNO = @bsno ";
private const string SQL_INSERT_FEE_PROFIT = " INSERT INTO fee_gain(GID, BSNO, RMBDR, USDDR, OTDR, RMBCR, USDCR, OTCR, DRTTL, CRTTL,RMBPROFIT, "
+ " USDPROFIT,OTPROFIT, TTLPROFIT, PROFITRATE,CREATEUSER,CREATETIME )"
+ " VALUES (@gid, @bsno, @rmb_dr, @usd_dr, @other_dr, @rmb_cr, @usd_cr, @other_cr, @dr_total, @cr_total,"
+ " @rmb_profit, @usd_profit, @other_profit, @profit_total, @profit_rate, @create_user, GETDATE())";
private const string SQL_UPDATE_FEE_PROFIT_BY_BSNO = " UPDATE fee_gain SET RMBDR = @rmb_dr,USDDR = @usd_dr,OTDR = @other_dr,RMBCR = @rmb_cr,USDCR = @usd_cr,OTCR = @other_cr,"
+ " DRTTL = @dr_total,CRTTL = @cr_total,RMBPROFIT = @rmb_profit,USDPROFIT = @usd_profit,OTPROFIT = @other_profit,TTLPROFIT = @profit_total,"
+ " PROFITRATE = @profit_rate,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE() WHERE BSNO = @bsno ";
#region 被注释的代码
/*
private const string SQL_UPDATE_FEE_GAIN_FOR_DELETE = " UPDATE fee_gain SET RMBDR = E.RMBDR,USDDR = E.USDDR,OTDR = E.OTDR,"
+ " RMBCR = E.RMBCR,USDCR = E.USDCR,OTCR = E.OTCR,DRTTL = E.DRTTL,CRTTL = E.CRTTL, "
+ " RMBPROFIT = E.RMBPROFIT,USDPROFIT = E.USDPROFIT,TTLPROFIT = E.TTLPROFIT, "
+ " PROFITRATE = E.PROFITRATE FROM ("
+ " SELECT A.GID,A.BSNO,CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' THEN RMBDR - AMOUNT ELSE RMBDR END as RMBDR,"
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'USD' THEN USDDR - AMOUNT ELSE USDDR END as USDDR,"
+ " CASE WHEN FEETYPE = 1 AND CURRENCY <> 'RMB' AND CURRENCY <> 'USD' THEN AMOUNT ELSE OTDR END as OTDR,"
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN RMBCR + AMOUNT ELSE RMBCR END as RMBCR,"
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'USD' THEN USDCR + AMOUNT ELSE USDCR END as USDCR,"
+ " CASE WHEN FEETYPE = 2 AND CURRENCY <> 'RMB' AND CURRENCY <> 'USD' THEN AMOUNT ELSE OTCR END as OTCR, "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' THEN DRTTL - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY <> 'RMB' THEN DRTTL - (AMOUNT*EXCHANGERATE) ELSE DRTTL END END as DRTTL,"
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN CRTTL - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY <> 'RMB' THEN CRTTL - (AMOUNT*EXCHANGERATE) ELSE CRTTL END END as CRTTL,"
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' AND RMBPROFIT > 0 THEN RMBPROFIT - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' AND RMBPROFIT < 0 THEN RMBPROFIT + (-AMOUNT) ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' AND RMBPROFIT > 0 THEN RMBPROFIT + AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' AND RMBPROFIT < 0 THEN RMBPROFIT + (-AMOUNT) ELSE RMBPROFIT END END END END as RMBPROFIT,"
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'USD' AND USDPROFIT > 0 THEN USDPROFIT - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'USD' AND USDPROFIT < 0 THEN USDPROFIT + (-AMOUNT) ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'USD' AND USDPROFIT > 0 THEN USDPROFIT + AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'USD' AND USDPROFIT < 0 THEN USDPROFIT + (-AMOUNT) ELSE USDPROFIT END END END END as USDPROFIT, "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' THEN TTLPROFIT - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN TTLPROFIT + AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY <> 'RMB' THEN TTLPROFIT - (AMOUNT * EXCHANGERATE) ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY <> 'RMB' THEN TTLPROFIT + (AMOUNT * EXCHANGERATE) END END END END as TTLPROFIT, "
+ " (CASE WHEN FEETYPE = 1 AND CURRENCY = 'RMB' THEN TTLPROFIT - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN TTLPROFIT + AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 1 AND CURRENCY <> 'RMB' THEN TTLPROFIT - (AMOUNT * EXCHANGERATE) ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY <> 'RMB' THEN TTLPROFIT + (AMOUNT * EXCHANGERATE) END END END END / "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY = 'RMB' THEN CRTTL - AMOUNT ELSE "
+ " CASE WHEN FEETYPE = 2 AND CURRENCY <> 'RMB' THEN CRTTL - (AMOUNT*EXCHANGERATE) ELSE CRTTL END END) * 100 as PROFITRATE "
+ " FROM ch_fee as A INNER JOIN op_seae as B ON A.BSNO = B.BSNO "
+ " INNER JOIN fee_gain as D ON B.BSNO = D.BSNO WHERE A.GID = @gid) as E WHERE fee_gain.BSNO = E.BSNO ";*/
#endregion
private const string SQL_UPDATE_FEE_PROFIT_PRECENT = " UPDATE fee_gain SET PROFITRATE = A.PROFITRATE FROM ("
+ " SELECT BSNO,(CAST(CAST(CASE WHEN CRTTL = 0 THEN 0 ELSE (ROUND(TTLPROFIT/CRTTL,4))*100 END as decimal(18,2)) as varchar(20))+'%')as PROFITRATE FROM fee_gain WHERE BSNO = @bsno"
+ " )as A WHERE fee_gain.BSNO = A.BSNO";
private const string SQL_SELECT_WAITTING_AUDIT_FEE = " SELECT GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = @bsno AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 1 or B.TYPE = 11 OR B.TYPE=72)"
+ " AND A.AUDITOR = @auditor ) "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 3 or B.TYPE = 13 OR B.TYPE=73) "
+ " AND A.AUDITOR = @auditor ))) ORDER BY ENTERDATE ASC ";
private const string SQL_UPDATE_FEE_GAIN_RECALCULATE = " UPDATE fee_gain SET RMBDR = B.RMBDR,RMBCR = B.RMBCR,USDDR = B.USDDR,USDCR = B.USDCR,RMBPROFIT = A.RMBPROFIT,"
+ " USDPROFIT = A.USDPROFIT,TTLPROFIT = A.TTLPROFIT,DRTTL = A.DRTTL,CRTTL = A.CRTTL,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE(),PROFITRATE = A.PROFITRATE "
+ " FROM (SELECT SUM(RMBDR) AS RMBDR,SUM(RMBCR) AS RMBCR,SUM(USDDR) AS USDDR,SUM(USDCR) AS USDCR "
+ " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
+ " FEETYPE FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS D) AS B, "
+ " (SELECT SUM(RMBDR) - SUM(RMBCR) AS RMBPROFIT,SUM(USDDR) - SUM(USDCR) AS USDPROFIT,SUM(RMBDR+USDTORMBDR) as DRTTL, "
+ " SUM(RMBCR+USDTORMBCR) as CRTTL,SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT, "
//+ " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((case when SUM(RMBDR+USDTORMBDR)=0 then 0 else (SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR) END),2))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE "
+ "(CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND(((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBCR+USDTORMBCR)),4))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE "
+ " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR,FEETYPE "
+ " FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS C) AS A"
+ " WHERE fee_gain.BSNO = @bsno ";
private const string SQL_INSERT_FEE_GAIN_RECALCULATE = " INSERT INTO fee_gain(BSNO,RMBDR,USDDR,OTDR,RMBCR,USDCR,OTCR,STLDRRMB,STLDRUSD, "
+ " STLDROT,STLCRRMB,STLCRUSD,STLCROT,STLDRTTL,STLCRTTL,RMBPROFIT,USDPROFIT,OTPROFIT, "
+ " DRTTL,CRTTL,TTLPROFIT,PROFITRATE,CREATEUSER,CREATETIME) "
+ " SELECT * FROM ("
+ " SELECT BSNO,SUM(RMBDR) AS RMBDR,SUM(USDDR) AS USDDR,0 AS OTDR,SUM(RMBCR) AS RMBCR,SUM(USDCR) AS USDCR,0 AS OTCR, "
+ " 0 AS STLDRRMB,0 AS STLDRUSD,0 AS STLDROT,0 AS STLCRRMB,0 AS STLCRUSD,0 AS STLCROT,0 AS STLDRTTL,0 AS STLCRTTL,SUM(RMBDR) - SUM(RMBCR) AS RMBPROFIT, "
+ " SUM(USDDR) - SUM(USDCR) AS USDPROFIT,0 AS OTPROFIT FROM "
+ " (SELECT CURRENCY,BSNO,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR, "
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR,FEETYPE "
+ " FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE,BSNO ) AS D GROUP BY BSNO) AS B, "
+ " (SELECT SUM(RMBDR+USDTORMBDR) as DRTTL,SUM(RMBCR+USDTORMBCR) as CRTTL,"
+ " SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT,"
//+ " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((case when SUM(RMBDR+USDTORMBDR)=0 then 0 else (SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR) END),2))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE,"
+ " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND(((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBCR+USDTORMBCR)),4))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE,"
+ " @create_user as CREATEUSER,GETDATE() as CREATETIME "
+ " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR,FEETYPE "
+ " FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS C) AS A ";
private const string SQL_UPDATE_CH_FEE_ISINVOICE_UNLOCK = " UPDATE ch_fee SET ISINVOICE = 0 WHERE GID = @gid";
private const string SQL_UPDATE_CH_FEE_ISINVOICE_LOCK = " UPDATE ch_fee SET ISINVOICE = 1 WHERE GID = @gid";
#region 禁开发票
/// <summary>
/// 禁开发票
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示加锁成功 值不等于1表示加锁失败</returns>
public int LockFeeISINVOICE(string tempGid)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,100)
};
parms[0].Value = tempGid;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_CH_FEE_ISINVOICE_LOCK, parms);
sqlTran.Commit();
iResult = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
iResult = -1;//有异常,更新失败
sqlTran.Rollback();
iResult = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 解禁发票
/// <summary>
/// 解禁发票
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示解锁成功 值不等于1表示解锁失败</returns>
public int UnLockFeeISINVOICE(string tempGid)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,100)
};
parms[0].Value = tempGid;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_CH_FEE_ISINVOICE_UNLOCK, parms);
sqlTran.Commit();
iResult = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
iResult = -1;//有异常,更新失败
sqlTran.Rollback();
iResult = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 查看费用是否已经进行付费申请、收付费结算操作
/// <summary>
/// 查看费用是否已经进行付费申请、收付费结算操作
/// </summary>
/// <param name="strFeeID">费用GID</param>
/// <returns>值1表示费用已经进行了申请或者结算操作 值0表示费用未进行任何结算操作 值-1表示异常</returns>
public int ValidateFeeRunning(string strFeeID)
{
int iResult = 0;
SqlParameter parm = new SqlParameter(PARM_FEE_GID, SqlDbType.VarChar, 36);
parm.Value = strFeeID;
using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
iResult = (int)SqlHelper.ExecuteScalar(sqlConnection, CommandType.Text, SQL_SELECT_FEE_IS_RUNNING, parm);
}
catch
{
iResult = -1;
}
}
return iResult;
}
#endregion
#region 获取插入费用表参数表
/// <summary>
/// 获取插入费用表参数表
/// </summary>
/// <returns>SqlParameter[]</returns>
private SqlParameter[] GetInsertParms()
{
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_BSNO,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_TYPE,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_DESCRIPTION,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_CUSTOMER_TYPE,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_UNIT_PRICE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_QUANTITY,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_AMOUNT,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_EXCHANGE_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_REASON,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_REMARK,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_COMMISSION_RATE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_SETTLEMENT,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_INVOICE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_ORDER_AMOUNT,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_ORDER_INVOCE,SqlDbType.Decimal,18),
new SqlParameter(PARM_FEE_SUBMIT_DATE,SqlDbType.SmallDateTime),
new SqlParameter(PARM_FEE_AUDIT_OPERATOR,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_AUDIT_DATE,SqlDbType.SmallDateTime),
new SqlParameter(PARM_FEE_ENTER_OPERATOR,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_ENTER_DATE,SqlDbType.SmallDateTime),
new SqlParameter(PARM_FEE_DEBITNO,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_ISDEBIT,SqlDbType.Bit),
new SqlParameter(PARM_FEE_ISOPEN,SqlDbType.Bit),
new SqlParameter(PARM_FEE_ISADVANCEPAY,SqlDbType.Bit),
new SqlParameter(PARM_FEE_SORT,SqlDbType.Int),
new SqlParameter(PARM_FEE_ISINVOICE,SqlDbType.Bit),
new SqlParameter(PARM_FEE_STATUS,SqlDbType.VarChar,20)
};
return parms;
}
#endregion
#region 插入费用信息
/// <summary>
/// 插入费用信息
/// </summary>
/// <param name="feeEntity"></param>
/// <returns></returns>
public int InsertFee(FeeEntity feeEntity)
{
int iResult = 0;
#region 获取参数
SqlParameter[] parms = GetInsertParms();
parms[0].Value = feeEntity.GID;
parms[1].Value = feeEntity.BSNO;
parms[2].Value = feeEntity.FeeType;
parms[3].Value = feeEntity.FeeName;
parms[4].Value = feeEntity.FeeDescription;
parms[5].Value = feeEntity.CustomerType;
parms[6].Value = feeEntity.CustomerName;
parms[7].Value = feeEntity.Unit;
parms[8].Value = feeEntity.UnitPrice;
parms[9].Value = feeEntity.Quantity;
parms[10].Value = feeEntity.Amount;
parms[11].Value = feeEntity.Currency;
parms[12].Value = feeEntity.ExchangeRate;
parms[13].Value = feeEntity.Reason;
parms[14].Value = feeEntity.Remark;
parms[15].Value = feeEntity.CommissionRate;
parms[16].Value = feeEntity.Settlement;
parms[17].Value = feeEntity.Invoice;
parms[18].Value = feeEntity.OrderAmount;
parms[19].Value = feeEntity.OrderInvoice;
parms[20].Value = feeEntity.SubmitDate;
parms[21].Value = feeEntity.AuditOperator;
parms[22].Value = feeEntity.AuditDate;
parms[23].Value = feeEntity.EnterOperator;
parms[24].Value = feeEntity.EnterDate;
parms[25].Value = feeEntity.DebitNO;
parms[26].Value = feeEntity.IsDebit;
parms[27].Value = feeEntity.IsOpen;
parms[28].Value = feeEntity.IsAdvancePay;
parms[29].Value = feeEntity.Sort;
parms[30].Value = feeEntity.IsInvoice;
parms[31].Value = feeEntity.FeeStatus;
#endregion
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
{
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_FEE, parms);
if (existVal > 0)
{
iResult = 1;
}
else
{
iResult = -1;//执行异常
}
}
return iResult;
}
#endregion
#region 通过费用GID获取ch_fee费用信息返回FeeEntity
/// <summary>
/// 通过费用GID获取ch_fee费用信息返回FeeEntity
/// </summary>
/// <param name="strGID">ch_fee.Gid</param>
/// <returns>返回FeeEntity</returns>
public IList<FeeEntity> GetFeeByWmsOutBsno(string strWmsOutBsno)
{
IList<FeeEntity> FeeEntities = new List<FeeEntity>();
SqlParameter parm = new SqlParameter(PARM_FEE_AUDIT_WMSOUTBSNO, SqlDbType.VarChar, 100);
parm.Value = strWmsOutBsno;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_BY_WmsOutBsno, parm))
{
try
{
while (sqlRead.Read())
{
FeeEntity feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
FeeEntities.Add(feeEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return FeeEntities;
}
#endregion
#region 通过费用GID获取ch_fee费用信息返回FeeEntity
/// <summary>
/// 通过费用GID获取ch_fee费用信息返回FeeEntity
/// </summary>
/// <param name="strGID">ch_fee.Gid</param>
/// <returns>返回FeeEntity</returns>
public FeeEntity GetFeeByID(string strGID)
{
FeeEntity feeEntity = null;
SqlParameter parm = new SqlParameter(PARM_FEE_GID, SqlDbType.VarChar, 36);
parm.Value = strGID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_BY_GID, parm))
{
try
{
while (sqlRead.Read())
{
feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntity;
}
#endregion
#region 通过委托编号BSNO获取费用信息
/// <summary>
/// 通过委托编号BSNO获取费用信息
/// </summary>
/// <param name="strGID"></param>
/// <returns></returns>
public IList<FeeEntity> GetFeeByBSNO(string strBSNO)
{
IList<FeeEntity> feeEntities = new List<FeeEntity>();
SqlParameter parm = new SqlParameter(PARM_FEE_BSNO, SqlDbType.VarChar, 100);
parm.Value = strBSNO;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_BY_BSNO, parm))
{
try
{
while (sqlRead.Read())
{
FeeEntity feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
feeEntities.Add(feeEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntities;
}
#endregion
#region 通过委托编号BSNO获取所有结算的费用信息
/// <summary>
/// 通过委托编号BSNO获取所有结算的费用信息
/// </summary>
/// <param name="strGID"></param>
/// <returns></returns>
public IList<FeeEntity> GetFeeByBSNOFEESTATUS1(string strBSNO)
{
IList<FeeEntity> feeEntities = new List<FeeEntity>();
SqlParameter parm = new SqlParameter(PARM_FEE_BSNO, SqlDbType.VarChar, 100);
parm.Value = strBSNO;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_BY_BSNO_FEESTATUS1, parm))
{
try
{
while (sqlRead.Read())
{
FeeEntity feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
feeEntities.Add(feeEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntities;
}
#endregion
#region 通过委托编号BSNO获取所有未结算的费用信息
/// <summary>
/// 通过委托编号BSNO获取所有未结算的费用信息
/// </summary>
/// <param name="strGID"></param>
/// <returns></returns>
public IList<FeeEntity> GetFeeByBSNOFEESTATUS(string strBSNO)
{
IList<FeeEntity> feeEntities = new List<FeeEntity>();
SqlParameter parm = new SqlParameter(PARM_FEE_BSNO, SqlDbType.VarChar, 100);
parm.Value = strBSNO;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_BY_BSNO_FEESTATUS, parm))
{
try
{
while (sqlRead.Read())
{
FeeEntity feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
feeEntities.Add(feeEntity);
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntities;
}
#endregion
#region 通过委托编号BSNO与费用类型1应收2应付获取费用信息返回FeeEntity
/// <summary>
/// 通过委托编号BSNO与费用类型1应收2应付获取费用信息返回FeeEntity
/// </summary>
/// <param name="strGID"></param>
/// <returns>返回FeeEntity</returns>
public FeeEntity GetFeeByBSNOAndType(string strBSNO, int iType)
{
FeeEntity feeEntity = null;
//SqlParameter[] parms = new SqlParameter[]{
// new SqlParameter(PARM_FEE_BSNO,SqlDbType.VarChar,36),
// new SqlParameter(PARM_FEE_TYPE,SqlDbType.VarChar,20)
//};
//parms[0].Value = strBSNO;
//parms[1].Value = strType == 1 ? "'%收%'" : "'%付%'";
//string query = (strType == 1) ? "'%收%'" : "'%付%'";
string strSql = " SELECT TOP 1 GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, REASON, REMARK, COMMISSIONRATE, SETTLEMENT, INVOICE, ORDERAMOUNT, ORDERINVOICE, SUBMITDATE, AUDITOPERATOR, "
+ " AUDITDATE, ENTEROPERATOR, ENTERDATE, DEBITNO, ISDEBIT, ISOPEN, ISADVANCEDPAY, SORT, ISINVOICE, FEESTATUS, FEEFRT "
+ " FROM ch_fee WHERE BSNO = '" + strBSNO + "' AND FEETYPE = " + iType;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, null))
{
try
{
while (sqlRead.Read())
{
feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntity;
}
#endregion
#region 通过委托编号BSNO与费用类型1应收2应付获取费用信息返回FeeEntity
/// <summary>
/// 通过委托编号BSNO与费用类型1应收2应付获取费用信息返回FeeEntity
/// </summary>
/// <param name="strGID"></param>
/// <returns>返回FeeEntity</returns>
public FeeEntity GetFeeByBSNOAndType(string strBSNO, int iType,string WmsOutBsno)
{
FeeEntity feeEntity = null;
//SqlParameter[] parms = new SqlParameter[]{
// new SqlParameter(PARM_FEE_BSNO,SqlDbType.VarChar,36),
// new SqlParameter(PARM_FEE_TYPE,SqlDbType.VarChar,20)
//};
//parms[0].Value = strBSNO;
//parms[1].Value = strType == 1 ? "'%收%'" : "'%付%'";
//string query = (strType == 1) ? "'%收%'" : "'%付%'";
string strSql = String.Format(" SELECT TOP 1 b.GID,b.BSNO,b.FEETYPE,b.FEENAME,b.FEEDESCRIPTION,b.CUSTOMERTYPE, "
+ " b.CUSTOMERNAME,b.UNIT,b.UNITPRICE,b.QUANTITY,b.AMOUNT,b.CURRENCY,b. EXCHANGERATE, "
+ " b.REASON,b.REMARK,b.COMMISSIONRATE,b.SETTLEMENT,b.INVOICE,b.ORDERAMOUNT,b.ORDERINVOICE,b.SUBMITDATE,b.AUDITOPERATOR, "
+ " b.AUDITDATE,b.ENTEROPERATOR,b.ENTERDATE,b.DEBITNO,b.ISDEBIT,b.ISOPEN,b.ISADVANCEDPAY,b.SORT,b.ISINVOICE,b.FEESTATUS,b.FEEFRT "
+ " from ch_fee b where b.WMSOUTBSNO='{0}' and FEETYPE={1} and b.BSNO='{2}'", WmsOutBsno, iType, strBSNO);
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, null))
{
try
{
while (sqlRead.Read())
{
feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
}
}
catch (Exception execError)
{
throw execError;
}
}
return feeEntity;
}
#endregion
#region 返回所有费用数据集
/// <summary>
/// 返回所有费用数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetFeeList()
{
DataSet userSet = new DataSet();
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_LIST);
return userSet;
}
#endregion
#region 更新费用列表信息
/// <summary>
/// 更新费用列表信息
/// </summary>
/// <param name="sqlList">更新SQL语句组,将所有要执行的更新语句写入ArrayList,每个索引对应一条SQL语句,执行时需要遍历操作</param>
/// <returns>返回状态值 为1表示更新完成;为-1更新出现异常但未正确回滚事务;为-2更新异常,事务已经成功回滚;默认状态为0</returns>
public int UpdateFeeFromGrid(ArrayList sqlList)
{
int result = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
for (int i = 0; i < sqlList.Count; i++)
{
string strUpdateSql = sqlList[i].ToString();
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strUpdateSql, null);
}
sqlTran.Commit();
result = 1;//状态为1表示更新成功
}
catch (Exception execError)
{
result = -1;//有异常,更新失败
sqlTran.Rollback();
result = -2;//更新异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
#region 插入费用列表信息
/// <summary>
/// 插入费用列表信息
/// </summary>
/// <param name="sqlList">插入SQL语句组,将所有要执行的插入语句写入ArrayList,每个索引对应一条SQL语句,执行时需要遍历操作</param>
/// <returns>返回状态值 为1表示插入完成;为-1插入出现异常但未正确回滚事务;为-2插入异常,事务已经成功回滚;默认状态为0</returns>
public int InsertFeeFromGrid(ArrayList sqlList)
{
int result = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
for (int i = 0; i < sqlList.Count; i++)
{
string strUpdateSql = sqlList[i].ToString();
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strUpdateSql, null);
}
sqlTran.Commit();
result = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
#region 通过费用GID删除ch_fee单条费用更新fee_gain重算利润
/// <summary>
/// 通过费用GID删除ch_fee单条费用更新fee_gain重算利润
/// </summary>
/// <param name="tempGid"></param>
/// <param name="tempCurrency"></param>
/// <param name="tempFeeType"></param>
/// <param name="tempAmount"></param>
/// <param name="tempRate"></param>
/// <param name="tempBSNO"></param>
/// <returns>返回操作结果</returns>
public int DeleteFeeByGid(string tempGid,string tempCurrency,int tempFeeType,decimal tempAmount,decimal tempRate,string tempBSNO)
{
int result = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//先将费用利润表中费用金额减兑
string strSql = "";
if(tempFeeType == 1)
{
if (tempCurrency == "RMB")
{
strSql = String.Format(" UPDATE fee_gain SET RMBDR = RMBDR - {0},DRTTL = DRTTL - {0},RMBPROFIT = RMBPROFIT - {0},TTLPROFIT = TTLPROFIT - {0} WHERE BSNO = '{1}' ", tempAmount, tempBSNO);
}
else
{
strSql = String.Format(" UPDATE fee_gain SET USDDR = USDDR - {0},DRTTL = DRTTL - {1},USDPROFIT = USDPROFIT - {0},TTLPROFIT = TTLPROFIT - {1} WHERE BSNO = '{2}' ", tempAmount, (tempAmount * tempRate), tempBSNO);
}
}
else
{
if (tempCurrency == "RMB")
{
strSql = String.Format(" UPDATE fee_gain SET RMBCR = RMBCR - {0},CRTTL = CRTTL - {0},RMBPROFIT = RMBPROFIT + {0},TTLPROFIT = TTLPROFIT + {0} WHERE BSNO = '{1}' ", tempAmount, tempBSNO);
}
else
{
strSql = String.Format(" UPDATE fee_gain SET USDCR = USDCR - {0},CRTTL = CRTTL - {1},USDPROFIT = USDPROFIT + {0},TTLPROFIT = TTLPROFIT + {1} WHERE BSNO = '{2}' ", tempAmount, (tempAmount * tempRate), tempBSNO);
}
}
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql, null);
//重新计算百分率(利润总和/应付费用总和)
SqlParameter[] precentParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100)
};
precentParms[0].Value = tempBSNO;
//SQL_UPDATE_FEE_PROFIT_PRECENT = " UPDATE fee_gain SET PROFITRATE = A.PROFITRATE "
//+ " FROM (SELECT BSNO,(CAST(CAST(CASE WHEN CRTTL = 0 THEN 0 ELSE (ROUND(TTLPROFIT/CRTTL,2))*100 "
//+ " END as decimal(18,2)) as varchar(20))+'%')as PROFITRATE "
//+ " FROM fee_gain WHERE BSNO = @bsno)as A WHERE fee_gain.BSNO = A.BSNO";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_PROFIT_PRECENT, precentParms);
SqlParameter parm = new SqlParameter(PARM_FEE_GID, SqlDbType.VarChar, 36);
parm.Value = tempGid;
//从费用表ch_fee中将费用删除
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_DELETE_FEE_BY_GID, parm);
result = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
#region 根据SQL语句更新ch_fee.feestatus费用状态信息
/// <summary>
/// 根据SQL语句更新ch_fee.feestatus费用状态
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public int UpdateFeeStatus(int iStatus, string strGID)
{
int result = 0;
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36)
};
parms[0].Value = iStatus;
parms[1].Value = strGID;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_UPDATE_FEE_STATUS_BY_GID, parms);
result = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
#region 更新费用审核状态
/// <summary>
/// 更新费用审核状态
/// </summary>
/// <param name="tempFeeGID">费用GID</param>
/// <param name="tempAuditStatus">费用审核状态</param>
/// <returns>值1状态更新成功 值小于1更细腻失败</returns>
public int UpdateFeeAuditStatus(string tempFeeGID, int tempAuditStatus)
{
int iResult = 0;
SqlParameter[] parms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_AUDIT_STATUS,SqlDbType.Int)
};
parms[0].Value = tempFeeGID;
parms[1].Value = tempAuditStatus;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_AUDITSTATUS, parms);
iResult = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
public FeeStatusType GetCurrentStatus(int iTempFeeStatus)
{
FeeStatusType feeStatusType = FeeStatusType.ENTERING;
switch (iTempFeeStatus)
{
case 0:
feeStatusType = FeeStatusType.AUDITPASS;
break;
case 1:
feeStatusType = FeeStatusType.ENTERING;
break;
case 2:
feeStatusType = FeeStatusType.POSTAUDIT;
break;
case 3:
feeStatusType = FeeStatusType.MODIFYAPPLY;
break;
case 4:
feeStatusType = FeeStatusType.DELETEAPPLY;
break;
case 5:
feeStatusType = FeeStatusType.CANCELAPPLY;
break;
case 6:
feeStatusType = FeeStatusType.REJECTAUDIT;
break;
case 7:
feeStatusType = FeeStatusType.REJECTAPPLY;
break;
case 8:
feeStatusType = FeeStatusType.SETTLEAPART;
break;
case 9:
feeStatusType = FeeStatusType.SETTLEFULL;
break;
}
return feeStatusType;
}
#region 保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain并返回操作结果
/// <summary>
///
/// </summary>
/// <param name="tempFeeEntities"></param>
/// <param name="tempBSNO"></param>
/// <param name="tempUserID"></param>
/// <returns></returns>
public int DoFee(IList<FeeEntity> tempFeeEntities, string tempBSNO,string tempUserID)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] validParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36)
};
foreach (FeeEntity feeEntity in tempFeeEntities)
{
int iFeeStatus = 0;
validParms[0].Value = feeEntity.GID;
object statusObj = SqlHelper.ExecuteScalar(sqlTran, CommandType.Text, SQL_SELECT_CH_FEE_STATUS, validParms);
if (statusObj == null)
{
iFeeStatus = -1;
}
else
{
iFeeStatus = (int)statusObj;
}
if (iFeeStatus == 1 || iFeeStatus == 6)
{
//只更新FEESTATUS = 1状态的费用信息其他状态不能编辑,所以其他状态不做更新操作)
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_UNIT_PRICE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_QUANTITY,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_COMMISSION_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_EXCHANGE_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_REMARK,SqlDbType.VarChar),
new SqlParameter(PARM_FEE_ISADVANCEPAY,SqlDbType.Bit),
//new SqlParameter(PARM_FEE_AUDIT_WMSOUTBSNO,SqlDbType.VarChar,100),
new SqlParameter("@LINENUM",SqlDbType.Int)
//PARM_FEE_AUDIT_WMSOUTBSNO
};
updateParms[0].Value = feeEntity.GID;
updateParms[1].Value = feeEntity.FeeName;
updateParms[2].Value = feeEntity.CustomerName;
updateParms[3].Value = feeEntity.Unit;
updateParms[4].Value = feeEntity.UnitPrice;
updateParms[5].Value = feeEntity.Quantity;
updateParms[6].Value = feeEntity.CommissionRate;
updateParms[7].Value = feeEntity.Amount;
updateParms[8].Value = feeEntity.Currency;
updateParms[9].Value = feeEntity.ExchangeRate;
updateParms[10].Value = feeEntity.FeeFrt;
updateParms[11].Value = feeEntity.Remark;
updateParms[12].Value = feeEntity.IsAdvancePay;
//updateParms[13].Value = feeEntity.WMSOUTBSNO.ToString().Trim().Equals(null) ? "" : feeEntity.WMSOUTBSNO.ToString().Trim();
updateParms[13].Value = feeEntity.LINENUM;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_CH_FE, updateParms);
}
else if (iFeeStatus < 0)
{
SqlParameter[] insertParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_UNIT_PRICE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_QUANTITY,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_COMMISSION_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_EXCHANGE_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_REMARK,SqlDbType.VarChar),
new SqlParameter(PARM_FEE_ISADVANCEPAY,SqlDbType.Bit),
new SqlParameter(PARM_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_ENTER_OPERATOR,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_AUDIT_WMSOUTBSNO,SqlDbType.VarChar,100),
new SqlParameter("@LINENUM",SqlDbType.Int)
};
insertParms[0].Value = feeEntity.GID;
insertParms[1].Value = feeEntity.FeeName;
insertParms[2].Value = feeEntity.CustomerName;
insertParms[3].Value = feeEntity.Unit;
insertParms[4].Value = feeEntity.UnitPrice;
insertParms[5].Value = feeEntity.Quantity;
insertParms[6].Value = feeEntity.CommissionRate;
insertParms[7].Value = feeEntity.Amount;
insertParms[8].Value = feeEntity.Currency;
insertParms[9].Value = feeEntity.ExchangeRate;
insertParms[10].Value = feeEntity.FeeFrt;
insertParms[11].Value = feeEntity.Remark;
insertParms[12].Value = feeEntity.IsAdvancePay;
insertParms[13].Value = feeEntity.FeeType;
insertParms[14].Value = feeEntity.BSNO;
insertParms[15].Value = feeEntity.EnterOperator;
insertParms[16].Value = feeEntity.FeeStatus;
insertParms[17].Value = feeEntity.WMSOUTBSNO.ToString().Trim().Equals(null) ? "" : feeEntity.WMSOUTBSNO.ToString().Trim();
insertParms[18].Value = feeEntity.LINENUM;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_CH_FEE, insertParms);
}
}
SqlParameter[] validProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100)
};
validProfitParms[0].Value = tempBSNO;
//保存利润信息
object bsnoObj = SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_PROFIT_BY_BSNO, validProfitParms);
if (bsnoObj == null)//如果没有相关利润信息,则插入新的利润信息
{
SqlParameter[] insertProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEEPROFIT_CREATE_USER,SqlDbType.VarChar,36)
};
insertProfitParms[0].Value = tempBSNO;
insertProfitParms[1].Value = tempUserID;
//SQL_INSERT_FEE_GAIN_RECALCULATE = " INSERT INTO fee_gain(BSNO,RMBDR,USDDR,OTDR,RMBCR,USDCR,OTCR,STLDRRMB,STLDRUSD, "
// + " STLDROT,STLCRRMB,STLCRUSD,STLCROT,STLDRTTL,STLCRTTL,RMBPROFIT,USDPROFIT,OTPROFIT, "
// + " DRTTL,CRTTL,TTLPROFIT,PROFITRATE,CREATEUSER,CREATETIME) "
// + " SELECT * FROM ("
// + " SELECT BSNO,SUM(RMBDR) AS RMBDR,SUM(USDDR) AS USDDR,0 AS OTDR,SUM(RMBCR) AS RMBCR,SUM(USDCR) AS USDCR,0 AS OTCR, "
// + " 0 AS STLDRRMB,0 AS STLDRUSD,0 AS STLDROT,0 AS STLCRRMB,0 AS STLCRUSD,0 AS STLCROT,0 AS STLDRTTL,0 AS STLCRTTL,SUM(RMBDR) - SUM(RMBCR) AS RMBPROFIT, "
// + " SUM(USDDR) - SUM(USDCR) AS USDPROFIT,0 AS OTPROFIT FROM "
// + " (SELECT CURRENCY,BSNO,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR, "
// + " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR,FEETYPE "
// + " FROM ch_fee WHERE BSNO = @bsno GROUP BY CURRENCY,EXCHANGERATE,FEETYPE,BSNO ) AS D GROUP BY BSNO) AS B, "
// + " (SELECT SUM(RMBDR+USDTORMBDR) as DRTTL,SUM(RMBCR+USDTORMBCR) as CRTTL,"
// + " SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT,"
// + " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR),2))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE,"
// + " @create_user as CREATEUSER,GETDATE() as CREATETIME "
// + " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
// + " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR,FEETYPE "
// + " FROM ch_fee WHERE BSNO = @bsno GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS C) AS A ";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_GAIN_RECALCULATE, insertProfitParms);
}
else
{
SqlParameter[] updateProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEEPROFIT_MODIFIED_USER,SqlDbType.VarChar,36)
};
updateProfitParms[0].Value = tempBSNO;
updateProfitParms[1].Value = tempUserID;
//SQL_UPDATE_FEE_GAIN_RECALCULATE = " UPDATE fee_gain SET RMBDR = B.RMBDR,RMBCR = B.RMBCR,USDDR = B.USDDR,USDCR = B.USDCR,RMBPROFIT = A.RMBPROFIT,"
// + " USDPROFIT = A.USDPROFIT,TTLPROFIT = A.TTLPROFIT,DRTTL = A.DRTTL,CRTTL = A.CRTTL,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE(),PROFITRATE = A.PROFITRATE "
// + " FROM (SELECT SUM(RMBDR) AS RMBDR,SUM(RMBCR) AS RMBCR,SUM(USDDR) AS USDDR,SUM(USDCR) AS USDCR "
// + " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
// + " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
// + " FEETYPE FROM ch_fee WHERE BSNO = @bsno GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS D) AS B, "
// + " (SELECT SUM(RMBDR) - SUM(RMBCR) AS RMBPROFIT,SUM(USDDR) - SUM(USDCR) AS USDPROFIT,SUM(RMBDR+USDTORMBDR) as DRTTL, "
// + " SUM(RMBCR+USDTORMBCR) as CRTTL,SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT, "
// + " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR),2))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE "
// + " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
// + " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR, "
// + " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR,FEETYPE "
// + " FROM ch_fee WHERE BSNO = @bsno GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS C) AS A"
// + " WHERE fee_gain.BSNO = @bsno ";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_GAIN_RECALCULATE, updateProfitParms);
}
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
#region 保存费用信息、利润信息
/// <summary>
/// 保存费用信息、利润信息
/// </summary>
/// <param name="tempFeeEntities">费用信息</param>
/// <param name="feeProfitEntity">利润信息</param>
/// <param name="tempBSNO">委托编号</param>
/// <returns></returns>
public int DoFee(IList<FeeEntity> tempFeeEntities, FeeProfitEntity feeProfitEntity, string tempBSNO)
{
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] validParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36)
};
foreach (FeeEntity feeEntity in tempFeeEntities)
{
int iFeeStatus = 0;
validParms[0].Value = feeEntity.GID;
object statusObj = SqlHelper.ExecuteScalar(sqlTran, CommandType.Text, SQL_SELECT_CH_FEE_STATUS, validParms);
if (statusObj == null)
{
iFeeStatus = -1;
}
else
{
iFeeStatus = (int)statusObj;
}
if (iFeeStatus == 1 || iFeeStatus == 6)
{
//只更新FEESTATUS = 1状态的费用信息其他状态不能编辑,所以其他状态不做更新操作)
SqlParameter[] updateParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_UNIT_PRICE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_QUANTITY,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_COMMISSION_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_EXCHANGE_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_REMARK,SqlDbType.VarChar),
new SqlParameter(PARM_FEE_ISADVANCEPAY,SqlDbType.Bit),
//new SqlParameter(PARM_FEE_AUDIT_WMSOUTBSNO,SqlDbType.VarChar,100),
new SqlParameter("@LINENUM",SqlDbType.Int)
};
updateParms[0].Value = feeEntity.GID;
updateParms[1].Value = feeEntity.FeeName;
updateParms[2].Value = feeEntity.CustomerName;
updateParms[3].Value = feeEntity.Unit;
updateParms[4].Value = feeEntity.UnitPrice;
updateParms[5].Value = feeEntity.Quantity;
updateParms[6].Value = feeEntity.CommissionRate;
updateParms[7].Value = feeEntity.Amount;
updateParms[8].Value = feeEntity.Currency;
updateParms[9].Value = feeEntity.ExchangeRate;
updateParms[10].Value = feeEntity.FeeFrt;
updateParms[11].Value = feeEntity.Remark;
updateParms[12].Value = feeEntity.IsAdvancePay;
//updateParms[13].Value = feeEntity.WMSOUTBSNO.Equals(null) ? "" : feeEntity.WMSOUTBSNO.ToString().Trim();
updateParms[13].Value = feeEntity.LINENUM;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_CH_FE, updateParms);
}
else if (iFeeStatus < 0)
{
SqlParameter[] insertParms = new SqlParameter[] {
new SqlParameter(PARM_FEE_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEE_NAME,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_CUSTOMER_NAME,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_UNIT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_UNIT_PRICE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_QUANTITY,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_COMMISSION_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_AMOUNT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_CURRENCY,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_EXCHANGE_RATE,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEE_FRT,SqlDbType.VarChar,20),
new SqlParameter(PARM_FEE_REMARK,SqlDbType.VarChar),
new SqlParameter(PARM_FEE_ISADVANCEPAY,SqlDbType.Bit),
new SqlParameter(PARM_FEE_TYPE,SqlDbType.Int),
new SqlParameter(PARM_FEE_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEE_ENTER_OPERATOR,SqlDbType.VarChar,50),
new SqlParameter(PARM_FEE_STATUS,SqlDbType.Int),
new SqlParameter(PARM_FEE_AUDIT_WMSOUTBSNO,SqlDbType.VarChar,100),
new SqlParameter("@LINENUM",SqlDbType.Int)
};
insertParms[0].Value = feeEntity.GID;
insertParms[1].Value = feeEntity.FeeName;
insertParms[2].Value = feeEntity.CustomerName;
insertParms[3].Value = feeEntity.Unit;
insertParms[4].Value = feeEntity.UnitPrice;
insertParms[5].Value = feeEntity.Quantity;
insertParms[6].Value = feeEntity.CommissionRate;
insertParms[7].Value = feeEntity.Amount;
insertParms[8].Value = feeEntity.Currency;
insertParms[9].Value = feeEntity.ExchangeRate;
insertParms[10].Value = feeEntity.FeeFrt;
insertParms[11].Value = feeEntity.Remark;
insertParms[12].Value = feeEntity.IsAdvancePay;
insertParms[13].Value = feeEntity.FeeType;
insertParms[14].Value = feeEntity.BSNO;
insertParms[15].Value = feeEntity.EnterOperator;
insertParms[16].Value = feeEntity.FeeStatus;
insertParms[17].Value = feeEntity.WMSOUTBSNO.Equals(null) ? "" : feeEntity.WMSOUTBSNO.ToString().Trim();
insertParms[18].Value = feeEntity.LINENUM;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_CH_FEE, insertParms);
}
}
//
if (feeProfitEntity != null)
{
SqlParameter[] validProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100)
};
validProfitParms[0].Value = tempBSNO;
//保存利润信息
object bsnoObj = SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_FEE_PROFIT_BY_BSNO, validProfitParms);
if (bsnoObj == null)
{
//如果没有与BSNO关联的费用利润信息,则插入新的费用利润
SqlParameter[] insertProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_GID,SqlDbType.VarChar,36),
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEEPROFIT_RMB_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_RMB_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_DR_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_CR_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_RMB_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_PROFIT_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_PROFIT_RATE,SqlDbType.VarChar,12),
new SqlParameter(PARM_FEEPROFIT_CREATE_USER,SqlDbType.VarChar,12)
};
insertProfitParms[0].Value = Guid.NewGuid().ToString();
insertProfitParms[1].Value = tempBSNO;
insertProfitParms[2].Value = feeProfitEntity.RMBDR;
insertProfitParms[3].Value = feeProfitEntity.USDDR;
insertProfitParms[4].Value = feeProfitEntity.OTHERDR;
insertProfitParms[5].Value = feeProfitEntity.RMBCR;
insertProfitParms[6].Value = feeProfitEntity.USDCR;
insertProfitParms[7].Value = feeProfitEntity.OTHERCR;
insertProfitParms[8].Value = feeProfitEntity.DRTTL;
insertProfitParms[9].Value = feeProfitEntity.CRTTL;
insertProfitParms[10].Value = feeProfitEntity.RMBProfit;
insertProfitParms[11].Value = feeProfitEntity.USDProfit;
insertProfitParms[12].Value = feeProfitEntity.OTHERProfit;
insertProfitParms[13].Value = feeProfitEntity.TTLProfit;
insertProfitParms[14].Value = feeProfitEntity.ProfitRate;
insertProfitParms[15].Value = feeProfitEntity.CreateUser;
//SQL_INSERT_FEE_PROFIT = " INSERT INTO fee_gain(GID, BSNO, RMBDR, USDDR, OTDR, RMBCR, USDCR, OTCR, DRTTL, CRTTL,RMBPROFIT, "
//+ " USDPROFIT,OTPROFIT, TTLPROFIT, PROFITRATE,CREATEUSER,CREATETIME )"
//+ " VALUES (@gid, @bsno, @rmb_dr, @usd_dr, @other_dr, @rmb_cr, @usd_cr, @other_cr, @dr_total, @cr_total,"
//+ " @rmb_profit, @usd_profit, @other_profit, @profit_total, @profit_rate, @create_user, GETDATE())";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_INSERT_FEE_PROFIT, insertProfitParms);
}
else
{
//如果存在记录,则更新费用利润表
//如果没有与BSNO关联的费用利润信息,则插入新的费用利润
SqlParameter[] upateProfitParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100),
new SqlParameter(PARM_FEEPROFIT_RMB_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_DR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_RMB_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_CR,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_DR_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_CR_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_RMB_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_USD_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_OTHER_PROFIT,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_PROFIT_TOTAL,SqlDbType.Decimal,20),
new SqlParameter(PARM_FEEPROFIT_PROFIT_RATE,SqlDbType.VarChar,12),
new SqlParameter(PARM_FEEPROFIT_MODIFIED_USER,SqlDbType.VarChar,12)
};
upateProfitParms[0].Value = tempBSNO;
upateProfitParms[1].Value = feeProfitEntity.RMBDR;
upateProfitParms[2].Value = feeProfitEntity.USDDR;
upateProfitParms[3].Value = feeProfitEntity.OTHERDR;
upateProfitParms[4].Value = feeProfitEntity.RMBCR;
upateProfitParms[5].Value = feeProfitEntity.USDCR;
upateProfitParms[6].Value = feeProfitEntity.OTHERCR;
upateProfitParms[7].Value = feeProfitEntity.DRTTL;
upateProfitParms[8].Value = feeProfitEntity.CRTTL;
upateProfitParms[9].Value = feeProfitEntity.RMBProfit;
upateProfitParms[10].Value = feeProfitEntity.USDProfit;
upateProfitParms[11].Value = feeProfitEntity.OTHERProfit;
upateProfitParms[12].Value = feeProfitEntity.TTLProfit;
upateProfitParms[13].Value = feeProfitEntity.ProfitRate;
upateProfitParms[14].Value = feeProfitEntity.ModifiedUser;
//SQL_UPDATE_FEE_PROFIT_BY_BSNO = " UPDATE fee_gain SET RMBDR = @rmb_dr,USDDR = @usd_dr,OTDR = @other_dr,RMBCR = @rmb_cr,USDCR = @usd_cr,OTCR = @other_cr,"
//+ " DRTTL = @dr_total,CRTTL = @cr_total,RMBPROFIT = @rmb_profit,USDPROFIT = @usd_profit,OTPROFIT = @other_profit,TTLPROFIT = @profit_total,"
//+ " PROFITRATE = @profit_rate,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE() WHERE BSNO = @bsno ";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_PROFIT_BY_BSNO, upateProfitParms);
}
}
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception execError)
{
iResult = -1;//有异常,插入失败
sqlTran.Rollback();
iResult = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult;
}
#endregion
public IList<FeeEntity> GetAuditFeeByBSNO(string tempBSNO, string tempUserID)
{
IList<FeeEntity> feeEntities = new List<FeeEntity>();
SqlParameter[] parms = new SqlParameter[]{
new SqlParameter(PARM_FEE_BSNO, SqlDbType.VarChar, 100),
new SqlParameter(PARM_WORKFLOW_DO_AUDITOR, SqlDbType.VarChar, 36)
};
parms[0].Value = tempBSNO;
parms[1].Value = tempUserID;
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_WAITTING_AUDIT_FEE, parms))
{
try
{
while (sqlRead.Read())
{
FeeEntity feeEntity = new FeeEntity();
if (!sqlRead.IsDBNull(0))
{
feeEntity.GID = sqlRead.GetString(0);
}
if (!sqlRead.IsDBNull(1))
{
feeEntity.BSNO = sqlRead.GetString(1);
}
if (!sqlRead.IsDBNull(2))
{
feeEntity.FeeType = sqlRead.GetInt32(2);
}
if (!sqlRead.IsDBNull(3))
{
feeEntity.FeeName = sqlRead.GetString(3);
}
if (!sqlRead.IsDBNull(4))
{
feeEntity.FeeDescription = sqlRead.GetString(4);
}
if (!sqlRead.IsDBNull(5))
{
feeEntity.CustomerType = sqlRead.GetString(5);
}
if (!sqlRead.IsDBNull(6))
{
feeEntity.CustomerName = sqlRead.GetString(6);
}
if (!sqlRead.IsDBNull(7))
{
feeEntity.Unit = sqlRead.GetString(7);
}
if (!sqlRead.IsDBNull(8))
{
feeEntity.UnitPrice = sqlRead.GetDecimal(8);
}
if (!sqlRead.IsDBNull(9))
{
feeEntity.Quantity = sqlRead.GetDecimal(9);
}
if (!sqlRead.IsDBNull(10))
{
feeEntity.Amount = sqlRead.GetDecimal(10);
}
if (!sqlRead.IsDBNull(11))
{
feeEntity.Currency = sqlRead.GetString(11);
}
if (!sqlRead.IsDBNull(12))
{
feeEntity.ExchangeRate = sqlRead.GetDecimal(12);
}
if (!sqlRead.IsDBNull(13))
{
feeEntity.Reason = sqlRead.GetString(13);
}
if (!sqlRead.IsDBNull(14))
{
feeEntity.Remark = sqlRead.GetString(14);
}
if (!sqlRead.IsDBNull(15))
{
feeEntity.CommissionRate = sqlRead.GetDecimal(15);
}
if (!sqlRead.IsDBNull(16))
{
feeEntity.Settlement = sqlRead.GetDecimal(16);
}
if (!sqlRead.IsDBNull(17))
{
feeEntity.Invoice = sqlRead.GetDecimal(17);
}
if (!sqlRead.IsDBNull(18))
{
feeEntity.OrderAmount = sqlRead.GetDecimal(18);
}
if (!sqlRead.IsDBNull(19))
{
feeEntity.OrderInvoice = sqlRead.GetDecimal(19);
}
if (!sqlRead.IsDBNull(20))
{
feeEntity.SubmitDate = sqlRead.GetDateTime(20);
}
if (!sqlRead.IsDBNull(21))
{
feeEntity.AuditOperator = sqlRead.GetString(21);
}
if (!sqlRead.IsDBNull(22))
{
feeEntity.AuditDate = sqlRead.GetDateTime(22);
}
if (!sqlRead.IsDBNull(23))
{
feeEntity.EnterOperator = sqlRead.GetString(23);
}
if (!sqlRead.IsDBNull(24))
{
feeEntity.EnterDate = sqlRead.GetDateTime(24);
}
if (!sqlRead.IsDBNull(25))
{
feeEntity.DebitNO = sqlRead.GetString(25);
}
if (!sqlRead.IsDBNull(26))
{
feeEntity.IsDebit = sqlRead.GetBoolean(26);
}
if (!sqlRead.IsDBNull(27))
{
feeEntity.IsOpen = sqlRead.GetBoolean(27);
}
if (!sqlRead.IsDBNull(28))
{
feeEntity.IsAdvancePay = sqlRead.GetBoolean(28);
}
if (!sqlRead.IsDBNull(29))
{
feeEntity.Sort = sqlRead.GetInt32(29);
}
if (!sqlRead.IsDBNull(30))
{
feeEntity.IsInvoice = sqlRead.GetBoolean(30);
}
if (!sqlRead.IsDBNull(31))
{
feeEntity.FeeStatus = sqlRead.GetInt32(31);
}
if (!sqlRead.IsDBNull(32))
{
feeEntity.FeeFrt = sqlRead.GetString(32);
}
feeEntities.Add(feeEntity);
}
}
catch (Exception execError)
{
throw execError;
}
return feeEntities;
}
}
#region 获取SQL语句查询数据集
/// <summary>
/// 获取SQL语句查询数据集
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataSet GetExcuteSql(string strSql)
{
DataSet tempSet = new DataSet();
tempSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
return tempSet;
}
#endregion
}
public enum FeeStatusType
{
AUDITPASS = 0,
ENTERING = 1,
POSTAUDIT = 2,
MODIFYAPPLY = 3,
DELETEAPPLY = 4,
CANCELAPPLY = 5,
REJECTAUDIT = 6,
REJECTAPPLY = 7,
SETTLEAPART = 8,
SETTLEFULL = 9
}
}