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.
D7QUANTAI/DSWeb/Settlements/PayAppAuditGridSource.aspx.cs

519 lines
24 KiB
C#

11 months ago
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.EntityDA;
using System.Text;
using System.Text.RegularExpressions;
namespace DSWeb.Settlements
{
public partial class PayAppAuditGridSource : System.Web.UI.Page
{
private string strHandle;
private string strPayAppGid;
private string strSearchCondition;//查询条件
private string strUserID;
private string strFeeSearch;//费用查询条件
private string strBSNO;//委托业务编号
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["payappid"] != null)
{
strPayAppGid = Request.QueryString["payappid"].ToString().Trim();
}
if (Request.QueryString["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearchCondition = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
//获取费用查询条件
if (Request.QueryString["fsearch"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strFeeSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["fsearch"].ToString())));
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (strHandle != null)
{
//handle=payapptotal 表示付费申请审核获取申请结算总费用
if (strHandle.Equals("payapptotal") && strPayAppGid != null)
{
Response.Write(GetPayAppTotal());
}
if (strHandle.Equals("ordersearch") && strSearchCondition != null)
{
Response.Write(GetSeaeOrderBySearch(strSearchCondition));
}
if (strHandle.Equals("feelist") && strFeeSearch != null)
{
Response.Write(GetFeeList(strBSNO));
}
}
}
#region 获取付费申请审核获取申请结算总费用
/// <summary>
/// 获取付费申请审核获取申请结算总费用
/// </summary>
/// <returns></returns>
private string GetPayAppTotal()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
string strSql = String.Format("SELECT GID,AMOUNTRMB,AMOUNTUSD,AMOUNTRMB-isnull(SETTLERMB,0) as SETTLERMB,AMOUNTUSD-isnull(SETTLEUSD,0) as SETTLEUSD FROM ch_fee_payapplication WHERE GID = '{0}'", strPayAppGid);
sourceTable = feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("total:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (i == 0)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
}
else
{
sourceBuilder.Append(",{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
}
sourceBuilder.Append("\"rmb\":\"" + sourceTable.Rows[i][1].ToString() + "\",");
sourceBuilder.Append("\"usd\":\"" + sourceTable.Rows[i][2].ToString() + "\",");
sourceBuilder.Append("\"rmbsettle\":\"" + sourceTable.Rows[i][3].ToString() + "\",");
sourceBuilder.Append("\"usdsettle\":\"" + sourceTable.Rows[i][4].ToString() + "\"}");
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 根据搜索条件获取等待付费申请审核的委托信息
/// <summary>
/// 根据搜索条件获取等待付费申请审核的委托信息
/// </summary>
/// <param name="tempSearch"></param>
/// <returns></returns>
public string GetSeaeOrderBySearch(string tempSearch)
{
string strBillNO = "";//申请单号
string strApplicationID = "";//付费结算申请表GID
string strUserID = "";//用户GID
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
int strtmpoplb = 0;
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
//case "cus"://Customer
// strSeaeCondition += String.Format("AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
// break;
case "bno"://BillNO
strSeaeCondition += String.Format(" AND (CUSTNO LIKE '%{0}%' OR MBLNO LIKE '%{0}%' OR HBLNO LIKE '%{0}%' OR CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "bt"://ETD BeginDate
strSeaeCondition += String.Format(" AND ETD >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "et"://ETD EndDate
strSeaeCondition += String.Format(" AND ETD <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "ves"://Vessel
strSeaeCondition += String.Format(" AND VESSEL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "voy"://Voyno
strSeaeCondition += String.Format(" AND VOYNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
//case "deno"://DebitNO
// //strSqlCondition += String.Format(" VOYNO LIKE '%{0}%' ", strArg[1]);
// break;
//case "ise"://IsSettled
// break;
//case "fty"://FeeType
// strSqlCondition += String.Format(" FEETYPE = {0} ", strArg[1]);
// break;
//case "cur"://Currency
// strSqlCondition += String.Format(" FEETYPE = {0} ", strArg[1]);
// break;
case "id":
strApplicationID = strArg[1].Replace("\"", "");
break;
case "billno":
strBillNO = strArg[1].Replace("\"", "");
break;
case "user":
strUserID = strArg[1].Replace("\"", "");
break;
case "bty"://业务类型
strtmpoplb = int.Parse(strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = "SELECT BSNO, CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE 1 > 0 AND BSNO IN ( "
// + "SELECT BSNO FROM ch_fee WHERE GID IN"
// + "(SELECT A.GID FROM ch_fee as A LEFT JOIN ch_fee_do as B ON A.GID = B.FEEID WHERE FEEID IS NULL) AND (FEESTATUS = 8 OR FEESTATUS = 0))"
// + strSeaeCondition;
//switch (strtmpoplb)
//{
// case 0://所有业务类型
// strSql = string.Format(" SELECT BSNO,'海运出口' OPLB, CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE 1 > 0 AND "
// + " BSNO IN (SELECT A.BSNO FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID INNER JOIN workflow_do as C ON B.BILLNO = C.BILLNO "
// + " WHERE (A.FEESTATUS = 8 OR A.FEESTATUS = 0) AND B.BILLNO = '{0}' AND C.AUDITOR = '{1}') "
// + " union all "
// + " SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,MBLNO,HBLNO FROM op_seai WHERE 1 > 0 AND "
// + " BSNO IN (SELECT A.BSNO FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID INNER JOIN workflow_do as C ON B.BILLNO = C.BILLNO "
// + " WHERE (A.FEESTATUS = 8 OR A.FEESTATUS = 0) AND B.BILLNO = '{0}' AND C.AUDITOR = '{1}') "
// + strSeaeCondition, strBillNO, strUserID);
// break;
// case 1://海运出口
// strSql= string.Format(" SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE 1 > 0 AND "
// + " BSNO IN (SELECT A.BSNO FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID INNER JOIN workflow_do as C ON B.BILLNO = C.BILLNO "
// + " WHERE (A.FEESTATUS = 8 OR A.FEESTATUS = 0) AND B.BILLNO = '{0}' AND C.AUDITOR = '{1}') "
// +strSeaeCondition, strBillNO, strUserID);
// break;
// case 2://海运进口
// strSql= string.Format(" SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,MBLNO,HBLNO FROM op_seai WHERE 1 > 0 AND "
// + " BSNO IN (SELECT A.BSNO FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID INNER JOIN workflow_do as C ON B.BILLNO = C.BILLNO "
// + " WHERE (A.FEESTATUS = 8 OR A.FEESTATUS = 0) AND B.BILLNO = '{0}' AND C.AUDITOR = '{1}') "
// + strSeaeCondition, strBillNO, strUserID);
// break;
// case 3:
// break;
// case 4:
// break;
// default:
// break;
//}
string strSql = "";
//2013-02-05 修改 begin
string sOPLBCondition = "";
switch (strtmpoplb)
{
case 0://所有业务类型
sOPLBCondition = "";
break;
case 1://海运出口op_Seae
sOPLBCondition = " and OPLBNAME='海运出口' ";
break;
case 2://海运进口op_Seai
sOPLBCondition = " and OPLBNAME='海运进口' ";
break;
case 3:
sOPLBCondition = " and OPLBNAME='空运出口' ";
break;
case 4:
sOPLBCondition = " and OPLBNAME='空运进口' ";
break;
case 5://陆运托运
sOPLBCondition = " and OPLBNAME='陆运托运' ";
break;
case 6://仓储费
sOPLBCondition = " and OPLBNAME='仓储费' ";
break;
case 7://仓储入库
sOPLBCondition = " and OPLBNAME='仓储入库' ";
break;
case 8://仓储出库
sOPLBCondition = " and OPLBNAME='仓储出库' ";
break;
case 9://陆运派车
sOPLBCondition = " and OPLBNAME='陆运派车' ";
break;
case 11://陆运派车
sOPLBCondition = " and OPLBNAME='报关业务' ";
break;
case 12://陆运派车
sOPLBCondition = " and OPLBNAME='大宗散货' ";
break;
default:
break;
}
strSql = string.Format(" SELECT BSNO,OPLBNAME, CUSTOMERNAME,MBLNO,HBLNO,CUSTOMNO FROM VW_Settlement WHERE 1 > 0 AND "
+ " BSNO IN (SELECT A.BSNO FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID INNER JOIN workflow_do as C ON B.BILLNO = C.BILLNO "
+ " WHERE (A.FEESTATUS = 8 OR A.FEESTATUS = 0) AND B.BILLNO = '{0}' AND C.AUDITOR = '{1}') {2}"
+ strSeaeCondition, strBillNO, strUserID, sOPLBCondition);
//end
sourceTable = feeSettlementDA.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 = 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="tempBSNO">委托业务编号GID</param>
/// <returns>返回json字符串</returns>
public string GetFeeList(string tempBSNO)
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
string strBillNO = "";
string strUserID = "";
if (strFeeSearch != null)
{
if (!strFeeSearch.Trim().Equals(""))
{
string tempSearch = strFeeSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "cus"://Customer
strCondition += String.Format(" AND B.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strCondition += String.Format(" AND A.FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strCondition += String.Format(" AND A.FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strCondition += String.Format(" AND B.CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strCondition += String.Format(" AND B.CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "billno":
strBillNO = strArg[1].Replace("\"", "").Trim();
break;
case "user":
strUserID = strArg[1].Replace("\"", "").Trim();
break;
default:
break;
}
}
}
}
}
//string strSql = String.Format("SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,AMOUNT-SETTLEMENT,AMOUNT-SETTLEMENT FROM ch_fee WHERE BSNO = '{0}' AND (FEESTATUS = 0 OR FEESTATUS = 8) AND GID NOT IN (SELECT FEEID FROM ch_fee_do WHERE BSNO IN ('{0}'))", tempBSNO);
string strSql = String.Format(" SELECT A.GID,A.FEETYPE,B.CUSTOMERNAME,A.FEENAME,B.CURRENCY,B.AMOUNT,B.DOAMOUNT,B.AMOUNT - B.DOAMOUNT "
+ " FROM ch_fee as A INNER JOIN ch_fee_do as B ON A.GID = B.FEEID WHERE BILLNO = '{0}' AND A.BSNO = '{1}' AND CATEGORY = 4 " + strCondition, strBillNO, tempBSNO);
sourceTable = getStatusNameTable(feeSettlementDA.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 = 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>
/// 将数据集表中费用状态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
}
}