using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DSWeb.EntityDA;
using DSWeb.Models;
using JsonHelper;
using System.Xml;
namespace DSWeb.CW
{
public partial class CwVouchersAddingDo : System.Web.UI.Page
{
public string strGIDS = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
public string strUserID;//用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
this.hdUserID.Value = strUserID.Trim();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["gids"] != null)
{
strGIDS = Request.QueryString["gids"].ToString().Trim().ToLower();
}
//grid
if (!IsPostBack)
{
this.hd_comboPREPARED.Value = strShowName.Trim();
tbVOUDATE.Text = T_ALL_DA.GetStrSQL("rq", "select convert(char(10),getdate(),20) as rq");
tbRATE.Text = T_ALL_DA.GetStrSQL("VALUE", "select top 1 isnull(VALUE,1) as VALUE from currency_exchange where COMPANYID='" + strCompanyID + "' and ISDELETE=0 and [type]='common'");
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "");
}
protected String getgid()
{
string strgid = Guid.NewGuid().ToString();
strgid = strgid.Replace("-", "");
strgid = "VOU" + strgid;
return strgid;
}
protected void btnEnter_Click(object sender, EventArgs e)
{
string sSQL = "";
int iResult = 0;
string zt = "";
if (cbISRATE.Checked == false && tbRATE.Text.Trim() == "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "");
return;
}
//
if (strGIDS.Trim() != "")
{
//帐套设置
sSQL = "SELECT top 1 * from cw_design";
DataSet dsCwDesign = T_ALL_DA.GetAllSQL(sSQL);
if (dsCwDesign == null)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "");
return;
}
//
string sGids = strGIDS.Trim().Replace(",", "','");
sGids = "'" + sGids.Trim() + "'";
//合并生成结算凭证
if (dsCwDesign.Tables[0].Rows[0]["ISMGSC"].ToString().Trim() == "True")
{
iResult = getSC(dsCwDesign, sGids.Trim(), "", cbISRATE.Checked, cbButtSettlement.Checked, tbVOUDATE.Text.Trim(), this.hd_comboPREPARED.Value.Trim(), tbRATE.Text.Trim());//, strEXPLAN, ds1.Tables[0].Rows[0]["DEPTID"].ToString().Trim(), ds1.Tables[0].Rows[0]["EMPLID"].ToString().Trim(), ds1.Tables[0].Rows[0]["SALE"].ToString().Trim());
zt += "," + iResult;
}
else
{
string[] items = sGids.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length > 0)
{
for (int i = 0; i < items.Length; i++)
{
iResult = getSC(dsCwDesign, items[i].ToString().Trim(), "", cbISRATE.Checked, cbButtSettlement.Checked, tbVOUDATE.Text.Trim(), this.hd_comboPREPARED.Value.Trim(), tbRATE.Text.Trim());//, strEXPLAN, ds1.Tables[0].Rows[0]["DEPTID"].ToString().Trim(), ds1.Tables[0].Rows[0]["EMPLID"].ToString().Trim(), ds1.Tables[0].Rows[0]["SALE"].ToString().Trim());
zt += "," + iResult;
}
}
}
//
if (zt.IndexOf("-") > 0)
{
Response.Write("");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "");
}
}
}
///
/// 生成凭证
///
/// 帐套设置数据集
/// gid业务编号
/// 船名航次
/// 是否按照系统录入汇率
/// 是否对抵结算是否生成银行账款
/// 凭证日期
/// 制单人
/// 自定义汇率
/// 规则生成的摘要
///
public int getSC(DataSet dsCwDesign, string sGids, string strVESSEL, bool ISRATE, bool isButtSettlement, string sVOUDATE, string sPREPARED, string dlRATE)//, string strEXPLAN, string strDEPTID, string strEMPLID, string strSALE)
{
#region 基本变量
//全部
string sSQL = "";
string sSQL_Y = "";
string sSQL_Z = "";
string strEXPLAN = "";
int iResult = 0;
int n = 0;
Decimal dEXCHANGERATE =0;
//应收应付账款
Decimal iAMTDR = 0;
Decimal iAMTCR = 0;
//差额主营业务收入
Decimal dRMBS = 0;
Decimal dRMBF = 0;
Decimal dUSDS = 0;
Decimal dUSDF = 0;
//总合计
Decimal strJie = 0;
Decimal strDai = 0;
string ls = "";
string strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim();
#endregion
#region 其他常用科目设置
//其他常用科目设置 应收RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet dsAR = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'";
DataSet dsARFC = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
DataSet dsAPFC = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim() + "'";
DataSet dsAPMBSPENDING = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 付费结算外币借方默认科目代码
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim() + "'";
DataSet dsAPTMSFC = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 预收账款
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["DR"].ToString().Trim() + "'";
DataSet dsDR = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 预收账款外币
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["DRFC"].ToString().Trim() + "'";
DataSet dsDRFC = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 预付账款
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["CR"].ToString().Trim() + "'";
DataSet dsCR = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 预付账款外币
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["CRFC"].ToString().Trim() + "'";
DataSet dsCRFC = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 汇兑损益
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + dsCwDesign.Tables[0].Rows[0]["EGOL"].ToString().Trim() + "'";
DataSet dsEGOL = T_ALL_DA.GetAllSQL(sSQL);
#endregion
#region 摘要
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strISEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
//if (sRPEXPLANAR.IndexOf("《结算单位》") > -1 || sRPEXPLANAP.IndexOf("《结算单位》") > -1)
//{
// strISEXPLAN += ",CUSTOMERNAME";
//}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1 || sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
strISEXPLAN += ",CUSTNO";
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1 || sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
strISEXPLAN += ",MBLNO";
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1 || sRPEXPLANAP.IndexOf("《船名》") > -1)
{
strISEXPLAN += ",VESSEL";
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1 || sRPEXPLANAP.IndexOf("《航次》") > -1)
{
strISEXPLAN += ",VOYNO";
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1 || sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
strISEXPLAN += ",BILLNO_ACAD";
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1 || sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
strISEXPLAN += ",BS_CUSTOMERNAME";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",CUSTNO";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",MBLNO";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strISEXPLAN += ",VESSEL";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",VOYNO";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",BILLNO_ACAD";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strISEXPLAN += ",BS_CUSTOMERNAME";
}
}
#endregion
#region 基本数据集
string strORDNO = getgid();
CwVouchersDA CwVouchersDA = new CwVouchersDA();
IList CwVouitemsEntities = new List();
//
//(CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as 类型
//,CUSTOMERNAME 客户名称
//,EXCHANGERATE 汇率
//,CURRENCY 币别`
//,ISADVANCEDPAY 是否垫付
//,SUM(AMOUNT) AS 金额
//,SUM(AMOUNT*EXCHANGERATE) AS 合计金额
//是否按照系统录入汇率
string ISADVANCE = T_ALL_DA.GetStrSQL("ISADVANCE", "select top 1 ISADVANCE from subcomp_seae_def where CORPID='" + strCompanyID + "'");//是否在结算页面显示预收预付信息录入
if (ISRATE == true)
{
#region 应收应付
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME,ORIGCURRENCY as CURRENCY,EXCHANGERATE"
+ ",SUM(ORIGAMOUNT) AS je"//AMOUNT
+ ",(case when (ORIGCURRENCY<>CURRENCY and CURRENCY='RMB') then sum(AMOUNT) else convert(decimal(18,2),round(SUM(ORIGAMOUNT*EXCHANGERATE),2)) end) AS hj"//
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE"//记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ"//记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE"//预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ"//预付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE"//实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ"//实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE"//财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END)),2)) AS FINANCIAL_MONEY_HJ"//财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE"//预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ"//预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY"//记账资料_币别
+ ",PREPAY_CURRENCY"//预付支资料_币别
+ ",AHSR_CURRENCY"//实付支资料_币别
+ ",FINANCIAL_CURRENCY"//财务费用_币别
+ ",ADVANCE_CURRENCY"//预付支取用资料_币别
+ ",(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE"//记账资料_汇率
+ ",(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END) as PREPAY_RATE"//预付支资料_汇率
+ ",(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END) as AHSR_RATE"//实付支资料_汇率
+ ",(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END) as FINANCIAL_RATE"//财务费用_汇率
+ ",(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END) as ADVANCE_RATE"//预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN
+" From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ORIGCURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY" + strISEXPLAN
+ " ORDER BY FEETYPE desc,ORIGCURRENCY,CUSTOMERNAME" + strISEXPLAN;//,CURRENCY
#endregion
#region 预收预付
sSQL_Y = "SELECT "
////+ "(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
//+ "(CASE WHEN SUBSTRING(RIGHT(billno,12),0,3)='DR' THEN '应收账款' WHEN SUBSTRING(RIGHT(billno,12),0,3)='CR' THEN '应付账款' ELSE '' END) as FEETYPE"
+ "(CASE WHEN Billtype=1 THEN '应收账款' WHEN Billtype=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME,CURRENCY,EXCHANGERATE"
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE"//记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ"//记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE"//预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ"//预付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE"//实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ"//实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE"//财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END)),2)) AS FINANCIAL_MONEY_HJ"//财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE"//预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ"//预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY"//记账资料_币别
+ ",PREPAY_CURRENCY"//预付支资料_币别
+ ",AHSR_CURRENCY"//实付支资料_币别
+ ",FINANCIAL_CURRENCY"//财务费用_币别
+ ",ADVANCE_CURRENCY"//预付支取用资料_币别
+ ",(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE"//记账资料_汇率
+ ",(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END) as PREPAY_RATE"//预付支资料_汇率
+ ",(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END) as AHSR_RATE"//实付支资料_汇率
+ ",(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END) as FINANCIAL_RATE"//财务费用_汇率
+ ",(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END) as ADVANCE_RATE"//预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD"// +strISEXPLAN
+ " From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and GID in (SELECT GID=(SELECT top 1 GID from VW_ch_fee_settlement_do where BILLNO=c.BILLNO ORDER BY CURRENCY desc) from VW_ch_fee_settlement_do as c WHERE gid_s in (" + sGids.Trim() + "))"
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY billno,CUSTOMERNAME,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY,Billtype"// + strISEXPLAN//,FEETYPE
+ " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME";// +strISEXPLAN;
#endregion
//对抵结算是否生成银行账款
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
#region 现金、账户合计
sSQL_Z = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",SETTLETYPE,CUSTOMERNAME,CURRENCY,EXCHANGERATE"
+ ",SUM(AMOUNT) AS je"
+ ",convert(decimal(18,2),round(SUM(AMOUNT*EXCHANGERATE),2)) AS hj"
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE"//记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ"//记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE"//预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ"//预付支资料_金额
//+ ",SUM(AMOUNT) AS AHSR_MONEY_JE"//实付支资料_金额
//+ ",convert(decimal(18,2),round(SUM(AMOUNT*(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ"//实付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE"//实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ"//实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE"//财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END)),2)) AS FINANCIAL_MONEY_HJ"//财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE"//预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ"//预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY"//记账资料_币别
+ ",PREPAY_CURRENCY"//预付支资料_币别
//+ ",CURRENCY as AHSR_CURRENCY"//实付支资料_币别
+ ",AHSR_CURRENCY"//实付支资料_币别
+ ",FINANCIAL_CURRENCY"//财务费用_币别
+ ",ADVANCE_CURRENCY"//预付支取用资料_币别
+ ",(case when ACCOUNTS_CURRENCY<>'RMB' AND ACCOUNTS_RATE=1 THEN EXCHANGERATE ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE"//记账资料_汇率
+ ",(case when PREPAY_CURRENCY<>'RMB' AND PREPAY_RATE=1 THEN EXCHANGERATE ELSE PREPAY_RATE END) as PREPAY_RATE"//预付支资料_汇率
+ ",(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN EXCHANGERATE ELSE AHSR_RATE END) as AHSR_RATE"//实付支资料_汇率
+ ",(case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN EXCHANGERATE ELSE FINANCIAL_RATE END) as FINANCIAL_RATE"//财务费用_汇率
+ ",(case when ADVANCE_CURRENCY<>'RMB' AND ADVANCE_RATE=1 THEN EXCHANGERATE ELSE ADVANCE_RATE END) as ADVANCE_RATE"//预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD" //+ strISEXPLAN
+ " From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY BILLNO,CUSTOMERNAME,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY,FEETYPE,Billtype" //+ strISEXPLAN
+ " ORDER BY CURRENCY,CUSTOMERNAME,FEETYPE"; //+ strISEXPLAN
#endregion
}
else
{
#region 现金、账户合计
sSQL_Z = "select FEETYPE,SETTLETYPE,CURRENCY,ACCOUNTRMB,ACCOUNTUSD,AHSR_CURRENCY,AHSR_RATE"//,EXCHANGERATE
+ ",sum(AHSR_MONEY_JE) as AHSR_MONEY_JE"
+ ",sum(AHSR_MONEY_HJ) as AHSR_MONEY_HJ"
+ " from ("
+ "SELECT "
////+ "(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
//+ "(CASE WHEN SUBSTRING(RIGHT(billno,12),0,3)='DR' THEN '应收账款' WHEN SUBSTRING(RIGHT(billno,12),0,3)='CR' THEN '应付账款' ELSE '' END) as FEETYPE"
+ "(CASE WHEN Billtype=1 THEN '应收账款' WHEN Billtype=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=b.CUSTOMERNAME)"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=b.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME"
+ ",(select top 1 CURRENCY from VW_ch_fee_settlement_do where billno=b.billno ORDER BY CURRENCY DESC) as CURRENCY"//,EXCHANGERATE
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE" //实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN (select top 1 EXCHANGERATE from VW_ch_fee_settlement_do where billno=b.billno ORDER BY CURRENCY DESC) ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ" //实付支资料_金额
+ ",AHSR_CURRENCY" //实付支资料_币别
+ ",(case when AHSR_CURRENCY<>'RMB' AND AHSR_RATE=1 THEN (select top 1 EXCHANGERATE from VW_ch_fee_settlement_do where billno=b.billno ORDER BY CURRENCY DESC) ELSE AHSR_RATE END) as AHSR_RATE" //实付支资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD"
+ " from VW_ch_fee_settlement_do as b WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY billno,CUSTOMERNAME,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,Billtype"//,FEETYPE,CURRENCY,EXCHANGERATE
+ " ) as a "
+ " GROUP BY FEETYPE,SETTLETYPE,CURRENCY,AHSR_CURRENCY,AHSR_RATE,ACCOUNTRMB,ACCOUNTUSD"//,EXCHANGERATE
+ " ORDER BY FEETYPE desc,CURRENCY";//
#endregion
}
}
else
{
#region 应收应付
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME,ORIGCURRENCY as CURRENCY"//CURRENCY
+ ",(CASE WHEN ORIGCURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE"//CURRENCY
+ ",SUM(ORIGAMOUNT) AS je"//AMOUNT
+ ",(case when (ORIGCURRENCY<>CURRENCY and CURRENCY='RMB') then sum(AMOUNT) else convert(decimal(18,2),round(SUM(ORIGAMOUNT*(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END)),2)) end) AS hj"
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE" //记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ" //记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE" //预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ" //预付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE" //实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ" //实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE" //财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE FINANCIAL_RATE END)),2)) AS FINANCIAL_MONEY_HJ" //财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE" //预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ" //预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY" //记账资料_币别
+ ",PREPAY_CURRENCY" //预付支资料_币别
+ ",AHSR_CURRENCY" //实付支资料_币别
+ ",FINANCIAL_CURRENCY" //财务费用_币别
+ ",ADVANCE_CURRENCY" //预付支取用资料_币别
+ ",(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE" //记账资料_汇率
+ ",(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END) as PREPAY_RATE" //预付支资料_汇率
+ ",(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END) as AHSR_RATE" //实付支资料_汇率
+ ",(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE FINANCIAL_RATE END) as FINANCIAL_RATE" //财务费用_汇率
+ ",(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END) as ADVANCE_RATE" //预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN
+ " From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ORIGCURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY" + strISEXPLAN
+ " ORDER BY FEETYPE desc,ORIGCURRENCY,CUSTOMERNAME" + strISEXPLAN;//,CURRENCY
#endregion
#region 预收预付
sSQL_Y = "SELECT "
////+ "(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
//+ "(CASE WHEN SUBSTRING(RIGHT(billno,12),0,3)='DR' THEN '应收账款' WHEN SUBSTRING(RIGHT(billno,12),0,3)='CR' THEN '应付账款' ELSE '' END) as FEETYPE"
+ "(CASE WHEN Billtype=1 THEN '应收账款' WHEN Billtype=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_settlement_do.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME,CURRENCY"
+ ",(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE"
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE" //记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ" //记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE" //预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ" //预付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE" //实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ" //实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE" //财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE (case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN " + dlRATE + " ELSE FINANCIAL_RATE END) END)),2)) AS FINANCIAL_MONEY_HJ" //财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE" //预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ" //预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY" //记账资料_币别
+ ",PREPAY_CURRENCY" //预付支资料_币别
+ ",AHSR_CURRENCY" //实付支资料_币别
+ ",FINANCIAL_CURRENCY" //财务费用_币别
+ ",ADVANCE_CURRENCY" //预付支取用资料_币别
+ ",(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE" //记账资料_汇率
+ ",(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END) as PREPAY_RATE" //预付支资料_汇率
+ ",(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END) as AHSR_RATE" //实付支资料_汇率
+ ",(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE (case when FINANCIAL_CURRENCY<>'RMB' AND FINANCIAL_RATE=1 THEN " + dlRATE + " ELSE FINANCIAL_RATE END) END) as FINANCIAL_RATE" //财务费用_汇率
+ ",(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END) as ADVANCE_RATE" //预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD"// + strISEXPLAN
+ " From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and GID in (SELECT GID=(SELECT top 1 GID from VW_ch_fee_settlement_do where BILLNO=c.BILLNO ORDER BY CURRENCY desc) from VW_ch_fee_settlement_do as c WHERE gid_s in (" + sGids.Trim() + "))"
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY billno,CUSTOMERNAME,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY,Billtype"// +strISEXPLAN//,FEETYPE
+ " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME";// +strISEXPLAN;
#endregion
//对抵结算是否生成银行账款
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
#region 现金、账户合计
sSQL_Z = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",SETTLETYPE,CUSTOMERNAME,CURRENCY"
+ ",(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE"
+ ",SUM(AMOUNT) AS je"
+ ",convert(decimal(18,2),round(SUM(AMOUNT*(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END)),2)) AS hj"
+ ",(ACCOUNTS_MONEY) AS ACCOUNTS_MONEY_JE" //记账资料_金额
+ ",convert(decimal(18,2),round((ACCOUNTS_MONEY*(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END)),2)) AS ACCOUNTS_MONEY_HJ" //记账资料_金额
+ ",(PREPAY_MONEY) AS PREPAY_MONEY_JE" //预付支资料_金额
+ ",convert(decimal(18,2),round((PREPAY_MONEY*(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END)),2)) AS PREPAY_MONEY_HJ" //预付支资料_金额
//+ ",SUM(AMOUNT) AS AHSR_MONEY_JE" //实付支资料_金额
//+ ",convert(decimal(18,2),round(SUM(AMOUNT*(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END)),2)) AS AHSR_MONEY_HJ" //实付支资料_金额
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE" //实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END)),2)) AS AHSR_MONEY_HJ" //实付支资料_金额
+ ",(FINANCIAL_MONEY) AS FINANCIAL_MONEY_JE" //财务费用_金额
+ ",convert(decimal(18,2),round((FINANCIAL_MONEY*(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE FINANCIAL_RATE END)),2)) AS FINANCIAL_MONEY_HJ" //财务费用_金额
+ ",(ADVANCE_MONEY) AS ADVANCE_MONEY_JE" //预付支取用资料_金额
+ ",convert(decimal(18,2),round((ADVANCE_MONEY*(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END)),2)) AS ADVANCE_MONEY_HJ" //预付支取用资料_金额
+ ",ACCOUNTS_CURRENCY" //记账资料_币别
+ ",PREPAY_CURRENCY" //预付支资料_币别
//+ ",CURRENCY as AHSR_CURRENCY" //实付支资料_币别
+ ",AHSR_CURRENCY" //实付支资料_币别
+ ",FINANCIAL_CURRENCY" //财务费用_币别
+ ",ADVANCE_CURRENCY" //预付支取用资料_币别
+ ",(CASE WHEN ACCOUNTS_CURRENCY='USD' THEN " + dlRATE + " ELSE ACCOUNTS_RATE END) as ACCOUNTS_RATE" //记账资料_汇率
+ ",(CASE WHEN PREPAY_CURRENCY='USD' THEN " + dlRATE + " ELSE PREPAY_RATE END) as PREPAY_RATE" //预付支资料_汇率
+ ",(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as AHSR_RATE" //实付支资料_汇率
+ ",(CASE WHEN FINANCIAL_CURRENCY='USD' THEN " + dlRATE + " ELSE FINANCIAL_RATE END) as FINANCIAL_RATE" //财务费用_汇率
+ ",(CASE WHEN ADVANCE_CURRENCY='USD' THEN " + dlRATE + " ELSE ADVANCE_RATE END) as ADVANCE_RATE" //预付支取用资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD" //+ strISEXPLAN
+ " From VW_ch_fee_settlement_do WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY BILLNO,CUSTOMERNAME,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,ACCOUNTS_CURRENCY,PREPAY_CURRENCY,AHSR_CURRENCY,FINANCIAL_CURRENCY,ADVANCE_CURRENCY,ACCOUNTS_RATE,PREPAY_RATE,AHSR_RATE,FINANCIAL_RATE,ADVANCE_RATE,ACCOUNTS_MONEY,PREPAY_MONEY,AHSR_MONEY,FINANCIAL_MONEY,ADVANCE_MONEY,FEETYPE,Billtype" //+ strISEXPLAN
+ " ORDER BY CURRENCY,CUSTOMERNAME,FEETYPE"; //+ strISEXPLAN
#endregion
}
else
{
#region 现金、账户合计
sSQL_Z = "select FEETYPE,SETTLETYPE,CURRENCY,ACCOUNTRMB,ACCOUNTUSD,AHSR_CURRENCY,AHSR_RATE"//,EXCHANGERATE
+ ",sum(AHSR_MONEY_JE) as AHSR_MONEY_JE"
+ ",sum(AHSR_MONEY_HJ) as AHSR_MONEY_HJ"
+ " from ("
+ "SELECT "
////+ "(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE"
//+ "(CASE WHEN SUBSTRING(RIGHT(billno,12),0,3)='DR' THEN '应收账款' WHEN SUBSTRING(RIGHT(billno,12),0,3)='CR' THEN '应付账款' ELSE '' END) as FEETYPE"
+ "(CASE WHEN Billtype=1 THEN '应收账款' WHEN Billtype=2 THEN '应付账款' ELSE '' END) as FEETYPE"
+ ",FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=b.CUSTOMERNAME)"
+ ",FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=b.CUSTOMERNAME)"
+ ",SETTLETYPE,CUSTOMERNAME"
+ ",(select top 1 CURRENCY from VW_ch_fee_settlement_do where billno=b.billno ORDER BY CURRENCY DESC) as CURRENCY"//,EXCHANGERATE
//+ ",(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE"
+ ",(AHSR_MONEY) AS AHSR_MONEY_JE"//实付支资料_金额
+ ",convert(decimal(18,2),round((AHSR_MONEY*(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END)),2)) AS AHSR_MONEY_HJ"//实付支资料_金额
+ ",AHSR_CURRENCY"//实付支资料_币别
+ ",(CASE WHEN AHSR_CURRENCY='USD' THEN " + dlRATE + " ELSE AHSR_RATE END) as AHSR_RATE"//实付支资料_汇率
+ ",ACCOUNTRMB,ACCOUNTUSD"
+ " From VW_ch_fee_settlement_do as b WHERE 1=1 "
+ " and gid_s in (" + sGids.Trim() + ") " + strVESSEL
+ " GROUP BY billno,CUSTOMERNAME,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD,AHSR_CURRENCY,AHSR_RATE,AHSR_MONEY,Billtype"//,CURRENCY,FEETYPE,EXCHANGERATE
+ " ) as a "
+ " GROUP BY FEETYPE,SETTLETYPE,CURRENCY,AHSR_CURRENCY,AHSR_RATE,ACCOUNTRMB,ACCOUNTUSD"//,EXCHANGERATE
+ " ORDER BY FEETYPE desc,CURRENCY";
#endregion
}
}
DataSet dsVWChFeeSettlementDo = T_ALL_DA.GetAllSQL(sSQL);
DataSet dsVWChFeeSettlementDo_Y = T_ALL_DA.GetAllSQL(sSQL_Y);
DataSet dsVWChFeeSettlementDo_Z = T_ALL_DA.GetAllSQL(sSQL_Z);
#endregion
if (dsVWChFeeSettlementDo != null)
{
//暂时停用
#region 插入明细表 应收账款、应付账款、银行账户(原结算信息)
/*
#region 插入明细表 应收账款、应付账款
for (int i = 0; i < dsVWChFeeSettlementDo.Tables[0].Rows.Count; i++)
{
n = i;// +1;
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity();
//CwVouitemsEntity.GID 唯一编码 newid()
CwVouitemsEntity.ORDNO = strORDNO.Trim();
CwVouitemsEntity.ITEMNO = n;// 行号
CwVouitemsEntity.PACCID = "";//父级科目贷码
CwVouitemsEntity.PROPERTY = 0;//科目属性
CwVouitemsEntity.GRADE = 0;//科目级别
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收账款
iAMTDR = iAMTDR + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
//
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim();//应收账款科目贷码
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
dRMBS += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
if (dsAR == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "D";//贷方向
}
else
{
CwVouitemsEntity.ACCNAME = dsAR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (dsAR.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "USD")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim();//应收账款外币科目贷码
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = "USD";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币贷方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
dUSDS += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
if (dsARFC == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "C";//贷方向
}
else
{
CwVouitemsEntity.ACCNAME = dsARFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (dsARFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
}
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付账款
iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
//
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim();//应付账款科目贷码
}
else
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码
}
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
dRMBF += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (dsAP == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "C";//贷方向
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True")
{
if (dsAPMBSPENDING == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
}
else
{
CwVouitemsEntity.ACCNAME = dsAPMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
}
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
}
else
{
CwVouitemsEntity.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
}
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "USD")
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPTMSFC"].ToString().Trim() == "True")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim();//应付账款科目贷码
}
else
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款外币科目贷码
}
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = "USD";//外币编号usd
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.FCYCR = 0;//外币借方金额
dUSDF += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (dsAPFC == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "C";//贷方向
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPTMSFC"].ToString().Trim() == "True")
{
if (dsAPTMSFC == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
}
else
{
CwVouitemsEntity.ACCNAME = dsAPTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
}
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
}
else
{
CwVouitemsEntity.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
}
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
}
//CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
}
CwVouitemsEntity.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity.QTYUNIT = "";//数量包装单位
CwVouitemsEntity.QTYDR = 0;//借方数量
CwVouitemsEntity.QTYCR = 0;//贷方数量
//
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
//if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
//{
// strISEXPLAN += " " + dsCwDesign.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
//}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
}
//
CwVouitemsEntity.EXPLAN = strEXPLAN;//摘要,规则生成
//strEXPLANALL = strEXPLAN;
CwVouitemsEntity.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity.SALE = "";//strSALE;//人员名称
CwVouitemsEntity.PITEMID = 0;//父级项目编号
CwVouitemsEntity.ITEMID = "0";//项目编号
CwVouitemsEntity.FIELD1 = "";//预留字段1
CwVouitemsEntity.FIELD2 = "";//预留字段2
CwVouitemsEntity.FIELD3 = "";//预留字段3
CwVouitemsEntity.FIELD4 = "";//预留字段4
CwVouitemsEntity.FIELD5 = "";//预留字段5
CwVouitemsEntity.FIELD6 = "";//预留字段6
CwVouitemsEntity.FIELD7 = "";//预留字段7
CwVouitemsEntity.FIELD8 = "";//预留字段8
CwVouitemsEntity.FIELD9 = "";//预留字段9
CwVouitemsEntity.FIELD10 = "";//预留字段10
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity.ISSYS = true;//是否手动录入
}
CwVouitemsEntity.FSETTLCODE = dsVWChFeeSettlementDo.Tables[0].Rows[i]["SETTLETYPE"].ToString().Trim();//结算方式
CwVouitemsEntity.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity.BLNO = "";//BILLNO
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[i]["mblno"].ToString().Trim();//
}
//strBILLNOALL = CwVouitemsEntity.BLNO.ToString().Trim();//
CwVouitemsEntities.Add(CwVouitemsEntity);
}
#endregion
#region 插入明细表 现金、账户,收入\成本 生成 全额\差额
//现金、账户
Decimal dRMB = dRMBS - dRMBF;
Decimal dUSD = dUSDS - dUSDF;
//收入\成本 生成 全额\差额
strJie = strJie + dRMBS + dUSDS * dEXCHANGERATE;
strDai = strDai + dRMBF + dUSDF * dEXCHANGERATE;
//
string ls = "";
string strBPVW = "";
//
////(CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as 类型
////,CUSTOMERNAME 客户名称
////,EXCHANGERATE 汇率
////,CURRENCY 币别`
////,ISADVANCEDPAY 是否垫付
////,SUM(AMOUNT) AS 金额
////,SUM(AMOUNT*EXCHANGERATE) AS 合计金额
//if (ISRATE == true)
//{
// sSQL = "SELECT BILLNO,(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE";
// sSQL += ",SETTLETYPE,EXCHANGERATE";
// sSQL += ",CURRENCY,SUM(AMOUNT) AS je,SUM(AMOUNT*EXCHANGERATE) AS hj";
// sSQL += ",ACCOUNTRMB,ACCOUNTUSD";
// sSQL += " From VW_ch_fee_settlement_do WHERE 1=1 ";
// sSQL += " and gid_s in (" + sGids.Trim() + ") ";
// sSQL += " GROUP BY BILLNO,FEETYPE,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD";
// sSQL += " ORDER BY BILLNO,FEETYPE desc,CURRENCY";
//}
//else
//{
// sSQL = "SELECT BILLNO,(CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE";
// sSQL += ",SETTLETYPE";
// sSQL += ",(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE";
// sSQL += ",CURRENCY,SUM(AMOUNT) AS je";
// sSQL += ",SUM(AMOUNT*(CASE WHEN CURRENCY='USD' THEN " + dlRATE + " ELSE EXCHANGERATE END)) AS hj";
// sSQL += ",ACCOUNTRMB,ACCOUNTUSD";
// sSQL += " From VW_ch_fee_settlement_do WHERE 1=1 ";
// sSQL += " and gid_s in (" + sGids.Trim() + ") ";
// sSQL += " GROUP BY BILLNO,FEETYPE,EXCHANGERATE,CURRENCY,SETTLETYPE,ACCOUNTRMB,ACCOUNTUSD";
// sSQL += " ORDER BY BILLNO,FEETYPE desc,CURRENCY";
//}
//DataSet dsVWChFeeSettlementDo0 = T_ALL_DA.GetAllSQL(sSQL);
//if (dsVWChFeeSettlementDo0 != null)
//{
for (int j = 0; j < dsVWChFeeSettlementDo.Tables[0].Rows.Count; j++)
{
n = n + 1;
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity();
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2.ORDNO = strORDNO.Trim();
CwVouitemsEntity2.ITEMNO = n;// 行号
CwVouitemsEntity2.PACCID = "";//父级科目贷码
CwVouitemsEntity2.PROPERTY = 0;//科目属性
CwVouitemsEntity2.GRADE = 0;//科目级别
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应收账款")
{
//iAMTDR = iAMTDR + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());
//
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";// in (select top 1 ACCOUNTRMB from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";// in (select top 1 ACCOUNTRMB from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//贷方向
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "USD")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";// in (select top 1 ACCOUNTUSD from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";// in (select top 1 ACCOUNTUSD from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
CwVouitemsEntity2.CORPID = "";// dsVWChFeeSettlementDo.Tables[0].Rows[j]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应付账款")
{
//iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());
//
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";// in (select top 1 ACCOUNTRMB from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";// in (select top 1 ACCOUNTRMB from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "USD")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";// in (select top 1 ACCOUNTUSD from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";// in (select top 1 ACCOUNTUSD from ch_fee_settlement where BILLNO='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["BILLNO"].ToString().Trim() + "')";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["hj"].ToString().Trim());
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["je"].ToString().Trim());//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
CwVouitemsEntity2.CORPID = "";//dsVWChFeeSettlementDo.Tables[0].Rows[j]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
}
CwVouitemsEntity2.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
//
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
//if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
//{
// strISEXPLAN += " " + dsCwDesign.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
//}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VOYNO"].ToString().Trim() + "'";
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
}
//
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity2.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity2.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity2.SALE = "";//strSALE;//人员名称
CwVouitemsEntity2.PITEMID = 0;//父级项目编号
CwVouitemsEntity2.ITEMID = "0";//项目编号
CwVouitemsEntity2.FIELD1 = "";//预留字段1
CwVouitemsEntity2.FIELD2 = "";//预留字段2
CwVouitemsEntity2.FIELD3 = "";//预留字段3
CwVouitemsEntity2.FIELD4 = "";//预留字段4
CwVouitemsEntity2.FIELD5 = "";//预留字段5
CwVouitemsEntity2.FIELD6 = "";//预留字段6
CwVouitemsEntity2.FIELD7 = "";//预留字段7
CwVouitemsEntity2.FIELD8 = "";//预留字段8
CwVouitemsEntity2.FIELD9 = "";//预留字段9
CwVouitemsEntity2.FIELD10 = "";//预留字段10
CwVouitemsEntity2.ISSYS = true;//是否手动录入
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = "";//BILLNOstrBILLNOALL
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity2.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[j]["mblno"].ToString().Trim();//BILLNO
}
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
//}
#endregion
*/
#endregion
#region 插入明细表 财务费用和现金分开生成
/*财务费用和现金分开生成
#region 插入明细表 实付支资料 现金、账户,收入\成本 生成 全额\差额
for (int j = 0; j < dsVWChFeeSettlementDo.Tables[0].Rows.Count; j++)
{
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity();
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2.ORDNO = strORDNO.Trim();
CwVouitemsEntity2.ITEMNO = n;// 行号
CwVouitemsEntity2.PACCID = "";//父级科目贷码
CwVouitemsEntity2.PROPERTY = 0;//科目属性
CwVouitemsEntity2.GRADE = 0;//科目级别
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_JE"].ToString().Trim());
if (dl != 0)
{
n = n + 1;
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 实收支资料
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_CURRENCY"].ToString().Trim() == "USD")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
CwVouitemsEntity2.CORPID = "";//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
#endregion
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 实付支资料
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_CURRENCY"].ToString().Trim() == "USD")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_HJ"].ToString().Trim());
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
CwVouitemsEntity2.CORPID = "";//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
#endregion
}
}
else
{
continue;
}
CwVouitemsEntity2.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["AHSR_RATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
//
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VOYNO"].ToString().Trim() + "'";
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
}
//
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity2.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity2.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity2.SALE = "";//strSALE;//人员名称
CwVouitemsEntity2.PITEMID = 0;//父级项目编号
CwVouitemsEntity2.ITEMID = "0";//项目编号
CwVouitemsEntity2.FIELD1 = "";//预留字段1
CwVouitemsEntity2.FIELD2 = "";//预留字段2
CwVouitemsEntity2.FIELD3 = "";//预留字段3
CwVouitemsEntity2.FIELD4 = "";//预留字段4
CwVouitemsEntity2.FIELD5 = "";//预留字段5
CwVouitemsEntity2.FIELD6 = "";//预留字段6
CwVouitemsEntity2.FIELD7 = "";//预留字段7
CwVouitemsEntity2.FIELD8 = "";//预留字段8
CwVouitemsEntity2.FIELD9 = "";//预留字段9
CwVouitemsEntity2.FIELD10 = "";//预留字段10
CwVouitemsEntity2.ISSYS = true;//是否手动录入
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = "";//BILLNOstrBILLNOALL
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity2.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[j]["mblno"].ToString().Trim();//BILLNO
}
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
#endregion
#region 插入明细表 财务费用 生成 全额\差额
for (int j = 0; j < dsVWChFeeSettlementDo.Tables[0].Rows.Count; j++)
{
CwVouitemsEntity CwVouitemsEntity3 = new CwVouitemsEntity();
//CwVouitemsEntity3.GID 唯一编码 newid()
CwVouitemsEntity3.ORDNO = strORDNO.Trim();
CwVouitemsEntity3.ITEMNO = n;// 行号
CwVouitemsEntity3.PACCID = "";//父级科目贷码
CwVouitemsEntity3.PROPERTY = 0;//科目属性
CwVouitemsEntity3.GRADE = 0;//科目级别
//
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
if (dl != 0)
{
n = n + 1;
if (dsEGOL != null)
{
CwVouitemsEntity3.ACCID = dsCwDesign.Tables[0].Rows[0]["EGOL"].ToString().Trim();//汇兑损益/财务费用科目贷码
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收财务费用
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "C";//贷方向
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity3.ISFCY = false;//是否外币
CwVouitemsEntity3.FCYNO = "RMB";//外币编号usd
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_CURRENCY"].ToString().Trim() == "USD")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity3.DC = "C";//贷方向
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity3.ISFCY = true;//是否外币
CwVouitemsEntity3.FCYNO = "USD";//外币编号usd
}
#endregion
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付财务费用
if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//借贷相反
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "C";//贷方向
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity3.ISFCY = false;//是否外币
CwVouitemsEntity3.FCYNO = "RMB";//外币编号usd
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_CURRENCY"].ToString().Trim() == "USD")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//借贷相反
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
strJie = strJie + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity3.DC = "C";//贷方向
strDai = strDai + Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity3.ISFCY = true;//是否外币
CwVouitemsEntity3.FCYNO = "USD";//外币编号usd
}
#endregion
}
CwVouitemsEntity3.ACCNAME = dsEGOL.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity3.ISDEPTACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity3.ISEMPLACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity3.ISCORPACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity3.ISITEMACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
CwVouitemsEntity3.CORPID = "";//客户(系统)
CwVouitemsEntity3.CUSTOMERNAME = "";//客户(系统)
}
else
{
continue;
}
}
else
{
continue;
}
//
CwVouitemsEntity3.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[j]["FINANCIAL_RATE"].ToString().Trim());//汇率
CwVouitemsEntity3.QTYUNIT = "";//数量包装单位
CwVouitemsEntity3.QTYDR = 0;//借方数量
CwVouitemsEntity3.QTYCR = 0;//贷方数量
//
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["VOYNO"].ToString().Trim() + "'";
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[j]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
}
//
CwVouitemsEntity3.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity3.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity3.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity3.SALE = "";//strSALE;//人员名称
CwVouitemsEntity3.PITEMID = 0;//父级项目编号
CwVouitemsEntity3.ITEMID = "0";//项目编号
CwVouitemsEntity3.FIELD1 = "";//预留字段1
CwVouitemsEntity3.FIELD2 = "";//预留字段2
CwVouitemsEntity3.FIELD3 = "";//预留字段3
CwVouitemsEntity3.FIELD4 = "";//预留字段4
CwVouitemsEntity3.FIELD5 = "";//预留字段5
CwVouitemsEntity3.FIELD6 = "";//预留字段6
CwVouitemsEntity3.FIELD7 = "";//预留字段7
CwVouitemsEntity3.FIELD8 = "";//预留字段8
CwVouitemsEntity3.FIELD9 = "";//预留字段9
CwVouitemsEntity3.FIELD10 = "";//预留字段10
CwVouitemsEntity3.ISSYS = true;//是否手动录入
CwVouitemsEntity3.FSETTLCODE = "";//结算方式
CwVouitemsEntity3.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity3.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity3.BLNO = "";//BILLNO strBILLNOALL
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity3.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[j]["mblno"].ToString().Trim();//BILLNO
}
CwVouitemsEntities.Add(CwVouitemsEntity3);
}
#endregion
*/
#endregion
//end
///////////////////////////////////////////////////////
#region 插入明细表 实付支资料 账户,收入\成本 生成 全额\差额
for (int i = 0; i < dsVWChFeeSettlementDo_Z.Tables[0].Rows.Count; i++)
{
CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity();
//CwVouitemsEntity2.GID 唯一编码 newid()
CwVouitemsEntity2.ORDNO = strORDNO.Trim();
CwVouitemsEntity2.ITEMNO = n;// 行号
CwVouitemsEntity2.PACCID = "";//父级科目贷码
CwVouitemsEntity2.PROPERTY = 0;//科目属性
CwVouitemsEntity2.GRADE = 0;//科目级别
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());
if (dl != 0)
{
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 实收支资料
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
continue;
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
continue;
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
//
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() != "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
continue;
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
continue;
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
//
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
//CwVouitemsEntity2.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity2.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity2.CORPID = "";//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
#endregion
#region 实收支摘要
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
//if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'" + strSelEXPLAN;
}
else
{
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
}
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 实付支资料
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
continue;
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
continue;
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
//
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() != "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
continue;
}
CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
continue;
}
CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
//
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
//CwVouitemsEntity2.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity2.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity2.CORPID = "";//客户(系统)
CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
#endregion
#region 实收支摘要
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
//if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'" + strSelEXPLAN;
}
else
{
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
}
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
}
else
{
continue;
}
n = n + 1;
CwVouitemsEntity2.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
//
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity2.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity2.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity2.SALE = "";//strSALE;//人员名称
CwVouitemsEntity2.PITEMID = 0;//父级项目编号
CwVouitemsEntity2.ITEMID = "0";//项目编号
CwVouitemsEntity2.FIELD1 = "";//预留字段1
CwVouitemsEntity2.FIELD2 = "";//预留字段2
CwVouitemsEntity2.FIELD3 = "";//预留字段3
CwVouitemsEntity2.FIELD4 = "";//预留字段4
CwVouitemsEntity2.FIELD5 = "";//预留字段5
CwVouitemsEntity2.FIELD6 = "";//预留字段6
CwVouitemsEntity2.FIELD7 = "";//预留字段7
CwVouitemsEntity2.FIELD8 = "";//预留字段8
CwVouitemsEntity2.FIELD9 = "";//预留字段9
CwVouitemsEntity2.FIELD10 = "";//预留字段10
CwVouitemsEntity2.ISSYS = true;//是否手动录入
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity2.BLNO = "";//BILLNOstrBILLNOALL
//if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
//{
// CwVouitemsEntity2.BLNO = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["mblno"].ToString().Trim();//BILLNO
//}
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
#endregion
#region 插入明细表 实付支资料 现金,收入\成本 生成 全额\差额
Decimal dlAMTDR = 0;//本位币贷方金额(互斥)
Decimal dlAMTCR = 0;//本位币借方金额(互斥)
Decimal dlFCYDR = 0;//外币借方金额
Decimal dlFCYCR = 0;//外币贷方金额
//
for (int i = 0; i < dsVWChFeeSettlementDo_Z.Tables[0].Rows.Count; i++)
{
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity();
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4.ORDNO = strORDNO.Trim();
CwVouitemsEntity4.ITEMNO = n;// 行号
CwVouitemsEntity4.PACCID = "";//父级科目贷码
CwVouitemsEntity4.PROPERTY = 0;//科目属性
CwVouitemsEntity4.GRADE = 0;//科目级别
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());
if (dl != 0)
{
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 实收支资料
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
else
{
continue;
}
CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
else
{
continue;
}
CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity4.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity4.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity4.FCYDR = 0;//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
CwVouitemsEntity4.ISFCY = false;//是否外币
CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() != "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
else
{
continue;
}
CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
else
{
continue;
}
CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity4.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity4.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity4.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
CwVouitemsEntity4.ISFCY = true;//是否外币
CwVouitemsEntity4.FCYNO = "USD";//外币编号usd
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
//CwVouitemsEntity4.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity4.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity4.CORPID = "";//客户(系统)
CwVouitemsEntity4.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
#endregion
#region 实收支摘要
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
//if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'" + strSelEXPLAN;
}
else
{
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
}
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 实付支资料
if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
else
{
continue;
}
CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
else
{
continue;
}
CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity4.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity4.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity4.FCYDR = 0;//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
CwVouitemsEntity4.ISFCY = false;//是否外币
CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "C";//贷方向
//
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
dlAMTDR += 0;//本位币贷方金额(互斥)
dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() != "RMB")
{
ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
if (strACCID.Trim() == "")
{
strACCID = "1001";
}
else
{
continue;
}
CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
if (strACCNAME.Trim() == "")
{
strACCNAME = "现金";
}
else
{
continue;
}
CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
//
CwVouitemsEntity4.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity4.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity4.FCYDR = 0;//外币借方金额
CwVouitemsEntity4.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity4.ISFCY = true;//是否外币
CwVouitemsEntity4.FCYNO = "USD";//外币编号usd
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "C";//贷方向
//
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
dlAMTDR += 0;//本位币贷方金额(互斥)
dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
}
//CwVouitemsEntity4.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity4.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity4.CORPID = "";//客户(系统)
CwVouitemsEntity4.CUSTOMERNAME = "";//客户(系统)
strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
#endregion
#region 实付支摘要
if (isButtSettlement == true || ISADVANCE.Trim() == "False")
{
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
//if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'" + strSelEXPLAN;
}
else
{
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "' and ACCOUNTUSD='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
}
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
}
}
#endregion
}
}
else
{
continue;
}
n = n + 1;
CwVouitemsEntity4.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
CwVouitemsEntity4.QTYUNIT = "";//数量包装单位
CwVouitemsEntity4.QTYDR = 0;//借方数量
CwVouitemsEntity4.QTYCR = 0;//贷方数量
//
CwVouitemsEntity4.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity4.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity4.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity4.SALE = "";//strSALE;//人员名称
CwVouitemsEntity4.PITEMID = 0;//父级项目编号
CwVouitemsEntity4.ITEMID = "0";//项目编号
CwVouitemsEntity4.FIELD1 = "";//预留字段1
CwVouitemsEntity4.FIELD2 = "";//预留字段2
CwVouitemsEntity4.FIELD3 = "";//预留字段3
CwVouitemsEntity4.FIELD4 = "";//预留字段4
CwVouitemsEntity4.FIELD5 = "";//预留字段5
CwVouitemsEntity4.FIELD6 = "";//预留字段6
CwVouitemsEntity4.FIELD7 = "";//预留字段7
CwVouitemsEntity4.FIELD8 = "";//预留字段8
CwVouitemsEntity4.FIELD9 = "";//预留字段9
CwVouitemsEntity4.FIELD10 = "";//预留字段10
CwVouitemsEntity4.ISSYS = true;//是否手动录入
CwVouitemsEntity4.FSETTLCODE = "";//结算方式
CwVouitemsEntity4.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity4.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity4.BLNO = "";//BILLNOstrBILLNOALL
//if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
//{
// CwVouitemsEntity4.BLNO = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["mblno"].ToString().Trim();//BILLNO
//}
CwVouitemsEntities.Add(CwVouitemsEntity4);
}
//if (CwVouitemsEntity4.FCYNO != null)
//{
// CwVouitemsEntity4.AMTDR = dlAMTDR;//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = dlAMTCR;//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = dlFCYDR;//外币借方金额
// CwVouitemsEntity4.FCYCR = dlFCYCR;//外币贷方金额
// CwVouitemsEntities.Add(CwVouitemsEntity4);
//}
#endregion
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
#region 插入明细表 应收账款、应付账款
for (int i = 0; i < dsVWChFeeSettlementDo.Tables[0].Rows.Count; i++)
{
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity();
//CwVouitemsEntity.GID 唯一编码 newid()
CwVouitemsEntity.ORDNO = strORDNO.Trim();
CwVouitemsEntity.ITEMNO = n;// 行号
CwVouitemsEntity.PACCID = "";//父级科目贷码
CwVouitemsEntity.PROPERTY = 0;//科目属性
CwVouitemsEntity.GRADE = 0;//科目级别
//
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
if (dl != 0)
{
n = n + 1;
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收账款
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
if (dsAR != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim();//应收账款科目贷码
if (dsAR.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR += dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBS += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
//
CwVouitemsEntity.ACCNAME = dsAR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() != "RMB")
{
if (dsARFC != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim();//应收账款外币科目贷码
if (dsARFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币贷方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd
dUSDS += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
//
CwVouitemsEntity.ACCNAME = dsARFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 应收摘要
//
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
//if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付账款
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
if (dsAP != null)
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim();//应付账款科目贷码
}
else
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码
}
if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
strJie += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
strDai += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBF += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True")
{
if (dsAPMBSPENDING == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
}
else
{
CwVouitemsEntity.ACCNAME = dsAPMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
}
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
}
else
{
CwVouitemsEntity.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
}
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() != "RMB")
{
if (dsAPFC != null)
{
if (dsCwDesign.Tables[0].Rows[0]["ISAPTMSFC"].ToString().Trim() == "True")
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim();//应付账款科目贷码
}
else
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款外币科目贷码
}
if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.FCYCR = 0;//外币借方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
strJie += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
strDai += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["hj"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd
dUSDF += Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
//
if (dsCwDesign.Tables[0].Rows[0]["ISAPTMSFC"].ToString().Trim() == "True")
{
if (dsAPTMSFC == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
}
else
{
CwVouitemsEntity.ACCNAME = dsAPTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
}
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
}
else
{
CwVouitemsEntity.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
}
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
#endregion
#region 应付摘要
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strSelEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
//if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
//{
// strSelEXPLAN += " and CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'";
//}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["MBLNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["VOYNO"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim() + "'";
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strSelEXPLAN += " and BS_CUSTOMERNAME = '" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["BS_CUSTOMERNAME"].ToString().Trim() + "'";
}
}
//
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'" + strSelEXPLAN;//BILLNO
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
}
else
{
continue;
}
//CwVouitemsEntity.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["ACCOUNTS_RATE"].ToString().Trim());//汇率
//dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["ACCOUNTS_RATE"].ToString().Trim());//汇率
if (dsVWChFeeSettlementDo.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
CwVouitemsEntity.FCYEXRATE = Decimal.Parse("1.00");//汇率
}
else
{
CwVouitemsEntity.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
}
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity.QTYUNIT = "";//数量包装单位
CwVouitemsEntity.QTYDR = 0;//借方数量
CwVouitemsEntity.QTYCR = 0;//贷方数量
//
CwVouitemsEntity.EXPLAN = strEXPLAN;//摘要,规则生成
//strEXPLANALL = strEXPLAN;
CwVouitemsEntity.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity.SALE = "";//strSALE;//人员名称
CwVouitemsEntity.PITEMID = 0;//父级项目编号
CwVouitemsEntity.ITEMID = "0";//项目编号
CwVouitemsEntity.FIELD1 = "";//预留字段1
CwVouitemsEntity.FIELD2 = "";//预留字段2
CwVouitemsEntity.FIELD3 = "";//预留字段3
CwVouitemsEntity.FIELD4 = "";//预留字段4
CwVouitemsEntity.FIELD5 = "";//预留字段5
CwVouitemsEntity.FIELD6 = "";//预留字段6
CwVouitemsEntity.FIELD7 = "";//预留字段7
CwVouitemsEntity.FIELD8 = "";//预留字段8
CwVouitemsEntity.FIELD9 = "";//预留字段9
CwVouitemsEntity.FIELD10 = "";//预留字段10
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity.ISSYS = true;//是否手动录入
}
CwVouitemsEntity.FSETTLCODE = dsVWChFeeSettlementDo.Tables[0].Rows[i]["SETTLETYPE"].ToString().Trim();//结算方式
CwVouitemsEntity.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity.BLNO = "";//BILLNO
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[i]["mblno"].ToString().Trim();//
}
CwVouitemsEntities.Add(CwVouitemsEntity);
}
#endregion
#region 插入明细表 预收支资料、预付支资料
for (int i = 0; i < dsVWChFeeSettlementDo_Y.Tables[0].Rows.Count; i++)
{
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity();
//CwVouitemsEntity.GID 唯一编码 newid()
CwVouitemsEntity.ORDNO = strORDNO.Trim();
CwVouitemsEntity.ITEMNO = n;// 行号
CwVouitemsEntity.PACCID = "";//父级科目贷码
CwVouitemsEntity.PROPERTY = 0;//科目属性
CwVouitemsEntity.GRADE = 0;//科目级别
//
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
if (dl != 0)
{
n = n + 1;
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 预收支资料
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsDR != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["DR"].ToString().Trim();//应收账款科目贷码
if (dsDR.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBS += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ACCNAME = dsDR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsDRFC != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["DRFC"].ToString().Trim();//应收账款外币科目贷码
if (dsDRFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币贷方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim();//外币编号usd
dUSDS += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ACCNAME = dsDRFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 预收支摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 预付支资料
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsCR != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["CR"].ToString().Trim();//应付账款科目贷码
if (dsCR.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBF += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.ACCNAME = dsCR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsCRFC != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["CRFC"].ToString().Trim();//应付账款外币科目贷码
if (dsCRFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.FCYCR = 0;//外币借方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_CURRENCY"].ToString().Trim();//外币编号usd
dUSDF += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.ACCNAME = dsCRFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
//CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
//CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 预收支摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
}
else
{
continue;
}
CwVouitemsEntity.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["PREPAY_RATE"].ToString().Trim());//汇率
CwVouitemsEntity.QTYUNIT = "";//数量包装单位
CwVouitemsEntity.QTYDR = 0;//借方数量
CwVouitemsEntity.QTYCR = 0;//贷方数量
//
CwVouitemsEntity.EXPLAN = strEXPLAN;//摘要,规则生成
//strEXPLANALL = strEXPLAN;
CwVouitemsEntity.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity.SALE = "";//strSALE;//人员名称
CwVouitemsEntity.PITEMID = 0;//父级项目编号
CwVouitemsEntity.ITEMID = "0";//项目编号
CwVouitemsEntity.FIELD1 = "";//预留字段1
CwVouitemsEntity.FIELD2 = "";//预留字段2
CwVouitemsEntity.FIELD3 = "";//预留字段3
CwVouitemsEntity.FIELD4 = "";//预留字段4
CwVouitemsEntity.FIELD5 = "";//预留字段5
CwVouitemsEntity.FIELD6 = "";//预留字段6
CwVouitemsEntity.FIELD7 = "";//预留字段7
CwVouitemsEntity.FIELD8 = "";//预留字段8
CwVouitemsEntity.FIELD9 = "";//预留字段9
CwVouitemsEntity.FIELD10 = "";//预留字段10
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity.ISSYS = true;//是否手动录入
}
CwVouitemsEntity.FSETTLCODE = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["SETTLETYPE"].ToString().Trim();//结算方式
CwVouitemsEntity.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity.BLNO = "";//BILLNO
//if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
//{
// CwVouitemsEntity.BLNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[0]["mblno"].ToString().Trim();//
//}
//strBILLNOALL = CwVouitemsEntity.BLNO.ToString().Trim();//
CwVouitemsEntities.Add(CwVouitemsEntity);
}
#endregion
///////////////////////////////////////////////////////
//暂时停用
#region 插入明细表 实付支资料 账户合计,收入\成本 生成 全额\差额
//for (int i = 0; i < dsVWChFeeSettlementDo_Z.Tables[0].Rows.Count; i++)
//{
// CwVouitemsEntity CwVouitemsEntity2 = new CwVouitemsEntity();
// //CwVouitemsEntity2.GID 唯一编码 newid()
// CwVouitemsEntity2.ORDNO = strORDNO.Trim();
// CwVouitemsEntity2.ITEMNO = n;// 行号
// CwVouitemsEntity2.PACCID = "";//父级科目贷码
// CwVouitemsEntity2.PROPERTY = 0;//科目属性
// CwVouitemsEntity2.GRADE = 0;//科目级别
// Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());
// if (dl != 0)
// {
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
// {
// #region 实收支资料
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// continue;
// }
// CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// continue;
// }
// CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
// CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
// CwVouitemsEntity2.FCYDR = 0;//外币借方金额
// CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
// strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// //
// CwVouitemsEntity2.ISFCY = false;//是否外币
// CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
// CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity2.DC = "D";//借方向
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "USD")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// continue;
// }
// CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// continue;
// }
// CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity2.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
// CwVouitemsEntity2.AMTCR = 0;//本位币借方金额(互斥)
// CwVouitemsEntity2.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
// CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
// strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// //
// CwVouitemsEntity2.ISFCY = true;//是否外币
// CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
// CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity2.DC = "D";//借方向
// }
// //CwVouitemsEntity2.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
// //CwVouitemsEntity2.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
// CwVouitemsEntity2.CORPID = "";//客户(系统)
// CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
// strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
// #endregion
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
// {
// #region 实付支资料
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// continue;
// }
// CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// continue;
// }
// CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
// CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
// CwVouitemsEntity2.FCYDR = 0;//外币借方金额
// CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
// strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// //
// CwVouitemsEntity2.ISFCY = false;//是否外币
// CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
// CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity2.DC = "C";//贷方向
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "USD")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// continue;
// }
// CwVouitemsEntity2.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// continue;
// }
// CwVouitemsEntity2.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity2.AMTDR = 0;//本位币贷方金额(互斥)
// CwVouitemsEntity2.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
// CwVouitemsEntity2.FCYDR = 0;//外币借方金额
// CwVouitemsEntity2.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
// strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// //
// CwVouitemsEntity2.ISFCY = true;//是否外币
// CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
// CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity2.DC = "C";//贷方向
// }
// //CwVouitemsEntity2.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
// //CwVouitemsEntity2.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
// CwVouitemsEntity2.CORPID = "";//客户(系统)
// CwVouitemsEntity2.CUSTOMERNAME = "";//客户(系统)
// strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
// #endregion
// }
// }
// else
// {
// continue;
// }
// n = n + 1;
// CwVouitemsEntity2.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
// dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
// CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
// CwVouitemsEntity2.QTYDR = 0;//借方数量
// CwVouitemsEntity2.QTYCR = 0;//贷方数量
// //
// //ISRPCLIENTNAME 是否收付客户名称
// //ISRPCOTCODE 是否收付业务编号
// //ISRPETD 是否收付航期
// //ISRPMBLNO 是否收付主提单号
// //ISRPCUSTNO 是否收付委托编号
// //ISRPVESSEL 是否收付船名
// //ISRPVOYNO 是否收付航次
// //string strSelEXPLAN = "";
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["CUSTNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["MBLNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["VESSEL"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["VOYNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim() + "'";
// //}
// //
// sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB=" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + " and ACCOUNTUSD=" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim();// +strSelEXPLAN;//and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'
// DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
// if (ds1 != null)
// {
// //ISCLIENTNAME 是否客户名称
// //ISCUSTNO 是否委托编号
// //ISMBLNO 是否主提单号
// //ISVESSEL 是否船名
// //ISVOYNO 是否航次
// //ISCOTCODE 是否业务编号
// //ISETD 是否航期
// strEXPLAN = "";
// if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
// }
// }
// //
// CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成ALL
// CwVouitemsEntity2.DEPTID = "";//strDEPTID;//部门(系统)
// CwVouitemsEntity2.EMPLID = "";//strEMPLID;//人员(系统)
// CwVouitemsEntity2.SALE = "";//strSALE;//人员名称
// CwVouitemsEntity2.PITEMID = 0;//父级项目编号
// CwVouitemsEntity2.ITEMID = "0";//项目编号
// CwVouitemsEntity2.FIELD1 = "";//预留字段1
// CwVouitemsEntity2.FIELD2 = "";//预留字段2
// CwVouitemsEntity2.FIELD3 = "";//预留字段3
// CwVouitemsEntity2.FIELD4 = "";//预留字段4
// CwVouitemsEntity2.FIELD5 = "";//预留字段5
// CwVouitemsEntity2.FIELD6 = "";//预留字段6
// CwVouitemsEntity2.FIELD7 = "";//预留字段7
// CwVouitemsEntity2.FIELD8 = "";//预留字段8
// CwVouitemsEntity2.FIELD9 = "";//预留字段9
// CwVouitemsEntity2.FIELD10 = "";//预留字段10
// CwVouitemsEntity2.ISSYS = true;//是否手动录入
// CwVouitemsEntity2.FSETTLCODE = "";//结算方式
// CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
// CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
// CwVouitemsEntity2.BLNO = "";//BILLNOstrBILLNOALL
// if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// {
// CwVouitemsEntity2.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[0]["mblno"].ToString().Trim();//BILLNO
// }
// CwVouitemsEntities.Add(CwVouitemsEntity2);
//}
#endregion
#region 插入明细表 实付支资料 现金合计,收入\成本 生成 全额\差额
//CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity();
//Decimal dlAMTDR = 0;//本位币贷方金额(互斥)
//Decimal dlAMTCR = 0;//本位币借方金额(互斥)
//Decimal dlFCYDR = 0;//外币借方金额
//Decimal dlFCYCR = 0;//外币贷方金额
////
//for (int i = 0; i < dsVWChFeeSettlementDo_Z.Tables[0].Rows.Count; i++)
//{
// //CwVouitemsEntity4.GID 唯一编码 newid()
// CwVouitemsEntity4.ORDNO = strORDNO.Trim();
// CwVouitemsEntity4.ITEMNO = n;// 行号
// CwVouitemsEntity4.PACCID = "";//父级科目贷码
// CwVouitemsEntity4.PROPERTY = 0;//科目属性
// CwVouitemsEntity4.GRADE = 0;//科目级别
// Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());
// if (dl != 0)
// {
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
// {
// #region 实收支资料
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity4.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = 0;//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = 0;//外币借方金额
// CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
// CwVouitemsEntity4.ISFCY = false;//是否外币
// CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
// CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity4.DC = "D";//借方向
// //
// strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
// dlAMTCR += 0;//本位币借方金额(互斥)
// dlFCYDR += 0;//外币借方金额
// dlFCYCR += 0;//外币贷方金额
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "USD")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity4.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = 0;//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
// CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
// CwVouitemsEntity4.ISFCY = true;//是否外币
// CwVouitemsEntity4.FCYNO = "USD";//外币编号usd
// CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity4.DC = "D";//借方向
// //
// strJie += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
// dlAMTCR += 0;//本位币借方金额(互斥)
// dlFCYDR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币借方金额
// dlFCYCR += 0;//外币贷方金额
// }
// //CwVouitemsEntity4.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
// //CwVouitemsEntity4.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
// CwVouitemsEntity4.CORPID = "";//客户(系统)
// CwVouitemsEntity4.CUSTOMERNAME = "";//客户(系统)
// strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim();
// #endregion
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
// {
// #region 实付支资料
// if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "RMB")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity4.AMTDR = 0;//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = 0;//外币借方金额
// CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
// CwVouitemsEntity4.ISFCY = false;//是否外币
// CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
// CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity4.DC = "C";//贷方向
// //
// strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// dlAMTDR += 0;//本位币贷方金额(互斥)
// dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
// dlFCYDR += 0;//外币借方金额
// dlFCYCR += 0;//外币贷方金额
// }
// else if (dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_CURRENCY"].ToString().Trim() == "USD")
// {
// ls = "select FINANCESOFTCODE from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCID = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", ls);
// if (strACCID.Trim() == "")
// {
// strACCID = "1001";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCID = strACCID.Trim();//科目贷码
// ls = "select BANKNAME from sys_bank where gid='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() + "'";
// string strACCNAME = T_ALL_DA.GetStrSQL("BANKNAME", ls);
// if (strACCNAME.Trim() == "")
// {
// strACCNAME = "现金";
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.ACCNAME = strACCNAME.Trim();//科目名称
// //
// CwVouitemsEntity4.AMTDR = 0;//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = 0;//外币借方金额
// CwVouitemsEntity4.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
// CwVouitemsEntity4.ISFCY = true;//是否外币
// CwVouitemsEntity4.FCYNO = "USD";//外币编号usd
// CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
// CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
// CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
// CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
// CwVouitemsEntity4.DC = "C";//贷方向
// //
// strDai += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());
// dlAMTDR += 0;//本位币贷方金额(互斥)
// dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
// dlFCYDR += 0;//外币借方金额
// dlFCYCR += Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_MONEY_JE"].ToString().Trim());//外币贷方金额
// }
// //CwVouitemsEntity4.CORPID = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
// //CwVouitemsEntity4.CUSTOMERNAME = dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
// CwVouitemsEntity4.CORPID = "";//客户(系统)
// CwVouitemsEntity4.CUSTOMERNAME = "";//客户(系统)
// strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim();
// #endregion
// }
// }
// else
// {
// continue;
// }
// CwVouitemsEntity4.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
// dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["AHSR_RATE"].ToString().Trim());//汇率
// CwVouitemsEntity4.QTYUNIT = "";//数量包装单位
// CwVouitemsEntity4.QTYDR = 0;//借方数量
// CwVouitemsEntity4.QTYCR = 0;//贷方数量
// //
// //ISRPCLIENTNAME 是否收付客户名称
// //ISRPCOTCODE 是否收付业务编号
// //ISRPETD 是否收付航期
// //ISRPMBLNO 是否收付主提单号
// //ISRPCUSTNO 是否收付委托编号
// //ISRPVESSEL 是否收付船名
// //ISRPVOYNO 是否收付航次
// //string strSelEXPLAN = "";
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and CUSTNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["CUSTNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and MBLNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["MBLNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and VESSEL = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["VESSEL"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and VOYNO = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["VOYNO"].ToString().Trim() + "'";
// //}
// //if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
// //{
// // strSelEXPLAN += " and BILLNO_ACAD = '" + dsVWChFeeSettlementDo.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim() + "'";
// //}
// //
// sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and ACCOUNTRMB=" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() + " and ACCOUNTUSD=" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim();// +strSelEXPLAN;// and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Z.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'
// DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
// if (ds1 != null)
// {
// //ISCLIENTNAME 是否客户名称
// //ISCUSTNO 是否委托编号
// //ISMBLNO 是否主提单号
// //ISVESSEL 是否船名
// //ISVOYNO 是否航次
// //ISCOTCODE 是否业务编号
// //ISETD 是否航期
// strEXPLAN = "";
// if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
// }
// if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
// }
// }
// //
// CwVouitemsEntity4.EXPLAN = strEXPLAN;//摘要,规则生成ALL
// CwVouitemsEntity4.DEPTID = "";//strDEPTID;//部门(系统)
// CwVouitemsEntity4.EMPLID = "";//strEMPLID;//人员(系统)
// CwVouitemsEntity4.SALE = "";//strSALE;//人员名称
// CwVouitemsEntity4.PITEMID = 0;//父级项目编号
// CwVouitemsEntity4.ITEMID = "0";//项目编号
// CwVouitemsEntity4.FIELD1 = "";//预留字段1
// CwVouitemsEntity4.FIELD2 = "";//预留字段2
// CwVouitemsEntity4.FIELD3 = "";//预留字段3
// CwVouitemsEntity4.FIELD4 = "";//预留字段4
// CwVouitemsEntity4.FIELD5 = "";//预留字段5
// CwVouitemsEntity4.FIELD6 = "";//预留字段6
// CwVouitemsEntity4.FIELD7 = "";//预留字段7
// CwVouitemsEntity4.FIELD8 = "";//预留字段8
// CwVouitemsEntity4.FIELD9 = "";//预留字段9
// CwVouitemsEntity4.FIELD10 = "";//预留字段10
// CwVouitemsEntity4.ISSYS = true;//是否手动录入
// CwVouitemsEntity4.FSETTLCODE = "";//结算方式
// CwVouitemsEntity4.FSETTLENO = "";//财务辅助编号
// CwVouitemsEntity4.MODIFIEDUSER = strUserID;//最后一次更新操作人
// CwVouitemsEntity4.BLNO = "";//BILLNOstrBILLNOALL
// if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
// {
// CwVouitemsEntity4.BLNO = dsVWChFeeSettlementDo.Tables[0].Rows[0]["mblno"].ToString().Trim();//BILLNO
// }
//}
//if (CwVouitemsEntity4.FCYNO != null)
//{
// n = n + 1;
// CwVouitemsEntity4.AMTDR = dlAMTDR;//本位币贷方金额(互斥)
// CwVouitemsEntity4.AMTCR = dlAMTCR;//本位币借方金额(互斥)
// CwVouitemsEntity4.FCYDR = dlFCYDR;//外币借方金额
// CwVouitemsEntity4.FCYCR = dlFCYCR;//外币贷方金额
// CwVouitemsEntities.Add(CwVouitemsEntity4);
//}
#endregion
//end
#region 插入明细表 财务费用 生成 全额\差额
CwVouitemsEntity CwVouitemsEntity3 = new CwVouitemsEntity();
dlAMTDR = 0;//本位币贷方金额(互斥)
dlAMTCR = 0;//本位币借方金额(互斥)
dlFCYDR = 0;//外币借方金额
dlFCYCR = 0;//外币贷方金额
//
for (int i = 0; i < dsVWChFeeSettlementDo_Y.Tables[0].Rows.Count; i++)
{
//CwVouitemsEntity3.GID 唯一编码 newid()
CwVouitemsEntity3.ORDNO = strORDNO.Trim();
CwVouitemsEntity3.ITEMNO = n;// 行号
CwVouitemsEntity3.PACCID = "";//父级科目贷码
CwVouitemsEntity3.PROPERTY = 0;//科目属性
CwVouitemsEntity3.GRADE = 0;//科目级别
//
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
if (dl != 0)
{
if (dsEGOL != null)
{
CwVouitemsEntity3.ACCID = dsCwDesign.Tables[0].Rows[0]["EGOL"].ToString().Trim();//汇兑损益/财务费用科目贷码
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收财务费用
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else
{
#region 正常的“财务费用”借贷方。
//CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
//CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
//CwVouitemsEntity3.FCYDR = 0;//外币借方金额
//CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
//CwVouitemsEntity3.DC = "C";//贷方向
////
//strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
//dlAMTDR += 0;//本位币贷方金额(互斥)
//dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
//dlFCYDR += 0;//外币借方金额
//dlFCYCR += 0;//外币贷方金额
#endregion
#region 因为客户要求“财务费用”必须放到借方,因此如果为贷方,则改为负数放到借方。
Decimal dAMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());
dAMTDR = dAMTDR * (-1);
CwVouitemsEntity3.AMTDR = dAMTDR;//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += dAMTDR;
dlAMTDR += dAMTDR;//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
#endregion
}
CwVouitemsEntity3.ISFCY = false;//是否外币
CwVouitemsEntity3.FCYNO = "RMB";//外币编号usd
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else
{
#region 正常的“财务费用”借贷方。
//CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
//CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
//CwVouitemsEntity3.FCYDR = 0;//外币借方金额
//CwVouitemsEntity3.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
//CwVouitemsEntity3.DC = "C";//贷方向
////
//strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
//dlAMTDR += 0;//本位币借方金额(互斥)
//dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
//dlFCYDR += 0;//外币借方金额
//dlFCYCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
#endregion
#region 因为客户要求“财务费用”必须放到借方,因此如果为贷方,则改为负数放到借方。
Decimal dAMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dAMTDR = dAMTDR * (-1);
CwVouitemsEntity3.AMTDR = dAMTDR;//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
Decimal dFCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());
dFCYDR = dFCYDR * (-1);
CwVouitemsEntity3.FCYDR = dFCYDR;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += dAMTDR;
dlAMTDR += dAMTDR;//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += dFCYDR;//外币借方金额
dlFCYCR += 0;//外币贷方金额
#endregion
}
CwVouitemsEntity3.ISFCY = true;//是否外币
CwVouitemsEntity3.FCYNO = "USD";//外币编号usd
}
CwVouitemsEntity3.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity3.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 应收财务费用摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付财务费用
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//借贷相反
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else
{
#region 正常的“财务费用”借贷方。
//CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
//CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
//CwVouitemsEntity3.FCYDR = 0;//外币借方金额
//CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
//CwVouitemsEntity3.DC = "C";//贷方向
////
//strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
//dlAMTDR += 0;//本位币借方金额(互斥)
//dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
//dlFCYDR += 0;//外币借方金额
//dlFCYCR += 0;//外币贷方金额
#endregion
#region 因为客户要求“财务费用”必须放到借方,因此如果为贷方,则改为负数放到借方。
Decimal dAMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());
dAMTDR = dAMTDR*(-1);
CwVouitemsEntity3.AMTDR = dAMTDR;//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += dAMTDR;
dlAMTDR += dAMTDR;//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += 0;//外币借方金额
dlFCYCR += 0;//外币贷方金额
#endregion
}
CwVouitemsEntity3.ISFCY = false;//是否外币
CwVouitemsEntity3.FCYNO = "RMB";//外币编号usd
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsEGOL.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//借贷相反
{
CwVouitemsEntity3.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dlAMTDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币借方金额
dlFCYCR += 0;//外币贷方金额
}
else
{
#region 正常的“财务费用”借贷方。
//CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
//CwVouitemsEntity3.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
//CwVouitemsEntity3.FCYDR = 0;//外币借方金额
//CwVouitemsEntity3.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
//CwVouitemsEntity3.DC = "C";//贷方向
////
//strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
//dlAMTDR += 0;//本位币借方金额(互斥)
//dlAMTCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
//dlFCYDR += 0;//外币借方金额
//dlFCYCR += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());//外币贷方金额
#endregion
#region 因为客户要求“财务费用”必须放到借方,因此如果为贷方,则改为负数放到借方。
Decimal dAMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_HJ"].ToString().Trim());
dAMTDR = dAMTDR * (-1);
CwVouitemsEntity3.AMTDR = dAMTDR;//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = 0;//本位币借方金额(互斥)
Decimal dFCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_MONEY_JE"].ToString().Trim());
dFCYDR = dFCYDR * (-1);
CwVouitemsEntity3.FCYDR = dFCYDR;//外币借方金额
CwVouitemsEntity3.FCYCR = 0;//外币贷方金额
CwVouitemsEntity3.DC = "D";//借方向
//
strJie += dAMTDR;
dlAMTDR += dAMTDR;//本位币贷方金额(互斥)
dlAMTCR += 0;//本位币借方金额(互斥)
dlFCYDR += dFCYDR;//外币借方金额
dlFCYCR += 0;//外币贷方金额
#endregion
}
CwVouitemsEntity3.ISFCY = true;//是否外币
CwVouitemsEntity3.FCYNO = "USD";//外币编号usd
}
CwVouitemsEntity3.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity3.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 应付财务费用摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTOMERNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim();
}
}
}
#endregion
}
CwVouitemsEntity3.ACCNAME = dsEGOL.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity3.ISDEPTACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity3.ISEMPLACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity3.ISCORPACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity3.ISITEMACC = Boolean.Parse(dsEGOL.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else
{
continue;
}
//
CwVouitemsEntity3.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FINANCIAL_RATE"].ToString().Trim());//汇率
CwVouitemsEntity3.QTYUNIT = "";//数量包装单位
CwVouitemsEntity3.QTYDR = 0;//借方数量
CwVouitemsEntity3.QTYCR = 0;//贷方数量
//
CwVouitemsEntity3.EXPLAN = strEXPLAN;//摘要,规则生成ALL
CwVouitemsEntity3.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity3.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity3.SALE = "";//strSALE;//人员名称
CwVouitemsEntity3.PITEMID = 0;//父级项目编号
CwVouitemsEntity3.ITEMID = "0";//项目编号
CwVouitemsEntity3.FIELD1 = "";//预留字段1
CwVouitemsEntity3.FIELD2 = "";//预留字段2
CwVouitemsEntity3.FIELD3 = "";//预留字段3
CwVouitemsEntity3.FIELD4 = "";//预留字段4
CwVouitemsEntity3.FIELD5 = "";//预留字段5
CwVouitemsEntity3.FIELD6 = "";//预留字段6
CwVouitemsEntity3.FIELD7 = "";//预留字段7
CwVouitemsEntity3.FIELD8 = "";//预留字段8
CwVouitemsEntity3.FIELD9 = "";//预留字段9
CwVouitemsEntity3.FIELD10 = "";//预留字段10
CwVouitemsEntity3.ISSYS = true;//是否手动录入
CwVouitemsEntity3.FSETTLCODE = "";//结算方式
CwVouitemsEntity3.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity3.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity3.BLNO = "";//BILLNO strBILLNOALL
//if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
//{
// CwVouitemsEntity3.BLNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["mblno"].ToString().Trim();//BILLNO
//}
}
if (CwVouitemsEntity3.FCYNO != null)
{
n = n + 1;
CwVouitemsEntity3.AMTDR = dlAMTDR;//本位币贷方金额(互斥)
CwVouitemsEntity3.AMTCR = dlAMTCR;//本位币借方金额(互斥)
CwVouitemsEntity3.FCYDR = dlFCYDR;//外币借方金额
CwVouitemsEntity3.FCYCR = dlFCYCR;//外币贷方金额
CwVouitemsEntities.Add(CwVouitemsEntity3);
}
#endregion
#region 插入明细表 预收支取用资料、预付支取用资料
for (int i = 0; i < dsVWChFeeSettlementDo_Y.Tables[0].Rows.Count; i++)
{
CwVouitemsEntity CwVouitemsEntity = new CwVouitemsEntity();
//CwVouitemsEntity.GID 唯一编码 newid()
CwVouitemsEntity.ORDNO = strORDNO.Trim();
CwVouitemsEntity.ITEMNO = n;// 行号
CwVouitemsEntity.PACCID = "";//父级科目贷码
CwVouitemsEntity.PROPERTY = 0;//科目属性
CwVouitemsEntity.GRADE = 0;//科目级别
//
Decimal dl = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
if (dl != 0)
{
n = n + 1;
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 预收支取用资料
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsDR != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["DR"].ToString().Trim();//应收账款科目贷码
if (dsDR.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//取用时与预收的借贷相反
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBS += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ACCNAME = dsDR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsDR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsDRFC != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["DRFC"].ToString().Trim();//应收账款外币科目贷码
if (dsDRFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//取用时与预收的借贷相反
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;//预收支资料_金额
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币贷方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//外币借方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;//预收支资料_金额
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim();//外币编号usd
dUSDS += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币借方金额(互斥)
CwVouitemsEntity.ACCNAME = dsDRFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsDRFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
#endregion
#region 预收支取用摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAR = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAR"].ToString().Trim();
if (sRPEXPLANAR.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《船名》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《航次》") > -1)
{
//sRPEXPLANAR = sRPEXPLANAR.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAR.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAR = sRPEXPLANAR.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAR;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
}
}
#endregion
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 预付支取用资料
if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim() == "RMB")
{
if (dsCR != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["CR"].ToString().Trim();//应付账款科目贷码
if (dsCR.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//取用时与预收的借贷相反
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
dRMBF += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ACCNAME = dsCR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsCR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
else if (dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim() != "RMB")
{
if (dsCRFC != null)
{
CwVouitemsEntity.ACCID = dsCwDesign.Tables[0].Rows[0]["CRFC"].ToString().Trim();//应付账款外币科目贷码
if (dsCRFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "贷")//取用时与预收的借贷相反
{
CwVouitemsEntity.AMTDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.FCYDR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.FCYCR = 0;//外币借方金额
CwVouitemsEntity.DC = "D";//借方向
iAMTDR = iAMTDR + dl;
strJie += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
else
{
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//外币贷方金额
CwVouitemsEntity.DC = "C";//贷方向
iAMTCR = iAMTCR + dl;
strDai += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_HJ"].ToString().Trim());
}
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_CURRENCY"].ToString().Trim();//外币编号usd
dUSDF += Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_MONEY_JE"].ToString().Trim());//本位币贷方金额(互斥)
CwVouitemsEntity.CORPID = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["FARCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
CwVouitemsEntity.ACCNAME = dsCRFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISCORPACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(dsCRFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
}
else
{
continue;
}
}
#endregion
#region 预付支取用摘要
sSQL = "select top 1 * from VW_ch_fee_settlement_do where gid_s in(" + sGids.Trim() + ") and CUSTOMERNAME='" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "' and ACCOUNTS_MONEY=" + dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ACCOUNTS_MONEY_JE"].ToString().Trim();// +strSelEXPLAN;
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
strEXPLAN = "";
if (dsCwDesign.Tables[0].Rows[0]["ISRPEXPLANMODEL"].ToString().Trim() == "True")
{
string sRPEXPLANAP = dsCwDesign.Tables[0].Rows[0]["RPEXPLANAP"].ToString().Trim();
if (sRPEXPLANAP.IndexOf("《结算单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《结算单位》", ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托编号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《委托编号》", ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《主提单号》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《主提单号》", ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《船名》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《船名》", ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《航次》") > -1)
{
//sRPEXPLANAP = sRPEXPLANAP.Replace("《航次》", ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《申请单号》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《申请单号》", ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim());
}
if (sRPEXPLANAP.IndexOf("《委托单位》") > -1)
{
sRPEXPLANAP = sRPEXPLANAP.Replace("《委托单位》", ds1.Tables[0].Rows[0]["BS_CUSTOMERNAME"].ToString().Trim());
}
strEXPLAN = sRPEXPLANAP;
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True")
{
//strEXPLAN += " " + ds1.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True")
{
strEXPLAN += " 申请单号:" + ds1.Tables[0].Rows[0]["BILLNO_ACAD"].ToString().Trim();
}
}
}
#endregion
}
}
else
{
continue;
}
CwVouitemsEntity.FCYEXRATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_RATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["ADVANCE_RATE"].ToString().Trim());//汇率
CwVouitemsEntity.QTYUNIT = "";//数量包装单位
CwVouitemsEntity.QTYDR = 0;//借方数量
CwVouitemsEntity.QTYCR = 0;//贷方数量
//
CwVouitemsEntity.EXPLAN = strEXPLAN;//摘要,规则生成
//strEXPLANALL = strEXPLAN;
CwVouitemsEntity.DEPTID = "";//strDEPTID;//部门(系统)
CwVouitemsEntity.EMPLID = "";//strEMPLID;//人员(系统)
CwVouitemsEntity.SALE = "";//strSALE;//人员名称
CwVouitemsEntity.PITEMID = 0;//父级项目编号
CwVouitemsEntity.ITEMID = "0";//项目编号
CwVouitemsEntity.FIELD1 = "";//预留字段1
CwVouitemsEntity.FIELD2 = "";//预留字段2
CwVouitemsEntity.FIELD3 = "";//预留字段3
CwVouitemsEntity.FIELD4 = "";//预留字段4
CwVouitemsEntity.FIELD5 = "";//预留字段5
CwVouitemsEntity.FIELD6 = "";//预留字段6
CwVouitemsEntity.FIELD7 = "";//预留字段7
CwVouitemsEntity.FIELD8 = "";//预留字段8
CwVouitemsEntity.FIELD9 = "";//预留字段9
CwVouitemsEntity.FIELD10 = "";//预留字段10
if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity.ISSYS = true;//是否手动录入
}
CwVouitemsEntity.FSETTLCODE = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["SETTLETYPE"].ToString().Trim();//结算方式
CwVouitemsEntity.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity.MODIFIEDUSER = Session["USERID"].ToString().Trim();//最后一次更新操作人
CwVouitemsEntity.BLNO = "";//BILLNO
//if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True")
//{
// CwVouitemsEntity.BLNO = dsVWChFeeSettlementDo_Y.Tables[0].Rows[i]["mblno"].ToString().Trim();//
//}
//strBILLNOALL = CwVouitemsEntity.BLNO.ToString().Trim();//
CwVouitemsEntities.Add(CwVouitemsEntity);
}
#endregion
///////////////////////////////////////////////////////
#region 插入主表
string rq = sVOUDATE.Trim();
CwVouchersEntity CwVouchersEntity = new CwVouchersEntity();
CwVouchersEntity.ORDNO = strORDNO.Trim();//唯一编码 newid() varchar (36)
CwVouchersEntity.VOUDATE = DateTime.Parse(rq.Trim());//凭证日期="";//datetime="";//
CwVouchersEntity.ACCYEAR = rq.Trim().Substring(0, 4);//年="";//int="";//
int iM1 = rq.Trim().IndexOf("-") + 1;
int iM2 = rq.Trim().LastIndexOf("-");
string strACCMONTH = "";
if (iM2 - iM1 == 1)
{
strACCMONTH = "0" + rq.Trim().Substring(iM1, iM2 - iM1);
}
else
{
strACCMONTH = rq.Trim().Substring(iM1, iM2 - iM1);
}
string strVOUNO = "";
strVOUNO = getVOUNO(dsCwDesign, rq.Trim().Substring(0, 4), strACCMONTH);
CwVouchersEntity.VOUNO = strVOUNO;//月初清零 varchar (16)
CwVouchersEntity.ACCMONTH = strACCMONTH;//月="";//int="";//
string strVOUALLNO = rq.Trim().Substring(0, 4) + strACCMONTH + strVOUNO;
CwVouchersEntity.VOUALLNO = strVOUALLNO;//月初清零 varchar (16)
CwVouchersEntity.VKNO = strBPVW.Trim();//凭证字="";//varchar="";//(8)
CwVouchersEntity.ATTACHS = int.Parse(dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//附件(单据)数="";//int="";//
CwVouchersEntity.AMTDR = strJie;// iAMTDR;//本位币借方="";//numeric(18, 2)="";//
CwVouchersEntity.AMTCR = strDai;//iAMTDR;// iAMTCR;//本位币贷方="";//numeric(18, 2)="";//
CwVouchersEntity.FCY = "";//是否含有外币科目="";//varchar="";//(1)
CwVouchersEntity.QTY = "";//是否含有数量科目="";//varchar="";//(1)
CwVouchersEntity.VOUPROP = "";//凭证属性="";//varchar="";//(1)
//CwVouchersEntity.PREPARED = T_ALL_DA.GetStrSQL("FINANCESOFTCODE", "select top 1 FINANCESOFTCODE from user_baseinfo where USERID in (select top 1 gid from [user] where SHOWNAME='" + this.hd_comboPREPARED.Value.Trim() + "' and ISDELETED=0)");//制单人="";//varchar="";//(10)
CwVouchersEntity.PREPARED = sPREPARED;//制单人="";//varchar="";//(10)
CwVouchersEntity.CHECKED = "";//审核人="";//varchar="";//(10)
CwVouchersEntity.ENTERED = "";//记账人="";//varchar="";//(10)
CwVouchersEntity.ERRMSG = "";//错误信息="";//varchar="";//(6)
CwVouchersEntity.ISDELETE = false;//是否废除="";//bit="";//Y
CwVouchersEntity.DELETEUSER = "";//废除操作人="";//Varchar(36)="";//Y
//CwVouchersEntity.DELETETIME="";//废除时间="";//Datetime="";//Y
#endregion
//生成入库
string strSel = " and gid_s in(" + sGids + ") " + strVESSEL;
iResult = CwVouchersDA.setInsertAll(CwVouchersEntity, CwVouitemsEntities, "VW_ch_fee_settlement_do", strVOUALLNO, strSel, Session["USERID"].ToString().Trim(), 2);
}
else
{
return -1;
}
return iResult;
}
#region 凭证号生成
///
/// 凭证号不补漏,顺序生成
///
///
///
///
protected String getVOUNO2(DataSet dsCwDesign, string strY, string strM)
{
string sVOUNO = "";
string strVOUNO = "select top 1 VOUNO from cw_vouchers where ACCYEAR='" + strY + "' and ACCMONTH='" + strM + "' order by convert(decimal(10),VOUNO) desc";
strVOUNO = T_ALL_DA.GetStrSQL("VOUNO", strVOUNO);
if (strVOUNO.Trim() == "")
{
strVOUNO = "0001";
}
else
{
sVOUNO = (int.Parse(strVOUNO) + 1).ToString().Trim();
strVOUNO = sVOUNO;
for (int i = 0; i < 4 - sVOUNO.Length;i++)
{
strVOUNO = "0" + strVOUNO;
}
}
return strVOUNO;
}
///
/// 凭证号补漏生成
///
///
///
///
protected String getVOUNO(DataSet dsCwDesign, string strY, string strM)
{
string sVOUNO = "";
string strVOUNO = "select top 1 VOUNO from cw_vouchers where ACCYEAR='" + strY + "' and ACCMONTH='" + strM + "' and (ISDELETE=0 or ISDELETE is null) order by convert(decimal(10),VOUNO) desc";
strVOUNO = T_ALL_DA.GetStrSQL("VOUNO", strVOUNO);
if (strVOUNO.Trim() == "")
{
strVOUNO = "0001";
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='凭证号' and RULETYPE=5");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["RULENOSTART"].ToString().Trim() != "")
{
strVOUNO = ds.Tables[0].Rows[0]["RULENOSTART"].ToString().Trim();
}
}
}
}
else
{
if (dsCwDesign.Tables[0].Rows[0]["ISFILLSERIALNO"].ToString().Trim() == "True")
{
string strFILL = "select top 1 serialno from code_fill_serialno where ISDELETE=0 and tablename='cw_vouchers' and serialno like '%" + strY + strM + "%' and serialno not in (select VOUALLNO from cw_vouchers where (ISDELETE=0 or ISDELETE is null)) order by serialno";
strFILL = T_ALL_DA.GetStrSQL("serialno", strFILL);
if (strFILL.Trim() != "")
{
strVOUNO = strFILL.Trim().Substring(strFILL.Length - 4);
//strVOUNO = strFILL.Trim().Substring(6);
return strVOUNO;
}
}
sVOUNO = (int.Parse(strVOUNO) + 1).ToString().Trim();
strVOUNO = sVOUNO;
for (int i = 0; i < 4 - sVOUNO.Length; i++)
{
strVOUNO = "0" + strVOUNO;
}
}
return strVOUNO;
}
#endregion
//
}
}