|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.UI;
|
|
|
using System.Web.UI.WebControls;
|
|
|
using System.Data;
|
|
|
using System.IO;
|
|
|
using DSWeb.EntityDA;
|
|
|
using System.Text;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.DataAccess;
|
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaiDAL;
|
|
|
|
|
|
namespace DSWeb.Reports
|
|
|
{
|
|
|
public partial class RptExport : System.Web.UI.Page
|
|
|
{
|
|
|
public string strUserID;//用户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)
|
|
|
{
|
|
|
strUserID = 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();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
string strGIDs = "";
|
|
|
string handle="";
|
|
|
string formname = "";
|
|
|
string condition1 = "";
|
|
|
string condition2 = "";
|
|
|
string condition3 = "";
|
|
|
string condition4 = "";
|
|
|
string condition5 = "";
|
|
|
string condition6 = "";
|
|
|
if (Request.QueryString["handle"] != null)
|
|
|
{
|
|
|
handle = Request.QueryString["handle"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["formname"] != null)
|
|
|
{
|
|
|
formname = Request.QueryString["formname"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition1"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition1 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition1"].ToString())));
|
|
|
//condition1 = Request.QueryString["condition1"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition2"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition2 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition2"].ToString())));
|
|
|
//condition2 = Request.QueryString["condition2"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition3"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition3 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition3"].ToString())));
|
|
|
//condition3 = Request.QueryString["condition3"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition4"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition4 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition4"].ToString())));
|
|
|
//condition4 = Request.QueryString["condition4"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition5"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition5 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition5"].ToString())));
|
|
|
//condition5 = Request.QueryString["condition5"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["condition6"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
condition6 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["condition6"].ToString())));
|
|
|
//condition6 = Request.QueryString["condition5"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["gids"] != null)
|
|
|
{
|
|
|
strGIDs = Request.QueryString["gids"].ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 调用函数
|
|
|
if (!IsPostBack)
|
|
|
{
|
|
|
if (handle.Trim() == "RptVwWmsStocktakeIndex")//导出_库存分段盘点_RptVwWmsStocktakeIndex.aspx
|
|
|
{
|
|
|
ExcelRptVwWmsStocktakeIndex(strGIDs, condition1, condition2, condition3, condition4, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsRptNoTotalIndex")
|
|
|
{
|
|
|
ExcelMsRptNoTotalIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsOpSeaiIndex")//导出_新海运进口委托列表_MsOpSeai_MsOpSeaiIndex.js
|
|
|
{
|
|
|
ExcelMsOpSeaiIndex(strGIDs, condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwGenlegAccitemsIndex")//导出_科目余额列表_RptCwGenlegAccitemsIndex.js
|
|
|
{
|
|
|
ExcelRptCwGenlegAccitemsIndex(condition1, condition2, condition3, condition4, condition5, condition6, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwGLIndex")//导出_科目总账_RptCwGLIndex.js
|
|
|
{
|
|
|
ExcelRptCwGLIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwSofpIndex")//导出_资产负债表列表_RptCwSofpIndex.aspx
|
|
|
{
|
|
|
ExcelRptCwSofpIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwPLIndex")//导出_资产负债表列表_RptCwSofpIndex.aspx
|
|
|
{
|
|
|
ExcelRptCwPLIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwGLDetailIndex")//导出_明细账_RptCwGLDetailIndex.js
|
|
|
{
|
|
|
ExcelRptCwGLDetailIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsCwVouchersGlIndex")//导出_总账凭证明细列表
|
|
|
{
|
|
|
ExcelMsCwVouchersGlIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsCwVouchersGlIndexHJ")//导出_总账凭证合计列表
|
|
|
{
|
|
|
ExcelMsCwVouchersGlIndexHJ(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwVouchersGlIndex")//凭证汇总表
|
|
|
{
|
|
|
ExcelRptCwVouchersGlIndex(condition1, condition2, condition3, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwGLDetailColumnIndex")//导出_多栏账_RptCwGLDetailColumnIndex.js
|
|
|
{
|
|
|
ExcelRptCwGLDetailColumnIndex(condition1, condition2, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCtGenlegAccitemsIndex")//导出_RptCtGenlegAccitemsIndex.js
|
|
|
{
|
|
|
ExcelRptCtGenlegAccitemsIndex(condition1, condition2, condition3, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCtGenlegAccitemsMonthIndex")//导出_RptCtGenlegAccitemsIndex.js
|
|
|
{
|
|
|
ExcelRptCtGenlegAccitemsMonthIndex(condition1, condition2, condition3, condition4, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCtBankJSCheckingIndex")//导出_RptCtBankJSCheckingIndex.js
|
|
|
{
|
|
|
ExcelRptCtBankJSCheckingIndex(condition1, condition2, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsCwVouchersIndex")//导出_接口凭证列表
|
|
|
{
|
|
|
ExcelMsCwVouchersIndex(condition1, strGIDs, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptCwCfsIndex")//导出_现金流量表
|
|
|
{
|
|
|
ExcelRptCwCfsIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsCwVouchersGlChFeeIndex")//导出_总账成本收入列表
|
|
|
{
|
|
|
ExcelMsCwVouchersGlChFeeIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "RptChFeeInvoiceDutyFreeIndex")//导出_免税明细列表
|
|
|
{
|
|
|
ExcelMsRptChFeeInvoiceDutyFreeIndex(condition1, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
else if (handle.Trim() == "MsCwVouchersGlIndex3")//导出_总账凭证_财务接口
|
|
|
{
|
|
|
ExcelMsCwVouchersGlIndex3(condition1, strGIDs, formname);
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>window.close();</script>");
|
|
|
}
|
|
|
//
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
#region 导出_库存分段盘点_RptVwWmsStocktakeIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_库存分段盘点_RptVwWmsStocktakeIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件1</param>
|
|
|
/// <param name="strCondition2">查询条件2</param>
|
|
|
/// <param name="strCondition3">查询条件3</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptVwWmsStocktakeIndex(string strGIDs, string strCondition, string strCondition2, string strCondition3, string strCondition4, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
if (strCondition.Trim() != "" || strCondition2.Trim() != "" || strCondition3.Trim() != "")
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = " and " + strCondition;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition2))
|
|
|
{
|
|
|
strCondition2 = " and " + strCondition2;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition3))
|
|
|
{
|
|
|
strCondition3 = " and " + strCondition3;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition4))
|
|
|
{
|
|
|
strCondition4 = " and " + strCondition4;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strGIDs))
|
|
|
{
|
|
|
strGIDs = " and GID in ('" + strGIDs.Trim().Replace(",","','") + "')";
|
|
|
}
|
|
|
|
|
|
//取个人配置的列顺序
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "";
|
|
|
string sSQL = "select * from IMPORT_TableCustomize where USERID='" + strUserID + "' and FORMNAME='" + formname + "' and hidden=0 order by DATAORDER";
|
|
|
DataSet dsITC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (dsITC != null)
|
|
|
{
|
|
|
if (dsITC.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dsITC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
strDataIndex += dsITC.Tables[0].Rows[i]["dataIndex"].ToString().Trim() + ",";//字段名称
|
|
|
strHeader += dsITC.Tables[0].Rows[i]["header"].ToString().Trim() + "\t";//中文名称
|
|
|
}
|
|
|
//
|
|
|
strDataIndex = strDataIndex.Trim().Substring(0, strDataIndex.Length - 1);//字段名称
|
|
|
strHeader = strHeader.Trim().Substring(0, strHeader.Length - 1);//中文名称
|
|
|
}
|
|
|
}
|
|
|
//没有设置个人配置,则取默认排列
|
|
|
if (strDataIndex.Trim() == "")
|
|
|
{
|
|
|
strDataIndex = "WMSDATE,CUSTOMERNAME,BLNO,STORAGENAME,GOODSNAME,GOODSMODEL,hj_GOODSRKSL,hj_GOODSPFSL_OUT,hj_GOODSPFSL_MONTH,hj_GOODSSTOCK,hj_GOODSPACK,hj_GOODSPACKPFSL,hj_GOODSPACKPFSL_MONTH,hj_GOODSPACKSTOCK, (SELECT CONTRACTNO FROM op_seai WHERE BSNO = ASSOCIATEDNO) CONTRACTNO,CHARGEUNIT,CUSTOMNO,GOODSGRADE,GOODSSLICE,GOODSSTANDARD,REMARK,hj_GOODSPACKACTUAL,hj_GOODSRKSLACTUAL,AREANAME";//字段名称
|
|
|
strHeader = "入库日期\t货主\t提单号\t仓库\t品名\t型号\t入库数量\t出库数量\t时间段出库数量\t库存数量\t入库件数\t出库件数\t时间段出库件数\t库存件数\t合同号\t计算单位\t备案清单号\t等级\t片数(件)\t规格\t备注\t实际件数\t实际数量\t库位";//中文名称
|
|
|
}
|
|
|
//
|
|
|
String strSql = "select " + strDataIndex
|
|
|
+ " from ("
|
|
|
+ "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
|
|
|
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
|
|
|
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
|
|
|
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
|
|
|
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
|
|
|
+ " from ("
|
|
|
+ "SELECT GID, CONVERT(char(10), WMSDATE, 120) AS WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSSTANDARD, '' AS REMARK, '' as GOODSGRADE, 0 as GOODSSLICE"
|
|
|
+ ", GOODSRKSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPFSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
|
|
|
+ ", GOODSPACK"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
|
|
|
+ ", GOODSPACKACTUAL, GOODSRKSLACTUAL, CORPID "
|
|
|
+ " FROM wms WHERE CHARGEUNIT <> 'CBM' AND ISDELETE = 0 " + strCondition
|
|
|
+ ") as A where 1=1 " + strCondition3 + strGIDs
|
|
|
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE"
|
|
|
+ " UNION ALL "
|
|
|
+ "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
|
|
|
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
|
|
|
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
|
|
|
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
|
|
|
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
|
|
|
+ " from ("
|
|
|
+ "SELECT i.GID, CONVERT(char(10), w.WMSDATE, 120) AS WMSDATE"
|
|
|
+ ", w.CUSTOMERNAME, w.BLNO, w.STORAGENAME, w.AREANAME, w.GOODSNAME, i.GOODSMODEL, w.ASSOCIATEDNO, w.CONTRACTNO, w.CHARGEUNIT, w.CUSTOMNO, i.GOODSGRADE, i.GOODSSLICE, i.GOODSSTANDARD, '' as REMARK"
|
|
|
+ ", i.GOODSRKSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPFSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
|
|
|
+ ", i.GOODSPACK"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
|
|
|
+ ", i.GOODSPACKACTUAL, i.GOODSRKSLACTUAL, w.CORPID "
|
|
|
+ " FROM wms_in AS i LEFT OUTER JOIN wms AS w ON i.ASSOCIATEDNO = w.GID WHERE i.CHARGEUNIT = 'CBM' AND i.ISDELETE = 0 " + strCondition
|
|
|
+ ") as A where 1=1 " + strCondition3 + strGIDs
|
|
|
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE"
|
|
|
+ " UNION ALL "
|
|
|
+ "select '总计:' as GID, '' as WMSDATE, '总计:' as CUSTOMERNAME, '' as BLNO, '' as STORAGENAME, '' as AREANAME, '' as GOODSNAME, '' as GOODSMODEL, '' as ASSOCIATEDNO, '' as CONTRACTNO, '' as CHARGEUNIT, '' as CUSTOMNO, '' as GOODSGRADE, 0 AS GOODSSLICE, '' as GOODSSTANDARD, '' AS REMARK"
|
|
|
+ ", ISNULL(sum(hj_GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
|
|
|
+ ", ISNULL(SUM(hj_GOODSPFSL_OUT), 0) AS hj_GOODSPFSL_OUT"//出库量
|
|
|
+ ", ISNULL(SUM(hj_GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
|
|
|
+ ", ISNULL(sum(hj_GOODSSTOCK), 0) AS hj_GOODSSTOCK"//库存量
|
|
|
+ ", ISNULL(sum(hj_GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
|
|
|
+ ", ISNULL(SUM(hj_GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
|
|
|
+ ", ISNULL(SUM(hj_GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
|
|
|
+ ", ISNULL(sum(hj_GOODSPACKSTOCK), 0) AS hj_GOODSPACKSTOCK"//剩余件数
|
|
|
+ ", ISNULL(sum(hj_GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
|
|
|
+ ", ISNULL(sum(hj_GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
|
|
|
+ " from ("
|
|
|
+ "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
|
|
|
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
|
|
|
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
|
|
|
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
|
|
|
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
|
|
|
+ " from ("
|
|
|
+ "SELECT GID, CONVERT(char(10), WMSDATE, 120) AS WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSSTANDARD, '' AS REMARK, '' as GOODSGRADE, 0 as GOODSSLICE"
|
|
|
+ ", GOODSRKSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPFSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
|
|
|
+ ", GOODSPACK"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=wms.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
|
|
|
+ ", GOODSPACKACTUAL, GOODSRKSLACTUAL, CORPID "
|
|
|
+ " FROM wms WHERE CHARGEUNIT <> 'CBM' AND ISDELETE = 0 " + strCondition
|
|
|
+ ") as A where 1=1 " + strCondition3 + strGIDs
|
|
|
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE"
|
|
|
+ " UNION ALL "
|
|
|
+ "select GID, WMSDATE, CUSTOMERNAME, BLNO, STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, ISNULL(GOODSSLICE, 0) AS GOODSSLICE, GOODSSTANDARD, '' AS REMARK"
|
|
|
+ ", ISNULL(sum(GOODSRKSL), 0) AS hj_GOODSRKSL"//入库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL), 0) AS hj_GOODSPFSL_OUT"//出库量
|
|
|
+ ", ISNULL(SUM(GOODSPFSL_MONTH), 0) AS hj_GOODSPFSL_MONTH"//出库量_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSRKSL), 0)-ISNULL(SUM(GOODSPFSL), 0)),0) AS hj_GOODSSTOCK"//入库量-出库量=库存量
|
|
|
+ ", ISNULL(sum(GOODSPACK), 0) AS hj_GOODSPACK"//入库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL), 0) AS hj_GOODSPACKPFSL"//出库件数
|
|
|
+ ", ISNULL(SUM(GOODSPACKPFSL_MONTH), 0) AS hj_GOODSPACKPFSL_MONTH"//出库件数_区间
|
|
|
+ ", ISNULL((ISNULL(sum(GOODSPACK), 0)-ISNULL(SUM(GOODSPACKPFSL), 0)),0) AS hj_GOODSPACKSTOCK"//入库件数-出库件数=剩余件数
|
|
|
+ ", ISNULL(sum(GOODSPACKACTUAL), 0) AS hj_GOODSPACKACTUAL"//实际件数
|
|
|
+ ", ISNULL(sum(GOODSRKSLACTUAL), 0) AS hj_GOODSRKSLACTUAL"//实际数量
|
|
|
+ " from ("
|
|
|
+ "SELECT i.GID, CONVERT(char(10), w.WMSDATE, 120) AS WMSDATE"
|
|
|
+ ", w.CUSTOMERNAME, w.BLNO, w.STORAGENAME, w.AREANAME, w.GOODSNAME, i.GOODSMODEL, w.ASSOCIATEDNO, w.CONTRACTNO, w.CHARGEUNIT, w.CUSTOMNO, i.GOODSGRADE, i.GOODSSLICE, i.GOODSSTANDARD, '' as REMARK"
|
|
|
+ ", i.GOODSRKSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPFSL"
|
|
|
+ ", isnull((select sum(GOODSPFSL) as GOODSPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPFSL_MONTH"
|
|
|
+ ", i.GOODSPACK"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition4 + "),0) as GOODSPACKPFSL"
|
|
|
+ ", isnull((select sum(GOODSPACKPFSL) as GOODSPACKPFSL from wms_out_detail where INBSNO=i.GID " + strCondition2 + "),0) as GOODSPACKPFSL_MONTH"
|
|
|
+ ", i.GOODSPACKACTUAL, i.GOODSRKSLACTUAL, w.CORPID "
|
|
|
+ " FROM wms_in AS i LEFT OUTER JOIN wms AS w ON i.ASSOCIATEDNO = w.GID WHERE i.CHARGEUNIT = 'CBM' AND i.ISDELETE = 0 " + strCondition
|
|
|
+ ") as A where 1=1 " + strCondition3 + strGIDs
|
|
|
+ " GROUP BY GID,CUSTOMERNAME, STORAGENAME, AREANAME, BLNO, GOODSNAME, GOODSMODEL, ASSOCIATEDNO, CONTRACTNO, CHARGEUNIT, CUSTOMNO, GOODSGRADE, GOODSSLICE, GOODSSTANDARD, GOODSRKSL, GOODSPACK, GOODSPACKACTUAL, GOODSRKSLACTUAL, WMSDATE) as C"
|
|
|
+ ") as B "
|
|
|
+ " order by CUSTOMERNAME,STORAGENAME, AREANAME, GOODSNAME, GOODSMODEL, WMSDATE, BLNO";
|
|
|
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_欠费统计报表_MsRptNoTotalIndex
|
|
|
/// <summary>
|
|
|
/// 导出_欠费统计报表_MsRptNoTotalIndex
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件1</param>
|
|
|
/// <param name="strCondition2">查询条件2</param>
|
|
|
/// <param name="strCondition3">查询条件3</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsRptNoTotalIndex(string strCondition,string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
if (strCondition.Trim() != "")
|
|
|
{
|
|
|
//取个人配置的列顺序
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "";
|
|
|
string sSQL = "select * from IMPORT_TableCustomize where USERID='" + strUserID + "' and FORMNAME='" + formname + "' and hidden=0 order by DATAORDER";
|
|
|
DataSet dsITC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (dsITC != null)
|
|
|
{
|
|
|
if (dsITC.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dsITC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
strDataIndex += dsITC.Tables[0].Rows[i]["dataIndex"].ToString().Trim() + ",";//字段名称
|
|
|
strHeader += dsITC.Tables[0].Rows[i]["header"].ToString().Trim() + "\t";//中文名称
|
|
|
}
|
|
|
//
|
|
|
strDataIndex = strDataIndex.Trim().Substring(0, strDataIndex.Length - 1);//字段名称
|
|
|
strHeader = strHeader.Trim().Substring(0, strHeader.Length - 1);//中文名称
|
|
|
}
|
|
|
}
|
|
|
//没有设置个人配置,则取默认排列
|
|
|
if (strDataIndex.Trim() == "")
|
|
|
{
|
|
|
strDataIndex = "CUSTNAME,OPLBNAME,BSTYPE,OPDATE,CUSTOMDATE,CUSTOMERNAME,CUSTNO, ENTERP,MBLNO,HBLNO,ETD,VESSEL,VOYNO,SALE,OP,PORTLOAD,PORTDISCHARGE,ACCDATE,"
|
|
|
+"CARRIER,BSSOURCE,TEU, KGS, GOODSNAME, RMBDR,STLRMBDR, BALRMBDR,USDDR,STLUSDDR, BALUSDDR, OTDR, STLOTDR,BALOTDR,TTLDR, STLTTLDR,BALTTLDR,"
|
|
|
+ "RMBCR,STLRMBCR,BALRMBCR,USDCR,STLUSDCR,BALUSDCR,OTCR,STLOTCR,BALOTCR,TTLCR,STLTTLCR,BALTTLCR";//字段名称
|
|
|
|
|
|
strHeader = "结算客户\t业务类型\t运输类型\t业务日期\t报关日期\t委托单位\t委托编号\t经营单位\t主提单号\t分提单号\t开船日期\t船名\t航次\t业务员\t操作\t起运港\t目的港"
|
|
|
+ "\t会计期间\t船公司\t业务来源\tTEU\tKGS\tGOODSNAME\tRMB应收\tRMB已收\tRMB未收\tUSD应收\tUSD已收\tUSD未收\t其他币别应收\t其他币别已收\t其他币别未收\t合计应收\t合计已收\t合计未收"
|
|
|
+ "\tRMB应付\tRMB已付\tRMB未付\tUSD应付\tUSD已付\tUSD未付\t其他币别应付\t其他币别已付\t其他币别未付\t合计应付\t合计已付\t合计未付";//中文名称
|
|
|
}
|
|
|
//
|
|
|
String strSql = "select " + strDataIndex
|
|
|
+ " from ("
|
|
|
+ "SELECT B.BSNO,F.CUSTOMERNAME AS CUSTNAME,B.OPLBNAME, B.BSTYPE"
|
|
|
+ ",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE"
|
|
|
+ ",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE"
|
|
|
|
|
|
+ ",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO"
|
|
|
+ ",case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD"
|
|
|
+ ",B.VESSEL, B.VOYNO,B.SALE, B.OP"
|
|
|
+ ",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS"
|
|
|
+ ",B.GOODSNAME"
|
|
|
+ ",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS TTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS TTLCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLCR"
|
|
|
+ " FROM CH_FEE F "
|
|
|
+ " INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) "
|
|
|
+ " Where 1=1 and " + strCondition
|
|
|
+ " GROUP BY B.BSNO,F.CUSTOMERNAME,B.OPLBNAME, B.BSTYPE"
|
|
|
+ ",B.OPDATE"
|
|
|
+ ",B.CUSTOMDATE"
|
|
|
+ ",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO"
|
|
|
+ ",B.ETD"
|
|
|
+ ",B.VESSEL, B.VOYNO,B.SALE, B.OP"
|
|
|
+ ",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS"
|
|
|
+ ",B.GOODSNAME "
|
|
|
+ " UNION ALL "
|
|
|
|
|
|
+ "SELECT '总计' AS BSNO,'总计' AS CUSTNAME,'' OPLBNAME, '' BSTYPE"
|
|
|
+ ",'' as OPDATE"
|
|
|
+ ",'' as CUSTOMDATE"
|
|
|
|
|
|
+ ",'' CUSTOMERNAME, '' CUSTNO,'' ENTERP, '' MBLNO, '' HBLNO"
|
|
|
+ ",'' as ETD"
|
|
|
+ ",'' VESSEL, '' VOYNO,'' SALE, '' OP"
|
|
|
+ ",'' PORTLOAD, '' PORTDISCHARGE,'' ACCDATE,'' CARRIER, '' BSSOURCE,SUM(TEU) AS TEU,SUM(KGS) AS KGS"
|
|
|
+ ",'' GOODSNAME"
|
|
|
+ ",sum(RMBDR) AS RMBDR,"
|
|
|
+ "SUM(STLRMBDR) AS STLRMBDR,"
|
|
|
+ "SUM(BALRMBDR) AS BALRMBDR,"
|
|
|
+ "SUM(USDDR) AS USDDR,"
|
|
|
+ "SUM(STLUSDDR) AS STLUSDDR,"
|
|
|
+ "SUM(BALUSDDR) AS BALUSDDR,"
|
|
|
+ "SUM(OTDR) AS OTDR,"
|
|
|
+ "SUM(STLOTDR) AS STLOTDR,"
|
|
|
+ "SUM(BALOTDR) AS BALOTDR,"
|
|
|
+ "SUM(TTLDR) AS TTLDR,"
|
|
|
+ "SUM(STLTTLDR) AS STLTTLDR,"
|
|
|
+ "SUM(BALTTLDR) AS BALTTLDR,"
|
|
|
+ "SUM(RMBCR) AS RMBCR,"
|
|
|
+ "SUM(STLRMBCR) AS STLRMBCR,"
|
|
|
+ "SUM(BALRMBCR) AS BALRMBCR,"
|
|
|
+ "SUM(USDCR) AS USDCR,"
|
|
|
+ "SUM(STLUSDCR) AS STLUSDCR,"
|
|
|
+ "SUM(BALUSDCR) AS BALUSDCR,"
|
|
|
+ "SUM(OTCR) AS OTCR,"
|
|
|
+ "SUM(STLOTCR) AS STLOTCR,"
|
|
|
+ "SUM(BALOTCR) AS BALOTCR,"
|
|
|
+ "SUM(TTLCR) AS TTLCR,"
|
|
|
+ "SUM(STLTTLCR) AS STLTTLCR,"
|
|
|
+ "SUM(BALTTLCR) AS BALTTLCR"
|
|
|
+ " FROM ("
|
|
|
+ "SELECT B.BSNO,F.CUSTOMERNAME AS CUSTNAME,B.OPLBNAME, B.BSTYPE"
|
|
|
+ ",case B.OPDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.OPDATE,23) end as OPDATE"
|
|
|
+ ",case B.CUSTOMDATE when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.CUSTOMDATE,23) end as CUSTOMDATE"
|
|
|
|
|
|
+ ",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO"
|
|
|
+ ",case B.ETD when '1900-01-01 00:00:00.000' then '' else CONVERT(varchar(100), B.ETD,23) end as ETD"
|
|
|
+ ",B.VESSEL, B.VOYNO,B.SALE, B.OP"
|
|
|
+ ",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS"
|
|
|
+ ",B.GOODSNAME"
|
|
|
+ ",isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS STLRMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS TTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 1 THEN ISNULL(AMOUNT-SETTLEMENT,0) * ISNULL(EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLDR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT,0) ELSE 0 END) ELSE 0 END),0) AS RMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLRMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'RMB' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END) ELSE 0 END),0) AS BALRMBCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT,0) ELSE 0 END)ELSE 0 END),0) AS USDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS STLUSDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN ISNULL(AMOUNT-SETTLEMENT,0) ELSE 0 END)ELSE 0 END),0) AS BALUSDCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT,0) END) END)ELSE 0 END),0) AS OTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(SETTLEMENT,0) END) END)ELSE 0 END),0) AS STLOTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN (CASE CURRENCY WHEN 'USD' THEN 0 ELSE (CASE CURRENCY WHEN 'RMB' THEN 0 ELSE ISNULL(AMOUNT-SETTLEMENT,0) END) END) ELSE 0 END),0) AS BALOTCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS TTLCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS STLTTLCR,"
|
|
|
+ "isnull(SUM(CASE FEETYPE WHEN 2 THEN ISNULL(AMOUNT-SETTLEMENT,0) *ISNULL( EXCHANGERATE,0) ELSE 0 END),0) AS BALTTLCR"
|
|
|
+ " FROM CH_FEE F "
|
|
|
+ " INNER JOIN V_OP_BILL B ON (F.BSNO=B.BSNO) "
|
|
|
+ " Where 1=1 and " + strCondition
|
|
|
+ " GROUP BY B.BSNO,F.CUSTOMERNAME,B.OPLBNAME, B.BSTYPE"
|
|
|
+ ",B.OPDATE"
|
|
|
+ ",B.CUSTOMDATE"
|
|
|
+ ",B.CUSTOMERNAME, B.CUSTNO,B.ENTERP, B.MBLNO, B.HBLNO"
|
|
|
+ ",B.ETD"
|
|
|
+ ",B.VESSEL, B.VOYNO,B.SALE, B.OP"
|
|
|
+ ",B.PORTLOAD, B.PORTDISCHARGE,B.ACCDATE,B.CARRIER, B.BSSOURCE,B.TEU,B.KGS"
|
|
|
+ ",B.GOODSNAME "
|
|
|
+ " ) AS X"
|
|
|
+ " GROUP BY BSNO,CUSTOMERNAME,OPLBNAME, BSTYPE"
|
|
|
+ ",OPDATE"
|
|
|
+ ",CUSTOMDATE"
|
|
|
+ ",CUSTOMERNAME, CUSTNO,ENTERP, MBLNO, HBLNO"
|
|
|
+ ",ETD"
|
|
|
+ ",VESSEL, VOYNO,SALE, OP"
|
|
|
+ ",PORTLOAD, PORTDISCHARGE,ACCDATE,CARRIER, BSSOURCE"
|
|
|
+ ",GOODSNAME) AS Z ";
|
|
|
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_新海运进口委托列表_MsOpSeai_MsOpSeaiIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_新海运进口委托列表_MsOpSeai_MsOpSeaiIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsOpSeaiIndex(string strGIDs, string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = " and " + strCondition;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strGIDs))
|
|
|
{
|
|
|
strGIDs = " and GID in ('" + strGIDs.Trim().Replace(",", "','") + "')";
|
|
|
}
|
|
|
//
|
|
|
var rangstr = MsOpSeaiDAL.GetRangDAStr("index", strUserID, strUserCode, strCompanyID);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT *");
|
|
|
strSql.Append(",0 as FENPIAO ");
|
|
|
strSql.Append(",dbo.F_GetBillDrFeeStatus(VW_OP_SEAI.BSNO) DRFEESTATUS");
|
|
|
strSql.Append(",dbo.F_GetBillCrFeeStatus(VW_OP_SEAI.BSNO) CRFEESTATUS");
|
|
|
strSql.Append(" from VW_OP_SEAI where MASTERNO=BSNO and BSNO not like 'topseailcl%'");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" AND EXISTS ( select 1 from VW_OP_SEAI B WHERE VW_OP_SEAI.BSNO=B.MASTERNO " + strCondition + " )");
|
|
|
}
|
|
|
|
|
|
//取个人配置的列顺序
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "";
|
|
|
string sSQL = "select * from IMPORT_TableCustomize where USERID='" + strUserID + "' and FORMNAME='" + formname + "' and hidden=0 order by DATAORDER";
|
|
|
DataSet dsITC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (dsITC != null)
|
|
|
{
|
|
|
if (dsITC.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dsITC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
strDataIndex += dsITC.Tables[0].Rows[i]["dataIndex"].ToString().Trim() + ",";//字段名称
|
|
|
strHeader += dsITC.Tables[0].Rows[i]["header"].ToString().Trim() + "\t";//中文名称
|
|
|
}
|
|
|
//
|
|
|
strDataIndex = strDataIndex.Trim().Substring(0, strDataIndex.Length - 1);//字段名称
|
|
|
strHeader = strHeader.Trim().Substring(0, strHeader.Length - 1);//中文名称
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//没有设置个人配置,则取默认排列
|
|
|
if (strDataIndex.Trim() == "")
|
|
|
{
|
|
|
strDataIndex = " BSSTATUSREF,FEESTATUSREF,BSTYPE,WMSTYPE,OPSTATUS,ETD,MBLNO,CUSTOMERNAME,TRADETYPE,BSDATE,CONTRACTNO,GOODSNAME,NUMBERPLATE,PKGS,KGS,NETWEIGHT,CNTRTOTAL,ORDERTYPE,CUSTNO,HBLNO,ACCDATE,BSSOURCE,BSSOURCEDETAIL,INPUTBY,CREATETIME,OP,SALE,VESSEL,VOYNO,PORTLOAD,PORTDISCHARGE,OTCNTR,TEU,COUNTRYOFORIGIN,UNITS,BALES,CUSTOMSER,CUSTOMNO,CUSTOMDATE,INSPECTION,INSPECTIONNO,INSPECTIONDATE,KINDPKGS,CBM,CARRIER,TRUCKER,VOUNO,FBP,BMDDATE,MDTDATE,TRADINGAGENCY,GOODSTYPENAME,SHOWNAME,EMAIL,TEL,FAX,TARRIFSPAIEDTIEM,APPROVENO,UPDATETIME,IMPORTVALUE,UNITPRICE,BLTYPE ";//字段名称
|
|
|
strHeader = "业务状态\t费用状态\t委托单类型\t仓储类型\t状态管理\t到港日期\t主提单号\t委托单位\t贸易方式\t接单日期\t合同号\t品名\t牌号\t件数\t毛重\t净重\t集装箱\t委托方式\t委托编号\t分提单号\t会计期间\t业务来源\t来源明细\t录入人\t创建时间\t操作员\t揽货人\t船名\t航次\t装货港\t卸货港\t其他箱型\t箱TEU\t原产地\t单位\t包装数\t报关行\t报关单号\t通关日期\t报检\t报检单号\t报检日期\t件数包装\t尺码\t船公司\t承运车队\t凭证号\t免箱期\t箱使到期日\t搬倒日期\t贸易代理\t品名类型\t委托单位联系人\t委托单位EMAIL\t委托单位TEL\t委托单位FAX\t交关税时间\t审批单号\t申报日期\t货值\t单价\t装运方式";//中文名称
|
|
|
}
|
|
|
//
|
|
|
String strSql2 = "SELECT " + strDataIndex + " from (" + strSql.ToString() + ") as y order by ETD desc,MBLNO,BSDATE desc";
|
|
|
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql2.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_科目余额列表_RptCwGenlegAccitemsIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_科目余额列表_RptCwGenlegAccitemsIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwGenlegAccitemsIndex(string strCondition, string strCondition2, string strCondition3, string strCondition4, string strCondition5, string strCondition6, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string strCwACCDATE = BasicDataRefDAL.GetCwACCDATE(strUserID);
|
|
|
string sstrCondition2end = strCondition2.Replace("=", ">=") + strCondition3.Replace("=", "<=");
|
|
|
string sACCDATE01end = " and ACCDATE>='" + DateTime.Parse(strCwACCDATE + "-01").Year.ToString() + "-01'" + strCondition3.Replace("=", "<=");
|
|
|
string strHeader = "";
|
|
|
if (strCondition5.Trim() == "综合本位币")
|
|
|
{
|
|
|
strHeader = "科目代码\t科目名称\t期初借方\t期初贷方\t本期借方\t本期贷方\t本年累计借方\t本年累计贷方\t期末借方\t期末贷方";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strHeader = "科目代码\t科目名称\t期初借方\t期初贷方\t本期借方\t本期贷方\t本年累计借方\t本年累计贷方\t期末借方\t期末贷方\t折合人民币期初借方\t折合人民币期初贷方\t折合人民币本期借方\t折合人民币本期贷方\t折合人民币本年累计借方\t折合人民币本年累计贷方\t折合人民币期末借方\t折合人民币期末贷方";
|
|
|
}
|
|
|
//
|
|
|
var strSql = new StringBuilder();
|
|
|
if (strCondition5.Trim() == "综合本位币")
|
|
|
{
|
|
|
#region 综合本位币
|
|
|
strSql.Append("SELECT LINKCODE,LINKNAME,QTYYEARDR,QTYYEARCR,QTYDR,QTYCR,QTYLASTDR,QTYLASTCR,QTYCPDR,QTYCPCR from ((");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
strSql.Append(",isnull(sum(YEARDR),0) as YEARDR,isnull(sum(YEARCR),0) as YEARCR,isnull(sum(YEARBLC),0) as YEARBLC,isnull(sum(DR),0) as DR,isnull(sum(CR),0) as CR,isnull(sum(BLC),0) as BLC,isnull(sum(LASTDR),0) as LASTDR,isnull(sum(LASTCR),0) as LASTCR,isnull(sum(LASTBLC),0) as LASTBLC,isnull(sum(AMTCPDR),0) as AMTCPDR,isnull(sum(AMTCPCR),0) as AMTCPCR,isnull(sum(QTYYEARDR),0) as QTYYEARDR,isnull(sum(QTYYEARCR),0) as QTYYEARCR,isnull(sum(QTYYEARBLC),0) as QTYYEARBLC,isnull(sum(QTYDR),0) as QTYDR,isnull(sum(QTYCR),0) as QTYCR,isnull(sum(QTYBLC),0) as QTYBLC,isnull(sum(QTYLASTDR),0) as QTYLASTDR,isnull(sum(QTYLASTCR),0) as QTYLASTCR,isnull(sum(QTYLASTBLC),0) as QTYLASTBLC,isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0))-(isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0)) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0))-(isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0)) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(",(LINKNAME+(case when (CORPACC='' or CORPACC is null) then '' else ('▁'+CORPACC) end)+(case when (DEPTACC='' or DEPTACC is null) then '' else ('▁'+DEPTACC) end)+(case when (EMPLACC='' or EMPLACC is null) then '' else ('▁'+EMPLACC) end)+(case when (ITEMACC='' or ITEMACC is null) then '' else ('▁'+ITEMACC) end)) as LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
}
|
|
|
strSql.Append(",0 as YEARDR");
|
|
|
strSql.Append(",0 as YEARCR");
|
|
|
strSql.Append(",0 as YEARBLC");
|
|
|
strSql.Append(",0 as DR");
|
|
|
strSql.Append(",0 as CR");
|
|
|
strSql.Append(",0 as BLC");
|
|
|
strSql.Append(",0 as LASTDR");
|
|
|
strSql.Append(",0 as LASTCR");
|
|
|
strSql.Append(",0 as LASTBLC");
|
|
|
strSql.Append(",0 as AMTCPDR");
|
|
|
strSql.Append(",0 as AMTCPCR");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 " + strCondition4 + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("select *,LINKCODE=(select top 1 ACCID from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),LINKNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where [STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1 " + strCondition4);
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(") as a");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC,STARTGID");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
}
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
strSql.Append(") union (");
|
|
|
strSql.Append("SELECT NEWID() as GID,'合计:' as LINKCODE,'' as DC,'' as LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
strSql.Append(",0 as YEARDR,0 as YEARCR,0 as YEARBLC,0 as DR,0 as CR,0 as BLC,0 as LASTDR,0 as LASTCR,0 as LASTBLC,0 as AMTCPDR,0 as AMTCPCR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARDR),0) as QTYYEARDR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARCR),0) as QTYYEARCR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARBLC),0) as QTYYEARBLC");
|
|
|
strSql.Append(",isnull(sum(QTYDR),0) as QTYDR");
|
|
|
strSql.Append(",isnull(sum(QTYCR),0) as QTYCR");
|
|
|
strSql.Append(",isnull(sum(QTYBLC),0) as QTYBLC");
|
|
|
strSql.Append(",isnull(sum(QTYLASTDR),0) as QTYLASTDR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTCR),0) as QTYLASTCR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTBLC),0) as QTYLASTBLC");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR");
|
|
|
strSql.Append(",isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",isnull(sum(QTYCPDR),0) as QTYCPDR");
|
|
|
strSql.Append(",isnull(sum(QTYCPCR),0) as QTYCPCR");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT *");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (QTYYEARDR+QTYDR)-(QTYYEARCR+QTYCR) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (QTYYEARCR+QTYCR)-(QTYYEARDR+QTYDR) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT STARTGID");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1" + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",DC=(select top 1 DC from [cw_accitems_gl] where gid=a.LINKGID)");
|
|
|
strSql.Append(" from cw_genleg_accitems as a");
|
|
|
strSql.Append(" where a.[STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1");
|
|
|
strSql.Append(" and LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and DETAILED=1)");//合计数不计算子科目,否则会造成重复合计
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(" group by LINKGID,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
strSql.Append(") as c");
|
|
|
strSql.Append(")) as d");
|
|
|
#endregion
|
|
|
}
|
|
|
else if (strCondition5.Trim() == "RMB")
|
|
|
{
|
|
|
#region RMB
|
|
|
strSql.Append("select LINKCODE,LINKNAME,YEARDR,YEARCR,DR,CR,LASTDR,LASTCR,AMTCPDR,AMTCPCR,QTYYEARDR,QTYYEARCR,QTYDR,QTYCR,QTYLASTDR,QTYLASTCR,QTYCPDR,QTYCPCR from ((");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
//strSql.Append(",YEARDR,YEARCR,YEARBLC,DR,CR,BLC,LASTDR,LASTCR,LASTBLC,QTYYEARDR,QTYYEARCR,QTYYEARBLC,QTYDR,QTYCR,QTYBLC,QTYLASTDR,QTYLASTCR,QTYLASTBLC,PFADR,PFACR");
|
|
|
strSql.Append(",isnull(sum(YEARDR),0) as YEARDR,isnull(sum(YEARCR),0) as YEARCR,isnull(sum(YEARBLC),0) as YEARBLC,isnull(sum(DR),0) as DR,isnull(sum(CR),0) as CR,isnull(sum(BLC),0) as BLC,isnull(sum(LASTDR),0) as LASTDR,isnull(sum(LASTCR),0) as LASTCR,isnull(sum(LASTBLC),0) as LASTBLC,isnull(sum(QTYYEARDR),0) as QTYYEARDR,isnull(sum(QTYYEARCR),0) as QTYYEARCR,isnull(sum(QTYYEARBLC),0) as QTYYEARBLC,isnull(sum(QTYDR),0) as QTYDR,isnull(sum(QTYCR),0) as QTYCR,isnull(sum(QTYBLC),0) as QTYBLC,isnull(sum(QTYLASTDR),0) as QTYLASTDR,isnull(sum(QTYLASTCR),0) as QTYLASTCR,isnull(sum(QTYLASTBLC),0) as QTYLASTBLC,isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",AMTCPDR=isnull((case when DC='借' then (isnull(sum(YEARDR),0)+isnull(sum(DR),0))-(isnull(sum(YEARCR),0)+isnull(sum(CR),0)) else 0 end),0)");
|
|
|
strSql.Append(",AMTCPCR=isnull((case when DC='贷' then (isnull(sum(YEARCR),0)+isnull(sum(CR),0))-(isnull(sum(YEARDR),0)+isnull(sum(DR),0)) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0))-(isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0)) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0))-(isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0)) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(",(LINKNAME+(case when (CORPACC='' or CORPACC is null) then '' else ('▁'+CORPACC) end)+(case when (DEPTACC='' or DEPTACC is null) then '' else ('▁'+DEPTACC) end)+(case when (EMPLACC='' or EMPLACC is null) then '' else ('▁'+EMPLACC) end)+(case when (ITEMACC='' or ITEMACC is null) then '' else ('▁'+ITEMACC) end)) as LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
}
|
|
|
strSql.Append(",YEARDR=isnull((select sum(AMTYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARCR=isnull((select sum(AMTYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARBLC=isnull((select sum(AMTYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",DR=isnull((select sum(AMTDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",CR=isnull((select sum(AMTCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",BLC=isnull((select sum(AMTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTDR=isnull((select sum(AMTDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTCR=isnull((select sum(AMTCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTBLC=isnull((select sum(AMTLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR ");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("select *,LINKCODE=(select top 1 ACCID from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),LINKNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where [STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4);
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(") as a");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC,STARTGID");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
}
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
strSql.Append(") union (");
|
|
|
strSql.Append("SELECT NEWID() as GID,'合计:' as LINKCODE,'' as DC,'' as LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
strSql.Append(",isnull(sum(YEARDR),0) as YEARDR");
|
|
|
strSql.Append(",isnull(sum(YEARCR),0) as YEARCR");
|
|
|
strSql.Append(",isnull(sum(YEARBLC),0) as YEARBLC");
|
|
|
strSql.Append(",isnull(sum(DR),0) as DR");
|
|
|
strSql.Append(",isnull(sum(CR),0) as CR");
|
|
|
strSql.Append(",isnull(sum(BLC),0) as BLC");
|
|
|
strSql.Append(",isnull(sum(LASTDR),0) as LASTDR");
|
|
|
strSql.Append(",isnull(sum(LASTCR),0) as LASTCR");
|
|
|
strSql.Append(",isnull(sum(LASTBLC),0) as LASTBLC");
|
|
|
strSql.Append(",isnull(sum(QTYYEARDR),0) as QTYYEARDR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARCR),0) as QTYYEARCR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARBLC),0) as QTYYEARBLC");
|
|
|
strSql.Append(",isnull(sum(QTYDR),0) as QTYDR");
|
|
|
strSql.Append(",isnull(sum(QTYCR),0) as QTYCR");
|
|
|
strSql.Append(",isnull(sum(QTYBLC),0) as QTYBLC");
|
|
|
strSql.Append(",isnull(sum(QTYLASTDR),0) as QTYLASTDR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTCR),0) as QTYLASTCR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTBLC),0) as QTYLASTBLC");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR");
|
|
|
strSql.Append(",isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",isnull(sum(AMTCPDR),0) as AMTCPDR");
|
|
|
strSql.Append(",isnull(sum(AMTCPCR),0) as AMTCPCR");
|
|
|
strSql.Append(",isnull(sum(QTYCPDR),0) as QTYCPDR");
|
|
|
strSql.Append(",isnull(sum(QTYCPCR),0) as QTYCPCR");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT *");
|
|
|
strSql.Append(",AMTCPDR=isnull((case when DC='借' then (YEARDR+DR)-(YEARCR+CR) else 0 end),0)");
|
|
|
strSql.Append(",AMTCPCR=isnull((case when DC='贷' then (YEARCR+CR)-(YEARDR+DR) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (QTYYEARDR+QTYDR)-(QTYYEARCR+QTYCR) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (QTYYEARCR+QTYCR)-(QTYYEARDR+QTYDR) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT STARTGID");
|
|
|
strSql.Append(",YEARDR=isnull((select sum(AMTYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARCR=isnull((select sum(AMTYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARBLC=isnull((select sum(AMTYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",DR=isnull((select sum(AMTDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",CR=isnull((select sum(AMTCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",BLC=isnull((select sum(AMTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTDR=isnull((select sum(AMTDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTCR=isnull((select sum(AMTCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTBLC=isnull((select sum(AMTLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",DC=(select top 1 DC from [cw_accitems_gl] where gid=a.LINKGID)");
|
|
|
strSql.Append(" from cw_genleg_accitems as a");
|
|
|
strSql.Append(" where a.[STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'");
|
|
|
strSql.Append(" and LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and DETAILED=1)");// + strCondition4//合计数不计算子科目,否则会造成重复合计
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(" group by LINKGID,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
strSql.Append(") as c");
|
|
|
strSql.Append(")) as d");
|
|
|
#endregion
|
|
|
}
|
|
|
else//外币
|
|
|
{
|
|
|
#region 外币
|
|
|
strSql.Append("select LINKCODE,LINKNAME,YEARDR,YEARCR,DR,CR,LASTDR,LASTCR,AMTCPDR,AMTCPCR,QTYYEARDR,QTYYEARCR,QTYDR,QTYCR,QTYLASTDR,QTYLASTCR,QTYCPDR,QTYCPCR from ((");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
//strSql.Append(",YEARDR,YEARCR,YEARBLC,DR,CR,BLC,LASTDR,LASTCR,LASTBLC,QTYYEARDR,QTYYEARCR,QTYYEARBLC,QTYDR,QTYCR,QTYBLC,QTYLASTDR,QTYLASTCR,QTYLASTBLC,PFADR,PFACR");
|
|
|
strSql.Append(",isnull(sum(YEARDR),0) as YEARDR,isnull(sum(YEARCR),0) as YEARCR,isnull(sum(YEARBLC),0) as YEARBLC,isnull(sum(DR),0) as DR,isnull(sum(CR),0) as CR,isnull(sum(BLC),0) as BLC,isnull(sum(LASTDR),0) as LASTDR,isnull(sum(LASTCR),0) as LASTCR,isnull(sum(LASTBLC),0) as LASTBLC,isnull(sum(QTYYEARDR),0) as QTYYEARDR,isnull(sum(QTYYEARCR),0) as QTYYEARCR,isnull(sum(QTYYEARBLC),0) as QTYYEARBLC,isnull(sum(QTYDR),0) as QTYDR,isnull(sum(QTYCR),0) as QTYCR,isnull(sum(QTYBLC),0) as QTYBLC,isnull(sum(QTYLASTDR),0) as QTYLASTDR,isnull(sum(QTYLASTCR),0) as QTYLASTCR,isnull(sum(QTYLASTBLC),0) as QTYLASTBLC,isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",AMTCPDR=isnull((case when DC='借' then (isnull(sum(YEARDR),0)+isnull(sum(DR),0))-(isnull(sum(YEARCR),0)+isnull(sum(CR),0)) else 0 end),0)");
|
|
|
strSql.Append(",AMTCPCR=isnull((case when DC='贷' then (isnull(sum(YEARCR),0)+isnull(sum(CR),0))-(isnull(sum(YEARDR),0)+isnull(sum(DR),0)) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0))-(isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0)) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (isnull(sum(QTYYEARCR),0)+isnull(sum(QTYCR),0))-(isnull(sum(QTYYEARDR),0)+isnull(sum(QTYDR),0)) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT newid() as GID,LINKCODE,DC");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(",(LINKNAME+(case when (CORPACC='' or CORPACC is null) then '' else ('▁'+CORPACC) end)+(case when (DEPTACC='' or DEPTACC is null) then '' else ('▁'+DEPTACC) end)+(case when (EMPLACC='' or EMPLACC is null) then '' else ('▁'+EMPLACC) end)+(case when (ITEMACC='' or ITEMACC is null) then '' else ('▁'+ITEMACC) end)) as LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(",LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
}
|
|
|
strSql.Append(",YEARDR=isnull((select sum(FCYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARCR=isnull((select sum(FCYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARBLC=isnull((select sum(FCYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",DR=isnull((select sum(FCYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",CR=isnull((select sum(FCYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",BLC=isnull((select sum(FCYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTDR=isnull((select sum(FCYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTCR=isnull((select sum(FCYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTBLC=isnull((select sum(FCYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4 + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR ");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("select *,LINKCODE=(select top 1 ACCID from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),LINKNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID),DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where [STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition4);
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(") as a");
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC,STARTGID");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
}
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
if (strCondition4.IndexOf("CORPACC") > -1)
|
|
|
{
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DEPTACC,EMPLACC,CORPACC,ITEMACC,DC");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//strSql.Append(" group by LINKGID,LINKCODE,LINKNAME,DC");
|
|
|
strSql.Append(" group by LINKCODE,LINKNAME,DC,DEPTACC,EMPLACC,CORPACC,ITEMACC");
|
|
|
}
|
|
|
strSql.Append(") union (");
|
|
|
strSql.Append("SELECT NEWID() as GID,'合计:' as LINKCODE,'' as DC,'' as LINKNAME,'' as DEPTACC,'' as EMPLACC,'' as CORPACC,'' as ITEMACC");
|
|
|
strSql.Append(",isnull(sum(YEARDR),0) as YEARDR");
|
|
|
strSql.Append(",isnull(sum(YEARCR),0) as YEARCR");
|
|
|
strSql.Append(",isnull(sum(YEARBLC),0) as YEARBLC");
|
|
|
strSql.Append(",isnull(sum(DR),0) as DR");
|
|
|
strSql.Append(",isnull(sum(CR),0) as CR");
|
|
|
strSql.Append(",isnull(sum(BLC),0) as BLC");
|
|
|
strSql.Append(",isnull(sum(LASTDR),0) as LASTDR");
|
|
|
strSql.Append(",isnull(sum(LASTCR),0) as LASTCR");
|
|
|
strSql.Append(",isnull(sum(LASTBLC),0) as LASTBLC");
|
|
|
strSql.Append(",isnull(sum(QTYYEARDR),0) as QTYYEARDR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARCR),0) as QTYYEARCR");
|
|
|
strSql.Append(",isnull(sum(QTYYEARBLC),0) as QTYYEARBLC");
|
|
|
strSql.Append(",isnull(sum(QTYDR),0) as QTYDR");
|
|
|
strSql.Append(",isnull(sum(QTYCR),0) as QTYCR");
|
|
|
strSql.Append(",isnull(sum(QTYBLC),0) as QTYBLC");
|
|
|
strSql.Append(",isnull(sum(QTYLASTDR),0) as QTYLASTDR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTCR),0) as QTYLASTCR");
|
|
|
strSql.Append(",isnull(sum(QTYLASTBLC),0) as QTYLASTBLC");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR");
|
|
|
strSql.Append(",isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",isnull(sum(AMTCPDR),0) as AMTCPDR");
|
|
|
strSql.Append(",isnull(sum(AMTCPCR),0) as AMTCPCR");
|
|
|
strSql.Append(",isnull(sum(QTYCPDR),0) as QTYCPDR");
|
|
|
strSql.Append(",isnull(sum(QTYCPCR),0) as QTYCPCR");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT *");
|
|
|
strSql.Append(",AMTCPDR=isnull((case when DC='借' then (YEARDR+DR)-(YEARCR+CR) else 0 end),0)");
|
|
|
strSql.Append(",AMTCPCR=isnull((case when DC='贷' then (YEARCR+CR)-(YEARDR+DR) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPDR=isnull((case when DC='借' then (QTYYEARDR+QTYDR)-(QTYYEARCR+QTYCR) else 0 end),0)");
|
|
|
strSql.Append(",QTYCPCR=isnull((case when DC='贷' then (QTYYEARCR+QTYCR)-(QTYYEARDR+QTYDR) else 0 end),0)");
|
|
|
strSql.Append(" from (");
|
|
|
strSql.Append("SELECT STARTGID");
|
|
|
strSql.Append(",YEARDR=isnull((select sum(FCYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARCR=isnull((select sum(FCYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",YEARBLC=isnull((select sum(FCYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",DR=isnull((select sum(FCYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",CR=isnull((select sum(FCYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",BLC=isnull((select sum(FCYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTDR=isnull((select sum(FCYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTCR=isnull((select sum(FCYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",LASTBLC=isnull((select sum(FCYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARDR=isnull((select sum(QTYYEARDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARCR=isnull((select sum(QTYYEARCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYYEARBLC=isnull((select sum(QTYYEARBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition2 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYBLC=isnull((select sum(QTYBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sstrCondition2end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTDR=isnull((select sum(QTYDR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTCR=isnull((select sum(QTYCR) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + sACCDATE01end + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",QTYLASTBLC=isnull((select sum(QTYLASTBLC) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'" + strCondition3 + " and LINKGID=a.LINKGID and DEPTACC=a.DEPTACC and EMPLACC=a.EMPLACC and CORPACC=a.CORPACC and ITEMACC=a.ITEMACC and [STARTGID]=a.[STARTGID]),0)");
|
|
|
strSql.Append(",isnull(sum(PFADR),0) as PFADR,isnull(sum(PFACR),0) as PFACR");
|
|
|
strSql.Append(",DC=(select top 1 DC from [cw_accitems_gl] where gid=a.LINKGID)");
|
|
|
strSql.Append(" from cw_genleg_accitems as a");
|
|
|
strSql.Append(" where a.[STARTGID]='" + strCwSTARTGID + "' and ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCondition5 + "'");
|
|
|
strSql.Append(" and LINKGID in (select GID from [cw_accitems_gl] where [YEAR]=SUBSTRING('" + strCwACCDATE + "',1,4) and DETAILED=1)");// + strCondition4//合计数不计算子科目,否则会造成重复合计
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
strSql.Append(" group by LINKGID,DEPTACC,EMPLACC,CORPACC,ITEMACC,STARTGID");
|
|
|
strSql.Append(") as b where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition6))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition6);
|
|
|
}
|
|
|
strSql.Append(") as c");
|
|
|
strSql.Append(")) as d");
|
|
|
#endregion
|
|
|
}
|
|
|
strSql.Append(" order by LINKCODE");
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.ToString().Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_科目总账列表_ExcelRptCwGLIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_科目总账列表_ExcelRptCwGLIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwGLIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//取个人配置的列顺序
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "";
|
|
|
string sSQL = "select * from IMPORT_TableCustomize where USERID='" + strUserID + "' and FORMNAME='" + formname + "' and hidden=0 order by DATAORDER";
|
|
|
DataSet dsITC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (dsITC != null)
|
|
|
{
|
|
|
if (dsITC.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dsITC.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
strDataIndex += dsITC.Tables[0].Rows[i]["dataIndex"].ToString().Trim() + ",";//字段名称
|
|
|
strHeader += dsITC.Tables[0].Rows[i]["header"].ToString().Trim() + "\t";//中文名称
|
|
|
}
|
|
|
strDataIndex = strDataIndex.Trim().Substring(0, strDataIndex.Length - 1);//字段名称
|
|
|
strHeader = strHeader.Trim().Substring(0, strHeader.Length - 1);//中文名称
|
|
|
}
|
|
|
}
|
|
|
//没有设置个人配置,则取默认排列
|
|
|
if (strDataIndex.Trim() == "")
|
|
|
{
|
|
|
strHeader = "科目代码\t科目名称\t会计期间\t摘要\t借方\t贷方\t方向\t余额";//中文名称
|
|
|
strDataIndex = "LINKCODE,LINKNAME,ACCDATE,EXPLAN,DR,CR,DC,BLC";//字段名称
|
|
|
}
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition.Replace("%2B", "+") + ") as y order by LINKCODE,ACCDATE,EXPLAN2";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_资产负债表列表_ExcelRptCwSofpIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_资产负债表列表_ExcelRptCwSofpIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwSofpIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "行号\t会计期间\t资产\t行次\t期末余额\t年初余额\t[负债和所有者权益(或股东权益)]\t行次2\t期末余额2\t年初余额2";//中文名称
|
|
|
string strDataIndex = "LINENUM,ACCDATE,ACCTYPE,LINENUM1,QTYLASTBLC,QTYYEARBLC,ACCTYPE2,LINENUM2,QTYLASTBLC2,QTYYEARBLC2";//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as a order by LINENUM";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_利润表列表_ExcelRptCwPLIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_利润表列表_ExcelRptCwPLIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwPLIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "会计期间\t项目\t行次\t本月金额\t本年累计金额";//中文名称
|
|
|
string strDataIndex = "ACCDATE,ACCTYPE,LINENUM,QTYBLC,QTYLASTBLC";//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as a order by LINENUM";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_科目明细账列表_ExcelRptCwGLDetailIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_科目明细账列表_ExcelRptCwGLDetailIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwGLDetailIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//取个人配置的列顺序
|
|
|
//string strHeader = "";
|
|
|
//string strDataIndex = "";
|
|
|
//string sSQL = "select * from IMPORT_TableCustomize where USERID='" + strUserID + "' and FORMNAME='" + formname + "' and hidden=0 order by DATAORDER";
|
|
|
//DataSet dsITC = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
//if (dsITC != null)
|
|
|
//{
|
|
|
// if (dsITC.Tables[0].Rows.Count > 0)
|
|
|
// {
|
|
|
// for (int i = 0; i < dsITC.Tables[0].Rows.Count; i++)
|
|
|
// {
|
|
|
// strDataIndex += dsITC.Tables[0].Rows[i]["dataIndex"].ToString().Trim() + ",";//字段名称
|
|
|
// strHeader += dsITC.Tables[0].Rows[i]["header"].ToString().Trim() + "\t";//中文名称
|
|
|
// }
|
|
|
// strDataIndex = strDataIndex.Trim().Substring(0, strDataIndex.Length - 1);//字段名称
|
|
|
// strHeader = strHeader.Trim().Substring(0, strHeader.Length - 1);//中文名称
|
|
|
// }
|
|
|
//}
|
|
|
////没有设置个人配置,则取默认排列
|
|
|
//if (strDataIndex.Trim() == "")
|
|
|
//{
|
|
|
// strHeader = "日期\t凭证字\t凭证号\t摘要\t借方\t贷方\t方向\t余额";//中文名称
|
|
|
// strDataIndex = "VOUDATE,VKNO,VOUNO,EXPLAN,DR,CR,DC,BLC";//字段名称
|
|
|
//}
|
|
|
//
|
|
|
//strCondition = "select " + strDataIndex + " from (" + strCondition.Replace("%2B", "+") + ") as y order by VOUDATE,EXPLAN2,VKNO,VOUNO";
|
|
|
strCondition = strCondition.Replace("%2B", "+");
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], "");//strHeader.Trim()
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_总账凭证明细列表_MsCwVouchersGlIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_总账凭证明细列表_MsCwVouchersGlIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsCwVouchersGlIndex(string strCondition, string formname)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "日期\t凭证字\t凭证号\t摘要\t会计科目\t借方金额\t贷方金额\t制单人\t改单人\t审核人";//中文名称
|
|
|
string strDataIndex = "VOUDATE,VKNO,VOUNO,EXPLAN,ACCALL,AMTDR,AMTCR,PREPARED,MODIFIEDUSERNAME_d,CHECKED";//字段名称
|
|
|
string strSql = "SELECT " + strDataIndex + " from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' and ISDELETE=0";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " and " + strCondition;
|
|
|
}
|
|
|
strSql += " order by VKNO,convert(INT,VOUNO) desc,VOUDATE desc,ITEMNO";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_总账凭证合计列表_MsCwVouchersGlIndexHJ.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_总账凭证合计列表_MsCwVouchersGlIndexHJ.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsCwVouchersGlIndexHJ(string strCondition, string formname)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "日期\t凭证字\t凭证号\t本位币借方\t本位币贷方\t外币借方\t外币贷方\t综合本位币借方\t综合本位币贷方\t制单人\t改单人\t审核人";//中文名称
|
|
|
string strDataIndex = "VOUDATE,VKNO,VOUNO,SUM(case when FCYNO='RMB' THEN AMTDR ELSE 0 END) as AMTDR,SUM(case when FCYNO='RMB' THEN AMTCR ELSE 0 END) as AMTCR,SUM(FCYDR) as FCYDR,SUM(FCYCR) as FCYCR,SUM(AMTDR) as QTYDR,SUM(AMTCR) as QTYCR,MODIFIEDUSERNAME,CHECKED";//字段名称
|
|
|
string strSql = "SELECT " + strDataIndex + " from VW_cw_vouchers_vouitems_gl WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' and ISDELETE=0";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql += " and " + strCondition;
|
|
|
}
|
|
|
strSql += " GROUP BY VOUDATE,VKNO,VOUNO,PREPARED,MODIFIEDUSERNAME,CHECKED";
|
|
|
strSql += " order by VKNO,convert(INT,VOUNO) desc,VOUDATE desc";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_凭证汇总表_RptCwVouchersGlIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_凭证汇总表__RptCwVouchersGlIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwVouchersGlIndex(string strCondition, string strCondition2, string strCondition3, string formname)
|
|
|
{
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "科目代码\t科目名称\t借方金额\t贷方金额";//中文名称
|
|
|
string strDataIndex = "ACCID,ACCNAME,DR,CR";//字段名称
|
|
|
string strSql = "SELECT " + strDataIndex + " from cw_vouitems_gl_rpt_temp WITH(NOLOCK) where STARTGID='" + strCwSTARTGID + "' and CREATEUSER='" + strUserID + "' and CORPID='" + strCompanyID + "' and (ACCID='合计:'" + strCondition2 + ") order by ACCID,ACCNAME";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_多栏账_RptCwGLDetailColumnIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_多栏账_RptCwGLDetailColumnIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwGLDetailColumnIndex(string strCondition, string strCondition2, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//取个人配置的列顺序
|
|
|
string strHeader = "日期\t凭证字\t凭证号\t摘要\t借方\t贷方\t方向\t余额" + strCondition2.Replace("[", "").Replace("]", "").Replace(",", "\t");//中文名称
|
|
|
string strDataIndex = "VOUDATE,VKNO,VOUNO,EXPLAN,DR,CR,DC,BLC" + strCondition2.Replace("(", "").Replace(")", "");//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as y order by VOUDATE,EXPLAN2,VKNO,VOUNO";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_RptCtGenlegAccitemsIndex.js
|
|
|
/// <summary>
|
|
|
/// 导出_RptCtGenlegAccitemsIndex.js
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCtGenlegAccitemsIndex(string strCondition, string strCondition2, string strCondition3, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
|
#region 基本信息
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUserID);
|
|
|
String sCondition = "";
|
|
|
String sCondition2 = "";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
sCondition += " and ([YEAR]+'-'+[MONTH]+'-'+[DAY])='" + strCondition + "'";
|
|
|
sCondition2 += " and VOUDATE='" + strCondition + "'";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition2))
|
|
|
{
|
|
|
if (strCondition2 != "undefined")
|
|
|
{
|
|
|
sCondition += " and LINKGID in (select GID from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCondition + "',1,4) and ACCID='" + strCondition2 + "')";
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition3))
|
|
|
{
|
|
|
sCondition += " and CURRENCY='" + strCondition3 + "'";
|
|
|
sCondition2 += " and FCYNO='" + strCondition3 + "'";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
if (strCondition3 == "RMB")
|
|
|
{
|
|
|
strSql.Append("select LINKCODE as 科目代码,LINKNAME as 科目名称,DC as 方向,QTYYEARBLC as 昨日余额,QTYDR as 今日借方,QTYCR as 今日贷方,DC2 as 方向,QTYLASTBLC as 今日余额,iDR as 借方笔数,iCR as 贷方笔数 from (");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("select LINKCODE as [科目代码],LINKNAME as [科目名称],DC as 方向,FCYYEARBLC as [昨日余额(原币)],QTYYEARBLC as [昨日余额(本位币)],FCYDR as [今日借方(原币)],QTYDR as [今日借方(本位币)],FCYCR as [今日贷方(原币)],QTYCR as [今日贷方(本位币)],DC2 as [方向],FCYLASTBLC as [今日余额(原币)],QTYLASTBLC as [今日余额(本位币)],iDR as [借方笔数],iCR as [贷方笔数] from (");
|
|
|
}
|
|
|
strSql.Append("select [GID],[YEAR],[MONTH],[DAY],[LINKGID],[CURRENCY],[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR]");
|
|
|
strSql.Append(",[AMTLASTBLC]=(case when AMTLASTBLC<0 then (0-AMTLASTBLC) else AMTLASTBLC end)");
|
|
|
strSql.Append(",[FCYYEARDR],[FCYYEARCR]");
|
|
|
strSql.Append(",[FCYYEARBLC]=(case when FCYYEARBLC<0 then (0-FCYYEARBLC) else FCYYEARBLC end)");
|
|
|
strSql.Append(",[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR]");
|
|
|
strSql.Append(",[FCYLASTBLC]=(case when FCYLASTBLC<0 then (0-FCYLASTBLC) else FCYLASTBLC end)");
|
|
|
strSql.Append(",[QTYYEARDR],[QTYYEARCR]");
|
|
|
strSql.Append(",[QTYYEARBLC]=(case when QTYYEARBLC<0 then (0-QTYYEARBLC) else QTYYEARBLC end)");
|
|
|
strSql.Append(",[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR]");
|
|
|
strSql.Append(",[QTYLASTBLC]=(case when QTYLASTBLC<0 then (0-QTYLASTBLC) else QTYLASTBLC end)");
|
|
|
strSql.Append(",[IsInitialEntry],[CORPID],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[ACCDATE],[STARTGID],LINKCODE=(select top 1 ACCID from [cw_accitems_gl] WITH(NOLOCK) WHERE STARTGID='" + strCwSTARTGID + "' AND gid=ct_genleg_accitems.LINKGID),LINKNAME=(select top 1 ACCNAME from [cw_accitems_gl] WITH(NOLOCK) WHERE STARTGID='" + strCwSTARTGID + "' AND gid=ct_genleg_accitems.LINKGID),DC=(CASE WHEN QTYYEARBLC<0 THEN '贷' ELSE '借' END),DC2=(CASE WHEN QTYLASTBLC<0 THEN '贷' ELSE '借' END),iDR=(SELECT COUNT(*) AS inum from ct_bank_journal WHERE STARTGID='" + strCtSTARTGID + "' and DR<>0 AND ACCGID=ct_genleg_accitems.LINKGID" + sCondition2 + "),iCR=(SELECT COUNT(*) AS inum from ct_bank_journal WHERE STARTGID='" + strCtSTARTGID + "' and CR<>0 AND ACCGID=ct_genleg_accitems.LINKGID" + sCondition2 + ") from ct_genleg_accitems where STARTGID='" + strCtSTARTGID + "'" + sCondition);
|
|
|
strSql.Append(") as ls order by LINKCODE");
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.ToString());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], "");
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_RptCtGenlegAccitemsMonthIndex.js
|
|
|
/// <summary>
|
|
|
/// 导出_RptCtGenlegAccitemsMonthIndex.js
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCtGenlegAccitemsMonthIndex(string strCondition, string strCondition2, string strCondition3, string strCondition4, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
|
#region 基本信息
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUserID);
|
|
|
String sCondition = "";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
sCondition += " and ([YEAR]+'-'+[MONTH])>='" + strCondition + "'";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition2))
|
|
|
{
|
|
|
sCondition += " and ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "'";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition3))
|
|
|
{
|
|
|
if (strCondition3 != "undefined")
|
|
|
{
|
|
|
sCondition += " and LINKGID in (select GID from cw_accitems_gl where [YEAR]=SUBSTRING('" + strCondition + "',1,4) and ACCID='" + strCondition3 + "')";
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition4))
|
|
|
{
|
|
|
sCondition += " and CURRENCY='" + strCondition4 + "'";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询数据
|
|
|
var strSql = new StringBuilder();
|
|
|
if (strCondition3 == "RMB")
|
|
|
{
|
|
|
strSql.Append("select LINKCODE as 科目代码,LINKNAME as 科目名称,DC as 方向,QTYYEARBLC as 期初余额,QTYDR as 本期借方,QTYCR as 本期贷方,DC2 as 方向,QTYLASTBLC as 期末余额,iDR as 借方笔数,iCR as 贷方笔数 from (");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("select LINKCODE as [科目代码],LINKNAME as [科目名称],DC as 方向,FCYYEARBLC as [期初余额(原币)],QTYYEARBLC as [期初余额(本位币)],FCYDR as [本期借方(原币)],QTYDR as [本期借方(本位币)],FCYCR as [本期贷方(原币)],QTYCR as [本期贷方(本位币)],DC2 as [方向],FCYLASTBLC as [期末余额(原币)],QTYLASTBLC as [期末余额(本位币)],iDR as [借方笔数],iCR as [贷方笔数] from (");
|
|
|
}
|
|
|
strSql.Append("SELECT newid() as GID,[LINKGID],[CURRENCY]");
|
|
|
strSql.Append(",LINKCODE=(select top 1 ACCID from [cw_accitems_gl] where gid=b.LINKGID)");
|
|
|
strSql.Append(",LINKNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=b.LINKGID)");
|
|
|
strSql.Append(",[AMTYEARDR],[AMTYEARCR],[AMTYEARBLC],[AMTDR],[AMTCR],[AMTBLC],[AMTLASTDR],[AMTLASTCR]");
|
|
|
strSql.Append(",[AMTLASTBLC]=(case when AMTLASTBLC<0 then (0-AMTLASTBLC) else AMTLASTBLC end)");
|
|
|
strSql.Append(",[FCYYEARDR],[FCYYEARCR]");
|
|
|
strSql.Append(",[FCYYEARBLC]=(case when FCYYEARBLC<0 then (0-FCYYEARBLC) else FCYYEARBLC end)");
|
|
|
strSql.Append(",[FCYDR],[FCYCR],[FCYBLC],[FCYLASTDR],[FCYLASTCR]");
|
|
|
strSql.Append(",[FCYLASTBLC]=(case when FCYLASTBLC<0 then (0-FCYLASTBLC) else FCYLASTBLC end)");
|
|
|
strSql.Append(",[QTYYEARDR],[QTYYEARCR]");
|
|
|
strSql.Append(",[QTYYEARBLC]=(case when QTYYEARBLC<0 then (0-QTYYEARBLC) else QTYYEARBLC end)");
|
|
|
strSql.Append(",[QTYDR],[QTYCR],[QTYBLC],[QTYLASTDR],[QTYLASTCR]");
|
|
|
strSql.Append(",[QTYLASTBLC]=(case when QTYLASTBLC<0 then (0-QTYLASTBLC) else QTYLASTBLC end)");
|
|
|
strSql.Append(",DC=(CASE WHEN QTYYEARBLC<0 THEN '贷' ELSE '借' END)");
|
|
|
strSql.Append(",DC2=(CASE WHEN QTYLASTBLC<0 THEN '贷' ELSE '借' END)");
|
|
|
strSql.Append(",iDR=(SELECT COUNT(*) AS inum from ct_bank_journal WHERE STARTGID='" + strCtSTARTGID + "' and DR<>0 AND ACCGID=b.LINKGID and ACCDATE>='" + strCondition + "' and ACCDATE<='" + strCondition + "' and FCYNO='" + strCondition4 + "')");
|
|
|
strSql.Append(",iCR=(SELECT COUNT(*) AS inum from ct_bank_journal WHERE STARTGID='" + strCtSTARTGID + "' and CR<>0 AND ACCGID=b.LINKGID and ACCDATE>='" + strCondition + "' and ACCDATE<='" + strCondition + "' and FCYNO='" + strCondition4 + "') ");
|
|
|
strSql.Append(" from ");
|
|
|
strSql.Append(" (");
|
|
|
strSql.Append(" select STARTGID,[LINKGID],[CURRENCY]");
|
|
|
strSql.Append(",[AMTYEARDR]=(select top 1 [AMTYEARDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[AMTYEARCR]=(select top 1 [AMTYEARCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[AMTYEARBLC]=(select top 1 [AMTYEARBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",ISNULL(sum([AMTDR]),0) as [AMTDR]");
|
|
|
strSql.Append(",ISNULL(sum([AMTCR]),0) as [AMTCR]");
|
|
|
strSql.Append(",ISNULL(sum([AMTBLC]),0) as [AMTBLC]");
|
|
|
strSql.Append(",[AMTLASTDR]=(select top 1 [AMTLASTDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[AMTLASTCR]=(select top 1 [AMTLASTCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[AMTLASTBLC]=(select top 1 [AMTLASTBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[FCYYEARDR]=(select top 1 [FCYYEARDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[FCYYEARCR]=(select top 1 [FCYYEARCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[FCYYEARBLC]=(select top 1 [FCYYEARBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",ISNULL(sum([FCYDR]),0) as [FCYDR]");
|
|
|
strSql.Append(",ISNULL(sum([FCYCR]),0) as [FCYCR]");
|
|
|
strSql.Append(",ISNULL(sum([FCYBLC]),0) as [FCYBLC]");
|
|
|
strSql.Append(",[FCYLASTDR]=(select top 1 [FCYLASTDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[FCYLASTCR]=(select top 1 [FCYLASTCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[FCYLASTBLC]=(select top 1 [FCYLASTBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[QTYYEARDR]=(select top 1 [QTYYEARDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[QTYYEARCR]=(select top 1 [QTYYEARCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",[QTYYEARBLC]=(select top 1 [QTYYEARBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])='" + strCondition + "' and CURRENCY='" + strCondition4 + "' ORDER BY [DAY])");
|
|
|
strSql.Append(",ISNULL(sum([QTYDR]),0) as [QTYDR]");
|
|
|
strSql.Append(",ISNULL(sum([QTYCR]),0) as [QTYCR]");
|
|
|
strSql.Append(",ISNULL(sum([QTYBLC]),0) as [QTYBLC]");
|
|
|
strSql.Append(",[QTYLASTDR]=(select top 1 [QTYLASTDR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[QTYLASTCR]=(select top 1 [QTYLASTCR] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(",[QTYLASTBLC]=(select top 1 [QTYLASTBLC] from ct_genleg_accitems WITH(NOLOCK) WHERE STARTGID='" + strCtSTARTGID + "' AND LINKGID=a.LINKGID AND ([YEAR]+'-'+[MONTH])<='" + strCondition2 + "' and CURRENCY='" + strCondition4 + "' ORDER BY [YEAR] DESC,[MONTH] DESC,[DAY] DESC)");
|
|
|
strSql.Append(" from ct_genleg_accitems as a");
|
|
|
strSql.Append(" WHERE a.STARTGID='" + strCtSTARTGID + "' AND" + sCondition);
|
|
|
strSql.Append(" GROUP BY [LINKGID],[CURRENCY],[STARTGID]");
|
|
|
strSql.Append(") as b");
|
|
|
strSql.Append(") as ls order by LINKCODE");
|
|
|
//strSql.Append(" and CORPID='" + companyid + "'");
|
|
|
#endregion
|
|
|
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.ToString());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], "");
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_RptCtGenlegAccitemsIndex.js
|
|
|
/// <summary>
|
|
|
/// 导出_RptCtBankJSCheckingIndex.js
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCtBankJSCheckingIndex(string strCondition, string strCondition2, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
string strCtSTARTGID = BasicDataRefDAL.GetCtSTARTGID(strUserID);
|
|
|
var strSql = new StringBuilder();
|
|
|
if (strCondition2 == "银行日记账")
|
|
|
{
|
|
|
if (strCondition.IndexOf("RMB") > -1)
|
|
|
{
|
|
|
strSql.Append("select VOUDATE as 凭证日期,ITEMNO as 当日序号,ACCDATE as 会计期间,EXPLAN as 摘要,VKNO as 凭证字,VOUNO as 凭证号,FENTRYID as 分录号,SETTLETYPENAME as 结算方式,BILLNO as 结算号,DR as 借方,CR as 贷方,DC as 方向,BLC as 余额,ENTERED as 经手人,CREATEUSERNAME as 制单人 from (");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("select VOUDATE as 凭证日期,ITEMNO as 当日序号,ACCDATE as 会计期间,EXPLAN as 摘要,VKNO as 凭证字,VOUNO as 凭证号,FENTRYID as 分录号,SETTLETYPENAME as 结算方式,BILLNO as 结算号,DR as 借方原币,QTYDR as 借方本位币,CR as 贷方原币,QTYCR as 贷方本位币,DC as 方向,BLC as 余额原币,QTYBLC as 余额本位币,ENTERED as 经手人,CREATEUSERNAME as 制单人 from (");
|
|
|
}
|
|
|
strSql.Append("SELECT *,CREATEUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_journal.CREATEUSER),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_journal.MODIFIEDUSER),ACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] where gid=ct_bank_journal.ACCGID),SETTLETYPENAME=isnull((select top 1 STLNAME from [code_stlmode] where STLCODE=ct_bank_journal.SETTLETYPE),''),ISCHECKING=(case when CHECKINGGID='' then '' else (case when CHECKINGGID like 'auto%' then '*' else '**' end) end),QTYBLC=CAST((BLC*FCYEXRATE) as decimal) from ct_bank_journal WITH(NOLOCK) where STARTGID='" + strCtSTARTGID + "'");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("select VOUDATE as 凭证日期,ITEMNO as 当日序号,ACCDATE as 会计期间,EXPLAN as 摘要,SETTLETYPENAME as 结算方式,BILLNO as 结算号,DR as 银行借方,CR as 银行贷方,DC as 方向,BLC as 余额,ENTERED as 经手人,CREATEUSERNAME as 制单人 from (");
|
|
|
strSql.Append("SELECT *,CREATEUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_statement.CREATEUSER),MODIFIEDUSERNAME=(select top 1 SHOWNAME from [user] where gid=ct_bank_statement.MODIFIEDUSER),ACCNAME=(select top 1 ACCNAME from [cw_accitems_gl] where STARTGID='" + strCwSTARTGID + "' and gid=ct_bank_statement.ACCGID),SETTLETYPENAME=(select top 1 STLNAME from [code_stlmode] where STLCODE=ct_bank_statement.SETTLETYPE),ISCHECKING=(case when CHECKINGGID='' then '' else (case when CHECKINGGID like 'auto%' then '*' else '**' end) end),ISIMPORTNAME=(case when ISIMPORT='True' then '是' else '' end) from ct_bank_statement WITH(NOLOCK) where STARTGID='" + strCtSTARTGID + "'");
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(") as ls");
|
|
|
strSql.Append(" order by VOUDATE,convert(decimal(10),ITEMNO)");
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strSql.ToString());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], "");
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_接口凭证列表_MsCwVouchersIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_接口凭证列表_MsCwVouchersIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsCwVouchersIndex(string strCondition, string strGIDs, string formname)
|
|
|
{
|
|
|
string sSQL = "";
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//帐套设置
|
|
|
sSQL = "SELECT top 1 * from cw_design";
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (ds == null)
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('请先设置帐套信息!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
//
|
|
|
string sgids = "'" + strGIDs.Trim().Replace(",", "','") + "'";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = " and " + strCondition;
|
|
|
}
|
|
|
if (strGIDs.Trim() != "")
|
|
|
{
|
|
|
strCondition += " and ORDNO in (" + sgids + ")";
|
|
|
}
|
|
|
|
|
|
//
|
|
|
//1. 金蝶迷你
|
|
|
//2. 金蝶标准
|
|
|
//3. 金蝶k3
|
|
|
//4. 用友U8
|
|
|
//5. 浪潮
|
|
|
//6. SyBase
|
|
|
//7. 用友NC
|
|
|
//8. 金蝶专业
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "1")
|
|
|
{
|
|
|
setExcelReport1(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "2")
|
|
|
{
|
|
|
setExcelReport2(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "3")
|
|
|
{
|
|
|
setExcelReport3(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "4")
|
|
|
{
|
|
|
setExcelReport4(strCondition, ds);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "5")
|
|
|
{
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "6")
|
|
|
{
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "7")
|
|
|
{
|
|
|
setExcelReportNC(strCondition, ds);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "8")
|
|
|
{
|
|
|
setExcelReport8(strCondition);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport1(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kismn.dbf";
|
|
|
string sName = "kismn";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
|
|
|
int iResult = CwVouitemsDA.setExcelReport1(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶迷你凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport2(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kisbz.dbf";
|
|
|
string sName = "kisbz";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
|
|
|
int iResult = CwVouitemsDA.setExcelReport2(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶标准凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport3(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kisk3.dbf";
|
|
|
string sName = "kisk3";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
|
|
|
int iResult = CwVouitemsDA.setExcelReport3(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶K3凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport4(string strCondition, DataSet dsCwDesign)
|
|
|
{//导出用友U8凭证
|
|
|
StringWriter sw = new StringWriter();
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string sSQL = "";
|
|
|
string ls = "";
|
|
|
//
|
|
|
sSQL = "SELECT VOUNO,(CASE WHEN ISNULL(EXPVOUNO,'')='' THEN VOUNO ELSE EXPVOUNO END) EXPVOUNO,VKNO, CONVERT(varchar(10), VOUDATE, 120) AS VOUDATE, ACCYEAR, ACCMONTH, ATTACHS, FCY, QTY, VOUPROP, PREPARED, CHECKED, ENTERED, ERRMSG, ISDELETE, DELETEUSER, DELETETIME, VOUALLNO, ISEXPORT, GID, ORDNO, ITEMNO, ACCID, PACCID, ACCNAME, PROPERTY, GRADE, DC, AMTDR, AMTCR, ISFCY, FCYNO, FCYEXRATE, FCYDR, FCYCR, QTYUNIT, QTYDR, QTYCR, EXPLAN, ISDEPTACC, ISEMPLACC, ISCORPACC, ISITEMACC, DEPTID, EMPLID, CORPID, PITEMID, ITEMID, FIELD10, FIELD9, FIELD8, FIELD7, FIELD6, FIELD5, FIELD4, CORPID as FIELD3, FIELD2, FIELD1, ISSYS, FSETTLCODE, FSETTLENO, MODIFIEDUSER, MODIFIEDTIME, CUSTOMERNAME, SALE, BLNO FROM VW_cw_vouchers_vouitems where 1=1" + strCondition + " order by VOUALLNO,ITEMNO";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (DS != null)
|
|
|
{
|
|
|
string strCompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select top 1 FULLNAME from company where gid='" + strCompanyID + "'");
|
|
|
//
|
|
|
ls = "填制凭证,V800";
|
|
|
sw.WriteLine(ls.Trim());
|
|
|
//用友U8 凭证导出 导出凭证
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
{
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
{
|
|
|
ls = (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//F1日期
|
|
|
ls += "," + (myRow["VKNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["VKNO"].ToString().Trim() + "\""));//F2类别
|
|
|
ls += "," + (myRow["EXPVOUNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["EXPVOUNO"].ToString().Trim() + "\""));//F3凭证号
|
|
|
ls += "," + (dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim() == "" ? "0" : dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//F4附单据数
|
|
|
ls += "," + (myRow["EXPLAN"].ToString().Trim() == "" ? "" : ("\"" + myRow["EXPLAN"].ToString().Trim() + "\""));//F5摘要
|
|
|
ls += "," + (myRow["ACCID"].ToString().Trim() == "" ? "" : ("\"" + myRow["ACCID"].ToString().Trim() + "\""));//F6科目编码
|
|
|
ls += "," + myRow["AMTDR"].ToString().Trim();//F7借方
|
|
|
ls += "," + myRow["AMTCR"].ToString().Trim();//F8贷方
|
|
|
ls += ",0.00";// + myRow["FCYNO"].ToString().Trim();//F9数量/外币编号
|
|
|
//
|
|
|
if (myRow["FCYDR"].ToString().Trim() != "0.00" || myRow["FCYCR"].ToString().Trim() != "0.00")
|
|
|
{
|
|
|
ls += "," + ((myRow["FCYDR"].ToString().Trim() == "0.00" ? myRow["FCYCR"].ToString().Trim() : myRow["FCYDR"].ToString().Trim()));//F10外币
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ls += "," + ((myRow["AMTDR"].ToString().Trim() == "0.00" ? myRow["AMTCR"].ToString().Trim() : myRow["AMTDR"].ToString().Trim()));//F7借方//F8贷方
|
|
|
}
|
|
|
//
|
|
|
ls += "," + Decimal.Parse(myRow["FCYEXRATE"].ToString().Trim()).ToString("F2");//F11汇率
|
|
|
ls += "," + (myRow["PREPARED"].ToString().Trim() == "" ? "" : ("\"" + myRow["PREPARED"].ToString().Trim() + "\""));//F12制单人
|
|
|
ls += "," + (myRow["FSETTLCODE"].ToString().Trim() == "" ? "" : ("\"" + myRow["FSETTLCODE"].ToString().Trim() + "\"")); ;//F13结算方式
|
|
|
string sbl = "";
|
|
|
sbl = T_ALL_DA.GetStrSQL("gid", "select gid from cw_design where AR='" + myRow["ACCID"].ToString().Trim() + "' or ARFC='" + myRow["ACCID"].ToString().Trim() + "' or AP='" + myRow["ACCID"].ToString().Trim() + "' or APFC='" + myRow["ACCID"].ToString().Trim() + "'");
|
|
|
if (sbl.Trim() == "" && myRow["ACCID"].ToString().Trim() != "100206")
|
|
|
{
|
|
|
ls += ",";//F14票号
|
|
|
ls += ",";//F15发生日期
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ls += "," + (myRow["BLNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["BLNO"].ToString().Trim() + "\""));//F14票号
|
|
|
ls += "," + (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//F15发生日期
|
|
|
}
|
|
|
//ls += ",";//F14票号
|
|
|
//ls += ",";//F15发生日期
|
|
|
ls += "," + (myRow["DEPTID"].ToString().Trim() == "" ? "" : ("\"" + myRow["DEPTID"].ToString().Trim() + "\""));//F16部门编码
|
|
|
ls += "," + (myRow["EMPLID"].ToString().Trim() == "" ? "" : ("\"" + myRow["EMPLID"].ToString().Trim() + "\""));//F17个人编码
|
|
|
ls += "," + (myRow["CORPID"].ToString().Trim() == "" ? "" : ("\"" + myRow["CORPID"].ToString().Trim() + "\""));//F18客户编码
|
|
|
ls += "," + (myRow["FIELD3"].ToString().Trim() == "" ? "" : ("\"" + myRow["FIELD3"].ToString().Trim() + "\"")); ;//F19供应商编码 FIELD3
|
|
|
ls += ",";//F20业务员
|
|
|
ls += "," + (myRow["ITEMID"].ToString().Trim() == "" ? "" : ("\"" + myRow["ITEMID"].ToString().Trim() + "\"")); ;//F21项目编码
|
|
|
ls += ",";//F22自定义项
|
|
|
ls += ",";//F23自定义项2
|
|
|
ls += ",";//F24自由项1
|
|
|
ls += ",";//F25自由项2
|
|
|
ls += ",";//F26自由项3
|
|
|
ls += ",";//F27自由项4
|
|
|
ls += ",0";//F28自由项5
|
|
|
ls += ",";//F29自由项6
|
|
|
ls += ",0.00";//F30自由项7
|
|
|
ls += ",";//F31自由项8
|
|
|
ls += ",";//F32自由项9
|
|
|
ls += ",";//F33自由项10
|
|
|
ls += ",";//F34外部系统标识
|
|
|
ls += ",";//F35业务类型
|
|
|
ls += ",";//F36单据类型
|
|
|
ls += ",";//F37单据日期
|
|
|
ls += ",";//F38单据号
|
|
|
ls += "," + (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim().Equals("True") ? "0" : "1");//F39凭证是否可改
|
|
|
ls += ",1";//F40分录是否可增删
|
|
|
ls += ",1";//F41合计金额是否保值
|
|
|
ls += ",1";//F42数值是否可改
|
|
|
ls += ",1";//F43科目是否可改
|
|
|
ls += ",";//F44受控科目
|
|
|
ls += ",1";//F45往来是否可改
|
|
|
ls += ",1";//F46部门是否可改
|
|
|
ls += ",1";//F47项目是否可改
|
|
|
ls += ",0";//F48往来项是否必输
|
|
|
ls += ",";//F49账套号
|
|
|
ls += ",";//F50核算单位
|
|
|
ls += ",";//F51会计年度
|
|
|
ls += ",";//F52会计期间
|
|
|
ls += ",";//F53类别顺序号
|
|
|
ls += ",";//F54凭证号
|
|
|
ls += ",";//F55审核人
|
|
|
ls += ",";//F56记账人
|
|
|
ls += ",0";//F57是否记账
|
|
|
ls += ",";//F58出纳人
|
|
|
ls += ",";//F59行号
|
|
|
ls += ",";//F60外币名称
|
|
|
ls += ",0.00";//F61单价
|
|
|
ls += ",";//F62科目名称
|
|
|
ls += ",";//F63部门名称
|
|
|
ls += ",";//F64个人名称
|
|
|
ls += "," + (myRow["CUSTOMERNAME"].ToString().Trim() == "" ? "" : ("\"" + myRow["CUSTOMERNAME"].ToString().Trim() + "\""));//F65客户简称
|
|
|
ls += ",";//F66供应商简称
|
|
|
ls += ",";//F67项目名称
|
|
|
ls += ",";//F68项目大类编码
|
|
|
ls += ",";//F69项目大类名称
|
|
|
ls += ",";//F70对方科目
|
|
|
ls += ",0";//F71银行两清标志
|
|
|
ls += ",0";//F72往来两清标志
|
|
|
ls += ",0";//F73银行核销标志
|
|
|
ls += ",";//F74外部系统名称
|
|
|
ls += ",";//F75外部账套号
|
|
|
ls += ",0";//F76外部会计年度
|
|
|
ls += ",0";//F77外部会计期间
|
|
|
ls += ",";//F78外部制单日期
|
|
|
ls += ",";//F79外部系统版本
|
|
|
ls += ",";//F80凭证标识
|
|
|
ls += ",";//F81分录自动编号
|
|
|
ls += ",";//F82唯一标识
|
|
|
ls += ",";//F83主管签字
|
|
|
ls += ",";//F84自由项11
|
|
|
ls += ",";//F85自由项12
|
|
|
ls += ",";//F86自由项13
|
|
|
ls += ",";//F87自由项14
|
|
|
ls += ",0";//F88自由项15
|
|
|
ls += ",0.00";//F89自由项16
|
|
|
sw.WriteLine(ls);
|
|
|
}
|
|
|
}
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers set ISEXPORT=1 where 1=1" + strCondition;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
//
|
|
|
sw.Close();
|
|
|
switch ("MUTEXT")
|
|
|
{
|
|
|
case "MUEXCEL":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
break;
|
|
|
case "MUTEXT":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
Response.ContentType = "application/txt";
|
|
|
break;
|
|
|
case "MUWORD":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
Response.ContentType = "application/ms-word";
|
|
|
break;
|
|
|
case "MUPDF":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
Response.ContentType = "application/pdf";
|
|
|
break;
|
|
|
case "MUXML":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
Response.ContentType = "application/xml";
|
|
|
break;
|
|
|
}
|
|
|
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
Response.Write(sw);
|
|
|
Response.End();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportNC(string strCondition, DataSet dsCwDesign)
|
|
|
{//导出用友NC凭证
|
|
|
StringWriter sw = new StringWriter();
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string sSQL = "";
|
|
|
string ls = "";
|
|
|
//
|
|
|
sSQL = "SELECT ROW_NUMBER() OVER (ORDER BY i.ACCID) AS RowNumber,'0010100011801-0001','01' pzlb,c.VOUNO,'0' fdjs, c.PREPARED, ";//0-5
|
|
|
sSQL = sSQL + " CONVERT(varchar(10), c.VOUDATE, 120) AS VOUDATE, i.EXPLAN,i.ACCID,'人民币' bz, "; //6-9
|
|
|
sSQL = sSQL + " i.FCYDR,i.AMTDR,'' jtbbj,'' qjbbj,'01120' ywdybm,'' dj,'' jfsl,'' dfsl, ";//10-17
|
|
|
sSQL = sSQL + " i.FCYCR,i.AMTCR,'' _20,'' _21,i.BLNO,'' _23,'' _24, CONVERT(varchar(10), c.VOUDATE, 120) AS BSDATE, ";//18-25
|
|
|
sSQL = sSQL + " '' _26,'' _27,'' _28,'' _29,'' _30,'' _31,'' _32,'' _33,'' _34,'' _35,'' _36, ";//26-36
|
|
|
sSQL = sSQL + " '1' _37,'' _38,'' _39,";//37-39
|
|
|
sSQL = sSQL + " i.FIELD1, i.FIELD2, i.FIELD3, i.FIELD4, i.FIELD5, i.FIELD6, i.FIELD7, i.FIELD8, i.FIELD9";
|
|
|
sSQL = sSQL + " FROM cw_vouchers AS c INNER JOIN cw_vouitems AS i ON c.ORDNO = i.ORDNO where 1=1" + strCondition.Replace("ORDNO", "i.ORDNO");
|
|
|
sSQL = sSQL + " order by i.ACCID ";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (DS != null)
|
|
|
{
|
|
|
string strCompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select top 1 FULLNAME from company where gid='" + strCompanyID + "'");
|
|
|
//
|
|
|
ls = "\"null_$head,main_m_pk_accountingbook,main_m_pk_vouchertype,main_m_num,main_m_attachment,main_pk_prepared,main_m_prepareddate,m_explanation,m_accsubjcode,m_pk_currtype,m_debitamount,m_localdebitamount,m_groupdebitamount,m_globaldebitamount,unitname,m_price,m_debitquantity,m_creditquantity,m_creditamount,m_localcreditamount,m_groupcreditamount,m_globalcreditamount,m_checkno,m_checkdate,verifyno,verifydate,m_bankaccount,billtype,m_checkstyle,vat_pk_vatcountry,vat_pk_receivecountry,vat_businesscode,vat_pk_clientvatcode,vat_pk_suppliervatcode,vat_pk_taxcode,vat_direction,vat_moneyamount,m_excrate2,excrate3,excrate4,ass_1,ass_2,ass_3,ass_4,ass_5,ass_6,ass_7,ass_8,ass_9\"\t核算账簿\t凭证类别编码 凭证号 附单据数 制单人编码 制单日期 摘要 科目编码 币种 原币借方金额 本币借方金额 集团本币借方金额 全局本币借方金额 业务单元编码 单价 借方数量 贷方数量 原币贷方金额 本币贷方金额 集团本币贷方金额 全局本币贷方金额 结算号 结算日期 核销号 业务日期 银行账户 票据类型 结算方式 报税国家 收货国 交易代码 客户VAT注册码 供应商VAT注册码 税码 VAT方向 计税金额 组织本币汇率 集团本币汇率 全局本币汇率 辅助核算1 辅助核算2 辅助核算3 辅助核算4 辅助核算5 辅助核算6 辅助核算7 辅助核算8 辅助核算9";
|
|
|
ls = ls.Replace(" ", "\t");
|
|
|
////////////////////////////////////
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers set ISEXPORT=1 where 1=1" + strCondition;
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
//
|
|
|
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], ls, 1);
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
/*
|
|
|
sw.WriteLine(ls.Trim());
|
|
|
//用友U8 凭证导出 导出凭证
|
|
|
var linenum = 0;
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
{
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
{
|
|
|
ls = linenum.ToString();//0列 行号
|
|
|
linenum++;
|
|
|
ls += "\t" + "0010100011801-0001";//1列 "核算账簿 推测是帐套号"
|
|
|
ls += "\t" + "1";//2列 凭证类别编码
|
|
|
ls += "\t" ;//3列 凭证号 自动生成
|
|
|
ls += "\t" +"0";//F4附单据数
|
|
|
ls += "\t" + (myRow["PREPARED"].ToString().Trim() == "" ? "" : ("\"" + myRow["PREPARED"].ToString().Trim() + "\""));//5 制单人
|
|
|
ls += "\t" + (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//6 制单日期
|
|
|
ls += "\t" + (myRow["EXPLAN"].ToString().Trim() == "" ? "" : ("\"" + myRow["EXPLAN"].ToString().Trim() + "\""));// 7 摘要
|
|
|
ls += "\t" + myRow["ACCID"].ToString().Trim();//8 科目编码
|
|
|
ls += "\t" + "人民币";//9 币种
|
|
|
ls += "\t" + myRow["FCYDR"].ToString().Trim();//10 原币借方
|
|
|
ls += "\t" + myRow["AMTDR"].ToString().Trim();//11 本币借方
|
|
|
ls += "\t";//集团本币借方金额
|
|
|
ls += "\t";//全局本币借方金额
|
|
|
ls += "\t"+"01120";//业务单元编码14
|
|
|
ls += "\t";//单价15
|
|
|
ls += "\t";//借方数量16
|
|
|
ls += "\t";//贷方数量17
|
|
|
ls += "\t" + myRow["FCYCR"].ToString().Trim(); ;//原币贷方金额18
|
|
|
ls += "\t" + myRow["AMTCR"].ToString().Trim();//本币贷方金额19
|
|
|
ls += "\t";//集团本币贷方金额 20
|
|
|
ls += "\t";//全局本币贷方金额21
|
|
|
ls += "\t";//结算号22//此处放置支票号
|
|
|
ls += "\t";//结算日期23
|
|
|
ls += "\t";//核销号24
|
|
|
ls += "\t"+ (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));;//业务日期25
|
|
|
ls += "\t";//银行账户26
|
|
|
ls += "\t";//票据类型27
|
|
|
ls += "\t";//结算方式
|
|
|
ls += "\t";//报税国家
|
|
|
ls += "\t";//收货国30
|
|
|
ls += "\t";//交易代码
|
|
|
ls += "\t";//客户VAT注册码
|
|
|
ls += "\t";//供应商VAT注册码
|
|
|
ls += "\t";//税码
|
|
|
ls += "\t";//VAT方向35
|
|
|
ls += "\t";//计税金额
|
|
|
ls += "\t"+"1";//组织本币汇率37
|
|
|
ls += "\t";//集团本币汇率
|
|
|
ls += "\t";//全局本币汇率
|
|
|
ls += "\t" + myRow["FIELD1"].ToString().Trim(); //辅助核算1 40
|
|
|
ls += "\t" + myRow["FIELD2"].ToString().Trim();//辅助核算2
|
|
|
ls += "\t" + myRow["FIELD3"].ToString().Trim();//辅助核算3
|
|
|
ls += "\t" + myRow["FIELD4"].ToString().Trim();//辅助核算4
|
|
|
ls += "\t" + myRow["FIELD5"].ToString().Trim();//辅助核算5
|
|
|
ls += "\t" + myRow["FIELD6"].ToString().Trim();//辅助核算6
|
|
|
ls += "\t" + myRow["FIELD7"].ToString().Trim();//辅助核算7
|
|
|
ls += "\t" + myRow["FIELD8"].ToString().Trim();//辅助核算8
|
|
|
ls += "\t" + myRow["FIELD9"].ToString().Trim();//辅助核算9 48
|
|
|
//共49列
|
|
|
|
|
|
sw.WriteLine(ls);
|
|
|
}
|
|
|
}
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers set ISEXPORT=1 where ORDNO in('" + sGid.Trim() + "')";
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
//
|
|
|
sw.Close();
|
|
|
switch ("MUEXCEL")
|
|
|
{
|
|
|
case "MUEXCEL":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
break;
|
|
|
case "MUTEXT":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
Response.ContentType = "application/txt";
|
|
|
break;
|
|
|
case "MUWORD":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
Response.ContentType = "application/ms-word";
|
|
|
break;
|
|
|
case "MUPDF":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
Response.ContentType = "application/pdf";
|
|
|
break;
|
|
|
case "MUXML":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
Response.ContentType = "application/xml";
|
|
|
break;
|
|
|
}
|
|
|
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
Response.Write(sw);
|
|
|
Response.End();*/
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport8(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kiszy.dbf";
|
|
|
string sName = "kiszy";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
CwVouitemsDA CwVouitemsDA = new CwVouitemsDA();
|
|
|
int iResult = CwVouitemsDA.setExcelReport8(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶专业版凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶迷你凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReport1(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
|
|
|
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
|
|
|
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
|
|
|
+ "select "
|
|
|
+ " VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
|
|
|
//+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,''"//财务说不需要提单号字段的内容导入金蝶中
|
|
|
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers set ISEXPORT=1 where 1=1" + strCondition;
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶标准凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReport2(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
|
|
|
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
|
|
|
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
|
|
|
+ "select "
|
|
|
+ " VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
|
|
|
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers set ISEXPORT=1 where 1=1" + strCondition;
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶K3凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReport3(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1"
|
|
|
+ ",FOBJNAME1,FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4"
|
|
|
+ ",FCLSNAME5,FOBJID5,FOBJNAME5,FCLSNAME6,FOBJID6,FOBJNAME6,FCLSNAME7,FOBJID7,FOBJNAME7,FCLSNAME8"
|
|
|
+ ",FOBJID8,FOBJNAME8,FOBJNAME9,FOBJID9,FCLSNAME9,FCLSNAME10,FOBJID10,FOBJNAME10,FCLSNAME11,FOBJID11"
|
|
|
+ ",FOBJNAME11,FCLSNAME12,FOBJID12,FOBJNAME12,FCLSNAME13,FOBJID13,FOBJNAME13,FCLSNAME14,FOBJID14,FOBJNAME14"
|
|
|
+ ",FCLSNAME15,FOBJID15,FOBJNAME15,FTRANSID,FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE"
|
|
|
+ ",FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT"
|
|
|
+ ",FPOSTED,FMODULE,FDELETED,FSERIALNO,FUNITNAME,FREFERENCE,FCASHFLOW) "
|
|
|
+ "select "
|
|
|
+ " VouDate,VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID"
|
|
|
+ ",CorpID,null,CorpID,CorpID,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,BLNO,FCYNO,FCYEXRATE,DC,AMTDR+AMTCR,null,0"
|
|
|
+ ",AMTDR,AMTCR,FSETTLCODE,FSETTLENO,PREPARED,null,null,null,null,ATTACHS"
|
|
|
+ ",'False',null,'False',VOUNO,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶专业版凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReport8(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
|
|
|
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
|
|
|
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
|
|
|
+ "select "
|
|
|
+ " VouDate,AccMonth,VKNO,VOUNO,ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
|
|
|
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers set ISEXPORT=1 where 1=1" + strCondition;
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
//
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_现金流量表列表_ExcelRptCwCfsIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_现金流量表列表_ExcelRptCwCfsIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelRptCwCfsIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "会计期间\t项目\t本月金额\t本年累计金额";
|
|
|
string strDataIndex = "ACCDATE,ITEMNAME,QTYBLC,QTYLASTBLC";//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as a order by LINENUM";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_总账成本收入列表_MsCwVouchersGlChFeeIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_总账成本收入列表_MsCwVouchersGlChFeeIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsCwVouchersGlChFeeIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "VOUALLNO as 凭证号,OPLBNAME as 业务类型,CUSTOMERNAME as 委托单位,CUSTNO as 委托单号,MBLNO as 主提单号,ACCDATE as 会计期间,ETD as 业务日期,FEETYPE as 费用类型,FEESTATUS as 费用状态,FEENAME as 费用名称,SETTLEMENTNAME as 结算单位,UNIT as 单位,UNITPRICE as 不含税单价,TAXRATE as 税率,TAXUNITPRICE as 单价,QUANTITY as 数量,NOTAXAMOUNT as 不含税金额,AMOUNT as 金额,CURRENCY as 币别,EXCHANGERATE as 汇率,ACCTAXRATE as 销项税率,SETTLEMENT as 结算金额,INVOICE as 开票金额,INVOICENUM as 发票号码,REMARK as 费用备注,ENTEROPERATOR as 录入人,ENTERDATE as 录入时间";//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as a order by LINENUM";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_免税明细列表_RptChFeeInvoiceDutyFreeIndex.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_免税明细列表_RptChFeeInvoiceDutyFreeIndex.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsRptChFeeInvoiceDutyFreeIndex(string strCondition, string formname)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string strHeader = "";
|
|
|
string strDataIndex = "CUSTOMERNAME_i as 委托方名称,INVOICENO as 发票号,MBLNO as [(运)提单号],VESSEL as 船名,VOYNO as 航次,PORTLOAD as 起运港,PORTDISCHARGE as 卸货港,REMARK as 备注,gjUSD as [国际运费USD],gjRMB as [国际运费RMB],gkRMB as 港口码头费,qtRMB as 其他收费项";//字段名称
|
|
|
//
|
|
|
strCondition = "select " + strDataIndex + " from (" + strCondition + ") as a order by INVOICENO,CUSTOMERNAME_i,MBLNO";
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(strCondition.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], strHeader.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出_总账凭证_财务接口_MsCwVouchersGlIndex3.aspx
|
|
|
/// <summary>
|
|
|
/// 导出_总账凭证_财务接口_MsCwVouchersGlIndex3.aspx
|
|
|
/// </summary>
|
|
|
/// <param name="strCondition">查询条件</param>
|
|
|
/// <param name="formname">页面框架名称(用于判断取个人列表配置)</param>
|
|
|
protected void ExcelMsCwVouchersGlIndex3(string strCondition, string strGIDs, string formname)
|
|
|
{
|
|
|
string sSQL = "";
|
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(strUserID);
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//帐套设置
|
|
|
sSQL = "SELECT top 1 * from cw_design_gl where STARTGID='" + strCwSTARTGID + "'";
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (ds == null)
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('请先设置帐套信息!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
//
|
|
|
string sgids = "'" + strGIDs.Trim().Replace(",", "','") + "'";
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = " and " + strCondition;
|
|
|
}
|
|
|
if (strGIDs.Trim() != "")
|
|
|
{
|
|
|
strCondition += " and ORDNO in (" + sgids + ")";
|
|
|
}
|
|
|
strCondition += " and STARTGID='" + strCwSTARTGID + "'";
|
|
|
|
|
|
//
|
|
|
//1. 金蝶迷你
|
|
|
//2. 金蝶标准
|
|
|
//3. 金蝶k3
|
|
|
//4. 用友U8
|
|
|
//5. 浪潮
|
|
|
//6. SyBase
|
|
|
//7. 用友NC
|
|
|
//8. 金蝶专业
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "1")
|
|
|
{
|
|
|
setExcelReportGlMN(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "2")
|
|
|
{
|
|
|
setExcelReportGlBZ(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "3")
|
|
|
{
|
|
|
setExcelReportGlK3(strCondition);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "4")
|
|
|
{
|
|
|
setExcelReportGlU8(strCondition, ds);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "5")
|
|
|
{
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "6")
|
|
|
{
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "7")
|
|
|
{
|
|
|
setExcelReportGlNC(strCondition, ds);
|
|
|
}
|
|
|
else if (ds.Tables[0].Rows[0]["FSOFTCODE"].ToString().Trim() == "8")
|
|
|
{
|
|
|
setExcelReportGlZY(strCondition);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlMN(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kismn.dbf";
|
|
|
string sName = "kismn";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
int iResult = setExcelReportGlMN(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶迷你凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlBZ(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
//string sGid = gids.Trim();
|
|
|
//sGid = sGid.Trim().Replace(",", "','");
|
|
|
//
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kisbz.dbf";
|
|
|
string sName = "kisbz";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
int iResult = setExcelReportGlBZ(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶标准凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlK3(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kisk3.dbf";
|
|
|
string sName = "kisk3";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
int iResult = setExcelReportGlK3(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶K3凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlU8(string strCondition, DataSet dsCwDesign)
|
|
|
{
|
|
|
//导出用友U8凭证
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string fileName = "U8_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
|
|
|
string filePath = xmlPath + "//" + fileName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
if (System.IO.File.Exists(filePath))
|
|
|
{
|
|
|
System.IO.File.Delete(filePath);
|
|
|
}
|
|
|
FileStream f = new FileStream(filePath, FileMode.Create);
|
|
|
StreamWriter sw = new StreamWriter(f, Encoding.Default);
|
|
|
//StringWriter sw = new StringWriter();
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string sSQL = "";
|
|
|
string ls = "";
|
|
|
//
|
|
|
#region sSQL
|
|
|
sSQL = "SELECT VOUNO, VKNO, CONVERT(varchar(10), VOUDATE, 120) AS VOUDATE, ACCYEAR, ACCMONTH, ATTACHS, FCY, QTY, VOUPROP, PREPARED, CHECKED, ENTERED, ERRMSG, ISDELETE, DELETEUSER, DELETETIME, VOUALLNO, ISEXPORT, GID, ORDNO, ITEMNO, ACCID, PACCID, ACCNAME, PROPERTY, GRADE, DC, AMTDR, AMTCR, ISFCY, FCYNO, FCYEXRATE, FCYDR, FCYCR, QTYUNIT, QTYDR, QTYCR, EXPLAN, ISDEPTACC, ISEMPLACC, ISCORPACC, ISITEMACC, DEPTID, EMPLID, CORPID, PITEMID, ITEMID, FIELD10, FIELD9, FIELD8, FIELD7, FIELD6, FIELD5, FIELD4, CORPID as FIELD3, FIELD2, FIELD1, ISSYS, FSETTLCODE, FSETTLENO,FSETTLDATE, MODIFIEDUSER, MODIFIEDTIME, CUSTOMERNAME, SALE, BLNO FROM VW_cw_vouchers_vouitems_gl where 1=1" + strCondition + " order by VOUALLNO,ITEMNO";
|
|
|
#endregion
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (DS != null)
|
|
|
{
|
|
|
string strCompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select top 1 FULLNAME from [company] where gid='" + strCompanyID + "'");
|
|
|
//
|
|
|
ls = "填制凭证,V800";
|
|
|
sw.WriteLine(ls.Trim());
|
|
|
//用友U8 凭证导出 导出凭证
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
{
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
{
|
|
|
#region 整合字符串
|
|
|
ls = (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//F1日期
|
|
|
ls += "," + (myRow["VKNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["VKNO"].ToString().Trim() + "\""));//F2类别
|
|
|
ls += "," + (myRow["VOUNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUNO"].ToString().Trim() + "\""));//F3凭证号
|
|
|
//ls += "," + (dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim() == "" ? "0" : dsCwDesign.Tables[0].Rows[0]["AFFIXNO"].ToString().Trim());//F4附单据数AFFIXNO
|
|
|
ls += "," + (myRow["ATTACHS"].ToString().Trim() == "" ? "0" : myRow["ATTACHS"].ToString().Trim());//F4附单据数
|
|
|
ls += "," + (myRow["EXPLAN"].ToString().Trim() == "" ? "" : ("\"" + myRow["EXPLAN"].ToString().Trim() + "\""));//F5摘要
|
|
|
ls += "," + (myRow["ACCID"].ToString().Trim() == "" ? "" : ("\"" + myRow["ACCID"].ToString().Trim() + "\""));//F6科目编码
|
|
|
ls += "," + myRow["AMTDR"].ToString().Trim();//F7借方
|
|
|
ls += "," + myRow["AMTCR"].ToString().Trim();//F8贷方
|
|
|
ls += ",0.00";// + myRow["FCYNO"].ToString().Trim();//F9数量/外币编号
|
|
|
//
|
|
|
if (myRow["FCYDR"].ToString().Trim() != "0.00" || myRow["FCYCR"].ToString().Trim() != "0.00")
|
|
|
{
|
|
|
ls += "," + ((myRow["FCYDR"].ToString().Trim() == "0.00" ? myRow["FCYCR"].ToString().Trim() : myRow["FCYDR"].ToString().Trim()));//F10外币
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ls += "," + ((myRow["AMTDR"].ToString().Trim() == "0.00" ? myRow["AMTCR"].ToString().Trim() : myRow["AMTDR"].ToString().Trim()));//F7借方//F8贷方
|
|
|
}
|
|
|
//
|
|
|
ls += "," + Decimal.Parse(myRow["FCYEXRATE"].ToString().Trim()).ToString("F2");//F11汇率
|
|
|
ls += "," + (myRow["PREPARED"].ToString().Trim() == "" ? "" : ("\"" + myRow["PREPARED"].ToString().Trim() + "\""));//F12制单人
|
|
|
ls += "," + (myRow["FSETTLCODE"].ToString().Trim() == "" ? "" : ("\"" + myRow["FSETTLCODE"].ToString().Trim() + "\"")); ;//F13结算方式
|
|
|
string sbl = "";
|
|
|
sbl = T_ALL_DA.GetStrSQL("gid", "select gid from cw_design_gl where AR='" + myRow["ACCID"].ToString().Trim() + "' or ARFC='" + myRow["ACCID"].ToString().Trim() + "' or AP='" + myRow["ACCID"].ToString().Trim() + "' or APFC='" + myRow["ACCID"].ToString().Trim() + "'");
|
|
|
if (sbl.Trim() == "" && myRow["ACCID"].ToString().Trim() != "100206")
|
|
|
{
|
|
|
ls += ",";//F14票号
|
|
|
ls += ",";//F15发生日期
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ls += "," + (myRow["BLNO"].ToString().Trim() == "" ? "" : ("\"" + myRow["BLNO"].ToString().Trim() + "\""));//F14票号
|
|
|
ls += "," + (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//F15发生日期
|
|
|
}
|
|
|
//ls += ",";//F14票号
|
|
|
//ls += ",";//F15发生日期
|
|
|
ls += "," + (myRow["DEPTID"].ToString().Trim() == "" ? "" : ("\"" + myRow["DEPTID"].ToString().Trim() + "\""));//F16部门编码
|
|
|
ls += "," + (myRow["EMPLID"].ToString().Trim() == "" ? "" : ("\"" + myRow["EMPLID"].ToString().Trim() + "\""));//F17个人编码
|
|
|
ls += "," + (myRow["CORPID"].ToString().Trim() == "" ? "" : ("\"" + myRow["CORPID"].ToString().Trim() + "\""));//F18客户编码
|
|
|
ls += "," + (myRow["FIELD3"].ToString().Trim() == "" ? "" : ("\"" + myRow["FIELD3"].ToString().Trim() + "\"")); ;//F19供应商编码 FIELD3
|
|
|
ls += ",";//F20业务员
|
|
|
ls += "," + (myRow["ITEMID"].ToString().Trim() == "" ? "" : ("\"" + myRow["ITEMID"].ToString().Trim() + "\"")); ;//F21项目编码
|
|
|
ls += ",";//F22自定义项
|
|
|
ls += ",";//F23自定义项2
|
|
|
ls += ",";//F24自由项1
|
|
|
ls += ",";//F25自由项2
|
|
|
ls += ",";//F26自由项3
|
|
|
ls += ",";//F27自由项4
|
|
|
ls += ",0";//F28自由项5
|
|
|
ls += ",";//F29自由项6
|
|
|
ls += ",0.00";//F30自由项7
|
|
|
ls += ",";//F31自由项8
|
|
|
ls += ",";//F32自由项9
|
|
|
ls += ",";//F33自由项10
|
|
|
ls += ",";//F34外部系统标识
|
|
|
ls += ",";//F35业务类型
|
|
|
ls += ",";//F36单据类型
|
|
|
ls += ",";//F37单据日期
|
|
|
ls += ",";//F38单据号
|
|
|
ls += "," + (dsCwDesign.Tables[0].Rows[0]["ISVBM"].ToString().Trim().Equals("True") ? "0" : "1");//F39凭证是否可改
|
|
|
ls += ",1";//F40分录是否可增删
|
|
|
ls += ",1";//F41合计金额是否保值
|
|
|
ls += ",1";//F42数值是否可改
|
|
|
ls += ",1";//F43科目是否可改
|
|
|
ls += ",";//F44受控科目
|
|
|
ls += ",1";//F45往来是否可改
|
|
|
ls += ",1";//F46部门是否可改
|
|
|
ls += ",1";//F47项目是否可改
|
|
|
ls += ",0";//F48往来项是否必输
|
|
|
ls += ",";//F49账套号
|
|
|
ls += ",";//F50核算单位
|
|
|
ls += ",";//F51会计年度
|
|
|
ls += ",";//F52会计期间
|
|
|
ls += ",";//F53类别顺序号
|
|
|
ls += ",";//F54凭证号
|
|
|
ls += ",";//F55审核人
|
|
|
ls += ",";//F56记账人
|
|
|
ls += ",0";//F57是否记账
|
|
|
ls += ",";//F58出纳人
|
|
|
ls += ",";//F59行号
|
|
|
ls += ",";//F60外币名称
|
|
|
ls += ",0.00";//F61单价
|
|
|
ls += ",";//F62科目名称
|
|
|
ls += ",";//F63部门名称
|
|
|
ls += ",";//F64个人名称
|
|
|
ls += "," + (myRow["CUSTOMERNAME"].ToString().Trim() == "" ? "" : ("\"" + myRow["CUSTOMERNAME"].ToString().Trim() + "\""));//F65客户简称
|
|
|
ls += ",";//F66供应商简称
|
|
|
ls += ",";//F67项目名称
|
|
|
ls += ",";//F68项目大类编码
|
|
|
ls += ",";//F69项目大类名称
|
|
|
ls += ",";//F70对方科目
|
|
|
ls += ",0";//F71银行两清标志
|
|
|
ls += ",0";//F72往来两清标志
|
|
|
ls += ",0";//F73银行核销标志
|
|
|
ls += ",";//F74外部系统名称
|
|
|
ls += ",";//F75外部账套号
|
|
|
ls += ",0";//F76外部会计年度
|
|
|
ls += ",0";//F77外部会计期间
|
|
|
ls += ",";//F78外部制单日期
|
|
|
ls += ",";//F79外部系统版本
|
|
|
ls += ",";//F80凭证标识
|
|
|
ls += ",";//F81分录自动编号
|
|
|
ls += ",";//F82唯一标识
|
|
|
ls += ",";//F83主管签字
|
|
|
ls += ",";//F84自由项11
|
|
|
ls += ",";//F85自由项12
|
|
|
ls += ",";//F86自由项13
|
|
|
ls += ",";//F87自由项14
|
|
|
ls += ",0";//F88自由项15
|
|
|
ls += ",0.00";//F89自由项16
|
|
|
#endregion
|
|
|
sw.WriteLine(ls);
|
|
|
}
|
|
|
}
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers_gl set ISEXPORT=1 where 1=1" + strCondition.Replace("ACCDATE", "(ACCYEAR+'-'+ACCMONTH)");
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
sw.Close();
|
|
|
f.Close();
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//
|
|
|
#region 暂时屏蔽
|
|
|
//switch ("MUTEXT")
|
|
|
//{
|
|
|
// case "MUEXCEL":
|
|
|
// Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
// Response.ContentType = "application/ms-excel";
|
|
|
// break;
|
|
|
// case "MUTEXT":
|
|
|
// Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
// Response.ContentType = "application/txt";
|
|
|
// break;
|
|
|
// case "MUWORD":
|
|
|
// Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
// Response.ContentType = "application/ms-word";
|
|
|
// break;
|
|
|
// case "MUPDF":
|
|
|
// Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
// Response.ContentType = "application/pdf";
|
|
|
// break;
|
|
|
// case "MUXML":
|
|
|
// Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
// Response.ContentType = "application/xml";
|
|
|
// break;
|
|
|
//}
|
|
|
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
//Response.Write(sw);
|
|
|
//Response.End();
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlNC(string strCondition, DataSet dsCwDesign)
|
|
|
{//导出用友NC凭证
|
|
|
StringWriter sw = new StringWriter();
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string sSQL = "";
|
|
|
string ls = "";
|
|
|
//
|
|
|
#region sSQL
|
|
|
sSQL = "SELECT ROW_NUMBER() OVER (ORDER BY ACCID) AS RowNumber,'0010100011801-0001','01' pzlb,VOUNO,'0' fdjs, PREPARED, ";//0-5
|
|
|
sSQL = sSQL + " CONVERT(varchar(10), VOUDATE, 120) AS VOUDATE, EXPLAN,ACCID,'人民币' bz, "; //6-9
|
|
|
sSQL = sSQL + " FCYDR,AMTDR,'' jtbbj,'' qjbbj,'01120' ywdybm,'' dj,'' jfsl,'' dfsl, ";//10-17
|
|
|
sSQL = sSQL + " FCYCR,AMTCR,'' _20,'' _21,BLNO,'' _23,'' _24, CONVERT(varchar(10), VOUDATE, 120) AS BSDATE, ";//18-25
|
|
|
sSQL = sSQL + " '' _26,'' _27,'' _28,'' _29,'' _30,'' _31,'' _32,'' _33,'' _34,'' _35,'' _36, ";//26-36
|
|
|
sSQL = sSQL + " '1' _37,'' _38,'' _39,";//37-39
|
|
|
sSQL = sSQL + " FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6, FIELD7, FIELD8, FIELD9";
|
|
|
sSQL = sSQL + " FROM VW_cw_vouchers_vouitems_gl where 1=1" + strCondition;
|
|
|
sSQL = sSQL + " order by ACCID ";
|
|
|
#endregion
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (DS != null)
|
|
|
{
|
|
|
string strCompanyName = T_ALL_DA.GetStrSQL("FULLNAME", "select top 1 FULLNAME from [company] where gid='" + strCompanyID + "'");
|
|
|
//
|
|
|
ls = "\"null_$head,main_m_pk_accountingbook,main_m_pk_vouchertype,main_m_num,main_m_attachment,main_pk_prepared,main_m_prepareddate,m_explanation,m_accsubjcode,m_pk_currtype,m_debitamount,m_localdebitamount,m_groupdebitamount,m_globaldebitamount,unitname,m_price,m_debitquantity,m_creditquantity,m_creditamount,m_localcreditamount,m_groupcreditamount,m_globalcreditamount,m_checkno,m_checkdate,verifyno,verifydate,m_bankaccount,billtype,m_checkstyle,vat_pk_vatcountry,vat_pk_receivecountry,vat_businesscode,vat_pk_clientvatcode,vat_pk_suppliervatcode,vat_pk_taxcode,vat_direction,vat_moneyamount,m_excrate2,excrate3,excrate4,ass_1,ass_2,ass_3,ass_4,ass_5,ass_6,ass_7,ass_8,ass_9\"\t核算账簿\t凭证类别编码 凭证号 附单据数 制单人编码 制单日期 摘要 科目编码 币种 原币借方金额 本币借方金额 集团本币借方金额 全局本币借方金额 业务单元编码 单价 借方数量 贷方数量 原币贷方金额 本币贷方金额 集团本币贷方金额 全局本币贷方金额 结算号 结算日期 核销号 业务日期 银行账户 票据类型 结算方式 报税国家 收货国 交易代码 客户VAT注册码 供应商VAT注册码 税码 VAT方向 计税金额 组织本币汇率 集团本币汇率 全局本币汇率 辅助核算1 辅助核算2 辅助核算3 辅助核算4 辅助核算5 辅助核算6 辅助核算7 辅助核算8 辅助核算9";
|
|
|
ls = ls.Replace(" ", "\t");
|
|
|
////////////////////////////////////
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers_gl set ISEXPORT=1 where 1=1" + strCondition.Replace("ACCDATE", "(ACCYEAR+'-'+ACCMONTH)");
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
//
|
|
|
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], ls, 1);
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
|
|
|
#region 暂时屏蔽
|
|
|
/*
|
|
|
sw.WriteLine(ls.Trim());
|
|
|
//用友U8 凭证导出 导出凭证
|
|
|
var linenum = 0;
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
{
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
{
|
|
|
ls = linenum.ToString();//0列 行号
|
|
|
linenum++;
|
|
|
ls += "\t" + "0010100011801-0001";//1列 "核算账簿 推测是帐套号"
|
|
|
ls += "\t" + "1";//2列 凭证类别编码
|
|
|
ls += "\t" ;//3列 凭证号 自动生成
|
|
|
ls += "\t" +"0";//F4附单据数
|
|
|
ls += "\t" + (myRow["PREPARED"].ToString().Trim() == "" ? "" : ("\"" + myRow["PREPARED"].ToString().Trim() + "\""));//5 制单人
|
|
|
ls += "\t" + (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));//6 制单日期
|
|
|
ls += "\t" + (myRow["EXPLAN"].ToString().Trim() == "" ? "" : ("\"" + myRow["EXPLAN"].ToString().Trim() + "\""));// 7 摘要
|
|
|
ls += "\t" + myRow["ACCID"].ToString().Trim();//8 科目编码
|
|
|
ls += "\t" + "人民币";//9 币种
|
|
|
ls += "\t" + myRow["FCYDR"].ToString().Trim();//10 原币借方
|
|
|
ls += "\t" + myRow["AMTDR"].ToString().Trim();//11 本币借方
|
|
|
ls += "\t";//集团本币借方金额
|
|
|
ls += "\t";//全局本币借方金额
|
|
|
ls += "\t"+"01120";//业务单元编码14
|
|
|
ls += "\t";//单价15
|
|
|
ls += "\t";//借方数量16
|
|
|
ls += "\t";//贷方数量17
|
|
|
ls += "\t" + myRow["FCYCR"].ToString().Trim(); ;//原币贷方金额18
|
|
|
ls += "\t" + myRow["AMTCR"].ToString().Trim();//本币贷方金额19
|
|
|
ls += "\t";//集团本币贷方金额 20
|
|
|
ls += "\t";//全局本币贷方金额21
|
|
|
ls += "\t";//结算号22//此处放置支票号
|
|
|
ls += "\t";//结算日期23
|
|
|
ls += "\t";//核销号24
|
|
|
ls += "\t"+ (myRow["VOUDATE"].ToString().Trim() == "" ? "" : ("\"" + myRow["VOUDATE"].ToString().Trim() + "\""));;//业务日期25
|
|
|
ls += "\t";//银行账户26
|
|
|
ls += "\t";//票据类型27
|
|
|
ls += "\t";//结算方式
|
|
|
ls += "\t";//报税国家
|
|
|
ls += "\t";//收货国30
|
|
|
ls += "\t";//交易代码
|
|
|
ls += "\t";//客户VAT注册码
|
|
|
ls += "\t";//供应商VAT注册码
|
|
|
ls += "\t";//税码
|
|
|
ls += "\t";//VAT方向35
|
|
|
ls += "\t";//计税金额
|
|
|
ls += "\t"+"1";//组织本币汇率37
|
|
|
ls += "\t";//集团本币汇率
|
|
|
ls += "\t";//全局本币汇率
|
|
|
ls += "\t" + myRow["FIELD1"].ToString().Trim(); //辅助核算1 40
|
|
|
ls += "\t" + myRow["FIELD2"].ToString().Trim();//辅助核算2
|
|
|
ls += "\t" + myRow["FIELD3"].ToString().Trim();//辅助核算3
|
|
|
ls += "\t" + myRow["FIELD4"].ToString().Trim();//辅助核算4
|
|
|
ls += "\t" + myRow["FIELD5"].ToString().Trim();//辅助核算5
|
|
|
ls += "\t" + myRow["FIELD6"].ToString().Trim();//辅助核算6
|
|
|
ls += "\t" + myRow["FIELD7"].ToString().Trim();//辅助核算7
|
|
|
ls += "\t" + myRow["FIELD8"].ToString().Trim();//辅助核算8
|
|
|
ls += "\t" + myRow["FIELD9"].ToString().Trim();//辅助核算9 48
|
|
|
//共49列
|
|
|
|
|
|
sw.WriteLine(ls);
|
|
|
}
|
|
|
}
|
|
|
//标记已经导出凭证
|
|
|
string sSql = " update cw_vouchers_gl set ISEXPORT=1 where ORDNO in('" + sGid.Trim() + "')";
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSql);
|
|
|
//
|
|
|
sw.Close();
|
|
|
switch ("MUEXCEL")
|
|
|
{
|
|
|
case "MUEXCEL":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
break;
|
|
|
case "MUTEXT":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
Response.ContentType = "application/txt";
|
|
|
break;
|
|
|
case "MUWORD":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
Response.ContentType = "application/ms-word";
|
|
|
break;
|
|
|
case "MUPDF":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
Response.ContentType = "application/pdf";
|
|
|
break;
|
|
|
case "MUXML":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
Response.ContentType = "application/xml";
|
|
|
break;
|
|
|
}
|
|
|
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
Response.Write(sw);
|
|
|
Response.End();*/
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void setExcelReportGlZY(string strCondition)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
string OppPath = "dbf";
|
|
|
string xmlPath = Server.MapPath(OppPath);
|
|
|
string xmlName = "kiszy.dbf";
|
|
|
string sName = "kiszy";
|
|
|
//
|
|
|
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
|
|
|
{
|
|
|
int iResult = setExcelReportGlZY(strCondition, xmlPath, sName);
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
string fileName = "vouitems.dbf";//客户端保存的文件名
|
|
|
string filePath = xmlPath + "//" + xmlName;// Server.MapPath(xmlPath + "//" + xmlName);//路径
|
|
|
|
|
|
//以字符流的形式下载文件
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
|
fs.Close();
|
|
|
Response.ContentType = "application/octet-stream";
|
|
|
//通知浏览器下载文件而不是打开
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
|
Response.BinaryWrite(bytes);
|
|
|
Response.Flush();
|
|
|
Response.End();
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证成功!');</script>");
|
|
|
//return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('导出凭证出错!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('金蝶专业版凭证文件缺失,请联系管理员!');</script>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶迷你凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReportGlMN(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
|
|
|
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
|
|
|
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
|
|
|
+ "select "
|
|
|
+ " VouDate,AccMonth,VKNO,VOUNO,(ITEMNO-1) as ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
|
|
|
//+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,''"//财务说不需要提单号字段的内容导入金蝶中
|
|
|
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems_gl where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers_gl set ISEXPORT=1 where 1=1" + strCondition.Replace("ACCDATE", "(ACCYEAR+'-'+ACCMONTH)");
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶标准凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReportGlBZ(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
//string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
//sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
sSql = "insert into OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1,FOBJNAME1"
|
|
|
+ ",FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4,FTRANSID"
|
|
|
+ ",FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FTRANSDATE,FCASHFLOW,FUNITNAME,FREFERENCE) "
|
|
|
+ "select "
|
|
|
+ " VouDate,AccMonth,VKNO,VOUNO,(ITEMNO-1) as ITEMNO,ExPlan,ACCID,CORPACC,CorpID,CUSTOMERNAME"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,BLNO"
|
|
|
+ ",FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems_gl where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers_gl set ISEXPORT=1 where 1=1" + strCondition.Replace("ACCDATE", "(ACCYEAR+'-'+ACCMONTH)");
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶K3凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReportGlK3(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID,FCLSNAME1,FOBJID1"
|
|
|
+ ",FOBJNAME1,FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4"
|
|
|
+ ",FCLSNAME5,FOBJID5,FOBJNAME5,FCLSNAME6,FOBJID6,FOBJNAME6,FCLSNAME7,FOBJID7,FOBJNAME7,FCLSNAME8"
|
|
|
+ ",FOBJID8,FOBJNAME8,FOBJNAME9,FOBJID9,FCLSNAME9,FCLSNAME10,FOBJID10,FOBJNAME10,FCLSNAME11,FOBJID11"
|
|
|
+ ",FOBJNAME11,FCLSNAME12,FOBJID12,FOBJNAME12,FCLSNAME13,FOBJID13,FOBJNAME13,FCLSNAME14,FOBJID14,FOBJNAME14"
|
|
|
+ ",FCLSNAME15,FOBJID15,FOBJNAME15,FTRANSID,FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE"
|
|
|
+ ",FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FSETTLDATE,FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT"
|
|
|
+ ",FPOSTED,FMODULE,FDELETED,FSERIALNO,FUNITNAME,FREFERENCE,FCASHFLOW) "
|
|
|
+ "select "
|
|
|
+ " VouDate,VouDate,AccMonth,VKNO,VOUNO,(ITEMNO-1) as ITEMNO,ExPlan,ACCID,CORPACC,CorpID"
|
|
|
+ ",CorpID,null,CorpID,CorpID,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,BLNO,FCYNO,FCYEXRATE,DC,AMTDR+AMTCR,null,0"
|
|
|
+ ",AMTDR,AMTCR,FSETTLCODE,FSETTLENO,FSETTLDATE,PREPARED,null,null,null,null,ATTACHS"
|
|
|
+ ",'False',null,'False',VOUNO,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems_gl where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 金蝶专业版凭证导出
|
|
|
/// </summary>
|
|
|
/// <param name="strGids">多个gid组成的字符串,例如 111,222,333</param>
|
|
|
/// <returns></returns>
|
|
|
public int setExcelReportGlZY(string strCondition, string sPath, string sName)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
try
|
|
|
{
|
|
|
string sSql = "delete from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
//string sSql = "delete from OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName;
|
|
|
bool bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
sSql = "insert into OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
//sSql = "insert into OpenDataSource('Microsoft.ACE.OLEDB.12.0','Data Source=" + sPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=')..." + sName + "("
|
|
|
+ " FDATE,FTRANSDATE,FPERIOD,FGROUP,FNUM,FENTRYID,FEXP,FACCTID"
|
|
|
+ ",FCLSNAME1,FOBJID1,FOBJNAME1,FCLSNAME2,FOBJID2,FOBJNAME2,FCLSNAME3,FOBJID3,FOBJNAME3,FCLSNAME4,FOBJID4,FOBJNAME4"
|
|
|
+ ",FCLSNAME5,FOBJID5,FOBJNAME5,FCLSNAME6,FOBJID6,FOBJNAME6,FCLSNAME7,FOBJID7,FOBJNAME7,FCLSNAME8,FOBJID8,FOBJNAME8"
|
|
|
+ ",FCLSNAME9,FOBJID9,FOBJNAME9,FCLSNAME10,FOBJID10,FOBJNAME10,FCLSNAME11,FOBJID11,FOBJNAME11,FCLSNAME12,FOBJID12,FOBJNAME12"
|
|
|
+ ",FCLSNAME13,FOBJID13,FOBJNAME13,FCLSNAME14,FOBJID14,FOBJNAME14,FCLSNAME15,FOBJID15,FOBJNAME15"
|
|
|
+ ",FTRANSID,FCYID,FEXCHRATE,FDC,FFCYAMT,FQTY,FPRICE,FDEBIT,FCREDIT,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",FPREPARE,FPAY,FCASH,FPOSTER,FCHECKER,FATTCHMENT,FPOSTED,FMODULE,FDELETED,FSERIALNO"
|
|
|
+ ",FUNITNAME,FREFERENCE,FCASHFLOW,FHANDLER) "
|
|
|
+ "select "
|
|
|
+ " VouDate,VouDate,AccMonth,VKNO,VOUNO,(ITEMNO-1) as ITEMNO,ExPlan,ACCID"
|
|
|
+ ",CORPACC,CorpID,CUSTOMERNAME,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null,null,null,null"
|
|
|
+ ",null,null,null,null,null,null,null,null,null"
|
|
|
+ ",BLNO,FCYNO,FCYEXRATE,DC,(case FCYNO when 'RMB' then AMTDR+AMTCR else FCYDR+FCYCR end) as FFCYAMT,null,0,AMTDR,AMTCR,FSETTLCODE,FSETTLENO,FSETTLDATE"
|
|
|
+ ",PREPARED,null,null,null,null,ATTACHS,'False',null,'False',VOUNO"
|
|
|
+ ",null,null,null,null "
|
|
|
+ " from VW_cw_vouchers_vouitems_gl where 1=1" + strCondition + " order by ORDNO,ITEMNO";
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
if (bl)
|
|
|
{
|
|
|
iResult = 1;
|
|
|
sSql = " update cw_vouchers_gl set ISEXPORT=1 where 1=1" + strCondition.Replace("ACCDATE", "(ACCYEAR+'-'+ACCMONTH)");
|
|
|
bl = SqlHelper.ExecuteSql(SqlHelper.ConnectionStringLocalTransaction, sSql);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iResult = -1;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
iResult = -1;//有异常,插入失败
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
return iResult;
|
|
|
}
|
|
|
|
|
|
//
|
|
|
#endregion
|
|
|
}
|
|
|
} |