using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Data.SqlClient; using System.Text; using System.Globalization; using JsonHelper; using DSWeb.Models; using DSWeb.EntityDA; using DSWeb.Log; using DSWeb.Authority; using DSWeb.DataAccess; using DSWeb.MvcShipping.Models.MsCwVouchersGlChFeeEntity; using DSWeb.MvcShipping.Models.MsCwAccitemsGl; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using HcUtility.Core; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.Account.Models.MsCwVouchersGl3; using DSWeb.MvcShipping.Models.MsCwVouchersGl; using DSWeb.MvcShipping.Models.MsCwVouitemsGl; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; namespace DSWeb.Temp { public partial class SetUpdateWmsRateFEESCALE : System.Web.UI.Page { public string strUserID2;//用户GID public string strCompanyID;//公司GID public string strShowName;//用户显示名 public string strDeptName;//部门名称 public string strUserCode;//用户显示名 protected void Page_Load(object sender, EventArgs e) { #region 基本信息 if (Session["USERID"] != null) { strUserID2 = Session["USERID"].ToString().Trim(); } if (Session["USERCODE"] != null) { strUserCode = Session["USERCODE"].ToString(); } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); } if (Session["DEPTNAME"] != null) { strDeptName = Session["DEPTNAME"].ToString(); } #endregion } #region 按照新算法更新wms_rate表中的费率区间 protected void Button1_Click(object sender, EventArgs e) { using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { T_ALL_DA T_ALL_DA = new T_ALL_DA(); string sSQL = "update wms_rate set ENDBILLINGDATE=(select top 1 STARTBILLINGDATEall=(select top 1 isnull(STARTBILLINGDATE,WMSDATE+isnull(FREESTORAGEPERIOD,0)-1) from wms where gid=a.bsno)+FEESCALE from wms_rate as a where GID=wms_rate.gid)"; int iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null); if (iState < 0) { sqlTran.Rollback(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", ""); return; } // sSQL = "select * from wms "; DataSet ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, sSQL.ToString(), null); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int FEESCALE = 0; int FEESCALE2 = 0; sSQL = "select * from wms_rate where bsno='" + ds.Tables[0].Rows[i]["GID"].ToString().Trim() + "' order by FEEGRADE "; DataSet ds2 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, sSQL.ToString(), null); if (ds2 != null) { if (ds2.Tables[0].Rows.Count > 0) { for (int j = 0; j < ds2.Tables[0].Rows.Count; j++) { FEESCALE = int.Parse(ds2.Tables[0].Rows[j]["FEESCALE"].ToString().Trim()); FEESCALE = FEESCALE - FEESCALE2; FEESCALE2 = FEESCALE + FEESCALE2; sSQL = "update wms_rate set FEESCALE=" + FEESCALE + " where GID='" + ds2.Tables[0].Rows[j]["GID"].ToString().Trim() + "'"; iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null); if (iState != 1) { sqlTran.Rollback(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", ""); return; } } } } } } } // sqlTran.Commit(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); } catch (Exception execError) { sqlTran.Rollback(); throw execError; } finally { SqlHelper.CloseConnection(); } } } #endregion #region 解决资通物流出入库的型号中文乱码问题 protected void Button2_Click(object sender, EventArgs e) { using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction)) { try { string sSQL = "select * from wms_out_detail where GOODSMODEL LIKE '%\\u%'"; DataSet ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, sSQL, null); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string ls = ds.Tables[0].Rows[i]["GOODSMODEL"].ToString().Trim(); ls = UnicodeToGB(ls.Trim()); sSQL = "update wms_out_detail set GOODSMODEL='" + ls + "' where GID='" + ds.Tables[0].Rows[i]["GID"].ToString().Trim() + "'"; int iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null); if (iState != 1) { sqlTran.Rollback(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", ""); return; } } } } // sSQL = "select * from wms_in where GOODSMODEL LIKE '%\\u%'"; ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, sSQL, null); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string ls = ds.Tables[0].Rows[i]["GOODSMODEL"].ToString().Trim(); ls = UnicodeToGB(ls.Trim()); sSQL = "update wms_in set GOODSMODEL='" + ls + "' where GID='" + ds.Tables[0].Rows[i]["GID"].ToString().Trim() + "'"; int iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null); if (iState != 1) { sqlTran.Rollback(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", ""); return; } } } } // sqlTran.Commit(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", ""); } catch (Exception execError) { sqlTran.Rollback(); throw execError; } finally { SqlHelper.CloseConnection(); } } } #region Unicode-GB Code转换 /// /// Unicode-GB Code转换 /// /// 将Unicode编码字符转换成GB编码字符 /// GB Code字符串 public string UnicodeToGB(string text) { UnicodeEncoding unicode = new UnicodeEncoding(); text = unicode.GetString(unicode.GetBytes(Regex.Unescape(text.Trim()))); return text; } /// /// Unicode-GB Code转换 /// /// 将Unicode编码字符转换成GB编码字符 /// GB Code字符串 public string UnicodeToGB_Old(string text) { MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))"); if (mc != null && mc.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (Match m2 in mc) { string v = m2.Value; if (v.IndexOf("\\") >= 0) { string word = v.Substring(2); byte[] codes = new byte[2]; int code = Convert.ToInt32(word.Substring(0, 2), 16); int code2 = Convert.ToInt32(word.Substring(2), 16); codes[0] = (byte)code2; codes[1] = (byte)code; sb.Append(Encoding.Unicode.GetString(codes)); } else { sb.Append(v); } } return sb.ToString(); } else { return text; } } #endregion #endregion #region 解决总账凭证录入的科目显示模式的变更问题 protected void Button3_Click(object sender, EventArgs e) { GetCwAccitemsGlAll(strUserID2); Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", ""); return; } #region 获取 总账科目信息(包含上级科目) static public void GetCwAccitemsGlAll(string strUserID3) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID3); string strSql = "SELECT * FROM (select *,PACCGID=(SELECT PACCGID from cw_accitems_gl where STARTGID='" + strCwSTARTGID + "' and GID=VW_cw_vouchers_vouitems_gl.ACCGID) from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "') as a where len(PACCGID)>2"; T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL(strSql); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string sPACCGID = ds.Tables[0].Rows[i]["PACCGID"].ToString(); string sACCNAME = ds.Tables[0].Rows[i]["ACCNAME"].ToString(); string sACCALL = ds.Tables[0].Rows[i]["ACCALL"].ToString(); string sACCALL2 = ""; string sACCIDNAME = setCAGA(sPACCGID, sACCNAME);//科目名称 int inum = sACCALL.IndexOf("▁"); if (inum > -1) { sACCALL2 = sACCALL.Substring(inum); sACCALL2 = sACCIDNAME + sACCALL2; } else { sACCALL2 = sACCIDNAME; } strSql = "update cw_vouitems_gl set ACCALL='" + sACCALL2 + "' where GID='" + ds.Tables[0].Rows[i]["GID"].ToString() + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(strSql); } } } } static public String setCAGA(string sPACCGID, string sACCNAME) { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string sSQL = "select *,(ACCNAME+'_" + sACCNAME + "') AS ACCIDNAME from cw_accitems_gl where gid='" + sPACCGID + "'"; DataSet ds = T_ALL_DA.GetAllSQL(sSQL); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { sPACCGID = ds.Tables[0].Rows[0]["PACCGID"].ToString(); sACCNAME = ds.Tables[0].Rows[0]["ACCIDNAME"].ToString(); if (sPACCGID.Length > 36) { sACCNAME=setCAGA(sPACCGID, sACCNAME); } } } return sACCNAME; } #endregion #endregion #region 解决接口凭证换新界面后ACCALL为空的问题 protected void Button4_Click(object sender, EventArgs e) { GetMsCwVouchersACCALL(); Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", ""); return; } #region 获取 根据其他字段拼接ACCALL内容 static public void GetMsCwVouchersACCALL() { bool bl = false; string strSql = "SELECT * FROM VW_cw_vouchers_vouitems where ACCALL='' or ACCALL is null"; T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL(strSql); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { #region 逐条执行 /* for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string ACCALL = ds.Tables[0].Rows[i]["ACCNAME"].ToString(); Boolean ISCORPACC = Boolean.Parse(ds.Tables[0].Rows[i]["ISCORPACC"].ToString());//客户 Boolean ISDEPTACC = Boolean.Parse(ds.Tables[0].Rows[i]["ISDEPTACC"].ToString());//部门 Boolean ISEMPLACC = Boolean.Parse(ds.Tables[0].Rows[i]["ISEMPLACC"].ToString());//人员 Boolean ISITEMACC = Boolean.Parse(ds.Tables[0].Rows[i]["ISITEMACC"].ToString());//项目 if (ISCORPACC) { if (ds.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() != "") { ACCALL += "▁" + ds.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } } if (ISDEPTACC) { if (ds.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim() != "") { ACCALL += "▁" + ds.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } } if (ISEMPLACC) { if (ds.Tables[0].Rows[i]["SALE"].ToString().Trim() != "") { ACCALL += "▁" + ds.Tables[0].Rows[i]["SALE"].ToString().Trim(); } } if (ISITEMACC) { if (ds.Tables[0].Rows[i]["ITEMNAME"].ToString().Trim() != "") { ACCALL += "▁" + ds.Tables[0].Rows[i]["ITEMNAME"].ToString().Trim(); } } strSql = "update cw_vouitems set ACCALL='" + ACCALL + "' where GID='" + ds.Tables[0].Rows[i]["GID"].ToString() + "'"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); } */ #endregion #region 分情况执行 strSql = "update cw_vouitems set ACCALL=ACCNAME"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); strSql = "update cw_vouitems set ACCALL=(ACCALL+'▁'+CUSTOMERNAME) where ISCORPACC=1"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); strSql = "update cw_vouitems set ACCALL=(ACCALL+'▁'+DEPTNAME) where ISDEPTACC=1"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); strSql = "update cw_vouitems set ACCALL=(ACCALL+'▁'+SALE) where ISEMPLACC=1"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); strSql = "update cw_vouitems set ACCALL=(ACCALL+'▁'+ITEMNAME) where ISITEMACC=1"; bl = T_ALL_DA.GetExecuteSqlCommand(strSql); #endregion } } } #endregion #endregion #region 解决因多会计造成的成本收入凭证重复的问题(根据ch_Fee中凭证号由系统自动生成) protected void Button5_Click(object sender, EventArgs e) { setAddCwVouchersGl(strUserID2); Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", ""); return; } #region 生成总账成本收入凭证 public static void setAddCwVouchersGl(string strUserID3) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID3); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL("select VOUALLNO from ch_fee where 1=1 and VOUALLNO<>'' and VOUALLNO is not NULL group by VOUALLNO order by VOUALLNO");// and CUSTOMERNAME='歌尔电子李珊珊'// and VOUALLNO in (select VOUALLNO from cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' and ORDNO not in (SELECT ORDNO from cw_vouitems_gl)) if(ds!=null) { if(ds.Tables[0].Rows.Count>0) { for(int i=0;i 0) { for (int j = 0; j < dsChFee.Tables[0].Rows.Count; j++) { if (j == 0) { strGids += dsChFee.Tables[0].Rows[j]["GID"].ToString(); sBSNO += dsChFee.Tables[0].Rows[j]["BSNO"].ToString(); sGidC += dsChFee.Tables[0].Rows[j]["GID"].ToString() + "@" + dsChFee.Tables[0].Rows[j]["BSNO"].ToString(); //rec.data.CUSTNO.toString(); } else { strGids += "," + dsChFee.Tables[0].Rows[j]["GID"].ToString(); if (sBSNO.IndexOf(dsChFee.Tables[0].Rows[j]["BSNO"].ToString()) < 0) { sBSNO += "," + dsChFee.Tables[0].Rows[j]["BSNO"].ToString(); } sGidC += "," + dsChFee.Tables[0].Rows[j]["GID"].ToString() + "@" + dsChFee.Tables[0].Rows[j]["BSNO"].ToString(); //rec.data.CUSTNO.toString(); } } } } // string sSQL = "select top 1 * from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUALLNO"].ToString() + "'"; DataSet dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = dsCwVgl.Tables[0].Rows[0]["MODIFIEDUSER"].ToString(); string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["MODIFIEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["MODIFIEDTIME"].ToString()); string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = dsCwVgl.Tables[0].Rows[0]["CHECKEDGID"].ToString(); DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "'"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGl(strGids, sBSNO, sGidC, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } else { sSQL = "select top 1 * from cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUALLNO"].ToString() + "'"; dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = "4741d389-81dd-4569-ac9b-330c61cecb1c";// string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Now; string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = "4741d389-81dd-4569-ac9b-330c61cecb1c"; DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "'"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGl(strGids, sBSNO, sGidC, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } } } } else { sSQL = "select top 1 * from cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUALLNO"].ToString() + "'"; dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = "4741d389-81dd-4569-ac9b-330c61cecb1c";// string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Now; string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = "4741d389-81dd-4569-ac9b-330c61cecb1c"; DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "'"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGl(strGids, sBSNO, sGidC, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } } } } } } } public static DBResult onAddCwVouchersGl(string strGids, string sBSNO, string sGidC, MsCwVouchersGl3 headData, List bodyList, string strUserID, string strSHOWNAME, string companyid, DateTime dateMODIFIEDTIME, string strORDNO, string sVKNO, string sVOUNO, string sVOUALLNO, Boolean blISCHECKED, string sCHECKEDGID, DateTime dateCHECKEDTIME) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); string sSQL = ""; int iResult = 0; string zt = ""; string sError = "操作完成!"; // //帐套设置 sSQL = "SELECT top 1 * from cw_design_gl WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "'";// and CORPID='"+companyid+"' DataSet dsCwDesign = T_ALL_DA.GetAllSQL(sSQL); if (dsCwDesign == null) { result.Success = false; result.Message = "请先设置帐套信息!" + result.Message; return result; } //帐套设置_核算科目 sSQL = "SELECT [GID],[LINKGID],[ITEMGID],[OPTYPE],[MODIFIEDUSER],[MODIFIEDTIME],[MODIFIEDUSERNAME]=(select top 1 SHOWNAME from [user] where gid=[cw_design_gl_item].MODIFIEDUSER),[ITEMCODE]=(SELECT top 1 ITEMCODE from cw_item where GID=[cw_design_gl_item].[ITEMGID]),[ITEMNAME]=(SELECT top 1 ITEMNAME from cw_item where GID=[cw_design_gl_item].[ITEMGID]) FROM [cw_design_gl_item] WITH(NOLOCK) where LINKGID in (SELECT top 1 GID from cw_design_gl WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "') ORDER BY [ITEMCODE]"; DataSet dsCwDesignItem = T_ALL_DA.GetAllSQL(sSQL); //合并生成成本收入凭证凭证 string[] itemsBSNO = sBSNO.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (dsCwDesign.Tables[0].Rows[0]["ISCTGCIC"].ToString().Trim() == "True") { string sGids = "'" + strGids.Trim().Replace(",", "','") + "'"; iResult = getSC(dsCwDesign, dsCwDesignItem, "", sGids.Trim(), headData, bodyList, strUserID, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); zt += "," + iResult; if (zt.IndexOf("-") > 0) { sError = "共" + itemsBSNO.Length + "票委托单,生成0条凭证,失败1条凭证!"; } else { sError = "共" + itemsBSNO.Length + "票委托单,生成1条凭证,失败0条凭证!"; } } else { int n = 0; if (itemsBSNO.Length > 0) { for (int k = 0; k < itemsBSNO.Length; k++) { string sGids = ""; string strBSNO = itemsBSNO[k].ToString().Trim(); string[] items = sGidC.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (items.Length > 0) { for (int i = 0; i < items.Length; i++) { string strls = ""; if (items[i].ToString().Trim().IndexOf(strBSNO) > -1) { strls = items[i].ToString().Trim().Replace("@" + strBSNO, ""); } else { continue; } if (sGids == "") sGids = strls; else { sGids += "," + strls; } } } // if (sGids != "") { sGids = "'" + sGids.Trim().Replace(",", "','") + "'"; string strISCTGCIC = ",bsno"; iResult = getSC(dsCwDesign, dsCwDesignItem, strISCTGCIC, sGids, headData, bodyList, strUserID, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); zt += "," + iResult; if (zt.IndexOf("-") < 0) { n++; } } } } sError = "共" + itemsBSNO.Length + "票委托单,生成" + n + "条凭证,失败" + (itemsBSNO.Length - n) + "条凭证!"; } // //if (zt.IndexOf("-") > 0) //{ // result.Success = false; // result.Message = "操作出错" + result.Message;//部分凭证生成 // return result; //} result.Success = true; result.Message = sError;//"操作完成!"; return result; } /// /// 生成凭证 /// /// 帐套设置数据集 /// gid业务编号 /// protected static int getSC(DataSet dsCwDesign, DataSet dsCwDesignItem, string strISCTGCIC, string sGids, MsCwVouchersGl3 headData, List bodyList, string strUserID, string strCompanyID, DateTime dateMODIFIEDTIME, string strORDNO, string sVKNO, string sVOUNO, string sVOUALLNO, Boolean blISCHECKED, string sCHECKEDGID, DateTime dateCHECKEDTIME) { var result = new DBResult(); #region 基本变量 //全部 string sSQL = ""; string strEXPLAN = ""; string strFCY = "RMB"; 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 strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); #endregion #region 科目设置 //科目设置 应收RMB sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() + "'"; DataSet dsAR = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应收USD sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "'"; DataSet dsARFC = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应付RMB sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "'"; DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应付USD sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "'"; DataSet dsAPFC = T_ALL_DA.GetAllSQL(sSQL); //主营业务收入 收入RMB sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() + "'"; DataSet dsMBINCOME = T_ALL_DA.GetAllSQL(sSQL); //主营业务支出 支出RMB sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() + "'"; DataSet dsMBSPENDING = T_ALL_DA.GetAllSQL(sSQL); //主营收入外币 收入USD sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim() + "'"; DataSet dsTMFCI = T_ALL_DA.GetAllSQL(sSQL); //主营支出外币 支出USD sSQL = "SELECT top 1 * from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and ACCID='" + dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim() + "'"; DataSet dsTMSFC = T_ALL_DA.GetAllSQL(sSQL); #endregion #region 摘要 string strISEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strISEXPLAN += ",SETTLEMENTNAME";//是否收付客户名称CUSTOMERNAME } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strISEXPLAN += ",CUSTNO";//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strISEXPLAN += ",MBLNO";//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strISEXPLAN += ",VESSEL";//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strISEXPLAN += ",VOYNO";//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strISEXPLAN += ",BSSOURCE";//是否业务来源 } string strISEXPLANnull = ""; if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strISEXPLANnull += ",SETTLEMENTNAME";//是否收付客户名称CUSTOMERNAME } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strISEXPLANnull += ",CUSTNO";//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strISEXPLANnull += ",MBLNO";//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strISEXPLANnull += ",VESSEL";//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strISEXPLANnull += ",VOYNO";//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strISEXPLANnull += ",BSSOURCE";//是否业务来源 } //if (dsCwDesign.Tables[0].Rows[0]["ISBILLNO"].ToString().Trim() == "True") //{ // strISEXPLANnull += ",BILLNO_ACAD";//是否申请单号 //} } #endregion #region 核算科目_分录 //string sqlItemAR = ""; //string sqlItemARFC = ""; //string sqlItemAP = ""; //string sqlItemAPFC = ""; //string sqlItemMBINCOME = ""; //string sqlItemTMFCI = ""; //string sqlItemMBSPENDING = ""; //string sqlItemTMSFC = ""; //string sqlItemCE = ""; //string sqlItemCEFC = ""; #endregion #region 基本数据集 //string strORDNO = getGid(); string sqlAR = ""; string sqlARFC = ""; string sqlAP = ""; string sqlAPFC = ""; string sqlMBINCOME = ""; string sqlTMFCI = ""; string sqlMBSPENDING = ""; string sqlTMSFC = ""; string sqlCE = ""; string sqlCEFC = ""; IList CwVouitemsEntities = new List(); //是否按照系统录入汇率 if (headData.ISRATE == true) { #region 科目设置:应收RMB dsAR、应收USD dsARFC if (dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim()) { #region 应收RMB==应收USD #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsAR.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAR = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlAR += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC;// sqlAR += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; // sqlARFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlARFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } else { sqlAR = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收'"; sqlAR += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 应收RMB!=应收USD #region 应收RMB #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlAR = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlAR += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #region 应收USD #region 摘要内容 sISEXPLAN = ""; //是否核算客户 if (dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlARFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlARFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:应付RMB dsAP、应付USD dsAPFC if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim()) { #region 应付RMB==应付USD string sISEXPLAN = ""; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAP = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlAP += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; // sqlAPFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlAPFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } else { sqlAP = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付'"; sqlAP += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 应付RMB!=应付USD #region 应付RMB string sISEXPLAN = ""; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAP = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlAP += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #region 应付USD sISEXPLAN = ""; //是否核算客户 if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAPFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlAPFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务收入RMB dsMBINCOME、主营收入外币USD dsTMFCI if (dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim()) { #region 主营业务收入RMB==主营收入外币USD string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsMBINCOME.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlMBINCOME = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlMBINCOME += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC;// sqlMBINCOME += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlTMFCI = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlTMFCI += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlMBINCOME = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收'"; sqlMBINCOME += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 主营业务收入RMB!=主营收入外币USD #region 主营业务收入RMB string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlMBINCOME = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlMBINCOME += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #region 主营收入外币USD sISEXPLAN = ""; //是否核算客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlTMFCI = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlTMFCI += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务支出RMB dsMBSPENDING、主营支出外币USD dsTMSFC if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim()) { #region 主营业务支出RMB==主营支出外币USD string sISEXPLAN = ""; //是否核算客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlMBSPENDING = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlMBSPENDING += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlTMSFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlTMSFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlMBSPENDING = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付'"; sqlMBSPENDING += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 主营业务支出RMB!=主营支出外币USD #region 主营业务支出RMB string sISEXPLAN = ""; //是否核算客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlMBSPENDING = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlMBSPENDING += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #region 主营支出外币USD sISEXPLAN = ""; //是否核算客户 if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlTMSFC = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlTMSFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务差额 if (dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim()) { #region 主营业务收入RMB==主营收入外币USD #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsMBINCOME.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlCE = "SELECT EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY='RMB'"; sqlCE += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC;// sqlCE += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlCEFC = "SELECT EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY<>'RMB'"; sqlCEFC += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlCE = "SELECT SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ")"; string strls = strISEXPLANnull.Trim() + sISEXPLAN.Trim() + strISCTGCIC; if (strls.Trim() != "") { strls = strls.Trim().Substring(1); sqlCE += " GROUP BY " + strls; sqlCE += " ORDER BY " + strls; } } #endregion } else { #region 主营业务收入RMB!=主营收入外币USD #region 主营业务收入RMB #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlCE = "SELECT SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY='RMB'"; string strls = strISEXPLANnull.Trim() + sISEXPLAN.Trim() + strISCTGCIC; if (strls.Trim() != "") { strls = strls.Trim().Substring(1); sqlCE += " GROUP BY " + strls; sqlCE += " ORDER BY " + strls; } #endregion #region 主营收入外币USD #region 摘要内容 sISEXPLAN = ""; //是否核算客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlCEFC = "SELECT EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY<>'RMB'"; sqlCEFC += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion } else { #region 提取费率 string tbRATE = ""; if (bodyList != null) { if (bodyList.Count > 0) { for (int i = 0; i < bodyList.Count; i++) { tbRATE += " WHEN CURRENCY='" + bodyList[i].CURR.ToString().Trim() + "' THEN " + bodyList[i].FCYEXRATE.ToString().Trim(); } } } #endregion #region 科目设置:应收RMB dsAR、应收USD dsARFC if (dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim()) { #region 应收RMB==应收USD string sISEXPLAN = ""; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsAR.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAR = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlAR += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC;// sqlAR += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; // sqlARFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlARFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } else { sqlAR = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收'"; sqlAR += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 应收RMB!=应收USD #region 应收RMB string sISEXPLAN = ""; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlAR = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlAR += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAR += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #region 应收USD sISEXPLAN = ""; //是否核算客户 if (dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlARFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlARFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlARFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:应付RMB dsAP、应付USD dsAPFC if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim()) { #region 应付RMB==应付USD string sISEXPLAN = ""; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAP = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlAP += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; // sqlAPFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlAPFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } else { sqlAP = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付'"; sqlAP += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 应付RMB!=应付USD #region 应付RMB string sISEXPLAN = ""; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAP = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlAP += " GROUP BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAP += " ORDER BY FEETYPE" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #region 应付USD sISEXPLAN = ""; //是否核算客户 if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAPFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlAPFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; sqlAPFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLAN + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务收入RMB dsMBINCOME、主营收入外币USD dsTMFCI if (dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim()) { #region 主营业务收入RMB==主营收入外币USD #region 核算项目 string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsMBINCOME.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlMBINCOME = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlMBINCOME += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC;// sqlMBINCOME += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlTMFCI = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlTMFCI += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlMBINCOME = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收'"; sqlMBINCOME += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 主营业务收入RMB!=主营收入外币USD #region 主营业务收入RMB string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlMBINCOME = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY='RMB'"; sqlMBINCOME += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBINCOME += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #region 主营收入外币USD sISEXPLAN = ""; //是否核算客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlTMFCI = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='收' and CURRENCY<>'RMB'"; sqlTMFCI += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMFCI += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务支出RMB dsMBSPENDING、主营支出外币USD dsTMSFC if (dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim()) { #region 主营业务支出RMB==主营支出外币USD string sISEXPLAN = ""; //是否核算客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币 if (dsMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlMBSPENDING = "SELECT FEETYPE,EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlMBSPENDING += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlTMSFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlTMSFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlMBSPENDING = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付'"; sqlMBSPENDING += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } #endregion } else { #region 主营业务支出RMB!=主营支出外币USD #region 主营业务支出RMB string sISEXPLAN = ""; //是否核算客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlMBSPENDING = "SELECT FEETYPE,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY='RMB'"; sqlMBSPENDING += " GROUP BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlMBSPENDING += " ORDER BY FEETYPE" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #region 主营支出外币USD sISEXPLAN = ""; //是否核算客户 if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlTMSFC = "SELECT FEETYPE,(CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM(AMOUNT) AS je,SUM(Convert(decimal(18,2),(AMOUNT*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and FEETYPE='付' and CURRENCY<>'RMB'"; sqlTMSFC += " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlTMSFC += " ORDER BY FEETYPE desc,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion #region 科目设置:主营业务差额 if (dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim()) { #region 主营业务收入RMB==主营收入外币USD #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsMBINCOME.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlCE = "SELECT EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY='RMB'"; sqlCE += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC;// sqlCE += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; // sqlCEFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY<>'RMB'"; sqlCEFC += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; } else { sqlCE = "SELECT SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ")"; string strls = strISEXPLANnull.Trim() + sISEXPLAN.Trim() + strISCTGCIC; if (strls.Trim() != "") { strls = strls.Trim().Substring(1); sqlCE += " GROUP BY " + strls; sqlCE += " ORDER BY " + strls; } } #endregion } else { #region 主营业务收入RMB!=主营收入外币USD #region 主营业务收入RMB #region 摘要内容 string sISEXPLAN = ""; //是否核算客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlCE = "SELECT SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*EXCHANGERATE))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCE += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY='RMB'"; string strls = strISEXPLANnull.Trim() + sISEXPLAN.Trim() + strISCTGCIC; if (strls.Trim() != "") { strls = strls.Trim().Substring(1); sqlCE += " GROUP BY " + strls; sqlCE += " ORDER BY " + strls; } #endregion #region 主营收入外币USD #region 摘要内容 sISEXPLAN = ""; //是否核算客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",SETTLEMENTNAME";//是否委托单位 } } //是否核算人员 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlCEFC = "SELECT (CASE" + tbRATE + " ELSE EXCHANGERATE END) as EXCHANGERATE,CURRENCY,SUM((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)) AS je,SUM(Convert(decimal(18,2),((case when FEETYPE='收' then AMOUNT else (-AMOUNT) end)*(CASE" + tbRATE + " ELSE EXCHANGERATE END)))) AS hj " + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " From VW_FEE WHERE 1=1 and GID in (" + sGids.Trim() + ") and CURRENCY<>'RMB'"; sqlCEFC += " GROUP BY EXCHANGERATE,CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; sqlCEFC += " ORDER BY CURRENCY" + strISEXPLANnull + sISEXPLAN + strISCTGCIC; #endregion #endregion } #endregion } DataSet dsVWChFeeAR = T_ALL_DA.GetAllSQL(sqlAR); DataSet dsVWChFeeARFC = null; if (sqlARFC.Trim() != "") { dsVWChFeeARFC = T_ALL_DA.GetAllSQL(sqlARFC); } DataSet dsVWChFeeAP = T_ALL_DA.GetAllSQL(sqlAP); DataSet dsVWChFeeAPFC = null; if (sqlAPFC.Trim() != "") { dsVWChFeeAPFC = T_ALL_DA.GetAllSQL(sqlAPFC); } DataSet dsVWChFeeMBINCOME = T_ALL_DA.GetAllSQL(sqlMBINCOME); DataSet dsVWChFeeTMFCI = null; if (sqlTMFCI.Trim() != "") { dsVWChFeeTMFCI = T_ALL_DA.GetAllSQL(sqlTMFCI); } DataSet dsVWChFeeMBSPENDING = T_ALL_DA.GetAllSQL(sqlMBSPENDING); DataSet dsVWChFeeTMSFC = null; if (sqlTMSFC.Trim() != "") { dsVWChFeeTMSFC = T_ALL_DA.GetAllSQL(sqlTMSFC); } DataSet dsVWChFeeCE = T_ALL_DA.GetAllSQL(sqlCE); DataSet dsVWChFeeCEFC = null; if (sqlCEFC.Trim() != "") { dsVWChFeeCEFC = T_ALL_DA.GetAllSQL(sqlCEFC); } #endregion if (dsVWChFeeAR != null || dsVWChFeeARFC != null || dsVWChFeeAP != null || dsVWChFeeAPFC != null) { #region 插入明细表:应收RMB dsAR if (dsVWChFeeAR != null) { for (int i = 0; i < dsVWChFeeAR.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAR.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVWChFeeAR.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVWChFeeAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAR.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeAR.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeAR.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeAR.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeAR.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeAR.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAR.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVWChFeeAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } #endregion #region 插入明细表:应收外币 dsARFC if (dsVWChFeeARFC != null) { for (int i = 0; i < dsVWChFeeARFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否收付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否收付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeARFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVWChFeeARFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeARFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeARFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVWChFeeARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsARFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsARFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeARFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeARFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeARFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeARFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeARFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsARFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeARFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVWChFeeARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } #endregion #region 插入明细表:应付RMB dsAP if (dsVWChFeeAP != null) { for (int i = 0; i < dsVWChFeeAP.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTCR = iAMTCR + Decimal.Parse(dsVWChFeeAP.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBF += Decimal.Parse(dsVWChFeeAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeAP.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeAP.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeAP.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeAP.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeAP.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAP.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVWChFeeAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();// } MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } #endregion #region 插入明细表:应付外币 dsAPFC if (dsVWChFeeAPFC != null) { for (int i = 0; i < dsVWChFeeAPFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否付付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否付付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否付付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否付付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeAPFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTDR = iAMTDR + Decimal.Parse(dsVWChFeeAPFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVWChFeeAPFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 dRMBS += Decimal.Parse(dsVWChFeeAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeAPFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeAPFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeAPFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeAPFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeAPFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeAPFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVWChFeeAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } #endregion #region 插入明细表 利润 收入\成本 生成 全额\差额 Decimal dRMB = dRMBS - dRMBF; Decimal dUSD = dUSDS - dUSDF; //收入\成本 生成 全额\差额 Decimal strJie = dRMBS + dUSDS * dEXCHANGERATE; Decimal strDai = dRMBF + dUSDF * dEXCHANGERATE; // if (dsCwDesign.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "全额")//全额1 { #region 全额 if (dsVWChFeeMBINCOME != null) { for (int i = 0; i < dsVWChFeeMBINCOME.Tables[0].Rows.Count; i++) { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBINCOME.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 收入 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeMBINCOME.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) strDai = strDai + MsCwVouitemsGl.AMTCR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsMBINCOME.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsMBINCOME.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeMBINCOME.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeMBINCOME.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeMBINCOME.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeMBINCOME.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeMBINCOME.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBINCOME.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = 1;//汇率 if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" + MsCwVouitemsGl.BLNO = "";// MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } if (dsVWChFeeTMFCI != null) { for (int i = 0; i < dsVWChFeeTMFCI.Tables[0].Rows.Count; i++) { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMFCI.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 收入_外币 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim();//主营业务收入科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeTMFCI.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) strDai = strDai + MsCwVouitemsGl.AMTCR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeTMFCI.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVWChFeeTMFCI.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsTMFCI.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsTMFCI.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeTMFCI.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeTMFCI.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeTMFCI.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeTMFCI.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeTMFCI.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMFCI.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeAR.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 "转运费" + MsCwVouitemsGl.BLNO = "";// MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } if (dsVWChFeeMBSPENDING != null) { for (int i = 0; i < dsVWChFeeMBSPENDING.Tables[0].Rows.Count; i++) { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 支出 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeMBSPENDING.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + MsCwVouitemsGl.AMTDR; MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeMBSPENDING.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeMBSPENDING.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeMBSPENDING.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeMBSPENDING.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeMBSPENDING.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = 1;//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } if (dsVWChFeeTMSFC != null) { for (int i = 0; i < dsVWChFeeTMSFC.Tables[0].Rows.Count; i++) { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeTMSFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 支出_外币 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim();//主营业务支出科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVWChFeeTMSFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + MsCwVouitemsGl.AMTDR; MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeTMSFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVWChFeeTMSFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeTMSFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeTMSFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeTMSFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeTMSFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeTMSFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeTMSFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } #endregion } else if (dsCwDesign.Tables[0].Rows[0]["AMCODE"].ToString().Trim() == "差额")//差额2 { #region 差额 if (dsVWChFeeCE != null) { for (int i = 0; i < dsVWChFeeCE.Tables[0].Rows.Count; i++) { if (Decimal.Parse(dsVWChFeeCE.Tables[0].Rows[i]["je"].ToString().Trim()) > 0)//收入 { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 差额_收入 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBINCOME"].ToString().Trim();//主营业务收入科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeCE.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) strDai = strDai + MsCwVouitemsGl.AMTCR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsMBINCOME.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsMBINCOME.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsMBINCOME.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeCE.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsMBINCOME.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeCE.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsMBINCOME.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeCE.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeCE.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsMBINCOME.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeCE.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBINCOME.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = 1;//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } else if (Decimal.Parse(dsVWChFeeCE.Tables[0].Rows[i]["je"].ToString().Trim()) < 0)//支出 { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCE.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 差额_支出 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["MBSPENDING"].ToString().Trim();//主营业务支出科目贷码 MsCwVouitemsGl.AMTDR = -Decimal.Parse(dsVWChFeeCE.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) strJie = strJie + MsCwVouitemsGl.AMTDR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeCE.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeCE.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeCE.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeCE.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeCE.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = 1;//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } if (dsVWChFeeCEFC != null) { for (int i = 0; i < dsVWChFeeCEFC.Tables[0].Rows.Count; i++) { if (Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["je"].ToString().Trim()) > 0)//外币收入 { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 差额_外币收入 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMFCI"].ToString().Trim();//主营业务收入科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) strDai = strDai + MsCwVouitemsGl.AMTCR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeCEFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsTMFCI.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsTMFCI.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsTMFCI.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeCEFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsTMFCI.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeCEFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsTMFCI.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeCEFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeCEFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsTMFCI.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeCEFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMFCI.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } else if (Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["je"].ToString().Trim()) < 0)//外币支出 { #region 摘要内容 if (dsCwDesign.Tables[0].Rows[0]["ISMBINCOME"].ToString().Trim() == "False")//是否合并生成成本收入凭证中的主营业务科目 { strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVWChFeeCEFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } } #endregion #region 差额_外币支出 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["TMSFC"].ToString().Trim();//主营业务收入科目贷码 MsCwVouitemsGl.AMTDR = -Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) strJie = strJie + MsCwVouitemsGl.AMTDR; MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVWChFeeCEFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = -Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 MsCwVouitemsGl.ACCNAME = dsTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";// strEMPLID;//人员(系统)本来应该放客户 MsCwVouitemsGl.CUSTOMERNAME = "";// strSALE;//人员(系统)本来应该放客户 if (dsTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVWChFeeCEFC.Tables[0].Rows[i]["SETTLEMENTNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVWChFeeCEFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVWChFeeCEFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVWChFeeCEFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVWChFeeCEFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVWChFeeCEFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = "";// if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 MsCwVouitemsGl.MODIFIEDTIME = dateMODIFIEDTIME; #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion } #endregion #region 插入主表 MsCwVouchersGl MsCwVouchersGl = new MsCwVouchersGl(); MsCwVouchersGl.ORDNO = strORDNO;//唯一编码 newid() varchar (36) MsCwVouchersGl.VOUDATE = headData.VOUDATE;//凭证日期 MsCwVouchersGl.VOUNO = sVOUNO;//月初清零 varchar (16) MsCwVouchersGl.ACCYEAR = DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString();//年 MsCwVouchersGl.ACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月 if (MsCwVouchersGl.ACCMONTH.ToString().Length == 1) { MsCwVouchersGl.ACCMONTH = "0" + MsCwVouchersGl.ACCMONTH.ToString();//月 } MsCwVouchersGl.VKNO = sVKNO;//凭证字 MsCwVouchersGl.VOUALLNO = sVOUALLNO;//年+月+自动生成编号=凭证号 MsCwVouchersGl.ATTACHS = 1;// int.Parse(dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//附件(单据)数 MsCwVouchersGl.AMTDR = strJie;// iAMTDR;//本位币借方 MsCwVouchersGl.AMTCR = strDai;//iAMTDR;// iAMTCR;//本位币贷方 MsCwVouchersGl.FCY = strFCY;//是否含有外币科目 MsCwVouchersGl.QTY = "";//是否含有数量科目 MsCwVouchersGl.VOUPROP = "";//凭证属性 MsCwVouchersGl.PREPARED = headData.PREPARED.ToString().Trim();//制单人 MsCwVouchersGl.ISCHECKED = blISCHECKED; MsCwVouchersGl.CHECKED = sCHECKEDGID;//审核人 MsCwVouchersGl.CHECKEDTIME = dateCHECKEDTIME; MsCwVouchersGl.ENTERED = "";//记账人 MsCwVouchersGl.ERRMSG = "";//错误信息 MsCwVouchersGl.ISDELETE = false;//是否废除 MsCwVouchersGl.DELETEUSER = "";//废除操作人 MsCwVouchersGl.STARTGID = strCwSTARTGID; MsCwVouchersGl.DbOperationType = DbOperationType.DbotIns; #endregion #region 生成入库 var modb = new ModelObjectDB(); result = modb.Save(MsCwVouchersGl); if (result.Success == true) { //int n = 1; BasicDataRefDAL.SetGLOrder(ref CwVouitemsEntities); foreach (var enumValue in CwVouitemsEntities) { enumValue.GID = Guid.NewGuid().ToString(); //enumValue.ITEMNO = n; enumValue.DbOperationType = DbOperationType.DbotIns; var modb2 = new ModelObjectDB(); DBResult result2 = modb2.Save(enumValue); //n++; } //更新 string blSQL = "update cw_vouchers_gl set CHECKEDTIME='" + dateCHECKEDTIME + "',ISCHECKED='" + blISCHECKED + "' where ORDNO='" + strORDNO + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL); //更新 blSQL = "UPDATE cw_vouchers_gl set amtdr=ISNULL((SELECT sum(amtdr) from cw_vouitems_gl where ORDNO=cw_vouchers_gl.ORDNO),0),amtcr=ISNULL((SELECT sum(amtcr) from cw_vouitems_gl where ORDNO=cw_vouchers_gl.ORDNO),0) where ORDNO='" + strORDNO + "'"; bl = T_ALL_DA.GetExecuteSqlCommand(blSQL); } else { //result.Success = false; //result.Message = result.Message; //return result; return -2;//重复数据 } #endregion } else { return -3;//结算无明细数据 } //result.Success = true; //result.Message = result.Message; //return result; return 1; } public static String getGid() { string strgid = Guid.NewGuid().ToString(); strgid = strgid.Replace("-", ""); strgid = "VOU" + strgid; return strgid; } #endregion #endregion #region 解决结算费用 生成到主营业务改为生成到应收付账款 中的问题(根据ch_fee_settlement中总账凭证号由系统重新生成结算凭证) protected void Button6_Click(object sender, EventArgs e) { setAddCwVouchersGlToSettlement(strUserID2); Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", ""); return; } #region 生成总账凭证 public static void setAddCwVouchersGlToSettlement(string strUserID3) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID3); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL("select VOUCHERNO from ch_fee_settlement where 1=1 and VOUCHERNO<>'' and VOUCHERNO is not NULL group by VOUCHERNO order by VOUCHERNO");// and CUSTOMERNAME='歌尔电子李珊珊' and VOUCHERNO like '%付2016040015%' if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string strGids = ""; DataSet dsChFee = T_ALL_DA.GetAllSQL("select * from ch_fee_settlement where 1=1 and VOUCHERNO='" + ds.Tables[0].Rows[i]["VOUCHERNO"].ToString() + "' order by VOUCHERNO"); if (dsChFee != null) { if (dsChFee.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsChFee.Tables[0].Rows.Count; j++) { if (j == 0) { strGids += dsChFee.Tables[0].Rows[j]["GID"].ToString(); } else { strGids += "," + dsChFee.Tables[0].Rows[j]["GID"].ToString(); } } } } // string sSQL = "select top 1 * from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUCHERNO"].ToString() + "'"; DataSet dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = dsCwVgl.Tables[0].Rows[0]["MODIFIEDUSER"].ToString(); string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["MODIFIEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["MODIFIEDTIME"].ToString()); string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = dsCwVgl.Tables[0].Rows[0]["CHECKEDGID"].ToString(); DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "' and (ACCID='5101' or ACCID='5401')"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGlToSettlement(strGids, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } else { sSQL = "select top 1 * from cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUALLNO"].ToString() + "'"; dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = "4741d389-81dd-4569-ac9b-330c61cecb1c";// string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Now; string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = "4741d389-81dd-4569-ac9b-330c61cecb1c"; DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "' and (ACCID='5101' or ACCID='5401')"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGlToSettlement(strGids, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } } } } else { sSQL = "select top 1 * from cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + ds.Tables[0].Rows[i]["VOUALLNO"].ToString() + "'"; dsCwVgl = T_ALL_DA.GetAllSQL(sSQL); if (dsCwVgl != null) { if (dsCwVgl.Tables[0].Rows.Count > 0) { List bodyList = null; var headData = new MsCwVouchersGl3(); headData.PREPARED = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); headData.VOUDATE = dsCwVgl.Tables[0].Rows[0]["VOUDATE"].ToString(); headData.ISRATE = true; string strUserID = "4741d389-81dd-4569-ac9b-330c61cecb1c"; string strSHOWNAME = dsCwVgl.Tables[0].Rows[0]["PREPARED"].ToString(); DateTime dateMODIFIEDTIME = DateTime.Now; string companyid = "Comcab2d43f60454327af30a131fc1d3abd"; string strORDNO = dsCwVgl.Tables[0].Rows[0]["ORDNO"].ToString(); string sVKNO = dsCwVgl.Tables[0].Rows[0]["VKNO"].ToString(); string sVOUNO = dsCwVgl.Tables[0].Rows[0]["VOUNO"].ToString(); string sVOUALLNO = dsCwVgl.Tables[0].Rows[0]["VOUALLNO"].ToString(); Boolean blISCHECKED = Boolean.Parse(dsCwVgl.Tables[0].Rows[0]["ISCHECKED"].ToString()); string sCHECKEDGID = "4741d389-81dd-4569-ac9b-330c61cecb1c"; DateTime dateCHECKEDTIME = DateTime.Parse(dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString() == "" ? DateTime.Now.ToString() : dsCwVgl.Tables[0].Rows[0]["CHECKEDTIME"].ToString()); // bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouitems_gl where ORDNO='" + strORDNO + "' and (ACCID='5101' or ACCID='5401')"); bl = T_ALL_DA.GetExecuteSqlCommand("delete from cw_vouchers_gl where ORDNO='" + strORDNO + "'"); // var result = new DBResult(); result = onAddCwVouchersGlToSettlement(strGids, headData, bodyList, strUserID, strSHOWNAME, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); } } } } } } } public static DBResult onAddCwVouchersGlToSettlement(string strGids, MsCwVouchersGl3 headData, List bodyList, string strUserID, string strSHOWNAME, string companyid, DateTime dateMODIFIEDTIME, string strORDNO, string sVKNO, string sVOUNO, string sVOUALLNO, Boolean blISCHECKED, string sCHECKEDGID, DateTime dateCHECKEDTIME) { var result = new DBResult(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string sSQL = ""; int iResult = 0; string zt = ""; string sGids = "'" + strGids.Trim().Replace(",", "','") + "'"; string sError = "操作完成!"; string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); // //帐套设置 sSQL = "SELECT top 1 * from cw_design_gl WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "'";// and CORPID='"+companyid+"' DataSet dsCwDesign = T_ALL_DA.GetAllSQL(sSQL); if (dsCwDesign == null) { result.Success = false; result.Message = "请先设置帐套信息!" + result.Message; return result; } //帐套设置_核算科目 sSQL = "SELECT [GID],[LINKGID],[ITEMGID],[OPTYPE],[MODIFIEDUSER],[MODIFIEDTIME],[MODIFIEDUSERNAME]=(select top 1 SHOWNAME from [user] where gid=[cw_design_gl_item].MODIFIEDUSER),[ITEMCODE]=(SELECT top 1 ITEMCODE from cw_item where GID=[cw_design_gl_item].[ITEMGID]),[ITEMNAME]=(SELECT top 1 ITEMNAME from cw_item where GID=[cw_design_gl_item].[ITEMGID]) FROM [cw_design_gl_item] WITH(NOLOCK) where LINKGID in (SELECT top 1 GID from cw_design_gl WITH(NOLOCK) where [STARTGID]='" + strCwSTARTGID + "') ORDER BY [ITEMCODE]"; DataSet dsCwDesignItem = T_ALL_DA.GetAllSQL(sSQL); //账户设置 sSQL = "select ACCOUNT from (SELECT isnull((case when isnull(ACCOUNTRMB,'')='' then isnull(ACCOUNTUSD,'') ELSE isnull(ACCOUNTRMB,'') END),'') as ACCOUNT from VW_ch_fee_settlement_do where 1=1 and gid_s in(" + sGids + ") and ((ACCOUNTRMB<>'' and ACCOUNTRMB is not NULL) OR (ACCOUNTUSD<>'' and ACCOUNTUSD is not NULL))) as a group by ACCOUNT";// where CORPID='"+companyid+"' DataSet dsACCOUNT = T_ALL_DA.GetAllSQL(sSQL); if (dsACCOUNT != null) { if (dsACCOUNT.Tables[0].Rows.Count > 0) { int isLS = 0; for (int i = 0; i < dsACCOUNT.Tables[0].Rows.Count; i++) { sSQL = "SELECT count(*) as inum from cw_accitems_gl INNER JOIN sys_bank on cw_accitems_gl.ACCID=sys_bank.CWGLACCID where sys_bank.GID in ('" + dsACCOUNT.Tables[0].Rows[i]["ACCOUNT"].ToString().Trim() + "') and cw_accitems_gl.[year]=SUBSTRING('" + strCwACCDATE + "',1,4)";// where CORPID='"+companyid+"' int inum = int.Parse(T_ALL_DA.GetStrSQL("inum", sSQL)); if (inum == 0) { isLS++; } } if (isLS > 0) { result.Success = false; result.Message = "请先设置账户总账代码信息!" + result.Message; return result; } } } //合并生成结算凭证 string[] items = sGids.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (dsCwDesign.Tables[0].Rows[0]["ISMGSC"].ToString().Trim() == "True") { iResult = getSCToSettlement(dsCwDesign, dsCwDesignItem, "", sGids.Trim(), headData, bodyList, strCwACCDATE, strUserID, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); zt += "," + iResult; if (zt.IndexOf("-") > 0) { sError = "共" + items.Length + "票结算单,生成0条凭证,失败1条凭证!"; } else { sError = "共" + items.Length + "票结算单,生成1条凭证,失败0条凭证!"; } } else { int n = 0; if (items.Length > 0) { for (int i = 0; i < items.Length; i++) { string strISMGSC = ",BILLNO,SETTLETYPE";// iResult = getSCToSettlement(dsCwDesign, dsCwDesignItem, strISMGSC, items[i].ToString().Trim(), headData, bodyList, strCwACCDATE, strUserID, companyid, dateMODIFIEDTIME, strORDNO, sVKNO, sVOUNO, sVOUALLNO, blISCHECKED, sCHECKEDGID, dateCHECKEDTIME); zt += "," + iResult; if (zt.IndexOf("-") < 0) { n++; } } } sError = "共" + items.Length + "票结算单,生成" + n + "条凭证,失败" + (items.Length - n) + "条凭证!"; } result.Success = true; result.Message = sError;//"操作完成!"; return result; } /// /// 生成凭证 /// /// 帐套设置数据集 /// gid业务编号 /// protected static int getSCToSettlement(DataSet dsCwDesign, DataSet dsCwDesignItem, string strISMGSC, string sGids, MsCwVouchersGl3 headData, List bodyList, string strACCDATE, string strUserID, string strCompanyID, DateTime dateMODIFIEDTIME, string strORDNO, string sVKNO, string sVOUNO, string sVOUALLNO, Boolean blISCHECKED, string sCHECKEDGID, DateTime dateCHECKEDTIME) { var result = new DBResult(); #region 基本变量 //全部 string sSQL = ""; string strEXPLAN = ""; string strFCY = "RMB"; string strIsExplan2 = ""; 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 strBPVW = dsCwDesign.Tables[0].Rows[0]["TVW"].ToString().Trim(); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID); #endregion #region 科目设置 //科目设置 应收RMB sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsAR = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应收外币 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsARFC = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应付RMB sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL); //科目设置 应付外币 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsAPFC = T_ALL_DA.GetAllSQL(sSQL); //科目设置 收费结算借方默认科目代码 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["ARMBSPENDING"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsARMBSPENDING = T_ALL_DA.GetAllSQL(sSQL); //科目设置 收费结算外币借方默认科目代码 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["ARTMSFC"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsARTMSFC = T_ALL_DA.GetAllSQL(sSQL); //科目设置 付费结算借方默认科目代码 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsAPMBSPENDING = T_ALL_DA.GetAllSQL(sSQL); //科目设置 付费结算外币借方默认科目代码 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsAPTMSFC = T_ALL_DA.GetAllSQL(sSQL); //科目设置 现金 sSQL = "SELECT top 1 * from cw_accitems_gl where ACCID='" + dsCwDesign.Tables[0].Rows[0]["CASH"].ToString().Trim() + "' and [YEAR]=SUBSTRING('" + strACCDATE + "',1,4)"; DataSet dsCASH = T_ALL_DA.GetAllSQL(sSQL); //科目设置 银行账号 sSQL = "SELECT cw_accitems_gl.*,sys_bank.GID as BankGid from cw_accitems_gl INNER JOIN sys_bank on cw_accitems_gl.ACCID=sys_bank.CWGLACCID where cw_accitems_gl.[YEAR]=SUBSTRING('" + strACCDATE + "',1,4) and sys_bank.GID in (select ACCOUNT from (SELECT isnull((case when isnull(ACCOUNTRMB,'')='' then isnull(ACCOUNTUSD,'') ELSE isnull(ACCOUNTRMB,'') END),'') as ACCOUNT from VW_ch_fee_settlement_do where 1=1 and gid_s in(" + sGids + ") and ((ACCOUNTRMB<>'' and ACCOUNTRMB is not NULL) OR (ACCOUNTUSD<>'' and ACCOUNTUSD is not NULL))) as a group by ACCOUNT)"; DataSet dsBank = T_ALL_DA.GetAllSQL(sSQL); #endregion #region 摘要 string strISEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strISEXPLAN += ",CUSTOMERNAME";//是否收付客户名称 } 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]["ISRPBSSOURCE"].ToString().Trim() == "True") { strISEXPLAN += ",BSSOURCE";//是否收付业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { if (strISMGSC.IndexOf("BILLNO") < 0) { strISEXPLAN += ",BILLNO";//是否收付结算单号 } } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strISEXPLAN += ",BILLNO_ACAD";//是否收付申请单号 } #endregion #region 基本数据集 #region 基本信息 //string strORDNO = getGid(); string sqlAR = ""; string sqlARFC = ""; string sqlAP = ""; string sqlAPFC = ""; string sqlCASH = ""; string sqlBank = ""; ArrayList alBank = new ArrayList(); ArrayList alBankDs = new ArrayList(); string sqlCASHCE = ""; string sqlBankCE = ""; ArrayList alBankCE = new ArrayList(); ArrayList alBankDsCE = new ArrayList(); IList CwVouitemsEntities = new List(); #endregion #region 提取费率 string tbRATE = ""; //是否按照系统录入汇率 if (headData.ISRATE == true) { tbRATE = "EXCHANGERATE"; } else { tbRATE = "(CASE"; if (bodyList != null) { if (bodyList.Count > 0) { for (int i = 0; i < bodyList.Count; i++) { tbRATE += " WHEN CURRENCY='" + bodyList[i].CURR.ToString().Trim() + "' THEN " + bodyList[i].FCYEXRATE.ToString().Trim();//ORIGCURRENCY } } } tbRATE += " ELSE EXCHANGERATE END)"; } #endregion #region 科目设置:应收RMB dsAR(ARMBSPENDING)、应收USD dsARFC(ARTMSFC) if (dsCwDesign.Tables[0].Rows[0]["ISARMBSPENDING"].ToString().Trim() == "True") { #region 科目设置:收费结算借方默认科目代码 if (dsCwDesign.Tables[0].Rows[0]["ARMBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["ARTMSFC"].ToString().Trim()) { #region 应收RMB==应收USD #region 核算项目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsARMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsARMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsARMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; sqlARFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; } else { sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; } #endregion } else { #region 应收RMB!=应收USD #region 应收RMB #region 核算项目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsARMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsARMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; #endregion #region 应收USD #region 核算项目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsARTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsARTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlARFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; #endregion #endregion } #endregion } else { if (dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim()) { #region 应收RMB==应收USD #region 核算项目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsAR.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; sqlARFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; } else { sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; } #endregion } else { #region 应收RMB!=应收USD #region 应收RMB #region 核算项目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlAR = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; #endregion #region 应收USD #region 核算项目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应收RMB!=应收USD,所以此处不需核算外币 sqlARFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=1 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; #endregion #endregion } } #endregion #region 科目设置:应付RMB dsAP(APMBSPENDING)、应付USD dsAPFC(APTMSFC) if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True") { #region 科目设置:付费结算借方默认科目代码 if (dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim()) { #region 应付RMB==应付USD #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; sqlAPFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; } else { sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; } #endregion } else { #region 应付RMB!=应付USD #region 应付RMB #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; #endregion #region 应付USD #region 核算科目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsAPTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAPTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion sqlAPFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; #endregion #endregion } #endregion } else { if (dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim() == dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim()) { #region 应付RMB==应付USD #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsAP.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; sqlAPFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; } else { sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; } #endregion } else { #region 应付RMB!=应付USD #region 应付RMB #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币,因 应付RMB!=应付USD,所以此处不需核算外币 sqlAP = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY='RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc" + strISEXPLAN + sISEXPLAN; #endregion #region 应付USD #region 核算科目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion sqlAPFC = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",ORIGCURRENCY as CURRENCY," + tbRATE + " as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + ",ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and FEETYPE=2 and ORIGCURRENCY<>'RMB'" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,EXCHANGERATE,CURRENCY,ORIGCURRENCY,ACCOUNTRMB,ACCOUNTUSD" + strISEXPLAN + sISEXPLAN + " ORDER BY FEETYPE desc,ORIGCURRENCY" + strISEXPLAN + sISEXPLAN; #endregion #endregion } } #endregion #region 科目设置:现金、账户 //对抵结算是否生成银行账款 if (headData.ButtSettlement == true) { #region 现金 #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsCASH.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlCASH = "SELECT FEETYPE,CURRENCY,(case when CURRENCY='RMB' then 1 else convert(numeric(8,5),round(SUM(hj)/SUM(je),5)) END) as EXCHANGERATE,SUM(je) AS je,SUM(hj) AS hj" + sISEXPLAN//,SETTLETYPE + strISEXPLAN + " from (" + "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",CURRENCY,1 as EXCHANGERATE" + ",SUM(AMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE + strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='' or ACCOUNTRMB is NULL) and (ACCOUNTUSD='' OR ACCOUNTUSD is NULL)" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY EXCHANGERATE,CURRENCY,FEETYPE" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + ") as a" + " GROUP BY EXCHANGERATE,CURRENCY,FEETYPE" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + " ORDER BY CURRENCY,FEETYPE" + sISEXPLAN;// + strISEXPLAN } else { sqlCASH = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='' or ACCOUNTRMB is NULL) and (ACCOUNTUSD='' OR ACCOUNTUSD is NULL)" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE" + sISEXPLAN//BILLNO,SETTLETYPE, + strISEXPLAN + " ORDER BY FEETYPE" + sISEXPLAN;// + strISEXPLAN } #endregion #region 银行账户 if (dsBank != null) { for (int i = 0; i < dsBank.Tables[0].Rows.Count; i++) { #region 循环账户 #region 核算科目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsBank.Tables[0].Rows[i]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsBank.Tables[0].Rows[i]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsBank.Tables[0].Rows[i]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsBank.Tables[0].Rows[i]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsBank.Tables[0].Rows[i]["ISFCY"].ToString().Trim() == "True") { sqlBank = "SELECT FEETYPE,CURRENCY,(case when CURRENCY='RMB' then 1 else convert(numeric(8,5),round(SUM(hj)/SUM(je),5)) END) as EXCHANGERATE,ACCOUNTRMB,ACCOUNTUSD,SUM(je) AS je,SUM(hj) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " from (" + "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE" + ",CURRENCY,1 as EXCHANGERATE,ACCOUNTRMB,ACCOUNTUSD" + ",SUM(AMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "' or ACCOUNTUSD='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "')" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY EXCHANGERATE,CURRENCY,ACCOUNTRMB,ACCOUNTUSD,FEETYPE" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + ") as a" + " GROUP BY EXCHANGERATE,CURRENCY,ACCOUNTRMB,ACCOUNTUSD,FEETYPE" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + " ORDER BY CURRENCY,FEETYPE" + sISEXPLAN;// + strISEXPLAN } else { sqlBank = "SELECT (CASE WHEN FEETYPE = 1 THEN '应收账款' WHEN FEETYPE=2 THEN '应付账款' ELSE '' END) as FEETYPE,'RMB' as CURRENCY,1 as EXCHANGERATE,ACCOUNTRMB,ACCOUNTUSD" + ",SUM(ORIGAMOUNT) AS je" + ",convert(decimal(18,2),round(SUM(ORIGAMOUNT*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "' or ACCOUNTUSD='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "')" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + sISEXPLAN//BILLNO,SETTLETYPE, + strISEXPLAN + " ORDER BY FEETYPE,ACCOUNTRMB,ACCOUNTUSD" + sISEXPLAN;// + strISEXPLAN } alBank.Add(sqlBank); #endregion } } #endregion } else { #region 现金 #region 核算科目 string sISEXPLAN = strISMGSC; //是否核算客户 if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsCASH.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True") { sqlCASHCE = "SELECT CURRENCY,(case when CURRENCY='RMB' then 1 else convert(numeric(8,5),round(SUM(hj)/SUM(je),5)) END) as EXCHANGERATE,SUM(je) AS je,SUM(hj) AS hj" + sISEXPLAN//,'' as SETTLETYPE,+ strISEXPLAN + " from (" + "SELECT CURRENCY,1 as EXCHANGERATE" + ",SUM((case when FEETYPE=1 then AMOUNT else (-AMOUNT) end)) AS je" + ",convert(decimal(18,2),round(SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)*" + tbRATE + "),2)) AS hj" + sISEXPLAN//'' as SETTLETYPE,+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='' or ACCOUNTRMB is NULL) and (ACCOUNTUSD='' OR ACCOUNTUSD is NULL)" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY EXCHANGERATE,CURRENCY" + sISEXPLAN//BILLNO,SETTLETYPE, + strISEXPLAN + ") as a" + " GROUP BY EXCHANGERATE,CURRENCY" + sISEXPLAN//BILLNO,SETTLETYPE, + strISEXPLAN + " ORDER BY CURRENCY" + sISEXPLAN;//BILLNO + strISEXPLAN } else { sqlCASHCE = "SELECT 'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)) AS je" + ",convert(decimal(18,2),round(SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,'' as SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='' or ACCOUNTRMB is NULL) and (ACCOUNTUSD='' OR ACCOUNTUSD is NULL)" + " and gid_s in (" + sGids.Trim() + ") "; string strls = sISEXPLAN.Trim();//strISEXPLAN.Trim() + if (strls.Trim() != "") { strls = strls.Trim().Substring(1); sqlCASHCE += " GROUP BY " + strls;//BILLNO,SETTLETYPE sqlCASHCE += " ORDER BY " + strls;//BILLNO } } #endregion #region 银行账户 if (dsBank != null) { for (int i = 0; i < dsBank.Tables[0].Rows.Count; i++) { #region 循环账户 #region 核算科目 sISEXPLAN = strISMGSC; //是否核算客户 if (dsBank.Tables[0].Rows[i]["ISCORPACC"].ToString().Trim() == "True") { if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() != "True") { sISEXPLAN += ",CUSTOMERNAME";//是否委托单位 } } //是否核算人员 if (dsBank.Tables[0].Rows[i]["ISEMPLACC"].ToString().Trim() == "True") { sISEXPLAN += ",SALE";//是否揽货人 } //是否核算部门 if (dsBank.Tables[0].Rows[i]["ISDEPTACC"].ToString().Trim() == "True") { sISEXPLAN += ",DEPTGID";//是否揽货人的部门 } //是否核算项目 if (dsBank.Tables[0].Rows[i]["ISITEMACC"].ToString().Trim() == "True") { if (dsCwDesignItem != null) { sISEXPLAN += ",OPLBNAME";//是否核算项目 } } #endregion //ISFCY 是否核算外币 if (dsBank.Tables[0].Rows[i]["ISFCY"].ToString().Trim() == "True") { sqlBankCE = "SELECT ACCOUNTRMB,ACCOUNTUSD,CURRENCY,(case when CURRENCY='RMB' then 1 else convert(numeric(8,5),round(SUM(hj)/SUM(je),5)) END) as EXCHANGERATE,SUM(je) AS je,SUM(hj) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " from (" + "SELECT ACCOUNTRMB,ACCOUNTUSD,CURRENCY,1 as EXCHANGERATE" + ",SUM((case when FEETYPE=1 then AMOUNT else (-AMOUNT) end)) AS je" + ",convert(decimal(18,2),round(SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "' or ACCOUNTUSD='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "')" + " and gid_s in (" + sGids.Trim() + ") " + " GROUP BY ACCOUNTRMB,ACCOUNTUSD,EXCHANGERATE,CURRENCY" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + ") as a" + " GROUP BY ACCOUNTRMB,ACCOUNTUSD,EXCHANGERATE,CURRENCY" + sISEXPLAN//,BILLNO,SETTLETYPE + strISEXPLAN + " ORDER BY CURRENCY" + sISEXPLAN;// + strISEXPLAN } else { sqlBankCE = "SELECT ACCOUNTRMB,ACCOUNTUSD,'RMB' as CURRENCY,1 as EXCHANGERATE" + ",SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)) AS je" + ",convert(decimal(18,2),round(SUM((case when FEETYPE=1 then ORIGAMOUNT else (-ORIGAMOUNT) end)*" + tbRATE + "),2)) AS hj" + sISEXPLAN//,SETTLETYPE+ strISEXPLAN + " From VW_ch_fee_settlement_do WHERE 1=1 and (ACCOUNTRMB='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "' or ACCOUNTUSD='" + dsBank.Tables[0].Rows[i]["BankGid"].ToString().Trim() + "')" + " and gid_s in (" + sGids.Trim() + ") "; sqlBankCE += " GROUP BY ACCOUNTRMB,ACCOUNTUSD" + sISEXPLAN.Trim();//strISEXPLAN.Trim() + sqlBankCE += " ORDER BY ACCOUNTRMB,ACCOUNTUSD" + sISEXPLAN.Trim();//strISEXPLAN.Trim() + } alBankCE.Add(sqlBankCE); #endregion } } #endregion } #endregion #region 数据集 DataSet dsVwcfsdAR = T_ALL_DA.GetAllSQL(sqlAR); DataSet dsVwcfsdARFC = null; if (sqlARFC.Trim() != "") { dsVwcfsdARFC = T_ALL_DA.GetAllSQL(sqlARFC); } DataSet dsVwcfsdAP = T_ALL_DA.GetAllSQL(sqlAP); DataSet dsVwcfsdAPFC = null; if (sqlAPFC.Trim() != "") { dsVwcfsdAPFC = T_ALL_DA.GetAllSQL(sqlAPFC); } DataSet dsVwcfsdCASH = null; if (sqlCASH.Trim() != "") { dsVwcfsdCASH = T_ALL_DA.GetAllSQL(sqlCASH); } if (alBank != null) { if (alBank.Count > 0) { for (int i = 0; i < alBank.Count; i++) { DataSet dsVwcfsdBank = null; if (alBank[i].ToString().Trim() != "")//sqlBank { dsVwcfsdBank = T_ALL_DA.GetAllSQL(alBank[i].ToString().Trim());//sqlBank if (dsVwcfsdBank != null) { if (dsVwcfsdBank.Tables[0].Rows.Count > 0) { alBankDs.Add(dsVwcfsdBank); } } } } } } DataSet dsVwcfsdCASHCE = null; if (sqlCASHCE.Trim() != "") { dsVwcfsdCASHCE = T_ALL_DA.GetAllSQL(sqlCASHCE); } if (alBankCE != null) { if (alBankCE.Count > 0) { for (int i = 0; i < alBankCE.Count; i++) { DataSet dsVwcfsdBankCE = null; if (alBankCE[i].ToString().Trim() != "")//sqlBankCE { dsVwcfsdBankCE = T_ALL_DA.GetAllSQL(alBankCE[i].ToString().Trim());//sqlBankCE if (dsVwcfsdBankCE != null) { if (dsVwcfsdBankCE.Tables[0].Rows.Count > 0) { alBankDsCE.Add(dsVwcfsdBankCE); } } } } } } #endregion #endregion if (dsVwcfsdAR != null || dsVwcfsdARFC != null || dsVwcfsdAP != null || dsVwcfsdAPFC != null) { if (dsCwDesign.Tables[0].Rows[0]["ISARMBSPENDING"].ToString().Trim() == "True") { #region 插入明细表:应收RMB dsAR(ARMBSPENDING) if (dsVwcfsdAR != null) { if (dsVwcfsdAR.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAR.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否申请单号 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["ARMBSPENDING"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsARMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsARMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsARMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsARMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsARMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsARMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsARMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAR.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsARMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAR.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsARMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAR.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAR.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsARMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAR.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsARMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要 MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表:应收外币 dsARFC(ARTMSFC) if (dsVwcfsdARFC != null) { if (dsVwcfsdARFC.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdARFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否收付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否收付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否收付业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否收付结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否收付申请单号 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["ARTMSFC"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVwcfsdARFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsARTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsARTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsARTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsARTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsARTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsARTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsARTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdARFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsARTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdARFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsARTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdARFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdARFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsARTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdARFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsARTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion } else { #region 插入明细表:应收RMB dsAR if (dsVwcfsdAR != null) { if (dsVwcfsdAR.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAR.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAR.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否申请单号 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AR"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdAR.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAR.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAR.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAR.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAR.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAR.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAR.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAR.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAR.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAR.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAR.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAR.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAR.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要 MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAR.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表:应收外币 dsARFC if (dsVwcfsdARFC != null) { if (dsVwcfsdARFC.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdARFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否收付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否收付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否收付业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否收付结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdARFC.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否收付申请单号 } #endregion #region 插入明细表 应收账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应收账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["ARFC"].ToString().Trim();//应收账款科目贷码 MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVwcfsdARFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsARFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsARFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsARFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdARFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsARFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdARFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsARFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdARFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdARFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsARFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdARFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsARFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdARFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdARFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion } if (dsCwDesign.Tables[0].Rows[0]["ISAPMBSPENDING"].ToString().Trim() == "True") { #region 插入明细表:应付RMB dsAP(APMBSPENDING) if (dsVwcfsdAP != null) { if (dsVwcfsdAP.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAP.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否申请单号 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTCR = iAMTCR + Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APMBSPENDING"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBF += Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAPMBSPENDING.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAPMBSPENDING.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAPMBSPENDING.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAP.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAP.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAP.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAPMBSPENDING.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAP.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPMBSPENDING.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();// } MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表:应付外币 dsAPFC(APTMSFC) if (dsVwcfsdAPFC != null) { if (dsVwcfsdAPFC.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAPFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否收付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否收付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否收付业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否收付结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否收付申请单号 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APTMSFC"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVwcfsdAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAPTMSFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAPTMSFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAPTMSFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAPTMSFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAPFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAPTMSFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAPFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAPFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAPTMSFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAPFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPTMSFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion } else { #region 插入明细表:应付RMB dsAP if (dsVwcfsdAP != null) { if (dsVwcfsdAP.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAP.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BILLNO"].ToString().Trim();//是否结算单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAP.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否申请单号 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTCR = iAMTCR + Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["AP"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = "RMB";//外币编号usd MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBF += Decimal.Parse(dsVwcfsdAP.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAP.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAP.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAP.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAP.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAP.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAP.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAP.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAP.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAP.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAP.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAP.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要,规则生成 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAP.Tables[0].Rows[i]["MBLNO"].ToString().Trim();// } MsCwVouitemsGl.FCYEXRATE = 1;//汇率 dEXCHANGERATE = 1;//汇率 if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表:应付外币 dsAPFC if (dsVwcfsdAPFC != null) { if (dsVwcfsdAPFC.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdAPFC.Tables[0].Rows.Count; i++) { #region 摘要内容 strEXPLAN = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPCLIENTNAME"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISRPCUSTNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTNO"].ToString().Trim();//是否收付委托编号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim();//是否收付主提单号 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVESSEL"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["VESSEL"].ToString().Trim();//是否收付船名 } if (dsCwDesign.Tables[0].Rows[0]["ISRPVOYNO"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["VOYNO"].ToString().Trim();//是否收付航次 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBSSOURCE"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim();//是否收付业务来源 } if (dsCwDesign.Tables[0].Rows[0]["ISRPBILLNO_ACAD"].ToString().Trim() == "True") { strEXPLAN += " " + dsVwcfsdAPFC.Tables[0].Rows[i]["BILLNO_ACAD"].ToString().Trim();//是否收付申请单号 } #endregion #region 插入明细表 应付账款 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;// 行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 #region 应付账款 iAMTDR = iAMTDR + Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim()); // MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["APFC"].ToString().Trim();//应付账款科目贷码 MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYNO = dsVwcfsdAPFC.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币 strFCY = MsCwVouitemsGl.FCYNO; MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 dRMBS += Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) // MsCwVouitemsGl.ACCNAME = dsAPFC.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 if (dsAPFC.Tables[0].Rows[0]["DC"].ToString().Trim() == "借") { MsCwVouitemsGl.DC = "D";//借方向 } else { MsCwVouitemsGl.DC = "C";//贷方向 } // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsAPFC.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdAPFC.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsAPFC.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdAPFC.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsAPFC.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdAPFC.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdAPFC.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsAPFC.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdAPFC.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsAPFC.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.EXPLAN = strEXPLAN;//摘要 strIsExplan2 = strEXPLAN;//摘要,规则生成 MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdAPFC.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = MsCwVouitemsGl.FCYEXRATE;//汇率 MsCwVouitemsGl.BLNO = ""; if (dsCwDesign.Tables[0].Rows[0]["ISRPMBLNO"].ToString().Trim() == "True") { MsCwVouitemsGl.BLNO = dsVwcfsdAPFC.Tables[0].Rows[i]["MBLNO"].ToString().Trim(); } if (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim() == "True") { MsCwVouitemsGl.ISSYS = false;//是否手动录入 } else { MsCwVouitemsGl.ISSYS = true;//是否手动录入 } #endregion MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//部门(系统) MsCwVouitemsGl.EMPLID = "";//人员(系统) MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion } #region 现金、账户 /* Decimal dRMB = dRMBS - dRMBF; Decimal dUSD = dUSDS - dUSDF; //收入\成本 生成 全额\差额 strJie = strJie + dRMBS + dUSDS * dEXCHANGERATE; strDai = strDai + dRMBF + dUSDF * dEXCHANGERATE; #region 插入明细表 现金_全额 if (dsVwcfsdCASH != null) { if (dsVwcfsdCASH.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdCASH.Tables[0].Rows.Count; i++) { if (dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim() == "") { continue; } #region 插入明细表 现金_全额 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["CASH"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsCASH.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 // if (dsVwcfsdCASH.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款") { if (dsVwcfsdCASH.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { MsCwVouitemsGl.AMTDR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = true;//是否外币 MsCwVouitemsGl.FCYDR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 MsCwVouitemsGl.FCYCR = 0;//外币借方金额 } MsCwVouitemsGl.DC = "D";//贷方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else if (dsVwcfsdCASH.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款") { if (dsVwcfsdCASH.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = true;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币贷方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 } MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.FCYNO = dsVwcfsdCASH.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = Decimal.Parse(dsVwcfsdCASH.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdCASH.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdCASH.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdCASH.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdCASH.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdCASH.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsCASH.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.BLNO = ""; MsCwVouitemsGl.EXPLAN = strIsExplan2;//摘要,规则生成ALL // MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//strDEPTID;//部门(系统) MsCwVouitemsGl.EMPLID = "";//strEMPLID;//人员(系统) MsCwVouitemsGl.SALE = "";//strSALE;//人员名称 MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.ISSYS = true;//是否手动录入 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表 现金_差额 if (dsVwcfsdCASHCE != null) { if (dsVwcfsdCASHCE.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsVwcfsdCASHCE.Tables[0].Rows.Count; i++) { if (dsVwcfsdCASHCE.Tables[0].Rows[i]["hj"].ToString().Trim() == "") { continue; } #region 插入明细表 现金_差额 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["CASH"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsCASH.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 // if (dsVwcfsdCASHCE.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { Decimal dlhj = Decimal.Parse(dsVwcfsdCASHCE.Tables[0].Rows[i]["hj"].ToString().Trim()); if (dlhj >= 0) { MsCwVouitemsGl.AMTDR = dlhj;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + dlhj; MsCwVouitemsGl.DC = "D";//贷方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = (-dlhj);//本位币借方金额(互斥) strJie = strJie + (-dlhj); MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { Decimal dlhj = Decimal.Parse(dsVwcfsdCASHCE.Tables[0].Rows[i]["hj"].ToString().Trim()); Decimal dlje = Decimal.Parse(dsVwcfsdCASHCE.Tables[0].Rows[i]["je"].ToString().Trim()); if (dlhj >= 0) { MsCwVouitemsGl.AMTDR = dlhj;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + dlhj; MsCwVouitemsGl.FCYDR = dlje;//外币贷方金额 MsCwVouitemsGl.FCYCR = 0;//外币借方金额 MsCwVouitemsGl.DC = "D";//贷方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = (-dlhj);//本位币借方金额(互斥) strJie = strJie + (-dlhj); MsCwVouitemsGl.FCYDR = 0;//外币贷方金额 MsCwVouitemsGl.FCYCR = (-dlje);//外币借方金额 MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.ISFCY = true;//是否外币 } // MsCwVouitemsGl.FCYNO = dsVwcfsdCASHCE.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(dsVwcfsdCASHCE.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = Decimal.Parse(dsVwcfsdCASHCE.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目 // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = dsVwcfsdCASHCE.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = dsVwcfsdCASHCE.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = dsVwcfsdCASHCE.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + dsVwcfsdCASHCE.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int j = 0; j < dsCwDesignItem.Tables[0].Rows.Count; j++) { if (dsVwcfsdCASHCE.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[j]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[j]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[j]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(dsCASH.Tables[0].Rows[0]["PACCGID"].ToString(), MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.BLNO = ""; MsCwVouitemsGl.EXPLAN = strIsExplan2;//摘要,规则生成ALL // MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//strDEPTID;//部门(系统) MsCwVouitemsGl.EMPLID = "";//strEMPLID;//人员(系统) MsCwVouitemsGl.SALE = "";//strSALE;//人员名称 MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.ISSYS = true;//是否手动录入 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } } } #endregion #region 插入明细表 账户_全额 if (alBankDs != null) { if (alBankDs.Count > 0) { for (int j = 0; j < alBankDs.Count; j++) { DataSet ds = (DataSet)alBankDs[j]; if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { #region 插入明细表 现金_全额 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["hj"].ToString().Trim() == "") { continue; } #region 插入明细表 现金_全额 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["CASH"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsCASH.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 string lsPACCGID = dsCASH.Tables[0].Rows[0]["PACCGID"].ToString().Trim(); if (dsBank != null) { if (dsBank.Tables[0].Rows.Count > 0) { for (int k = 0; k < dsBank.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() == dsBank.Tables[0].Rows[k]["BankGid"].ToString().Trim() || ds.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() == dsBank.Tables[0].Rows[k]["BankGid"].ToString().Trim()) { MsCwVouitemsGl.ACCID = dsBank.Tables[0].Rows[k]["ACCID"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsBank.Tables[0].Rows[k]["ACCNAME"].ToString().Trim();//科目名称 lsPACCGID = dsBank.Tables[0].Rows[0]["PACCGID"].ToString().Trim(); } } } } // if (ds.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应收账款") { if (ds.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { MsCwVouitemsGl.AMTDR = Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { MsCwVouitemsGl.AMTDR = 0;//本位币借方金额(互斥)Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = true;//是否外币 MsCwVouitemsGl.FCYDR = Decimal.Parse(ds.Tables[0].Rows[i]["je"].ToString().Trim());//外币贷方金额 MsCwVouitemsGl.FCYCR = 0;//外币借方金额 } MsCwVouitemsGl.DC = "D";//贷方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else if (ds.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "应付账款") { if (ds.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim());//本位币借方金额(互斥) strJie = strJie + Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); MsCwVouitemsGl.ISFCY = true;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币贷方金额 MsCwVouitemsGl.FCYCR = Decimal.Parse(ds.Tables[0].Rows[i]["je"].ToString().Trim());//外币借方金额 } MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.FCYNO = ds.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(ds.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = Decimal.Parse(ds.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门,按规则设置生成 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员,按规则设置生成 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户,按规则设置生成 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目,按规则设置生成 // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = ds.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = ds.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = ds.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + ds.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int k = 0; k < dsCwDesignItem.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[k]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[k]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[k]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(lsPACCGID, MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.BLNO = ""; MsCwVouitemsGl.EXPLAN = strIsExplan2;//摘要,规则生成ALL // MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//strDEPTID;//部门(系统) MsCwVouitemsGl.EMPLID = "";//strEMPLID;//人员(系统) MsCwVouitemsGl.SALE = "";//strSALE;//人员名称 MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.ISSYS = true;//是否手动录入 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } #endregion } } } } } #endregion #region 插入明细表 账户_差额 if (alBankDsCE != null) { if (alBankDsCE.Count > 0) { for (int j = 0; j < alBankDsCE.Count; j++) { DataSet ds = (DataSet)alBankDsCE[j]; if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { #region 插入明细表 账户_差额 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["hj"].ToString().Trim() == "") { continue; } #region 插入明细表 账户_差额 MsCwVouitemsGl MsCwVouitemsGl = new MsCwVouitemsGl(); //MsCwVouitemsGl.GID 唯一编码 newid() MsCwVouitemsGl.ORDNO = strORDNO.Trim(); MsCwVouitemsGl.ITEMNO = 0;//行号 MsCwVouitemsGl.PACCID = "";//父级科目贷码 MsCwVouitemsGl.PROPERTY = 0;//科目属性 MsCwVouitemsGl.GRADE = 0;//科目级别 MsCwVouitemsGl.ACCID = dsCwDesign.Tables[0].Rows[0]["CASH"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsCASH.Tables[0].Rows[0]["ACCNAME"].ToString().Trim();//科目名称 string lsPACCGID = dsCASH.Tables[0].Rows[0]["PACCGID"].ToString().Trim(); if (dsBank != null) { if (dsBank.Tables[0].Rows.Count > 0) { for (int k = 0; k < dsBank.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[i]["ACCOUNTRMB"].ToString().Trim() == dsBank.Tables[0].Rows[k]["BankGid"].ToString().Trim() || ds.Tables[0].Rows[i]["ACCOUNTUSD"].ToString().Trim() == dsBank.Tables[0].Rows[k]["BankGid"].ToString().Trim()) { MsCwVouitemsGl.ACCID = dsBank.Tables[0].Rows[k]["ACCID"].ToString().Trim();//科目代码 MsCwVouitemsGl.ACCNAME = dsBank.Tables[0].Rows[k]["ACCNAME"].ToString().Trim();//科目名称 lsPACCGID = dsBank.Tables[0].Rows[0]["PACCGID"].ToString().Trim(); } } } } // if (ds.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() == "RMB") { Decimal dlhj = Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); if (dlhj >= 0) { MsCwVouitemsGl.AMTDR = dlhj;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + dlhj; MsCwVouitemsGl.DC = "D";//贷方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = (-dlhj);//本位币借方金额(互斥) strJie = strJie + (-dlhj); MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.ISFCY = false;//是否外币 MsCwVouitemsGl.FCYDR = 0;//外币借方金额 MsCwVouitemsGl.FCYCR = 0;//外币贷方金额 } else { Decimal dlhj = Decimal.Parse(ds.Tables[0].Rows[i]["hj"].ToString().Trim()); Decimal dlje = Decimal.Parse(ds.Tables[0].Rows[i]["je"].ToString().Trim()); if (dlhj >= 0) { MsCwVouitemsGl.AMTDR = dlhj;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = 0;//本位币借方金额(互斥) strDai = strDai + dlhj; MsCwVouitemsGl.FCYDR = dlje;//外币贷方金额 MsCwVouitemsGl.FCYCR = 0;//外币借方金额 MsCwVouitemsGl.DC = "D";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BRTW"].ToString().Trim(); } else { MsCwVouitemsGl.AMTDR = 0;//本位币贷方金额(互斥) MsCwVouitemsGl.AMTCR = (-dlhj);//本位币借方金额(互斥) strJie = strJie + (-dlhj); MsCwVouitemsGl.FCYDR = 0;//外币贷方金额 MsCwVouitemsGl.FCYCR = (-dlje);//外币借方金额 MsCwVouitemsGl.DC = "C";//借方向 strBPVW = dsCwDesign.Tables[0].Rows[0]["BPVW"].ToString().Trim(); } MsCwVouitemsGl.ISFCY = true;//是否外币 } // MsCwVouitemsGl.FCYNO = ds.Tables[0].Rows[i]["CURRENCY"].ToString().Trim();//外币编号usd MsCwVouitemsGl.FCYEXRATE = Decimal.Parse(ds.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 dEXCHANGERATE = Decimal.Parse(ds.Tables[0].Rows[i]["EXCHANGERATE"].ToString().Trim());//汇率 MsCwVouitemsGl.ISDEPTACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim());//核算部门 MsCwVouitemsGl.ISEMPLACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim());//核算人员 MsCwVouitemsGl.ISCORPACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim());//核算客户 MsCwVouitemsGl.ISITEMACC = Boolean.Parse(dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim());//核算项目 // string strACCALL = ""; //是否核算客户 MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = "";//客户(系统) if (dsCASH.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True") { MsCwVouitemsGl.CORPID = "";//客户(系统) MsCwVouitemsGl.CUSTOMERNAME = ds.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim();//客户(系统) strACCALL += "▁" + MsCwVouitemsGl.CUSTOMERNAME; } //是否核算人员_揽货人 if (dsCASH.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True") { MsCwVouitemsGl.SALE = ds.Tables[0].Rows[i]["SALE"].ToString().Trim();//人员名称 strACCALL += "▁" + MsCwVouitemsGl.SALE; } //是否核算部门 if (dsCASH.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True") { MsCwVouitemsGl.DEPTGID = ds.Tables[0].Rows[i]["DEPTGID"].ToString().Trim();//揽货人的部门 strACCALL += "▁" + ds.Tables[0].Rows[i]["DEPTNAME"].ToString().Trim(); } //是否核算项目 if (dsCASH.Tables[0].Rows[0]["ISITEMACC"].ToString().Trim() == "True") { MsCwVouitemsGl.ITEMGID = ""; if (dsCwDesignItem != null) { for (int k = 0; k < dsCwDesignItem.Tables[0].Rows.Count; k++) { if (ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim() == dsCwDesignItem.Tables[0].Rows[k]["OPTYPE"].ToString().Trim()) { MsCwVouitemsGl.ITEMGID = dsCwDesignItem.Tables[0].Rows[k]["ITEMGID"].ToString().Trim();//是否核算项目 strACCALL += "▁" + dsCwDesignItem.Tables[0].Rows[k]["ITEMNAME"].ToString().Trim(); } } } } MsCwVouitemsGl.ACCALL = BasicDataRefDAL.setCAGA(lsPACCGID, MsCwVouitemsGl.ACCNAME.ToString().Trim()) + strACCALL; MsCwVouitemsGl.BLNO = ""; MsCwVouitemsGl.EXPLAN = strIsExplan2;//摘要,规则生成ALL // MsCwVouitemsGl.QTYUNIT = "";//数量包装单位 MsCwVouitemsGl.QTYDR = 0;//借方数量 MsCwVouitemsGl.QTYCR = 0;//贷方数量 MsCwVouitemsGl.DEPTID = "";//strDEPTID;//部门(系统) MsCwVouitemsGl.EMPLID = "";//strEMPLID;//人员(系统) MsCwVouitemsGl.SALE = "";//strSALE;//人员名称 MsCwVouitemsGl.PITEMID = 0;//父级项目编号 MsCwVouitemsGl.ITEMID = "";//项目编号 MsCwVouitemsGl.FIELD1 = "";//预留字段1 MsCwVouitemsGl.FIELD2 = "";//预留字段2 MsCwVouitemsGl.FIELD3 = "";//预留字段3 MsCwVouitemsGl.FIELD4 = "";//预留字段4 MsCwVouitemsGl.FIELD5 = "";//预留字段5 MsCwVouitemsGl.FIELD6 = "";//预留字段6 MsCwVouitemsGl.FIELD7 = "";//预留字段7 MsCwVouitemsGl.FIELD8 = "";//预留字段8 MsCwVouitemsGl.FIELD9 = "";//预留字段9 MsCwVouitemsGl.FIELD10 = "";//预留字段10 MsCwVouitemsGl.ISSYS = true;//是否手动录入 MsCwVouitemsGl.FSETTLCODE = "";//结算方式 MsCwVouitemsGl.FSETTLENO = "";//财务辅助编号 MsCwVouitemsGl.FSETTLDATE = DateTime.Parse(DateTime.Parse(headData.VOUDATE).ToString("yyyy-MM-dd"));//结算日期 MsCwVouitemsGl.MODIFIEDUSER = strUserID;//最后一次更新操作人 #endregion CwVouitemsEntities.Add(MsCwVouitemsGl); } #endregion } } } } } #endregion */ #endregion #region 插入主表 MsCwVouchersGl MsCwVouchersGl = new MsCwVouchersGl(); MsCwVouchersGl.ORDNO = strORDNO;//唯一编码 newid() varchar (36) MsCwVouchersGl.VOUDATE = headData.VOUDATE;//凭证日期 MsCwVouchersGl.VOUNO = sVOUNO;//月初清零 varchar (16) MsCwVouchersGl.ACCYEAR = DateTime.Parse(headData.VOUDATE.ToString()).Year.ToString();//年 MsCwVouchersGl.ACCMONTH = DateTime.Parse(headData.VOUDATE.ToString()).Month.ToString();//月 if (MsCwVouchersGl.ACCMONTH.ToString().Length == 1) { MsCwVouchersGl.ACCMONTH = "0" + MsCwVouchersGl.ACCMONTH.ToString();//月 } MsCwVouchersGl.VKNO = sVKNO;//凭证字 MsCwVouchersGl.VOUALLNO = sVOUALLNO;//年+月+自动生成编号=凭证号 MsCwVouchersGl.ATTACHS = 1;// int.Parse(dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//附件(单据)数 MsCwVouchersGl.AMTDR = strJie;// iAMTDR;//本位币借方 MsCwVouchersGl.AMTCR = strDai;//iAMTDR;// iAMTCR;//本位币贷方 MsCwVouchersGl.FCY = strFCY;//是否含有外币科目 MsCwVouchersGl.QTY = "";//是否含有数量科目 MsCwVouchersGl.VOUPROP = "";//凭证属性 MsCwVouchersGl.PREPARED = headData.PREPARED.ToString().Trim();//制单人 MsCwVouchersGl.ISCHECKED = blISCHECKED; MsCwVouchersGl.CHECKED = sCHECKEDGID;//审核人 MsCwVouchersGl.CHECKEDTIME = dateCHECKEDTIME; MsCwVouchersGl.ENTERED = "";//记账人 MsCwVouchersGl.ERRMSG = "";//错误信息 MsCwVouchersGl.ISDELETE = false;//是否废除 MsCwVouchersGl.DELETEUSER = "";//废除操作人 MsCwVouchersGl.STARTGID = strCwSTARTGID; MsCwVouchersGl.DbOperationType = DbOperationType.DbotIns; #endregion #region 生成入库 var modb = new ModelObjectDB(); result = modb.Save(MsCwVouchersGl); if (result.Success == true) { //int n = 1; BasicDataRefDAL.SetGLOrder(ref CwVouitemsEntities); foreach (var enumValue in CwVouitemsEntities) { enumValue.GID = Guid.NewGuid().ToString(); //enumValue.ITEMNO = n;//行号 enumValue.DbOperationType = DbOperationType.DbotIns; var modb2 = new ModelObjectDB(); DBResult result2 = modb2.Save(enumValue); //n++; } //更新 string blSQL = "update cw_vouchers_gl set CHECKEDTIME='" + dateCHECKEDTIME + "',ISCHECKED='" + blISCHECKED + "' where ORDNO='" + strORDNO + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blSQL); //更新 blSQL = "UPDATE cw_vouchers_gl set amtdr=ISNULL((SELECT sum(amtdr) from cw_vouitems_gl where ORDNO=cw_vouchers_gl.ORDNO),0),amtcr=ISNULL((SELECT sum(amtcr) from cw_vouitems_gl where ORDNO=cw_vouchers_gl.ORDNO),0) where ORDNO='" + strORDNO + "'"; bl = T_ALL_DA.GetExecuteSqlCommand(blSQL); } else { //result.Success = false; //result.Message = result.Message; //return result; return -2;//重复数据 } #endregion } else { return -3;//结算无明细数据 } //result.Success = true; //result.Message = result.Message; //return result; return 1; } #endregion #endregion #region 解决总账凭证重新排序的问题(同时更新ch_fee、ch_fee_settlement中的关联的总账凭证号) protected void Button7_Click(object sender, EventArgs e) { string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID2); T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string sSQL = "SELECT VKNO,ACCYEAR,ACCMONTH FROM cw_vouchers_gl where STARTGID='" + strCwSTARTGID + "' group BY VKNO,ACCYEAR,ACCMONTH ORDER BY VKNO,ACCYEAR,ACCMONTH"; DataSet ds = T_ALL_DA.GetAllSQL(sSQL); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { for (int i=0; i 0) { for (int j = 0; j < dsVOUALLNO.Tables[0].Rows.Count; j++) { string oldVOUALLNO = dsVOUALLNO.Tables[0].Rows[j]["VOUALLNO"].ToString(); string sVOUNO = (j + 1).ToString(); string strVOUNO = (j + 1).ToString(); for (int n = 0; n < 4 - sVOUNO.Length; n++) { strVOUNO = "0" + strVOUNO; } string newVOUALLNO = dsVOUALLNO.Tables[0].Rows[j]["VKNO"].ToString() + dsVOUALLNO.Tables[0].Rows[j]["ACCYEAR"].ToString() + dsVOUALLNO.Tables[0].Rows[j]["ACCMONTH"].ToString() + strVOUNO; // if (oldVOUALLNO.Trim() != "") { sSQL = "UPDATE cw_vouchers_gl SET VOUALLNO='" + newVOUALLNO + "',VOUNO=" + (j + 1) + " where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + oldVOUALLNO + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL); sSQL = "UPDATE cw_vouno_bs_gl SET VOUCHERNO='" + newVOUALLNO + "' where STARTGID='" + strCwSTARTGID + "' and VOUALLNO='" + oldVOUALLNO + "'"; bl = T_ALL_DA.GetExecuteSqlCommand(sSQL); } } } } } } } Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", ""); return; } #endregion // } }