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

1701 lines
120 KiB
C#

3 years ago
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 CwVouchersAdding : System.Web.UI.Page
{
public string strHandle = "";
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["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
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 VALUE from currency_exchange where COMPANYID='" + strCompanyID + "' and ISDELETE=0 and [type]='common'");
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initcomboPREPARED();</script>");
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "VOU" + strBSNO;
return strBSNO;
}
protected void btnEnter_Click(object sender, EventArgs e)
{
string strEXPLAN = "";
string sSQL = "";
int iResult = 0;
string zt = "";
if (cbISRATE.Checked == false && tbRATE.Text.Trim() == "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('如果不“按照系统录入汇率”计算,则“凭证美元汇率”不允许为空!');</script>");
return;
}
//
if (strGIDS.Trim() != "")
{
//帐套设置
sSQL = "SELECT top 1 * from cw_design";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds == null)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('请先设置帐套信息!');</script>");
return;
}
//
string sGids = strGIDS.Trim().Replace(",", "','");
sGids = "'" + sGids.Trim() + "'";
//根据船名航次生成凭证
//if (ds.Tables[0].Rows[0]["ISATTNOTCVVGV"].ToString().Trim() == "True")
//{
// //不同的船名航次分开判断
// sSQL = "select VESSEL,VOYN from "+strHandle+" where bsno in(" + sGids + ") group by VESSEL,VOYNO";
// DataSet ds4 = T_ALL_DA.GetAllSQL(sSQL);
// if (ds4 != null)
// {
// for (int i = 0; i < ds4.Tables[0].Rows.Count; i++)
// {
// //ISVESSEL 是否船名
// //ISVOYNO 是否航次
// if (ds.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds4.Tables[0].Rows[i]["VESSEL"].ToString().Trim();
// }
// if (ds.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
// {
// strEXPLAN += " " + ds4.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
// }
// strVESSEL = " and VESSEL='" + ds4.Tables[0].Rows[i]["VESSEL"].ToString().Trim() + "' and VOYNO='" + ds4.Tables[0].Rows[0]["VOYNO"].ToString().Trim() + "'";
// iResult = getSC(ds, sGids, strVESSEL, strEXPLAN);
// zt += "," + iResult;
// }
// }
//}
//else
//{
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet ds2 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
DataSet ds3 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'";
DataSet ds6 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
DataSet ds7 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 收入RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() + "'";
DataSet ds8 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 支出RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "'";
DataSet ds9 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 收入USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["TMFCI"].ToString().Trim() + "'";
DataSet ds10 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 支出USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "'";
DataSet ds11 = T_ALL_DA.GetAllSQL(sSQL);
string[] items = sGids.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (items.Length > 0)
{
for (int i = 0; i < items.Length; i++)
{
strEXPLAN = "";
sSQL = "select *";
sSQL += ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=" + strHandle + ".CUSTOMERNAME)";
sSQL += ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=" + strHandle + ".CUSTOMERNAME)";
sSQL += ", DEPTID=(select top 1 FINANCESOFTCODE from sys_dept where DEPTNAME="+strHandle+".SALEDEPT and LINKID='" + strCompanyID + "')";
sSQL += ", EMPLID=(select top 1 FINANCESOFTCODE from user_baseinfo where USERID in (select gid from [user] where ISDELETED=0 and SHOWNAME="+strHandle+".SALE) and COMPANYNAME=(select [NAME] from [company] where GID='" + strCompanyID + "'))";
sSQL += " from "+strHandle+" where bsno in(" + items[i].ToString().Trim() + ")";
DataSet ds5 = T_ALL_DA.GetAllSQL(sSQL);
if (ds5 != null)
{
//ISCLIENTNAME 是否客户名称
//ISCUSTNO 是否委托编号
//ISMBLNO 是否主提单号
//ISVESSEL 是否船名
//ISVOYNO 是否航次
//ISCOTCODE 是否业务编号
//ISETD 是否航期
if (ds.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds5.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
}
if (ds.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds5.Tables[0].Rows[0]["CUSTNO"].ToString().Trim();
}
if (ds.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds5.Tables[0].Rows[0]["MBLNO"].ToString().Trim();
}
if (ds.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds5.Tables[0].Rows[0]["VESSEL"].ToString().Trim();
}
if (ds.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
{
strEXPLAN += " " + ds5.Tables[0].Rows[0]["VOYNO"].ToString().Trim();
}
iResult = getSC(ds, items[i].ToString().Trim(), "", strEXPLAN, ds5.Tables[0].Rows[0]["DEPTID"].ToString().Trim(), ds5.Tables[0].Rows[0]["EMPLID"].ToString().Trim(), ds5.Tables[0].Rows[0]["SALE"].ToString().Trim(), ds5.Tables[0].Rows[0]["MBLNO"].ToString().Trim());
}
zt += "," + iResult;
}
}
//}
//
if (zt.IndexOf("-") > 0)
{
Response.Write("<script>alert('部分凭证生成出错!');history.back();</script>");
}
else
{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('生成凭证成功!');window.opener.location.reload();window.close();history.back();</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('生成凭证成功!'); parentWin = window.parent.opener._this;parentWin.onDsQuery() </script>");
}
}
}
/// <summary>
/// 生成凭证
/// </summary>
/// <param name="ds">帐套设置数据集</param>
/// <param name="sGids">BSNO业务编号</param>
/// <param name="strVESSEL">船名航次</param>
/// <param name="strEXPLAN">规则生成的摘要</param>
/// <returns></returns>
protected int getSC(DataSet ds, string sGids, string strVESSEL, string strEXPLAN, string strDEPTID, string strEMPLID, string strSALE,string strBLNO)
{
#region 基本设置
string sSQL = "";
Decimal iAMTDR = 0;
Decimal iAMTCR = 0;
int iResult = 0;
//差额主营业务收入
Decimal dRMBS = 0;
Decimal dRMBF = 0;
Decimal dUSDS = 0;
Decimal dUSDF = 0;
int n = 0;
Decimal usdRATES = 0;
Decimal usdRATEF = 0;
//Decimal dEXCHANGERATE =0;
//其他常用科目设置 应收RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet ds2 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
DataSet ds3 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应收USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'";
DataSet ds6 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 应付USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'";
DataSet ds7 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 收入RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() + "'";
DataSet ds8 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 支出RMB
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "'";
DataSet ds9 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 收入USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["TMFCI"].ToString().Trim() + "'";
DataSet ds10 = T_ALL_DA.GetAllSQL(sSQL);
//其他常用科目设置 支出USD
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "'";
DataSet ds11 = T_ALL_DA.GetAllSQL(sSQL);
#endregion
#region 摘要
//ISRPCLIENTNAME 是否收付客户名称
//ISRPCOTCODE 是否收付业务编号
//ISRPETD 是否收付航期
//ISRPMBLNO 是否收付主提单号
//ISRPCUSTNO 是否收付委托编号
//ISRPVESSEL 是否收付船名
//ISRPVOYNO 是否收付航次
string strISEXPLAN = "";
//if (ds.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True")
//{
// strISEXPLAN += " " + ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
//}
if (ds.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",CUSTNO";
}
if (ds.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",MBLNO";
}
if (ds.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True")
{
strISEXPLAN += ",VESSEL";
}
if (ds.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True")
{
strISEXPLAN += ",VOYNO";
}
#endregion
if (strHandle.Trim() == "op_seae" || strHandle.Trim() == "op_seai" || strHandle.Trim() == "op_aire" || strHandle.Trim() == "op_airi" || strHandle.Trim() == "op_other" || strHandle.Trim() == "v_op_bill")
{
string strORDNO = getBSNO();
CwVouchersDA CwVouchersDA = new CwVouchersDA();
IList<CwVouitemsEntity> CwVouitemsEntities = new List<CwVouitemsEntity>();
#region 基本语句
//
//(CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as 类型
//,CUSTOMERNAME 客户名称
//,EXCHANGERATE 汇率
//,CURRENCY 币别`
//,ISADVANCEDPAY 是否垫付
//,SUM(AMOUNT) AS 金额
//,SUM(AMOUNT*EXCHANGERATE) AS 合计金额
if (cbISRATE.Checked == true)
{
if (ds.Tables[0].Rows[0]["AR"].ToString().Trim() == ds.Tables[0].Rows[0]["ARFC"].ToString().Trim())
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE";
sSQL += ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ",CUSTOMERNAME,1 EXCHANGERATE,'RMB' CURRENCY,ISADVANCEDPAY,SUM(AMOUNT*EXCHANGERATE) AS je,SUM(AMOUNT*EXCHANGERATE) AS hj " + strISEXPLAN;
sSQL += " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from " + strHandle + " where bsno in(" + sGids.Trim() + ") " + strVESSEL + ")";
sSQL += " GROUP BY FEETYPE,CUSTOMERNAME,ISADVANCEDPAY" + strISEXPLAN;
sSQL += " ORDER BY FEETYPE desc,CUSTOMERNAME" + strISEXPLAN;
}
else
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE";
sSQL += ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ",CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY,SUM(AMOUNT) AS je,SUM(AMOUNT*EXCHANGERATE) AS hj " + strISEXPLAN;
sSQL += " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from " + strHandle + " where bsno in(" + sGids.Trim() + ") " + strVESSEL + ")";
sSQL += " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY" + strISEXPLAN;
sSQL += " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME" + strISEXPLAN;
}
}
else
{
sSQL = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' ELSE '应付账款' END) as FEETYPE";
sSQL += ", FAPCODE=(select top 1 FAPCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ", FARCODE=(select top 1 FARCODE from info_client where SHORTNAME=VW_ch_fee_op.CUSTOMERNAME)";
sSQL += ",CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY,SUM(AMOUNT) AS je,SUM(AMOUNT*" + tbRATE.Text.Trim() + ") AS hj " + strISEXPLAN;
sSQL += " From VW_ch_fee_op WHERE 1=1 and bsno in (select BSNO from " + strHandle + " where bsno in(" + sGids.Trim() + ") " + strVESSEL + ")";
sSQL += " GROUP BY FEETYPE,CUSTOMERNAME,EXCHANGERATE,CURRENCY,ISADVANCEDPAY" + strISEXPLAN;
sSQL += " ORDER BY FEETYPE desc,CURRENCY,CUSTOMERNAME" + strISEXPLAN;
}
#endregion
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
#region 应收、应付账款
for (int i = 0; i < ds1.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 (ds1.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收账款
iAMTDR = iAMTDR + Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()),2, MidpointRounding.AwayFromZero);
//
if (ds1.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
#region RMB
CwVouitemsEntity.ACCID = ds.Tables[0].Rows[0]["AR"].ToString().Trim();//应收账款科目贷码
CwVouitemsEntity.AMTDR = Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()),2, MidpointRounding.AwayFromZero);//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
dRMBS += Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()), 2, MidpointRounding.AwayFromZero);//本位币借方金额(互斥)
if (ds2 == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.ACCNAME = ds2.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(ds2.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds2.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
#endregion
}
else if (ds1.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() != "RMB")
{
#region 外币
CwVouitemsEntity.ACCID = ds.Tables[0].Rows[0]["ARFC"].ToString().Trim();//应收账款外币科目贷码
CwVouitemsEntity.AMTDR = Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()),2, MidpointRounding.AwayFromZero);//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = "USD";//外币编号usd
CwVouitemsEntity.FCYDR = Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
dUSDS += Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim());//本位币借方金额(互斥)
if (ds6 == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.ACCNAME = ds6.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(ds6.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds6.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
usdRATES = Decimal.Parse(ds1.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
#endregion
}
if (ds2.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
{
CwVouitemsEntity.CORPID = ds1.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = ds1.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
}
else {
CwVouitemsEntity.CORPID ="";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME ="";//客户(系统)
}
#endregion
}
else if (ds1.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付账款
iAMTCR = iAMTCR + Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()),2, MidpointRounding.AwayFromZero);
//
if (ds1.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB")
{
#region RMB
CwVouitemsEntity.ACCID = ds.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim()),2, MidpointRounding.AwayFromZero);//本位币贷方金额(互斥)
CwVouitemsEntity.ISFCY = false;//是否外币
CwVouitemsEntity.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = 0;//外币贷方金额
dRMBF += Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim()), 2, MidpointRounding.AwayFromZero);//本位币贷方金额(互斥)
if (ds3 == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "C";//贷方向
}
else
{
CwVouitemsEntity.ACCNAME = ds3.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(ds3.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds3.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
#endregion
}
else if (ds1.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() != "RMB")
{
#region 外币
CwVouitemsEntity.ACCID = ds.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款外币科目贷码
CwVouitemsEntity.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity.AMTCR = Math.Round(Decimal.Parse(ds1.Tables[0].Rows[i]["hj"].ToString().Trim()),2, MidpointRounding.AwayFromZero);//本位币贷方金额(互斥)
CwVouitemsEntity.ISFCY = true;//是否外币
CwVouitemsEntity.FCYNO = "USD";//外币编号usd
CwVouitemsEntity.FCYDR = 0;//外币借方金额
CwVouitemsEntity.FCYCR = Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额
dUSDF += Decimal.Parse(ds1.Tables[0].Rows[i]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (ds7 == null)
{
CwVouitemsEntity.ACCNAME = "";//科目名称
CwVouitemsEntity.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity.DC = "C";//贷方向
}
else
{
CwVouitemsEntity.ACCNAME = ds7.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity.ISDEPTACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity.ISEMPLACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity.ISCORPACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity.ISITEMACC = Boolean.Parse(ds7.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds7.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity.DC = "D";//借方向
}
else
{
CwVouitemsEntity.DC = "C";//贷方向
}
}
usdRATEF = Decimal.Parse(ds1.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
#endregion
}
if (ds3.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
{
CwVouitemsEntity.CORPID = ds1.Tables[0].Rows[i]["FAPCODE"].ToString().Trim();//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = ds1.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统)
}
else
{
CwVouitemsEntity.CORPID = "";//客户(系统)
CwVouitemsEntity.CUSTOMERNAME = "";//客户(系统)
}
#endregion
}
CwVouitemsEntity.FCYEXRATE = Decimal.Parse(ds1.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity.QTYUNIT = "";//数量包装单位
CwVouitemsEntity.QTYDR = 0;//借方数量
CwVouitemsEntity.QTYCR = 0;//贷方数量
CwVouitemsEntity.EXPLAN = strEXPLAN +" "+ ds1.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//摘要,规则生成 "转运费" +
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 (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity.ISSYS = true;//是否手动录入
}
CwVouitemsEntity.FSETTLCODE = "";//结算方式
CwVouitemsEntity.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity.BLNO = strBLNO;//
if (strBLNO.Trim() == "")
{
if (ds.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity.BLNO = ds1.Tables[0].Rows[i]["mblno"].ToString().Trim();//
}
}
CwVouitemsEntities.Add(CwVouitemsEntity);
}
#endregion
#region 收入\成本 生成 全额\差额
Decimal dRMB = dRMBS - dRMBF;
Decimal dUSD = dUSDS - dUSDF;
//收入\成本 生成 全额\差额
Decimal strJie = dRMBS + Math.Round(dUSDS * usdRATES, 2, MidpointRounding.AwayFromZero);
Decimal strDai = dRMBF + Math.Round(dUSDF * usdRATEF,2, MidpointRounding.AwayFromZero);
if (ds.Tables[0].Rows[0]["ISTCOIIED"].ToString().Trim() == "True")//是否核算外币
{
if (ds.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "1")//全额
{
//for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
//{
#region 全额
/*
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 (ds1.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应收账款")
{
#region 应收账款
//iAMTDR = iAMTDR + Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());
//
if (ds1.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "RMB")
{
#region RMB
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity2.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币贷方金额(互斥)
strDai = strDai + Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
//dRMBS += Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币借方金额(互斥)
if (ds8 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
#endregion
}
else if (ds1.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() != "RMB")
{
#region 外币
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["TMFCI"].ToString().Trim();//主营收入外币科目贷码
CwVouitemsEntity2.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.AMTCR = Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());//本位币贷方金额(互斥)
strDai = strDai + Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
//dUSDS += Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币借方金额(互斥)
if (ds10 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds10.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds10.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
#endregion
}
#endregion
}
else if (ds1.Tables[0].Rows[j]["FEETYPE"].ToString().Trim() == "应付账款")
{
#region 应付账款
//iAMTCR = iAMTCR + Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());
//
if (ds1.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() == "RMB")
{
#region RMB
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码
CwVouitemsEntity2.AMTDR = Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());
CwVouitemsEntity2.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
//dRMBF += Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (ds9 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds9.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds9.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
#endregion
}
else if (ds1.Tables[0].Rows[j]["CURRENCY"].ToString().Trim() != "RMB")
{
#region 外币
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["TMSFC"].ToString().Trim();//主营支出外币科目贷码
CwVouitemsEntity2.AMTDR = Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());//本位币借方金额(互斥)
strJie = strJie + Decimal.Parse(ds1.Tables[0].Rows[j]["hj"].ToString().Trim());
CwVouitemsEntity2.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//外币贷方金额
//dUSDF += Decimal.Parse(ds1.Tables[0].Rows[j]["je"].ToString().Trim());//本位币贷方金额(互斥)
if (ds11 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds11.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds11.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds11.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds11.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds11.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds11.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
#endregion
}
#endregion
}
CwVouitemsEntity2.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity2.FCYEXRATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity2.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity2.ISSYS = true;//是否手动录入
}
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = strBLNO;//
if (strBLNO.Trim() == "")
{
if (ds.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True")
{
CwVouitemsEntity2.BLNO = ds1.Tables[0].Rows[j]["mblno"].ToString().Trim();//
}
}
CwVouitemsEntities.Add(CwVouitemsEntity2);
*/
#endregion
//}
#region 全额
Decimal dlSR = dRMBS;
if (dlSR != 0)
{
#region 收入RMB
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;//科目级别
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity2.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.AMTCR = dRMBS;//本位币贷方金额(互斥)
strDai = strDai + dRMBS;
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
if (ds8 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
CwVouitemsEntity2.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity2.FCYEXRATE = 1;//汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity2.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity2.ISSYS = true;//是否手动录入
}
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
dlSR = dUSDS * usdRATES;
if (dlSR != 0)
{
#region 收入USD
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;//科目级别
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity2.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity2.AMTCR = (dUSDS * usdRATES);//本位币贷方金额(互斥)
strDai = strDai + (dUSDS * usdRATES);
CwVouitemsEntity2.ISFCY = true;//是否外币
CwVouitemsEntity2.FCYNO = "USD";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = dUSDS;//外币贷方金额
CwVouitemsEntity2.FCYEXRATE = usdRATES;//汇率
if (ds8 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
CwVouitemsEntity2.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity2.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity2.ISSYS = true;//是否手动录入
}
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
Decimal dlZC = dRMBF;
if (dlZC != 0)
{
#region 支出RMB
n = n + 1;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity();
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4.ORDNO = strORDNO.Trim();
CwVouitemsEntity4.ITEMNO = n;// 行号
CwVouitemsEntity4.PACCID = "";//父级科目贷码
CwVouitemsEntity4.PROPERTY = 0;//科目属性
CwVouitemsEntity4.GRADE = 0;//科目级别
CwVouitemsEntity4.ACCID = ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码
CwVouitemsEntity4.AMTDR = dRMBF;//本位币借方金额(互斥)
strJie = strJie + dRMBF;
CwVouitemsEntity4.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity4.ISFCY = false;//是否外币
CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity4.FCYDR = 0;//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
if (ds9 == null)
{
CwVouitemsEntity4.ACCNAME = "";//科目名称
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.ACCNAME = ds9.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity4.ISDEPTACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds9.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.DC = "C";//贷方向
}
}
CwVouitemsEntity4.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity4.FCYEXRATE = 1;//汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4.QTYUNIT = "";//数量包装单位
CwVouitemsEntity4.QTYDR = 0;//借方数量
CwVouitemsEntity4.QTYCR = 0;//贷方数量
CwVouitemsEntity4.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity4.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity4.ISSYS = true;//是否手动录入
}
CwVouitemsEntity4.FSETTLCODE = "";//结算方式
CwVouitemsEntity4.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity4.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity4.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity4);
}
dlZC = dUSDF * usdRATEF;
if (dlZC != 0)
{
#region 支出USD
n = n + 1;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity();
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4.ORDNO = strORDNO.Trim();
CwVouitemsEntity4.ITEMNO = n;// 行号
CwVouitemsEntity4.PACCID = "";//父级科目贷码
CwVouitemsEntity4.PROPERTY = 0;//科目属性
CwVouitemsEntity4.GRADE = 0;//科目级别
CwVouitemsEntity4.ACCID = ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码
CwVouitemsEntity4.AMTDR = (dUSDF * usdRATEF);//本位币借方金额(互斥)
strJie = strJie + (dUSDF * usdRATEF);
CwVouitemsEntity4.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity4.ISFCY = true;//是否外币
CwVouitemsEntity4.FCYNO = "USD";//外币编号usd
CwVouitemsEntity4.FCYDR = dUSDF;//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
CwVouitemsEntity4.FCYEXRATE = usdRATEF;//汇率
if (ds9 == null)
{
CwVouitemsEntity4.ACCNAME = "";//科目名称
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.ACCNAME = ds9.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity4.ISDEPTACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds9.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.DC = "C";//贷方向
}
}
CwVouitemsEntity4.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4.QTYUNIT = "";//数量包装单位
CwVouitemsEntity4.QTYDR = 0;//借方数量
CwVouitemsEntity4.QTYCR = 0;//贷方数量
CwVouitemsEntity4.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity4.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity4.ISSYS = true;//是否手动录入
}
CwVouitemsEntity4.FSETTLCODE = "";//结算方式
CwVouitemsEntity4.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity4.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity4.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity4);
}
#endregion
}
else if (ds.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "2")//差额
{
#region 差额
if (dRMB != 0)
{
#region dRMB != 0
CwVouitemsEntity CwVouitemsEntity1 = new CwVouitemsEntity();
//CwVouitemsEntity1.GID 唯一编码 newid()
CwVouitemsEntity1.ORDNO = strORDNO.Trim();
n = n + 1;
CwVouitemsEntity1.ITEMNO = n;// 行号
CwVouitemsEntity1.PACCID = "";//父级科目贷码
CwVouitemsEntity1.PROPERTY = 0;//科目属性
CwVouitemsEntity1.GRADE = 0;//科目级别
CwVouitemsEntity1.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity1.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity1.AMTCR = Decimal.Parse(dRMB.ToString().Trim());//本位币贷方金额(互斥)
strDai = strDai + Decimal.Parse(dRMB.ToString().Trim());
CwVouitemsEntity1.ISFCY = false;//是否外币
CwVouitemsEntity1.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity1.FCYDR = 0;//外币借方金额
CwVouitemsEntity1.FCYCR = 0;//外币贷方金额
if (ds8 == null)
{
CwVouitemsEntity1.ACCNAME = "";//科目名称
CwVouitemsEntity1.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity1.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity1.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity1.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity1.DC = "C";//贷方向
}
else
{
CwVouitemsEntity1.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity1.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity1.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity1.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity1.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity1.DC = "D";//借方向
}
else
{
CwVouitemsEntity1.DC = "C";//贷方向
}
}
CwVouitemsEntity1.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity1.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity1.FCYEXRATE = 1;//汇率
CwVouitemsEntity1.QTYUNIT = "";//数量包装单位
CwVouitemsEntity1.QTYDR = 0;//借方数量
CwVouitemsEntity1.QTYCR = 0;//贷方数量
CwVouitemsEntity1.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
CwVouitemsEntity1.DEPTID = strDEPTID;//部门(系统)
CwVouitemsEntity1.EMPLID = strEMPLID;//人员(系统)
CwVouitemsEntity1.SALE = strSALE;//人员名称
CwVouitemsEntity1.PITEMID = 0;//父级项目编号
CwVouitemsEntity1.ITEMID = "0";//项目编号
CwVouitemsEntity1.FIELD1 = "";//预留字段1
CwVouitemsEntity1.FIELD2 = "";//预留字段2
CwVouitemsEntity1.FIELD3 = "";//预留字段3
CwVouitemsEntity1.FIELD4 = "";//预留字段4
CwVouitemsEntity1.FIELD5 = "";//预留字段5
CwVouitemsEntity1.FIELD6 = "";//预留字段6
CwVouitemsEntity1.FIELD7 = "";//预留字段7
CwVouitemsEntity1.FIELD8 = "";//预留字段8
CwVouitemsEntity1.FIELD9 = "";//预留字段9
CwVouitemsEntity1.FIELD10 = "";//预留字段10
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity1.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity1.ISSYS = true;//是否手动录入
}
CwVouitemsEntity1.FSETTLCODE = "";//结算方式
CwVouitemsEntity1.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity1.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity1.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity1);
}
if (dUSD != 0)
{
#region dUSD != 0
CwVouitemsEntity CwVouitemsEntity3 = new CwVouitemsEntity();
CwVouitemsEntity3.ORDNO = strORDNO.Trim();
n = n + 1;
CwVouitemsEntity3.ITEMNO = n;// 行号
CwVouitemsEntity3.PACCID = "";//父级科目贷码
CwVouitemsEntity3.PROPERTY = 0;//科目属性
CwVouitemsEntity3.GRADE = 0;//科目级别
CwVouitemsEntity3.ACCID = ds.Tables[0].Rows[0]["TMFCI"].ToString().Trim();//应收账款外币科目贷码
CwVouitemsEntity3.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity3.AMTCR = Math.Round(Decimal.Parse(dUSD.ToString().Trim()) * (usdRATEF == 0 ? usdRATES : usdRATEF),2,MidpointRounding.AwayFromZero);//本位币贷方金额(互斥)
strDai = strDai + Math.Round(Decimal.Parse(dUSD.ToString().Trim()) * (usdRATEF == 0 ? usdRATES : usdRATEF), 2, MidpointRounding.AwayFromZero);
CwVouitemsEntity3.ISFCY = true;//是否外币
CwVouitemsEntity3.FCYNO = "USD";//外币编号usd
CwVouitemsEntity3.FCYDR = 0;//外币借方金额
CwVouitemsEntity3.FCYCR = Decimal.Parse(dUSD.ToString().Trim());//外币贷方金额
if (ds10 == null)
{
CwVouitemsEntity3.ACCNAME = "";//科目名称
CwVouitemsEntity3.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity3.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity3.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity3.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity3.DC = "C";//贷方向
}
else
{
CwVouitemsEntity3.ACCNAME = ds10.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity3.ISDEPTACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity3.ISEMPLACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity3.ISCORPACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity3.ISITEMACC = Boolean.Parse(ds10.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds10.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity3.DC = "D";//借方向
}
else
{
CwVouitemsEntity3.DC = "C";//贷方向
}
}
CwVouitemsEntity3.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity3.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity3.FCYEXRATE = (usdRATEF == 0 ? usdRATES : usdRATEF);//汇率
CwVouitemsEntity3.QTYUNIT = "";//数量包装单位
CwVouitemsEntity3.QTYDR = 0;//借方数量
CwVouitemsEntity3.QTYCR = 0;//贷方数量
CwVouitemsEntity3.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity3.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity3.ISSYS = true;//是否手动录入
}
CwVouitemsEntity3.FSETTLCODE = "";//结算方式
CwVouitemsEntity3.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity3.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity3.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity3);
}
#endregion
}
}
else
{
if (ds.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "1")//全额
{
#region 全额
// Decimal dlSR = dRMBS + (dUSDS * usdRATES);
Decimal dlSR =iAMTDR;
if (dlSR!=0)
{
#region 收入
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;//科目级别
CwVouitemsEntity2.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity2.AMTDR = 0;//本位币借方金额(互斥)
//CwVouitemsEntity2.AMTCR = dRMBS + (dUSDS * usdRATES);//本位币贷方金额(互斥)
//strDai = strDai + dRMBS + (dUSDS * usdRATES);
CwVouitemsEntity2.AMTCR = iAMTDR;//本位币贷方金额(互斥)
strDai = strDai + iAMTDR;
CwVouitemsEntity2.ISFCY = false;//是否外币
CwVouitemsEntity2.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity2.FCYDR = 0;//外币借方金额
CwVouitemsEntity2.FCYCR = 0;//外币贷方金额
if (ds8 == null)
{
CwVouitemsEntity2.ACCNAME = "";//科目名称
CwVouitemsEntity2.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity2.DC = "C";//贷方向
}
else
{
CwVouitemsEntity2.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity2.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity2.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity2.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity2.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity2.DC = "D";//借方向
}
else
{
CwVouitemsEntity2.DC = "C";//贷方向
}
}
CwVouitemsEntity2.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity2.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity2.FCYEXRATE = 1;//汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity2.QTYUNIT = "";//数量包装单位
CwVouitemsEntity2.QTYDR = 0;//借方数量
CwVouitemsEntity2.QTYCR = 0;//贷方数量
CwVouitemsEntity2.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity2.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity2.ISSYS = true;//是否手动录入
}
CwVouitemsEntity2.FSETTLCODE = "";//结算方式
CwVouitemsEntity2.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity2.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity2.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity2);
}
Decimal dlZC = dRMBF + Math.Round((dUSDF * usdRATEF),2,MidpointRounding.AwayFromZero);
if (dlZC != 0)
{
#region 支出
n = n + 1;
CwVouitemsEntity CwVouitemsEntity4 = new CwVouitemsEntity();
//CwVouitemsEntity4.GID 唯一编码 newid()
CwVouitemsEntity4.ORDNO = strORDNO.Trim();
CwVouitemsEntity4.ITEMNO = n;// 行号
CwVouitemsEntity4.PACCID = "";//父级科目贷码
CwVouitemsEntity4.PROPERTY = 0;//科目属性
CwVouitemsEntity4.GRADE = 0;//科目级别
CwVouitemsEntity4.ACCID = ds.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码
//CwVouitemsEntity4.AMTDR = dRMBF + (dUSDF * usdRATEF);//本位币借方金额(互斥)
//strJie = strJie + dRMBF + (dUSDF * usdRATEF);
CwVouitemsEntity4.AMTDR = iAMTCR;//本位币借方金额(互斥)
strJie = strJie +iAMTCR;
CwVouitemsEntity4.AMTCR = 0;//本位币贷方金额(互斥)
CwVouitemsEntity4.ISFCY = false;//是否外币
CwVouitemsEntity4.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity4.FCYDR = 0;//外币借方金额
CwVouitemsEntity4.FCYCR = 0;//外币贷方金额
if (ds9 == null)
{
CwVouitemsEntity4.ACCNAME = "";//科目名称
CwVouitemsEntity4.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.ACCNAME = ds9.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity4.ISDEPTACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity4.ISEMPLACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity4.ISCORPACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity4.ISITEMACC = Boolean.Parse(ds9.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds9.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity4.DC = "D";//借方向
}
else
{
CwVouitemsEntity4.DC = "C";//贷方向
}
}
CwVouitemsEntity4.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity4.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity4.FCYEXRATE = 1;//汇率
//dEXCHANGERATE = Decimal.Parse(ds1.Tables[0].Rows[j]["EXCHANGERATE"].ToString().Trim());//汇率
CwVouitemsEntity4.QTYUNIT = "";//数量包装单位
CwVouitemsEntity4.QTYDR = 0;//借方数量
CwVouitemsEntity4.QTYCR = 0;//贷方数量
CwVouitemsEntity4.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
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
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity4.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity4.ISSYS = true;//是否手动录入
}
CwVouitemsEntity4.FSETTLCODE = "";//结算方式
CwVouitemsEntity4.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity4.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity4.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity4);
}
#endregion
}
else if (ds.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "2")//差额
{
if (dRMB != 0 || dUSD != 0)
{
#region 差额
CwVouitemsEntity CwVouitemsEntity1 = new CwVouitemsEntity();
//CwVouitemsEntity1.GID 唯一编码 newid()
CwVouitemsEntity1.ORDNO = strORDNO.Trim();
n = n + 1;
CwVouitemsEntity1.ITEMNO = n;// 行号
CwVouitemsEntity1.PACCID = "";//父级科目贷码
CwVouitemsEntity1.PROPERTY = 0;//科目属性
CwVouitemsEntity1.GRADE = 0;//科目级别
CwVouitemsEntity1.ACCID = ds.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码
CwVouitemsEntity1.AMTDR = 0;//本位币借方金额(互斥)
CwVouitemsEntity1.AMTCR = Decimal.Parse(dRMB.ToString().Trim()) + Math.Round((Decimal.Parse(dUSD.ToString().Trim()) * (usdRATEF == 0 ? usdRATES : usdRATEF)), 2, MidpointRounding.AwayFromZero);//本位币贷方金额(互斥)
strDai = strDai + Decimal.Parse(dRMB.ToString().Trim()) + Math.Round((Decimal.Parse(dUSD.ToString().Trim()) * (usdRATEF == 0 ? usdRATES : usdRATEF)), 2, MidpointRounding.AwayFromZero);
CwVouitemsEntity1.ISFCY = false;//是否外币
CwVouitemsEntity1.FCYNO = "RMB";//外币编号usd
CwVouitemsEntity1.FCYDR = 0;//外币借方金额
CwVouitemsEntity1.FCYCR = 0;//外币贷方金额
if (ds8 == null)
{
CwVouitemsEntity1.ACCNAME = "";//科目名称
CwVouitemsEntity1.ISDEPTACC = false;//核算部门,按规则设置生成
CwVouitemsEntity1.ISEMPLACC = false;//核算人员,按规则设置生成
CwVouitemsEntity1.ISCORPACC = false;//核算客户,按规则设置生成
CwVouitemsEntity1.ISITEMACC = false;//核算项目,按规则设置生成
CwVouitemsEntity1.DC = "C";//贷方向
}
else
{
CwVouitemsEntity1.ACCNAME = ds8.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称
CwVouitemsEntity1.ISDEPTACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成
CwVouitemsEntity1.ISEMPLACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成
CwVouitemsEntity1.ISCORPACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成
CwVouitemsEntity1.ISITEMACC = Boolean.Parse(ds8.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成
if (ds8.Tables[0].Rows[0]["DC"].ToString().Trim() == "借")
{
CwVouitemsEntity1.DC = "D";//借方向
}
else
{
CwVouitemsEntity1.DC = "C";//贷方向
}
}
CwVouitemsEntity1.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户
CwVouitemsEntity1.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户
CwVouitemsEntity1.FCYEXRATE = 1;//汇率
CwVouitemsEntity1.QTYUNIT = "";//数量包装单位
CwVouitemsEntity1.QTYDR = 0;//借方数量
CwVouitemsEntity1.QTYCR = 0;//贷方数量
CwVouitemsEntity1.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" +
CwVouitemsEntity1.DEPTID = strDEPTID;//部门(系统)
CwVouitemsEntity1.EMPLID = strEMPLID;//人员(系统)
CwVouitemsEntity1.SALE = strSALE;//人员名称
CwVouitemsEntity1.PITEMID = 0;//父级项目编号
CwVouitemsEntity1.ITEMID = "0";//项目编号
CwVouitemsEntity1.FIELD1 = "";//预留字段1
CwVouitemsEntity1.FIELD2 = "";//预留字段2
CwVouitemsEntity1.FIELD3 = "";//预留字段3
CwVouitemsEntity1.FIELD4 = "";//预留字段4
CwVouitemsEntity1.FIELD5 = "";//预留字段5
CwVouitemsEntity1.FIELD6 = "";//预留字段6
CwVouitemsEntity1.FIELD7 = "";//预留字段7
CwVouitemsEntity1.FIELD8 = "";//预留字段8
CwVouitemsEntity1.FIELD9 = "";//预留字段9
CwVouitemsEntity1.FIELD10 = "";//预留字段10
if (ds.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True")
{
CwVouitemsEntity1.ISSYS = false;//是否手动录入
}
else
{
CwVouitemsEntity1.ISSYS = true;//是否手动录入
}
CwVouitemsEntity1.FSETTLCODE = "";//结算方式
CwVouitemsEntity1.FSETTLENO = "";//财务辅助编号
CwVouitemsEntity1.MODIFIEDUSER = strUserID;//最后一次更新操作人
CwVouitemsEntity1.BLNO = strBLNO;//
#endregion
CwVouitemsEntities.Add(CwVouitemsEntity1);
}
}
}
#endregion
#region 插入主表
string rq = tbVOUDATE.Text.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("-");
CwVouchersEntity.ACCMONTH = rq.Trim().Substring(iM1, iM2 - iM1);//月="";//int="";// 
string strVOUNO =getVOUNO(rq.Trim().Substring(0, 4), rq.Trim().Substring(iM1, iM2 - iM1));
CwVouchersEntity.VOUNO = strVOUNO;//月初清零 varchar (16)
if (iM2 - iM1 == 1)
{
strVOUNO = rq.Trim().Substring(0, 4) + "0"+rq.Trim().Substring(iM1, iM2 - iM1) + strVOUNO;
}
else
{
strVOUNO = rq.Trim().Substring(0, 4) + rq.Trim().Substring(iM1, iM2 - iM1) + strVOUNO;
}
CwVouchersEntity.VOUALLNO = strVOUNO;//月初清零 varchar (16)
CwVouchersEntity.VKNO = ds.Tables[0].Rows[0]["TVW"].ToString().Trim();//凭证字="";//varchar="";//(8)
CwVouchersEntity.ATTACHS = int.Parse(ds.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 = this.hd_comboPREPARED.Value.Trim();//制单人="";//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 bsno in(" + sGids + ") " + strVESSEL;
iResult = CwVouchersDA.setInsertAll(CwVouchersEntity, CwVouitemsEntities, strHandle, strVOUNO, strSel, strUserID,1);
}
}
return iResult;
}
protected String getVOUNO(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;
}
//
}
}