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

654 lines
31 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
namespace DSWeb.Settlements
{
public partial class PayApplicationGridSource : System.Web.UI.Page
{
private string strHandle;//值为payapp表示获取付费申请列表值
private string strUserID;
private string strBillNO;//申请业务编号
private string strBSNO;//委托业务编号
private string strPaySettleAppID;//付费申请GID
private string strRunSettleID;//运行结算表GID
private string strPaySettleID;//付费结算表GID
private string stroplb; //业务类别0 海运出口2 海运进口3 空运出口4 空运进口5 陆运6 仓储费7 仓储入库8 仓储出库
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["uid"] != null)
{
strUserID = Request.QueryString["uid"].ToString();
}
//if (Session["USERID"] != null)
//{
// strUserID = Session["USERID"].ToString();
//}
if (Request.QueryString["billno"] != null)
{
strBillNO = Request.QueryString["billno"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString();
}
if (Request.QueryString["paysettleappid"] != null)
{
strPaySettleAppID = Request.QueryString["paysettleappid"].ToString();
}
if(Request.QueryString["runsettleid"] != null)
{
strRunSettleID = Request.QueryString["runsettleid"].ToString().Trim();
}
if(Request.QueryString["paysettleid"] != null)
{
strPaySettleID = Request.QueryString["paysettleid"].ToString().Trim();
}
if (strHandle != null)
{
//获取付费信息
if (strHandle.Equals("payapporderlist") && strBillNO != null)
{
Response.Write(GetPayAppSettlementOrderList(strBillNO));
}
if (strHandle.Equals("payappfeelist") && strBillNO != null && strBSNO != null)
{
Response.Write(GetPayAppSettlementFeeList(strBillNO, strBSNO));
}
if (strHandle.Equals("payappeditfee") && strPaySettleAppID != null && strBSNO != null)
{
Response.Write(GetPaySettleApplicaionEditFeeByGID(strPaySettleAppID,strBSNO));
}
if (strHandle.Equals("payappopseaelist") && strPaySettleAppID != null)
{
Response.Write(GetPaySettleAppOpSeaeList(strPaySettleAppID));
}
if (strHandle.Equals("payappfeelist") && strPaySettleAppID != null && strBSNO != null)
{
Response.Write(GetPaySettleAppFeeList(strPaySettleAppID,strBSNO));
}
if (strHandle.Equals("runsettlelist") && strRunSettleID != null)
{
Response.Write(GetRunSettleList(strRunSettleID));
}
if (strHandle.Equals("runfeedolist") && strRunSettleID != null)
{
Response.Write(GetRunFeeDoList(strRunSettleID, strBSNO));
}
//获取付费结算的委托信息
if (strHandle.Equals("payasettleopseaelist") && strPaySettleID != null)
{
Response.Write(GetPaySettleOpSeaeList(strPaySettleID));
}
if (strHandle.Equals("paysettlefeelist") && strPaySettleID != null)
{
Response.Write(GetPaySettleFeeList(strPaySettleID, strBSNO));
}
}
}
#region 获取付费申请委托信息
/// <summary>
/// 根据申请业务编号获取付费申请委托信息
/// </summary>
/// <param name="tempBillNO">申请业务编号</param>
/// <returns></returns>
private string GetPayAppSettlementOrderList(string tempBillNO)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
//string strSql = string.Format("(SELECT BSNO, CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE 1 > 0 AND "
// + " BSNO IN (SELECT BSNO FROM ch_fee_do WHERE BILLNO = '{0}'))"
// + " UNION ALL "
// + " (SELECT BSNO, CUSTOMERNAME,MBLNO,HBLNO FROM op_seai WHERE 1 > 0 AND "
// + " BSNO IN (SELECT BSNO FROM ch_fee_do WHERE BILLNO = '{0}'))", tempBillNO);
//sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
//2013-02-05 修改
string strSql = string.Format("(SELECT BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM VW_Settlement WHERE 1 > 0 AND "
+ " BSNO IN (SELECT BSNO FROM ch_fee_do WHERE BILLNO = '{0}'))", tempBillNO);
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
private string GetPayAppSettlementFeeList(string tempBillNO,string tempBSNO)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
//string strSql = String.Format(" SELECT FEEID as GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,(case when AMOUNT-DOAMOUNT=0 then 0 else DOAMOUNT end) as DOAMOUNT,(case when AMOUNT-DOAMOUNT=0 then DOAMOUNT else AMOUNT-DOAMOUNT end) as wj FROM ch_fee_do WHERE BILLNO = '{0}' AND BSNO = '{1}' ", tempBillNO, tempBSNO);
string strSql = String.Format(" SELECT FEEID as GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,DOAMOUNT=isnull((select sum(DOAMOUNT) from ch_fee_do where (ISDELETED=0 or ISDELETED is null) and (billno like '%DR%' or billno like '%CR%') and feeid in (select feeid from ch_fee_do where billno='{0}') and feeid=a.feeid),0),wj=(select AMOUNT from ch_fee where gid=a.feeid)-isnull((select sum(DOAMOUNT) from ch_fee_do where (ISDELETED=0 or ISDELETED is null) and (billno like '%DR%' or billno like '%CR%') and feeid in (select feeid from ch_fee_do where billno='{0}') and feeid=a.feeid),0),REMARK=(select top 1 REMARK from ch_fee where gid=a.feeid) FROM ch_fee_do as a WHERE BILLNO = '{0}' AND BSNO = '{1}' ", tempBillNO, tempBSNO);
sourceTable = getStatusNameTable(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#region 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// <summary>
/// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// </summary>
/// <param name="tempTable">原数据源DataTable</param>
/// <returns>返回新数据源DataTable</returns>
private DataTable getStatusNameTable(DataTable tempTable)
{
DataTable sourceTable = tempTable;
DataTable cloneTable = new DataTable();
int iSwitch = 0;
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (iSwitch == 0)
{
for (int j = 0; j < sourceTable.Columns.Count; j++)
{
if (sourceTable.Columns[j].ColumnName.Equals("FEETYPE"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = sourceTable.Columns[j].DataType;
cloneTable.Columns.Add(newColumn);
}
}
iSwitch = 1;
}
DataRow cloneRow = cloneTable.NewRow();
for (int k = 0; k < sourceTable.Columns.Count; k++)
{
if (sourceTable.Columns[k].ColumnName.Equals("FEETYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "收";
break;
case 2:
strFeeStatus = "付";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
//cloneTable.Columns.Remove("FEESTATUS");
//cloneTable.Columns.Add(new DataColumn("FEESTATUS", System.Type.GetType("System.String")));
return cloneTable;
}
#endregion
#region 获取付费申请费用信息
/// <summary>
/// 获取付费申请费用信息
/// </summary>
/// <param name="tempPaySettlementAppID">付费申请GID</param>
/// <param name="tempBSNO">委托编号</param>
/// <returns>JSON数据集</returns>
private string GetPaySettleApplicaionEditFeeByGID(string tempPaySettlementAppID, string tempBSNO)
{
FeePaySettleApplicationDA feePaySettleApplicaionDA = new FeePaySettleApplicationDA();
string strConditionBSNO = tempBSNO.Trim() == "" ? "" : " AND C.BSNO = '" + tempBSNO + "'";
string strSql = " SELECT C.GID,CASE WHEN C.FEETYPE = 1 THEN '收' ELSE '付' END as FEETYPE,C.FEENAME,C.CUSTOMERNAME,C.UNIT, "
+ " C.UNITPRICE,C.QUANTITY,C.AMOUNT,C.CURRENCY,C.EXCHANGERATE,ISNULL(C.ORDERAMOUNT,0) as ORDERAMOUNT,C.AMOUNT - ISNULL(C.ORDERAMOUNT,0) as UNODERAMOUNT,C.REMARK "
+ " FROM ch_fee_do as A INNER JOIN ch_fee_payapplication as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON A.FEEID = C.GID WHERE B.GID = '" + tempPaySettlementAppID + "' " + strConditionBSNO;
DataTable invoiceTable = new DataTable();
invoiceTable = feePaySettleApplicaionDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < invoiceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + invoiceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < invoiceTable.Columns.Count; j++)
{
if (j == invoiceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + invoiceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + invoiceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == invoiceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
private string GetPaySettleAppOpSeaeList(string tempPaySettleAppGID)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
//string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO "
// + " FROM (select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seae UNION ALL select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seai) AS A INNER JOIN ch_fee_do as B ON A.BSNO = B.BSNO "
// + " INNER JOIN ch_fee_payapplication AS C ON B.BILLNO = C.BILLNO "
// + " WHERE C.GID = '{0}' ", tempPaySettleAppGID);
//2013-02-05 修改
string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO,A.CUSTOMNO,A.CUSTOMNO2 "
+ " FROM VW_Settlement AS A INNER JOIN ch_fee_do as B ON A.BSNO = B.BSNO "
+ " INNER JOIN ch_fee_payapplication AS C ON B.BILLNO = C.BILLNO "
+ " WHERE C.GID = '{0}' ", tempPaySettleAppGID);
DataTable sourceTable = new DataTable();
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#region 获取付费结算委托信息
/// <summary>
/// 获取付费结算委托信息
/// </summary>
/// <param name="tempPaySettleGID">付费结算表GID</param>
/// <returns>返回与付费结算关联的委托信息</returns>
private string GetPaySettleOpSeaeList(string tempPaySettleGID)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
//string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO "
// + " FROM (select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seae union all select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seai) AS A "
// + " INNER JOIN ch_fee_do as B ON A.BSNO = B.BSNO "
// + " INNER JOIN ch_fee_settlement AS C ON B.BILLNO = C.BILLNO "
// + " WHERE C.GID = '{0}' ", tempPaySettleGID);
//2013-02-05 修改
string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO,A.CUSTOMNO,A.CUSTOMNO2 "
+ " FROM (select * from VW_Settlement) AS A "
+ " INNER JOIN ch_fee_do as B ON A.BSNO = B.BSNO "
+ " INNER JOIN ch_fee_settlement AS C ON B.BILLNO = C.BILLNO "
+ " WHERE C.GID = '{0}' ", tempPaySettleGID);
DataTable sourceTable = new DataTable();
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取付费申请关联的委托信息的费用明细
/// <summary>
/// 获取付费申请关联的委托信息的费用明细
/// </summary>
/// <param name="tempPaySettleAppGID">付费申请GID</param>
/// <param name="tempBSNO">委托业务编号BSNO</param>
/// <returns>返回付费申请关联的委托信息的费用明细</returns>
private string GetPaySettleAppFeeList(string tempPaySettleAppGID,string tempBSNO)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = String.Format(" SELECT A.FEEID,CASE WHEN A.FEETYPE = 1 THEN '收' ELSE '付' END as FEETYPE,A.FEENAME,A.CUSTOMERNAME,ISNULL(B.UNIT,1) AS UNIT, "
+ " B.UNITPRICE,B.QUANTITY,B.AMOUNT,B.CURRENCY,A.EXCHANGERATE,A.ORIGAMOUNT AS ORDERAMOUNT,"
+ " CASE WHEN B.ORDERAMOUNT = B.AMOUNT THEN 0 ELSE B.AMOUNT - B.ORDERAMOUNT END AS UNODERAMOUNT,B.REMARK "
+ " FROM ch_fee_do AS A LEFT JOIN ch_fee as B ON A.FEEID = B.GID "
+ " INNER JOIN ch_fee_payapplication as C ON A.BILLNO = C.BILLNO "
+ " WHERE A.BSNO = '{0}' AND C.GID = '{1}' ", tempBSNO,tempPaySettleAppGID);
DataTable sourceTable = new DataTable();
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取付费结算关联的委托信息的费用明细
/// <summary>
/// 获取付费结算关联的委托信息的费用明细
/// </summary>
/// <param name="tempPaySettleGID">付费结算GID</param>
/// <param name="tempBSNO">委托业务编号BSNO</param>
/// <returns>返回付费申请关联的委托信息的费用明细</returns>
private string GetPaySettleFeeList(string tempPaySettleGID, string tempBSNO)
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = String.Format(" SELECT A.FEEID,CASE WHEN A.FEETYPE = 1 THEN '收' ELSE '付' END as FEETYPE,A.FEENAME,A.CUSTOMERNAME,ISNULL(B.UNIT,1) AS UNIT, "
+ " B.UNITPRICE,B.QUANTITY,B.AMOUNT,B.CURRENCY,A.EXCHANGERATE,A.DOAMOUNT AS SETTLEAMOUNT,"//
//+ " CASE WHEN B.ORDERAMOUNT = B.AMOUNT THEN 0 ELSE B.AMOUNT - B.SETTLEMENT END AS UNODERAMOUNT "
+ " isnull(B.AMOUNT - B.SETTLEMENT,0) AS UNODERAMOUNT,B.REMARK "
+ " FROM ch_fee_do AS A LEFT JOIN ch_fee as B ON A.FEEID = B.GID "
+ " INNER JOIN ch_fee_settlement as C ON A.BILLNO = C.BILLNO "
+ " WHERE A.BSNO = '{0}' AND C.GID = '{1}' ", tempBSNO, tempPaySettleGID);
DataTable sourceTable = new DataTable();
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
private string GetRunSettleList(string tempRunSettleID)
{
RunFeeSettlementDA runFeeSettlementDA = new RunFeeSettlementDA();
//string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO "
// + " FROM (select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seae union all select BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO from op_seai) AS A INNER JOIN run_fee_do as B ON A.BSNO = B.BSNO "
// + " INNER JOIN run_fee_settlement AS C ON B.RUNSETTLEID = C.GID "
// + " WHERE C.GID = '{0}' ", tempRunSettleID);
//2013-02-05 修改
string strSql = String.Format(" SELECT A.BSNO,A.CUSTOMERNAME,A.CUSTNO,A.MBLNO,A.HBLNO,A.CUSTOMNO,A.CUSTOMNO2 "
+ " FROM (select * from VW_Settlement) AS A INNER JOIN run_fee_do as B ON A.BSNO = B.BSNO "
+ " INNER JOIN run_fee_settlement AS C ON B.RUNSETTLEID = C.GID "
+ " WHERE C.GID = '{0}' ", tempRunSettleID);
DataTable sourceTable = new DataTable();
sourceTable = runFeeSettlementDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
private string GetRunFeeDoList(string tempRunSettleID, string tempBSNO)
{
RunFeeSettlementDA runFeeSettlementDA = new RunFeeSettlementDA();
string strSql = String.Format(" SELECT A.FEEID,CASE WHEN A.FEETYPE = 1 THEN '收' ELSE '付' END as FEETYPE,A.FEENAME,A.CUSTOMERNAME,ISNULL(B.UNIT,1) AS UNIT, "
+ " B.UNITPRICE,B.QUANTITY,B.AMOUNT,B.CURRENCY,A.EXCHANGERATE,A.ORIGAMOUNT AS ORDERAMOUNT,"
+ " CASE WHEN B.ORDERAMOUNT = B.AMOUNT THEN 0 ELSE B.AMOUNT - B.ORDERAMOUNT END AS UNODERAMOUNT,B.REMARK "
+ " FROM run_fee_do AS A LEFT JOIN ch_fee as B ON A.FEEID = B.GID "
+ " INNER JOIN run_fee_settlement as C ON A.RUNSETTLEID = C.GID "
+ " WHERE A.BSNO = '{0}' AND C.GID = '{1}' ", tempBSNO, tempRunSettleID);
DataTable sourceTable = new DataTable();
sourceTable = runFeeSettlementDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
}
}