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.
291 lines
12 KiB
C#
291 lines
12 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using DSWeb.Models;
|
|
using DSWeb.EntityDA;
|
|
using System.Text;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Linq;
|
|
using JsonHelper;
|
|
using System.Xml;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace DSWeb.Settlements
|
|
{
|
|
public partial class DoPayApplicationSettlementGridSource : System.Web.UI.Page
|
|
{
|
|
private string strReadXmlType = "";//读取xml串方式 "init"-初始化获取所有账户信息;"add"-添加新的账户信息;"delete"-删除账户信息;"exist"查看是否有与委托相关账户
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
public string strUserID;//用户GID
|
|
public string strCompanyID;//公司GID
|
|
public string strShowName;//用户显示名
|
|
public string strDeptName;//部门名称
|
|
public int feetype = 0;
|
|
public string customername;
|
|
public string handle;
|
|
public string settlementid;
|
|
public string billno;
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
#region 判断参数是否正确
|
|
if (Session["USERID"] != null)
|
|
{
|
|
strUserID = Session["USERID"].ToString().Trim();
|
|
}
|
|
if (Session["SHOWNAME"] != null)
|
|
{
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
}
|
|
if (Session["COMPANYID"] != null)
|
|
{
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
}
|
|
if (Session["DEPTNAME"] != null)
|
|
{
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
}
|
|
//
|
|
if (Request.QueryString["read"] != null)
|
|
{
|
|
strReadXmlType = Request.QueryString["read"].ToString().Trim();
|
|
}
|
|
if (Request.QueryString["feetype"] != null)
|
|
{
|
|
feetype = int.Parse(Request.QueryString["feetype"].ToString());
|
|
}
|
|
if (Request.QueryString["customername"] != null)
|
|
{
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
customername = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["customername"].ToString())));
|
|
}
|
|
if (Request.QueryString["handle"] != null)
|
|
{
|
|
handle = Request.QueryString["handle"].ToString();
|
|
}
|
|
if (Request.QueryString["settlementid"] != null)
|
|
{
|
|
settlementid = Request.QueryString["settlementid"].ToString();
|
|
}
|
|
if (Request.QueryString["billno"] != null)
|
|
{
|
|
billno = Request.QueryString["billno"].ToString();
|
|
}
|
|
#endregion
|
|
|
|
//
|
|
if (!strReadXmlType.Equals(""))
|
|
{
|
|
if (strReadXmlType.Equals("init") || strReadXmlType.Equals("exist"))
|
|
{
|
|
string strOutputXml = "";
|
|
strOutputXml = GetCells(strReadXmlType);
|
|
//输出XML字符串
|
|
Response.ContentType = "text/xml";
|
|
strOutputXml.Replace("&", "&");
|
|
Response.Write(strOutputXml);
|
|
}
|
|
else if (strReadXmlType.Equals("getshow"))
|
|
{
|
|
// 获取预收预付的明细信息
|
|
Response.Write(GetSHOW());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//访问参数不正确
|
|
Response.ContentType = "text/xml";
|
|
Response.Write("-2");
|
|
}
|
|
}
|
|
|
|
#region 获取预收预付的明细信息
|
|
/// <summary>
|
|
/// 获取预收预付的明细信息
|
|
/// </summary>
|
|
private string GetSHOW()
|
|
{
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
string strSql = " SELECT SETTLEBILLNO,CUSTOMERNAME,CURRENCY,DOAMOUNT,SETTLEUSER=(select top 1 SHOWNAME from [user] where gid=ch_fee_advance_payment_detail.SETTLEUSER),SETTLETIME FROM ch_fee_advance_payment_detail "
|
|
+ " WHERE billno = '" + billno + "' and FEETYPE=" + feetype + " and (ISDELETE=0 or ISDELETE is null) and COMPANYID='" + strCompanyID + "'";
|
|
|
|
DataTable sourceTable = new DataTable();
|
|
sourceTable = T_ALL_DA.GetExcuteSql(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 = 0; 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
|
|
|
|
/// <summary>
|
|
/// 获取账户信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetCells(string readXmlType)
|
|
{
|
|
WmsRateDA WmsRateEntity = new WmsRateDA();
|
|
WmsRateDA WmsRateDA = new WmsRateDA();
|
|
|
|
if (strReadXmlType.Equals("exist"))
|
|
{
|
|
return "1";//存在账户
|
|
}
|
|
else if (!strReadXmlType.Equals("exist"))
|
|
{
|
|
//获取所有账户信息,用做Grid显示
|
|
DataTable WmsRateTable = new DataTable();
|
|
|
|
//初始化
|
|
string strInitSql = "";
|
|
if (customername.ToString().Trim() == "")
|
|
{
|
|
strInitSql = "SELECT GID,CUSTOMERNAME,BILLNO,CREATETIME,CURRENCY,EXCHANGERATE,AMOUNT,(AMOUNT-DOAMOUNT) as DOAMOUNT2,0 as DOAMOUNT FROM ch_fee_advance_payment WHERE 1<0";
|
|
}
|
|
else
|
|
{
|
|
if (handle == "add")
|
|
{
|
|
strInitSql = "SELECT GID,CUSTOMERNAME,BILLNO,CREATETIME,CURRENCY,EXCHANGERATE,AMOUNT,(AMOUNT-DOAMOUNT) as DOAMOUNT2,0 as DOAMOUNT FROM ch_fee_advance_payment WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and AMOUNT<>DOAMOUNT and customername='" + customername.ToString().Trim() + "' and FEETYPE=" + feetype + " ORDER BY CUSTOMERNAME,BILLNO,CREATETIME,CURRENCY";
|
|
}
|
|
else
|
|
{
|
|
strInitSql = "select a.GID,a.CUSTOMERNAME,a.BILLNO,a.CREATETIME,a.CURRENCY,a.EXCHANGERATE,a.AMOUNT,a.DOAMOUNT2,a.DOAMOUNT "
|
|
+ " from (SELECT GID,CUSTOMERNAME,BILLNO,CREATETIME,CURRENCY,EXCHANGERATE,AMOUNT"
|
|
+ ",(AMOUNT-DOAMOUNT+isnull((select isnull(DOAMOUNT,0) from ch_fee_advance_payment_detail where 1=1 and (ISDELETE=0 or ISDELETE is null) and LINKGID=ch_fee_advance_payment.GID and SETTLELINKGID='" + settlementid + "'),0)) as DOAMOUNT2"
|
|
+ ",isnull((select isnull(DOAMOUNT,0) from ch_fee_advance_payment_detail where (ISDELETE=0 or ISDELETE is null) and LINKGID=ch_fee_advance_payment.GID and SETTLELINKGID='" + settlementid + "'),0) as DOAMOUNT "
|
|
+ " FROM ch_fee_advance_payment WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and customername='" + customername.ToString().Trim() + "' and FEETYPE=" + feetype + " and LINKGID<>'" + settlementid + "') as a"
|
|
+ " where a.DOAMOUNT2<>0 ORDER BY a.CUSTOMERNAME,a.BILLNO,a.CREATETIME,a.CURRENCY";
|
|
}
|
|
}
|
|
WmsRateTable = getStatusNameTable(WmsRateDA.GetExcuteSql(strInitSql).Tables[0]);
|
|
|
|
//编排字符串 xml串
|
|
StringBuilder dataBuilder = new StringBuilder();
|
|
|
|
dataBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
|
dataBuilder.Append("<rows>");
|
|
|
|
int iCount = WmsRateTable.Rows.Count;
|
|
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
int jCount = WmsRateTable.Columns.Count;
|
|
dataBuilder.Append("<row id=\"" + WmsRateTable.Rows[i]["GID"].ToString() + "\">");
|
|
dataBuilder.Append("<cell>0</cell>");
|
|
for (int j = 1; j < jCount; j++)
|
|
{
|
|
switch (j)
|
|
{
|
|
case 1:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 2:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 3:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 4:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 5:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 6:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 7:
|
|
dataBuilder.Append("<cell>" + WmsRateTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
}
|
|
|
|
}
|
|
dataBuilder.Append("</row>");
|
|
}
|
|
dataBuilder.Append("</rows>");
|
|
|
|
return dataBuilder.ToString();
|
|
}
|
|
else
|
|
{
|
|
return "-3";//没有相关的账户
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将数据集表中账户状态WmsRateStatus和应收应付类型WmsRateType的数字状态位转换成文字
|
|
/// </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++)
|
|
{
|
|
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++)
|
|
{
|
|
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
|
|
}
|
|
cloneTable.Rows.Add(cloneRow);
|
|
}
|
|
return cloneTable;
|
|
}
|
|
|
|
//
|
|
}
|
|
}
|