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.
DS7/DSWeb/Settlements/SettlementGridSourceApp.asp...

5721 lines
286 KiB
C#

2 years 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 System.Text;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using DSWeb.Authority;
using DSWeb.Log;
namespace DSWeb.Settlements
{
public partial class SettlementGridSourceApp : PageBase
{
private string strHandle;//操作方式
private string strCondition;//委托条件查询
private string strBSNO;//委托编号GID
private string strSearch;//查询条件
private string strFeeSearch;//费用查询条件
private string strCurrency;//币别名称
private string strBillNO;//结算编号
private string strALLBSNO;//所有委托信息
private string strOrderCacheName;//缓存名称
private string strSelectedOrder;//已经选择的委托信息
private string strCheckType;//全选类型 值"check"选中的值 值"uncheck"去除选择的值
private string strFeeID;//费用GID
private string strPostSessionID;//提交发票申请Session
private decimal dExchangeRate;//折算汇率
private decimal dCSTL;//本次结算
private decimal dUSTL;//未结金额
private int iCurrentPage;//当前页数
private int iShowPage;//显示最大页数
private string strSettlementID;//收费结算GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string strDoTypeName;//调用页面标识
private string strUserID;//登录人GID
private string strVerifyCacheName;//实收核销缓存名称
private string strRecvAmountGID;//实收核销费用GID
private string strPayAppGID;//付费申请GID
private string strTotalCacheName;//结算合计缓存名称
private string strBsnoCacheName;//委托缓存名称
private string stroplb;//业务类别
private string strbstype;//业务类别
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].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();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString().Trim();
}
if (Request.QueryString["bstype"] != null)
{
strbstype = Request.QueryString["bstype"].ToString().Trim();
}
if (Request.QueryString["condition"] != null)
{
strCondition = Request.QueryString["condition"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["billno"] != null)
{
strBillNO = Request.QueryString["billno"].ToString();
}
if (Request.QueryString["payappid"] != null)
{
strPayAppGID = Request.QueryString["payappid"].ToString();
}
if (Request.QueryString["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
if (Request.QueryString["fsearch"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strFeeSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["fsearch"].ToString())));
}
if (Request.QueryString["all"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strALLBSNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["all"].ToString())));
}
if (Request.QueryString["ordercachename"] != null)
{
strOrderCacheName = Request.QueryString["ordercachename"].ToString();
}
if (Request.QueryString["selectedorder"] != null)
{
strSelectedOrder = Request.QueryString["selectedorder"].ToString();
}
if (Request.QueryString["op"] != null)
{
strCheckType = Request.QueryString["op"].ToString();
}
if (Request.QueryString["feeid"] != null)
{
strFeeID = Request.QueryString["feeid"].ToString().Trim();
}
if (Request.QueryString["postsession"] != null)
{
strPostSessionID = Request.QueryString["postsession"].ToString();
}
if (Request.QueryString["exchange"] != null)
{
dExchangeRate = decimal.Parse(Request.QueryString["exchange"].ToString());
}
if (Request.QueryString["cstl"] != null)
{
dCSTL = decimal.Parse(Request.QueryString["cstl"].ToString());
}
if (Request.QueryString["ustl"] != null)
{
dUSTL = decimal.Parse(Request.QueryString["ustl"].ToString());
}
if (Request.QueryString["currency"] != null)
{
strCurrency = Request.QueryString["currency"].ToString().Trim().ToUpper();
}
if (Request.QueryString["cur_page"] != null)
{
iCurrentPage = int.Parse(Request.QueryString["cur_page"].ToString().Trim());
}
else
{
iCurrentPage = 0;
}
if (Request.QueryString["show_page"] != null)
{
iShowPage = int.Parse(Request.QueryString["show_page"].ToString().Trim());
}
else
{
iShowPage = 0;
}
if (Request.QueryString["settlementid"] != null)
{
strSettlementID = Request.QueryString["settlementid"].ToString();
}
if (Request.QueryString["do"] != null)
{
strDoTypeName = Request.QueryString["do"].ToString().ToLower();
}
if (Request.QueryString["verifycachename"] != null)
{
strVerifyCacheName = Request.QueryString["verifycachename"].ToString();
}
if (Request.QueryString["recvamountid"] != null)
{
strRecvAmountGID = Request.QueryString["recvamountid"].ToString();
}
if (Request.QueryString["totalcachename"] != null)
{
strTotalCacheName = Request.QueryString["totalcachename"].ToString();
}
if (Request.QueryString["bsnocachename"] != null)
{
strBsnoCacheName = Request.QueryString["bsnocachename"].ToString();
}
if (strHandle != null)
{
if (strHandle == "orderlist")
{
Response.Write(GetSeaeOrder());
}
else if (strHandle == "feelist" && strBSNO != null)
{
Response.Write(GetFeeList(strBSNO));
}
else if (strHandle == "ordersearch")
{
Response.Write(GetSeaeOrderBySearch(strSearch));
}
else if (strHandle == "billlist")
{
Response.Write(GetSettleBill(strBillNO));
}
else if (strHandle == "settlelist")
{
Response.Write(GetSettleList());
}
else if (strHandle == "settlelistpage")
{
Response.Write(GetSettleListPage());
}
else if (strHandle == "orderfee")
{
Response.Write(GetSelectedOrderFee(strBSNO));
}
else if (strHandle == "bankinfo")
{
Response.Write(GetBankInfoList());
}
else if (strHandle == "cacheorder" && strOrderCacheName != null && strBsnoCacheName != null && strTotalCacheName != null && strSearch != null)
{
//当全选委托时缓存数据
//Response.Write(CacheOrderFee(strSelectedOrder, strOrderCacheName));
Response.Write(CheckAllOrder(strSearch, strBsnoCacheName, strOrderCacheName, strTotalCacheName, strCheckType));
}
else if (strHandle == "checkorder" && strBSNO != null && strOrderCacheName != null && strCheckType != null && strBsnoCacheName != null && strTotalCacheName != null)
{
//单选委托信息
Response.Write(ExcuteCheckOrder(strBSNO, strCheckType, strOrderCacheName,strBsnoCacheName,strTotalCacheName));
}
else if (strHandle == "checkfee" && strFeeID != null && strOrderCacheName != null && strCheckType != null && strBsnoCacheName != null && strTotalCacheName != null && strBSNO != null)
{
Response.Write(ExcuteCheckFee(strFeeID, strCheckType, strOrderCacheName, strBsnoCacheName, strTotalCacheName, strBSNO));
}
else if (strHandle == "checkallfee" && strBSNO != null && strOrderCacheName != null && strCheckType != null)
{
//费用全选操作
Response.Write(ExcuteCheckAllFee(strBSNO, strCheckType, strOrderCacheName, strBsnoCacheName, strTotalCacheName));
}
else if (strHandle == "validatepost" && strOrderCacheName != null)
{
//查看是否有不同的结算单位
Response.Write(ValidatePostInfo(strOrderCacheName));
}
else if (strHandle == "valibsnotype"&&strBsnoCacheName!=null)
{
Response.Write(ValiBsnoTypeName(strBsnoCacheName));
}
else if (strHandle == "postrecvsettle" && strPostSessionID != null && strOrderCacheName != null)
{
//提交收费结算SESSION信息
Response.Write(PostRecvSettlementSession(strPostSessionID, strOrderCacheName));
}
else if (strHandle == "postpaysettle" && strPostSessionID != null && strOrderCacheName != null)
{
//提交付费申请SESSION信息
Response.Write(PostPaySettlementSession(strPostSessionID, strBsnoCacheName, strOrderCacheName, strTotalCacheName));
}
else if (strHandle == "changefee" && strOrderCacheName != null && strFeeID != null && strBsnoCacheName != null && strTotalCacheName != null && strBSNO != null)
{
//更改本次结算费用金额
Response.Write(ChangeFeeCstl(strOrderCacheName, strFeeID, dCSTL, dUSTL, strBsnoCacheName, strTotalCacheName, strBSNO));
}
else if (strHandle == "settleeditfee" && strSettlementID != null && strBSNO != null)
{
Response.Write(GetSettlementEditFeeByGID(strSettlementID, strBSNO));
}
else if (strHandle == "paysettleeditfee" && strSettlementID != null && strBSNO != null)
{
Response.Write(GetSettlementEditFeeByGID(strSettlementID, strBSNO));
}
else if (strHandle == "payauditorderlist" && strBillNO != null)
{
Response.Write(GetFeePayApplyOrder(strBillNO, strSearch));
}
else if (strHandle == "payauditfeelist" && strBSNO != null)
{
Response.Write(GetPaySettleApplicationList(strBSNO));
}
else if (strHandle == "cancelrecvsettle" && strBillNO != null)
{
//撤销收费结算
//Response.Write(CancelRecvSettlement(strUserID, strBillNO));
Response.Write(CacelRecvSettle(strBillNO));
}
else if (strHandle == "cancelpaysettle" && strBillNO != null)
{
Response.Write(CancelPaySettlement(strUserID, strBillNO));
}
else if (strHandle == "getrecvamount")
{
Response.Write(GetReceiveAmountList());
}
else if (strHandle == "getrecvamountpage")
{
Response.Write(GetReceiveAmountListPage());
}
else if (strHandle == "getunverfiyrecvamount")
{
Response.Write(GetUnverifyReceiveAmountList());
}
else if (strHandle == "getunverfiyrecvamountpage")
{
Response.Write(GetUnverifyReceiveAmountListPage());
}
else if (strHandle == "cacheverify")
{
Response.Write(CacheReceiveAmountVerify(strVerifyCacheName, strRecvAmountGID));
}
else if (strHandle == "getverifycache" && strVerifyCacheName != null)
{
Response.Write(GetVerifyCacheRecvAmount(strVerifyCacheName));
}
else if (strHandle == "deleterecvamount" && strRecvAmountGID != null)
{
Response.Write(DeleteReceiveAmountByGID(strRecvAmountGID));
}
else if (strHandle == "refreshorder" && strOrderCacheName != null && strBsnoCacheName != null && strTotalCacheName != null && strSearch != null)
{
Response.Write(RefreshOrder(strSearch, strBsnoCacheName, strOrderCacheName, strTotalCacheName, strCheckType));
}
else if (strHandle == "getchecksumfeejson" && strFeeID != null && strDoTypeName != null)
{
//动态计算当前选中行的人民币、美元应收应付合计金额
Response.Write(GetCheckSumfeeJson(strDoTypeName, strFeeID));
}
}
}
#region 删除实收费用
/// <summary>
/// 删除实收费用
/// </summary>
/// <param name="tempRecvAmountGID">实收费用GID</param>
/// <returns>值1表示删除成功 值不等于1表示删除失败</returns>
private int DeleteReceiveAmountByGID(string tempRecvAmountGID)
{
int iResult = 0;
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
ReceiveAmountEntity receiveAmountEntity = new ReceiveAmountEntity();
receiveAmountEntity = receiveAmountDA.GetRecvAmountByGID(tempRecvAmountGID);
if (receiveAmountEntity != null)
{
if (receiveAmountEntity.GID != null)
{
if (receiveAmountEntity.IsFinish)
{
iResult = -2;//实收费用已经核销不能删除
}
else if (receiveAmountEntity.DoAmount > 0)
{
iResult = -3;//实收费用已经进行了部分核销不能删除
}
else if (receiveAmountEntity.IsDelete)
{
iResult = -4;//实收费用已被删除,不能重复操作
}
else
{
iResult = receiveAmountDA.DeleteRecvAmountByGID(tempRecvAmountGID);
}
}
}
return iResult;
}
#endregion
#region 获取实收缓存信息
/// <summary>
/// 获取实收缓存信息
/// </summary>
/// <param name="tempVerifyCacheName">实收缓存名称</param>
/// <returns>返回JSON数据</returns>
private string GetVerifyCacheRecvAmount(string tempVerifyCacheName)
{
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
DataTable sourceTable;
DataTable cacheTable = new DataTable();
if (Session[tempVerifyCacheName] != null)
{
cacheTable = (DataTable)Session[tempVerifyCacheName];
}
string strRecvSql = "";
if (cacheTable != null)
{
if (cacheTable.Rows.Count > 0)
{
for (int i = 0; i < cacheTable.Rows.Count; i++)
{
strRecvSql += "'"+cacheTable.Rows[i]["GID"].ToString() + "',";
}
}
}
if (strRecvSql.Trim().EndsWith(","))
{
strRecvSql = strRecvSql.Trim().Substring(0, strRecvSql.Trim().Length - 1);
}
string strSql = String.Format("SELECT A.GID,B.SHORTNAME,A.CURRENCY,(ISNULL(A.RECVAMOUNT,0) - ISNULL(A.DOAMOUNT,0)) AS DOAMOUNT,(ISNULL(A.RECVAMOUNT,0) - ISNULL(A.DOAMOUNT,0)) AS UNSETTLE "
+ " FROM ch_fee_recvamount AS A INNER JOIN info_client AS B ON A.CLIENTID = B.GID WHERE A.GID IN ({0})", strRecvSql);
sourceTable = receiveAmountDA.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("\"1\",");
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="tempCacheName">缓存名称</param>
/// <param name="tempRecvAmountGID">实收费用GID</param>
/// <returns>值1表示缓存成功 值不等于1表示缓存失败</returns>
private int CacheReceiveAmountVerify(string tempCacheName,string tempRecvAmountGID)
{
int iResult = 0;
DataTable recvAmountTable;
if (Session[tempCacheName] != null)
{
recvAmountTable = (DataTable)Session[tempCacheName];
for (int i = 0; i < recvAmountTable.Rows.Count; i++)
{
if (!recvAmountTable.Rows[i]["GID"].ToString().Equals(tempRecvAmountGID))
{
DataRow newRow = recvAmountTable.NewRow();
newRow["GID"] = tempRecvAmountGID;
recvAmountTable.Rows.Add(newRow);
}
}
}
else
{
recvAmountTable = new DataTable();
recvAmountTable.Columns.Add("GID");
DataRow newRow = recvAmountTable.NewRow();
newRow["GID"] = tempRecvAmountGID;
recvAmountTable.Rows.Add(newRow);
}
Session[tempCacheName] = recvAmountTable;
iResult = 1;
return iResult;
}
#endregion
#region 获取实收录入总页数
/// <summary>
/// 获取实收录入总页数
/// </summary>
/// <returns></returns>
private int GetUnverifyReceiveAmountListPage()
{
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
string strSql = "SELECT COUNT(*) FROM ch_fee_recvamount as A WHERE ISNULL(ISDELETE,0) <> 1 AND ISFINISH <> 1 ";
//string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
// strSql += strAuthorityCondition;
//}
string strCondition = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime"://Customer
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
strSql += strCondition;
}
}
int iTotal = int.Parse(receiveAmountDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 获取所有未核销实收金额信息
/// <summary>
/// 获取所有未核销实收金额信息
/// </summary>
/// <returns>返回JSON未核销实收金额信息</returns>
private string GetUnverifyReceiveAmountList()
{
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,A.DESCRIPTION, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME, A.CURRENCY,ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT,A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID "
+ " WHERE ISNULL(ISDELETE,0) <> 1 AND ISNULL(ISFINISH,0) <> 1 " + strAuthorityCondition + strCondition
+ " ORDER BY A.CREATETIME DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,A.DESCRIPTION, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME,A.CURRENCY,ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT,A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID WHERE ISNULL(ISDELETE,0) <> 1 AND ISNULL(ISFINISH,0) <> 1 AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_recvamount WHERE 1 > 0 " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 AND ISNULL(ISFINISH,0) <> 1 ORDER BY CREATETIME DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY A.CREATETIME DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,A.DESCRIPTION, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME,A.CURRENCY, ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT, A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID WHERE ISNULL(ISDELETE,0) <> 1 AND ISNULL(ISFINISH,0) <> 1 "
+ " ORDER BY A.CREATETIME DESC ";
}
sourceTable = receiveAmountDA.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>
/// <returns></returns>
private int GetReceiveAmountListPage()
{
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
string strSql = "SELECT COUNT(*) FROM ch_fee_recvamount as A WHERE ISNULL(ISDELETE,0) <> 1 ";
//string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
// strSql += strAuthorityCondition;
//}
string strCondition = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime"://Customer
strCondition += String.Format(" AND convert(char(10),CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND (CLIENTID IN (SELECT GID FROM info_client WHERE SHORTNAME LIKE '%{0}%')) ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND NO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
strSql += strCondition;
}
}
int iTotal = int.Parse(receiveAmountDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 获取所有实收录入信息
/// <summary>
/// 获取所有实收录入信息
/// </summary>
/// <returns>返回JSON实收录入数据集信息</returns>
private string GetReceiveAmountList()
{
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND (A.CLIENTID IN (SELECT GID FROM info_client WHERE SHORTNAME LIKE '%{0}%')) ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.NO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,A.DESCRIPTION,A.NO, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME, A.CURRENCY,ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT,A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID WHERE ISDELETE <> 1 AND COMPANYID = '"+strCompanyID+"' "
+ strAuthorityCondition + strCondition
+ " ORDER BY A.CREATETIME DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,A.DESCRIPTION,A.NO, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME,A.CURRENCY,ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT,A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID WHERE ISDELETE <> 1 AND COMPANYID = '"+strCompanyID+"' AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_recvamount WHERE 1 > 0 " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY CREATETIME DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY A.CREATETIME DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,A.DESCRIPTION,A.NO, A.RECVAMOUNT, ISNULL(D.SHORTNAME,'') AS CUSTOMERNAME,B.SHOWNAME AS CREATEUSER, A.CREATETIME,A.CURRENCY, ISNULL(A.DOAMOUNT,0) AS DOAMOUNT,(A.RECVAMOUNT - ISNULL(A.DOAMOUNT,0)) AS UNSETTLEAMOUNT, A.SETTLETIME, C.SHOWNAME AS SETTLEUSER,A.REMARK "
+ " FROM ch_fee_recvamount as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID LEFT JOIN [user] AS C ON A.SETTLEUSER = C.GID LEFT JOIN info_client AS D ON A.CLIENTID = D.GID WHERE ISDELETE <> 1 AND COMPANYID = '"+strCompanyID+"' " + strAuthorityCondition + strCondition
+ " ORDER BY A.CREATETIME DESC ";
}
sourceTable = getStatusNameTable(receiveAmountDA.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="tempUserID">用户GID</param>
/// <param name="tempBillNO">业务编号</param>
/// <returns>值等于1表示撤销成功 值不等1表示撤销失败</returns>
private string CancelPaySettlement(string tempUserID, string tempBillNO)
{
string strResult = "";
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity();
feeSettlementEntity = feeSettlementDA.GetFeeSettlementByBillNO(tempBillNO);
if (feeSettlementEntity != null)
{
if (feeSettlementEntity.GID != null)
{
if (!feeSettlementEntity.IsDelete)
{
strResult = feeSettlementDA.RevocateSettlement(tempUserID, tempBillNO).ToString();
}
else
{
strResult = "-3";//收费结算已撤销,不能重复操作
}
}
else
{
strResult = "-4";//收费结算信息不存在
}
}
else
{
strResult = "-4";//收费结算信息不存在
}
return strResult;
}
#endregion
#region 撤销收费结算(不包含收费申请结算)
/// <summary>
/// 撤销收费结算(不包含收费申请结算)
/// </summary>
/// <param name="tempUserID">用户GID</param>
/// <param name="tempBillNO">业务编号</param>
/// <returns>值等于1表示撤销成功 值不等1表示撤销失败</returns>
private string CancelRecvSettlement(string tempUserID,string tempBillNO)
{
string strResult = "";
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity();
feeSettlementEntity = feeSettlementDA.GetFeeSettlementByBillNO(tempBillNO);
if (feeSettlementEntity != null)
{
if (feeSettlementEntity.GID != null)
{
if (!feeSettlementEntity.IsDelete)
{
strResult = feeSettlementDA.RevocateSettlement(tempUserID, tempBillNO).ToString();
}
else
{
strResult = "-3";//收费结算已撤销,不能重复操作
}
}
else
{
strResult = "-4";//收费结算信息不存在
}
}
else
{
strResult = "-4";//收费结算信息不存在
}
return strResult;
}
#endregion
#region 撤销收费结算(包含收费申请结算)
/// <summary>
/// 撤销收费结算(包含收费申请结算)
/// </summary>
/// <param name="strPaySettleID">收费结算GID</param>
/// <returns>值1表示结算成功 值不等于1表示结算失败</returns>
private int CacelRecvSettle(string tempBillNO)
{
int iResult = 0;
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity();
feeSettlementEntity = feeSettlementDA.GetFeeSettlementByBillNO(tempBillNO);
if (feeSettlementEntity != null)
{
if (feeSettlementEntity.GID != null)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string ssql = "select count(*) as nums from ch_fee_advance_payment_detail where BILLNO='" + feeSettlementEntity.BillNO.ToString() + "' and (ISDELETE=0 or ISDELETE is null)";
int nums = int.Parse(T_ALL_DA.GetStrSQL("nums", ssql));
if (nums != 0)//判断是否存在预收预收主表中的预收支资料
{
return -5;
}
//
ssql = "select count(*) as nums from ch_fee_settlement where BILLNO='" + feeSettlementEntity.BillNO.ToString() + "' and (ISDELETE=0 or ISDELETE is null) and (VOUNO is not null and VOUNO<>'')";
nums = int.Parse(T_ALL_DA.GetStrSQL("nums", ssql));
if (nums != 0)//判断是否存在预收预付主表中的预付支资料
{
return -6;
}
//
iResult = feeSettlementDA.CacelRecvSettle(feeSettlementEntity.GID.ToString().Trim(), feeSettlementEntity.BillNO, strUserID, feeSettlementEntity.CompanyID);
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "撤销收费结算信息";
logEntity.LogType = "CANCEL 撤销操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.CANCEL), "收费结算", "结算单号:" + feeSettlementEntity.BillNO);
Logger.Instance.WriteLog(logEntity);
}
}
}
return iResult;
}
#endregion
#region 获取收费结算费用明细
/// <summary>
/// 获取收费结算费用明细
/// </summary>
/// <param name="tempPaySettlementAppID">付费申请GID</param>
/// <param name="tempBSNO">委托编号</param>
/// <returns>JSON数据集</returns>
private string GetSettlementEditFeeByGID(string tempSettlementID, 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.SETTLEMENT,0) as SETTLEMENT,C.AMOUNT - ISNULL(C.SETTLEMENT,0) as UNSETTLEMENT,C.REMARK "//,ISNULL(A.AMOUNT,0) as SETTLEMENT,C.AMOUNT - ISNULL(A.AMOUNT,0) as UNSETTLEMENT
+ " FROM ch_fee_do as A INNER JOIN ch_fee_settlement as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON A.FEEID = C.GID WHERE B.GID = '" + tempSettlementID + "' " + strConditionBSNO;
DataTable sourceTable = new DataTable();
sourceTable = feePaySettleApplicaionDA.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
/// <summary>
/// 获取收费结算分页总页数
/// </summary>
/// <returns>返回总页数</returns>
private string GetSettleListPage()
{
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "DR";
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
string strSql = "SELECT COUNT(*) FROM ch_fee_settlement as A WHERE BILLNO LIKE '%DR%' AND ISNULL(ISDELETE,0) <> 1 ";
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
strSql += strAuthorityCondition;
}
//
string strCondition = "";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime"://Customer
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%') and BILLNO LIKE '%DR%')", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where INVOICENUM LIKE '%{0}%') and BILLNO LIKE '%DR%')", strArg[1].Replace("\"", ""));
break;
case "amount1"://
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2"://
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
//
strSql += strCondition;
}
}
int iTotal = int.Parse(feeSettlementDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal.ToString();
}
public string GetFeePayApplyOrder(string tempBillNO, string tempSearch)
{
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
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
strFeeCondition += String.Format(" AND C.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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND C.FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND C.FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND C.CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND C.CURRENCY LIKE '%{0}%' ", "USD");
}
break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = String.Format("SELECT BSNO FROM ch_fee WHERE GID IN (SELECT B.FEEID from ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO WHERE BILLNO = {0})",tempBillNO);
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO = '" + tempBillNO + "' "
// + strFeeCondition + " ) " + strSeaeCondition;
//string strSql = String.Format(" SELECT BSNO,'海运出口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='{0}' {1} ) {2} "
// + " union all "
// + " SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='{0}' {1} ) {2} "
// ,tempBillNO, strFeeCondition, strSeaeCondition);
//2013-02-05 修改
string strSql = String.Format(" SELECT BSNO,OPLBNAME,CUSTOMERNAME,MBLNO"
+ ",(SELECT (sum(case B.FEETYPE when 2 then B.AMOUNT else 0 end)-sum(case B.FEETYPE when 1 then B.AMOUNT else 0 end)) as AMOUNT FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO WHERE B.BSNO=VW_Settlement.BSNO and CURRENCY='RMB' and A.BILLNO ='{0}') as RMBSUM"
+ ",(SELECT (sum(case B.FEETYPE when 2 then B.AMOUNT else 0 end)-sum(case B.FEETYPE when 1 then B.AMOUNT else 0 end)) as AMOUNT FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO WHERE B.BSNO=VW_Settlement.BSNO and CURRENCY='USD' and A.BILLNO ='{0}') as USDSUM"
+ ",CUSTOMNO,CUSTOMNO2,CUSTNO,HBLNO"
+ " FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='{0}' {1} ) {2} "
, tempBillNO, strFeeCondition, strSeaeCondition);
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();
}
#region 获取付费申请费用信息列表数据源
/// <summary>
/// 获取付费申请费用信息列表数据源
/// </summary>
/// <param name="tempBSNO">委托业务编号GID</param>
/// <returns>返回json字符串</returns>
public string GetPaySettleApplicationList(string tempBSNO)
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
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 C.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 C.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 C.FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strCondition += String.Format(" AND C.CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strCondition += String.Format(" AND C.CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "billno"://Currency
string strbillno = strArg[1].Replace("\"", "").Trim();
if (strbillno.Trim() != "")
{
strCondition += String.Format(" AND A.billno = '{0}' ", strbillno.Trim());
}
break;
default:
break;
}
}
}
}
}
//string strSql = String.Format(" SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,C.AMOUNT,B.AMOUNT,B.AMOUNT "
// + " FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE "
// + " C.BSNO IN (SELECT BSNO FROM op_seae WHERE 1 > 0 AND BSNO = '{0}') {1}", strBSNO, strCondition);
//string strSql = String.Format(" SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,C.AMOUNT,B.AMOUNT,B.AMOUNT,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE "
// + " C.BSNO IN (SELECT BSNO FROM op_seae WHERE 1 > 0 AND BSNO = '{0}') {1}"
// + " union all "
// + " SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,C.AMOUNT,B.AMOUNT,B.AMOUNT,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE "
// + " C.BSNO IN (SELECT BSNO FROM op_seai WHERE 1 > 0 AND BSNO = '{0}') {1}"
// , strBSNO, strCondition);
//2013-02-05 修改
string strSql = String.Format(" SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,C.AMOUNT,B.AMOUNT,B.AMOUNT,OPLB=(SELECT OPLB FROM VW_Settlement WHERE BSNO=C.BSNO),C.REMARK "
+ " FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE "
+ " C.BSNO IN (SELECT BSNO FROM VW_Settlement WHERE 1 > 0 AND BSNO = '{0}') {1}", strBSNO, strCondition);
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
public string GetBankInfoList()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strSql = "SELECT GID,CODENAME,CURRENCY,BANKNAME,ACCOUNT FROM sys_bank";
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("banks:[");
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("\"code\":\"" + sourceTable.Rows[i][1].ToString() + "\",");
sourceBuilder.Append("\"cur\":\"" + sourceTable.Rows[i][2].ToString() + "\",");
sourceBuilder.Append("\"bank\":\"" + sourceTable.Rows[i][3].ToString() + "\",");
sourceBuilder.Append("\"acc\":\"" + sourceTable.Rows[i][4].ToString() + "\"}");
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
public string GetSettleList()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
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 "btime":
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime":
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus":
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%') and BILLNO LIKE '%DR%')", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where INVOICENUM LIKE '%{0}%') and BILLNO LIKE '%DR%')", strArg[1].Replace("\"", ""));
break;
case "amount1":
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2":
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
}
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
}
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "DR";
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", INVOICENUM=(select top 1 INVOICENUM from ch_fee where gid in (select top 1 feeid from ch_fee_do where billno=A.billno))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " A.REMARK "
+ " FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%DR%' " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY BILLNO DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", INVOICENUM=(select top 1 INVOICENUM from ch_fee where gid in (select top 1 feeid from ch_fee_do where billno=A.billno))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " A.REMARK "
+ " FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%DR%' AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_settlement WHERE BILLNO LIKE '%DR%' " + strAuthorityCondition.Replace("A.","") + strCondition.Replace("A.","") + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY BILLNO DESC ) " + strAuthorityCondition + strCondition
+ " AND ISNULL(ISDELETE,0) <> 1 ORDER BY BILLNO DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", INVOICENUM=(select top 1 INVOICENUM from ch_fee where gid in (select top 1 feeid from ch_fee_do where billno=A.billno))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " A.REMARK "
+ " FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%DR%' " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY BILLNO DESC ";
}
sourceTable = getStatusNameTableBillStatus(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++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
public string GetSettleBill(string strBillNO)
{
//FeeDoDA feeDoDA = new FeeDoDA();
//DataTable feeDoTable = feeDoDA.GetExcuteSql("SELECT * FROM ch_fee_do")
return "{rows:[]}";
}
public string GetSelectedOrderFee(string tempBSNO)
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
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 CUSTOMERNAME = '{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 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 FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "amount1"://
strCondition += String.Format(" AND AMOUNT >= '{0}'", strArg[1].Replace("\"", ""));
break;
case "amount2"://
strCondition += String.Format(" AND AMOUNT <= '{0}'", strArg[1].Replace("\"", ""));
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 GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,AMOUNT-SETTLEMENT,AMOUNT-SETTLEMENT FROM ch_fee "
// + " WHERE BSNO IN ('{0}') AND FEESTATUS = 0 AND GID NOT IN (SELECT FEEID FROM ch_fee_do) " + strCondition, tempBSNO);
//string strSql = String.Format(" SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,CASE WHEN C.FEESTATUS = 8 THEN C.AMOUNT - D.DOAMOUNT "
// + " ELSE CASE WHEN C.FEESTATUS =0 AND C.ORDERAMOUNT <> C.AMOUNT THEN C.AMOUNT - C.ORDERAMOUNT END END , "
// + " CASE WHEN C.FEESTATUS = 8 THEN C.AMOUNT - D.DOAMOUNT "
// + " ELSE CASE WHEN C.FEESTATUS =0 AND C.ORDERAMOUNT <> C.AMOUNT THEN C.AMOUNT - C.ORDERAMOUNT END END ,0 "
// + " FROM ch_fee as C LEFT JOIN ch_fee_do as D ON C.GID = D.FEEID WHERE C.GID IN ( SELECT A.GID FROM ch_fee as A LEFT JOIN ch_fee_do as B ON A.GID = B.FEEID "
// + " WHERE A.BSNO IN ('{0}') AND (FEEID IS NULL OR FEESTATUS = 8 OR (A.FEESTATUS = 0 AND A.ORDERAMOUNT <> A.AMOUNT AND A.AMOUNT > 0)) "
// + " ) AND (FEESTATUS = 8 OR FEESTATUS = 0) " + strCondition, tempBSNO);
//string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END, "
// + " CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END "
// + " FROM ch_fee WHERE GID NOT IN "
// + " (SELECT DISTINCT B.FEEID FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B "
// + " ON A.BILLNO = B.BILLNO WHERE A.BILLSTATUS < 4) AND AMOUNT <> SETTLEMENT AND ORDERAMOUNT <= AMOUNT AND BSNO IN ('{0}') AND (FEESTATUS = 0 OR FEESTATUS = 8)" + strCondition, tempBSNO);
//string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END, "
// + " CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END "
// + " FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " AND BSNO IN ('{0}') "
// //+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
// + strCondition+" ORDER BY CUSTOMERNAME DESC ", tempBSNO);
//2014-05-12 修改(包含负数)
string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL,REMARK "
+ " FROM ch_fee "
+ " WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) "
+ " AND BSNO IN ('{0}') "
//+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
+ strCondition + " ORDER BY CUSTOMERNAME DESC ", tempBSNO);
sourceTable = getStatusNameTable(feeSettlementDA.GetExcuteSql(strSql).Tables[0]);
DataTable feeTable = null;
if (strOrderCacheName != null)
{
if (Session[strOrderCacheName] != null)
{
feeTable = (DataTable)Session[strOrderCacheName];
}
}
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:[");
if (feeTable != null)
{
int iCount = 0;
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(sourceTable.Rows[i][0].ToString()))
{
sourceBuilder.Append("\"1\",");
iCount++;
break;
}
}
if (iCount == 0)
{
sourceBuilder.Append("\"0\",");
}
iCount = 0;
}
else
{
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>
/// <returns>返回json字符串</returns>
public string GetSeaeOrder()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = "SELECT BSNO,CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 8 OR FEESTATUS = 0)) ";
//string strSql = "SELECT BSNO,'海运出口' OPLB,CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 8 OR FEESTATUS = 0)) "
// + " union all "
// + "SELECT BSNO,'海运进口' OPLB,CUSTOMERNAME,MBLNO,HBLNO FROM op_seai WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 8 OR FEESTATUS = 0)) ";
//2013-02-05 修改
string strSql = "SELECT BSNO,OPLBNAME,CUSTOMERNAME,MBLNO,HBLNO,CUSTOMNO FROM VW_Settlement WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 8 OR FEESTATUS = 0)) ";
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
public string GetSeaeOrderBySearch(string tempSearch)
{
if (strOrderCacheName != null)
{
if (Session[strOrderCacheName] != null)
{
Session.Remove(strOrderCacheName);
}
}
int strtmpoplb =0;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
string strAuthorityCondition = "";
if (strDoTypeName != null)
{
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID,strbstype);
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID,strbstype);
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID,strbstype);
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID,strbstype);
}
}
}
else
{
strAuthorityCondition = " AND 1< 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
strFeeCondition += String.Format(" AND CUSTOMERNAME = '{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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "bty"://业务类型
strtmpoplb = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "amount1"://
strFeeCondition += String.Format(" AND AMOUNT >= '{0}'", strArg[1].Replace("\"", ""));
break;
case "amount2"://
strFeeCondition += String.Format(" AND AMOUNT <= '{0}'", strArg[1].Replace("\"", ""));
break;
case "accSta":
strSeaeCondition += string.Format(" AND ACCDATE ='{0}'",strArg[1].Replace("\"",""));
break;
case "op":
strSeaeCondition += string.Format(" AND op ='{0}'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = "SELECT BSNO, CUSTOMERNAME,CUSTNO,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 OR FEESTATUS = 8 OR (A.FEESTATUS = 0 AND A.ORDERAMOUNT <> B.DOAMOUNT)) AND (FEESTATUS = 8 OR FEESTATUS = 0))"
// + strSeaeCondition;
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE GID NOT IN "
// + " (SELECT DISTINCT B.FEEID FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO "
// + " WHERE A.BILLSTATUS < 4) AND ISNULL(SETTLEMENT,0) <> ISNULL(AMOUNT,0) AND (FEESTATUS = 0 OR FEESTATUS = 8) " + strFeeCondition + strAuthorityCondition + " ) " + strSeaeCondition;
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + strFeeCondition + strAuthorityCondition + " ) " + strSeaeCondition + " ORDER BY CUSTOMERNAME DESC ";
string strSql = "";
//switch (strtmpoplb)
//{
// case 0://所有业务类型
// strSql =String.Format ( " SELECT BSNO,'海运出口' OPLB,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} "
// + " union all "
// + " SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 1://海运出口op_Seae
// strSql = String.Format(" SELECT BSNO,'海运出口' OPLB,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} "
// + " ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 2://海运进口op_Seai
// strSql = String.Format(" SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 3:
// break;
// case 4:
// break;
// default:
// break;
//}
//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,CUSTNO,MBLNO,HBLNO,CUSTOMNO,CUSTOMNO2 FROM VW_Settlement WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) {0} "
////+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
//+ " ) {1} {2} {3} ORDER BY CUSTOMERNAME,CUSTNO ASC ", strFeeCondition, strAuthorityCondition, strSeaeCondition, sOPLBCondition);
//2014-05-12 修改(包含负数)
strSql = String.Format(" SELECT BSNO,OPLBNAME,CUSTOMERNAME,MBLNO,CUSTNO,HBLNO,CUSTOMNO,CUSTOMNO2 FROM VW_Settlement WHERE BSNO IN (SELECT BSNO FROM ch_fee WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) {0} "
//+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
+ " ) {1} {2} {3} ORDER BY MBLNO,CUSTOMERNAME,CUSTNO ASC ", strFeeCondition, strAuthorityCondition, strSeaeCondition, 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();
}
#region 获取费用信息列表数据源
/// <summary>
/// 获取费用信息列表数据源
/// </summary>
/// <param name="tempBSNO">委托业务编号GID</param>
/// <returns>返回json字符串</returns>
public string GetFeeList(string tempBSNO)
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
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 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 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 FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
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);
//20110-08-16 注释掉,重新更改费用检索条件,增加部分结算费用信息的现实 JHQ
//string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,AMOUNT-SETTLEMENT,AMOUNT-SETTLEMENT 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 A.BSNO IN ('{0}') AND FEEID IS NULL) AND (FEESTATUS = 8 OR FEESTATUS = 0)" + strCondition, tempBSNO);
//string strSql = String.Format("SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN FEESTATUS = 8 THEN AMOUNT - SETTLEMENT ELSE CASE WHEN FEESTATUS =0 AND ORDERAMOUNT <> AMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT END END, "
// + "0 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 A.BSNO IN ('{0}') AND (FEEID IS NULL OR FEESTATUS = 8 OR (A.FEESTATUS = 0 AND A.ORDERAMOUNT <> A.AMOUNT)) "
// + ") AND (FEESTATUS = 8 OR FEESTATUS = 0) " + strCondition, tempBSNO);
//string strSql = String.Format(" SELECT C.GID,C.FEETYPE,C.CUSTOMERNAME,C.FEENAME,C.CURRENCY,CASE WHEN C.FEESTATUS = 8 THEN C.AMOUNT - D.DOAMOUNT "
// + " ELSE CASE WHEN C.FEESTATUS =0 AND C.ORDERAMOUNT <> C.AMOUNT THEN C.AMOUNT - C.ORDERAMOUNT END END , "
// + " CASE WHEN C.FEESTATUS = 8 THEN C.AMOUNT - D.DOAMOUNT "
// + " ELSE CASE WHEN C.FEESTATUS =0 AND C.ORDERAMOUNT <> C.AMOUNT THEN C.AMOUNT - C.ORDERAMOUNT END END ,0 "
// + " FROM ch_fee as C LEFT JOIN ch_fee_do as D ON C.GID = D.FEEID WHERE C.GID IN ( SELECT A.GID FROM ch_fee as A LEFT JOIN ch_fee_do as B ON A.GID = B.FEEID "
// + " WHERE A.BSNO IN ('{0}') AND (FEEID IS NULL OR FEESTATUS = 8 OR (A.FEESTATUS = 0 AND A.ORDERAMOUNT <> A.AMOUNT AND A.AMOUNT > 0)) "
// + " ) AND (FEESTATUS = 8 OR FEESTATUS = 0) " + strCondition, tempBSNO);
//string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
//+ " CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL"
//+ " FROM ch_fee WHERE GID NOT IN "
//+ " (SELECT DISTINCT B.FEEID FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B "
//+ " ON A.BILLNO = B.BILLNO WHERE A.BILLSTATUS < 4) AND AMOUNT <> SETTLEMENT AND ORDERAMOUNT <= AMOUNT AND BSNO IN ('{0}') " + strCondition, tempBSNO);
//2014-05-12 修改(包含负数)
string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL,REMARK"
+ " FROM ch_fee WHERE GID NOT IN "
+ " (SELECT DISTINCT B.FEEID FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B "
+ " ON A.BILLNO = B.BILLNO WHERE A.BILLSTATUS < 4)"
+ " AND AMOUNT <> SETTLEMENT"
+ " AND ((case when ORDERAMOUNT<0 then (-ORDERAMOUNT) else ORDERAMOUNT end) <= (case when AMOUNT<0 then (-AMOUNT) else AMOUNT end))"
+ " AND BSNO IN ('{0}') " + strCondition, 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
/// <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;
}
private DataTable getStatusNameTableBillStatus(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("BILLSTATUS") || sourceTable.Columns[j].ColumnName.Equals("SETTLEMODE") || sourceTable.Columns[j].ColumnName.Equals("SETTLETYPE"))
{
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("BILLSTATUS"))
{
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 if (sourceTable.Columns[k].ColumnName.Equals("SETTLEMODE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "申请";
break;
case 2:
strFeeStatus = "自由";
break;
case 3:
strFeeStatus = "发票";
break;
case 4:
strFeeStatus = "流程";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("SETTLETYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "现金";
break;
case 2:
strFeeStatus = "支票";
break;
case 3:
strFeeStatus = "电汇";
break;
case 4:
strFeeStatus = "转账";
break;
case 5:
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;
}
#region 当委托全选或者是去除全选时,缓存费用信息
/// <summary>
/// 当委托全选或者是去除全选时,缓存费用信息
/// </summary>
/// <param name="tempSelectedOrder">选中的委托信息组</param>
/// <param name="tempOrderCacheName">缓存名称</param>
/// <returns>返回动态计算的应收应付金额合计</returns>
private string CacheOrderFee(string tempSelectedOrder, string tempOrderCacheName)
{
string strResult = "";
int iAuthorityStatus = 0;
int iForbidCount = 0;//没有权限添加的委托信息统计
UserAuthorityManage userAuthorityManage = null;
if (strDoTypeName == "paysettle")
{
userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
}
if (strDoTypeName == "recvsettle")
{
userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
}
if (strDoTypeName == "paysettleapp")
{
userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
}
ArrayList groupArray = new ArrayList();
string strBsnoGroup = "";
string strList = tempSelectedOrder;
string strFilter = "";
if (strList.IndexOf("[") >= 0 && strList.IndexOf("]") > 0)
{
strFilter = strList.Substring(strList.IndexOf("[") + 1, strList.IndexOf("]") - strList.IndexOf("[") - 1);
string[] strFees = strFilter.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
if (strFees.Length > 0)
{
for (int i = 0; i < strFees.Length; i++)
{
strFees[i] = strFees[i].ToString().Replace("{", "");
strFees[i] = strFees[i].ToString().Replace("}", "");
string[] strCell = strFees[i].Split(new char[] { ',' });
if (strCell.Length > 0)
{
FeeDoEntity feeDoEntity = new FeeDoEntity();
for (int j = 0; j < strCell.Length; j++)
{
string[] strArg = strCell[j].Split(new char[] { ':' });
switch (strArg[0].Replace("\"", ""))
{
case "bsno":
groupArray.Add(strArg[1].ToString().Replace("\"", "").Trim());
if (strDoTypeName == "paysettle")
{
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strArg[1].ToString().Replace("\"", "").Trim(), "", strUserID);
}
}
else if (strDoTypeName == "recvsettle")
{
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strArg[1].ToString().Replace("\"", "").Trim(), "", strUserID);
}
}
else if (strDoTypeName == "paysettleapp")
{
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strArg[1].ToString().Replace("\"", "").Trim(), "", strUserID);
}
}
//strBsnoGroup += "'" + strArg[1].ToString().Replace("\"", "").Trim() + "',";
if (iAuthorityStatus == 1)
{
strBsnoGroup += "'" + strArg[1].ToString().Replace("\"", "").Trim() + "',";
}
else
{
iForbidCount++;
}
break;
default:
break;
}
}
}
}
}
}
if (strCheckType != null)
{
if (strCheckType.Trim().ToLower().Equals("check"))
{
if (strBsnoGroup.Trim().EndsWith(","))
{
strBsnoGroup = strBsnoGroup.Substring(0, strBsnoGroup.Length - 1);
}
if (strBsnoGroup.Trim().Equals(""))
{
strBsnoGroup = "''";
}
string strSql = GetSearchSql(strSearch, strBsnoGroup);//String.Format("SELECT * FROM ch_fee WHERE BSNO IN ({0})", strBsnoGroup);
DataTable feeTable = new DataTable();
FeeDA feeDA = new FeeDA();
feeTable = feeDA.GetExcuteSql(strSql).Tables[0];
if (feeTable.Rows.Count > 0)
{
Session[tempOrderCacheName] = feeTable;
}
//strResult = GetSumFeeJson(feeTable,1);
if (iForbidCount > 0)
{
strResult = GetSumFeeJson(feeTable, -iForbidCount,0,false);
}
else
{
strResult = GetSumFeeJson(feeTable, 1, 1, true);
}
}
else
{
if (Session[tempOrderCacheName] != null)
{
DataTable feeTable = (DataTable)Session[tempOrderCacheName];
if (groupArray.Count > 0)
{
for (int j = 0; j < groupArray.Count; j++)
{
for (int i = 0; i < feeTable.Rows.Count; i++)
{
if (feeTable.Rows[i]["BSNO"].ToString().Trim().Equals(groupArray[j].ToString()))
{
feeTable.Rows.Remove(feeTable.Rows[i]);
i = -1;
continue;
}
}
}
if (feeTable.Rows.Count == 0)
{
Session.Remove(tempOrderCacheName);
//strResult = GetSumFeeJson(feeTable,1);
if (iForbidCount > 0)
{
strResult = GetSumFeeJson(feeTable, -iForbidCount, 0, false);
}
else
{
strResult = GetSumFeeJson(feeTable, 1, 2, true);
}
}
else
{
Session[tempOrderCacheName] = feeTable;
//strResult = GetSumFeeJson(feeTable,1);
if (iForbidCount > 0)
{
strResult = GetSumFeeJson(feeTable, -iForbidCount, 0, false);
}
else
{
strResult = GetSumFeeJson(feeTable, 1, 2, true);
}
}
}
}
}
}
return strResult;
}
#endregion
#region 选中委托信息,默认缓存委托信息内的所有费用信息
/// <summary>
/// 选中委托信息,默认缓存委托信息内的所有费用信息
/// </summary>
/// <param name="tempBSNO">委托编号</param>
/// <param name="tempCheckType">选中类型 值check表示选中 值uncheck表示取消选中</param>
/// <param name="tempCacheName">缓存名称</param>
/// <param name="tempBsnoCacheName">委托缓存名称</param>
/// <param name="tempTotalCacheName">合计缓存名称</param>
/// <returns>返回重新计算后的利润信息JSON</returns>
private string ExcuteCheckOrder(string tempBSNO, string tempCheckType, string tempCacheName,string tempBsnoCacheName,string tempTotalCacheName)
{
string strResult = "";
DataTable feeTable = null;
int iAuthorityStatus = 0;
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1,0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1,0, false);
return strResult;
}
}
//如果已经存在选中费用明细,则从Session中获取费用信息进行添加
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
if (tempCheckType.Trim().ToLower().Equals("check"))
{
string strSql = GetSearchSql(strSearch, "'" + tempBSNO + "'");
DataTable checkFeeTable = new DataTable();
DataTable bsnoTable = null;
FeeDA feeDA = new FeeDA();
//checkFeeTable = feeDA.GetFeeListByCondition(strSql).Tables[0];
checkFeeTable = GetFeeByOrderBsnoTable(strSearch, tempBSNO);
if (checkFeeTable.Rows.Count > 0)
{
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
int iCount = 0;
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
iCount++;
break;
}
}
if (iCount == 0)
{
//缓存新的费用信息
DataRow newRow = feeTable.NewRow();
newRow["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
newRow["BSNO"] = checkFeeTable.Rows[i]["BSNO"].ToString();
newRow["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
newRow["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
newRow["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
newRow["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
newRow["CTL"] = checkFeeTable.Rows[i]["CTL"].ToString();
newRow["UCTL"] = checkFeeTable.Rows[i]["UCTL"].ToString();
newRow["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
feeTable.Rows.Add(newRow);
}
}
Session[tempCacheName] = feeTable;
}
if (Session[tempBsnoCacheName] != null)
{
bsnoTable = (DataTable)Session[tempBsnoCacheName];
for (int i = 0; i < bsnoTable.Rows.Count; i++)
{
if (bsnoTable.Rows[i]["BSNO"].ToString().Equals(tempBSNO))
{
bsnoTable.Rows.RemoveAt(i);
break;
}
}
//
DataTable checkBsnoTable = GetOrderTable(strSearch, tempBSNO);
int iBsnoCount = 0;
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
bsnoTable.Rows[j]["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
bsnoTable.Rows[j]["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
bsnoTable.Rows[j]["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
bsnoTable.Rows[j]["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
bsnoTable.Rows[j]["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
iBsnoCount++;
break;
}
}
if (iBsnoCount == 0)
{
//BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO
//缓存新的委托信息
DataRow newRow = bsnoTable.NewRow();
newRow["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
newRow["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
newRow["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
newRow["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
newRow["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
bsnoTable.Rows.Add(newRow);
}
}
else
{
bsnoTable = GetOrderTable(strSearch, tempBSNO);
}
Session[strBsnoCacheName] = bsnoTable;
strResult = GetSumFeeJson(feeTable, 1, 1, false);
}
else if (tempCheckType.Trim().ToLower().Equals("uncheck"))
{
//string strSql = GetSearchSql(strSearch, "'" + tempBSNO + "'");
DataTable checkFeeTable = null;
//FeeDA feeDA = new FeeDA();
//checkFeeTable = feeDA.GetFeeListByCondition(strSql).Tables[0];
checkFeeTable = GetFeeByOrderBsnoTable(strSearch, tempBSNO);
if (checkFeeTable.Rows.Count > 0)
{
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
feeTable.Rows.Remove(feeTable.Rows[j]);
break;
}
}
}
Session[tempCacheName] = feeTable;
}
DataTable bsnoTable = null;
if (Session[tempBsnoCacheName] != null)
{
bsnoTable = (DataTable)Session[tempBsnoCacheName];
for (int i = 0; i < bsnoTable.Rows.Count; i++)
{
if (bsnoTable.Rows[i]["BSNO"].ToString().Equals(tempBSNO))
{
bsnoTable.Rows.RemoveAt(i);
break;
}
}
Session[tempBsnoCacheName] = bsnoTable;
}
strResult = GetSumFeeJson(feeTable, 1, 2, false);
}
//strResult = GetSumFeeJson(feeTable, 1);
}
else
{
if (tempCheckType.Trim().ToLower().Equals("check"))
{
DataTable bsnoTable = null;
//如果当前选中的委托下的费用未进行过缓存,则将所有费用明细缓存
if (Session[strBsnoCacheName] != null)
{
bsnoTable = (DataTable)Session[strBsnoCacheName];
}
else
{
bsnoTable = GetOrderTable(strSearch, tempBSNO);
Session[strBsnoCacheName] = bsnoTable;
}
feeTable = GetFeeByOrderBsnoTable(strSearch, tempBSNO);
Session[tempCacheName] = feeTable;
strResult = GetSumFeeJson(feeTable, 1, 1, false);
}
else
{
//如果在没有缓存费用明细情况下,取消选中状态,将委托缓存信息内相关委托移除,最后再缓存
DataTable bsnoTable = null;
if (Session[strBsnoCacheName] != null)
{
bsnoTable = (DataTable)Session[strBsnoCacheName];
}
if (bsnoTable != null)
{
for (int i = 0; i < bsnoTable.Rows.Count; i++)
{
if (bsnoTable.Rows[i]["BSNO"].ToString().Equals(tempBSNO))
{
bsnoTable.Rows.RemoveAt(i);
break;
}
}
Session[strBsnoCacheName] = bsnoTable;
}
strResult = GetSumFeeJson(feeTable, 1, 2, false);
}
}
return strResult;
}
#endregion
#region 单选费用操作
/// <summary>
/// 单选费用操作
/// </summary>
/// <param name="tempBSNO">委托编号BSNO</param>
/// <param name="tempCheckType">选中类型 值check选中状态 值uncheck取消选中状态</param>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回缓存数据合计费用JSON</returns>
private string ExcuteCheckFee(string tempFeeID, string tempCheckType, string tempCacheName,string tempBsnoCacheName,string tempTotalCacheName,string tempBSNO)
{
string strResult = "";
DataTable feeTable = (DataTable)Session[tempCacheName] ?? CreateFeeTable();
DataTable bsnoTable = (DataTable)Session[tempBsnoCacheName] ?? CreateBsnoTable();
DataTable totalTable = (DataTable)Session[tempTotalCacheName] ?? CreateTotalTable();
int iAuthorityStatus = 0;
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID, "VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
if (tempCheckType.Trim().ToLower().Equals("check"))
{
DataTable checkFeeTable = GetSimpleFeeByGID(tempFeeID);
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
int iCount = 0;
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
feeTable.Rows[j]["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
feeTable.Rows[j]["BSNO"] = checkFeeTable.Rows[i]["BSNO"].ToString();
feeTable.Rows[j]["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
feeTable.Rows[j]["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
feeTable.Rows[j]["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
feeTable.Rows[j]["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
feeTable.Rows[j]["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
feeTable.Rows[j]["CTL"] = checkFeeTable.Rows[i]["CTL"].ToString();
feeTable.Rows[j]["UCTL"] = checkFeeTable.Rows[i]["UCTL"].ToString();
feeTable.Rows[j]["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
iCount++;
break;
}
}
if (iCount == 0)
{
//缓存新的费用信息
DataRow newRow = feeTable.NewRow();
newRow["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
newRow["BSNO"] = checkFeeTable.Rows[i]["BSNO"].ToString();
newRow["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
newRow["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
newRow["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
newRow["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
newRow["CTL"] = checkFeeTable.Rows[i]["CTL"].ToString();
newRow["UCTL"] = checkFeeTable.Rows[i]["UCTL"].ToString();
newRow["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
feeTable.Rows.Add(newRow);
}
}
DataTable checkBsnoTable = GetOrderTable(strSearch, tempBSNO);
int iBsnoCount = 0;
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
bsnoTable.Rows[j]["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
bsnoTable.Rows[j]["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
bsnoTable.Rows[j]["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
bsnoTable.Rows[j]["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
bsnoTable.Rows[j]["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
iBsnoCount++;
break;
}
}
if (iBsnoCount == 0)
{
//BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO
//缓存新的委托信息
DataRow newRow = bsnoTable.NewRow();
newRow["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
newRow["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
newRow["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
newRow["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
newRow["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
bsnoTable.Rows.Add(newRow);
}
Session[tempBsnoCacheName] = bsnoTable;
Session[tempCacheName] = feeTable;
strResult = GetSumFeeJson(feeTable, 1, 1, false);
}
else
{
int isExistCount = 0;
DataTable checkFeeTable = GetSimpleFeeByGID(tempFeeID);
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
int feeCount = feeTable.Rows.Count;
for (int j = 0; j < feeCount; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
feeTable.Rows.Remove(feeTable.Rows[j]);
j = j - 1;
feeCount = feeTable.Rows.Count;
//isExistCount--;
continue;
}
if (feeTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
isExistCount++;
}
}
}
if (isExistCount == 0)
{
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
bsnoTable.Rows.RemoveAt(j);
break;
}
}
if (bsnoTable.Rows.Count > 0)
{
Session[tempBsnoCacheName] = bsnoTable;
}
else
{
Session.Remove(tempBsnoCacheName);
}
}
if (feeTable.Rows.Count > 0)
{
Session[tempCacheName] = feeTable;
}
else
{
Session.Remove(tempCacheName);
}
strResult = GetSumFeeJson(feeTable, 1, 2, false);
}
return strResult;
}
#endregion
#region 动态计算人民币、美元应收应付合计金额
/// <summary>
/// 动态计算人民币、美元应收应付合计金额
/// </summary>
/// <param name="tempFeeTable">数据表</param>
/// <param name="tempState">返回状态信息</param>
/// <param name="tempCheckType">是否是选中状态1-选中状态 2-取消选中状态</param>
/// <param name="tempCheckAll">是否是全选操作</param>
/// <returns>返回JSON状态信息</returns>
private string GetSumFeeJson(DataTable tempFeeTable, int tempState,int tempCheckType,bool tempCheckAll)
{
StringBuilder totalBuilder = new StringBuilder();
decimal RecvRmbTotal = 0;
decimal PayRmbTotal = 0;
decimal RecvUsdTotal = 0;
decimal PayUsdTotal = 0;
decimal RmbTotal = 0;
decimal UsdTotal = 0;
if (tempFeeTable != null)
{
if (tempFeeTable.Rows.Count > 0)
{
if (tempCheckType == 1)//选中状态
{
for (int i = 0; i < tempFeeTable.Rows.Count; i++)
{
string tempCurrency = tempFeeTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper();
decimal tempFee = decimal.Parse(tempFeeTable.Rows[i]["CTL"].ToString());
int tempFeeType = int.Parse(tempFeeTable.Rows[i]["FEETYPE"].ToString());
if (tempFeeType == 1 && tempCurrency == "RMB" && tempFee != 0)//tempFee > 0
{
RecvRmbTotal += tempFee;
}
else if (tempFeeType == 1 && tempCurrency == "USD" && tempFee != 0)//tempFee > 0
{
RecvUsdTotal += tempFee;
}
else if (tempFeeType == 2 && tempCurrency == "RMB" && tempFee != 0)//tempFee > 0
{
PayRmbTotal += tempFee;
}
else if (tempFeeType == 2 && tempCurrency == "USD" && tempFee != 0)//tempFee > 0
{
PayUsdTotal += tempFee;
}
}
if (strDoTypeName == "paysettle" || strDoTypeName == "paysettleapp")
{
RmbTotal = PayRmbTotal - RecvRmbTotal;
UsdTotal = PayUsdTotal - RecvUsdTotal;
}
else
{
RmbTotal = RecvRmbTotal - PayRmbTotal;
UsdTotal = RecvUsdTotal - PayUsdTotal;
}
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"recvrmb\":" + RecvRmbTotal.ToString() + ",");
totalBuilder.Append("\"recvusd\":" + RecvUsdTotal.ToString() + ",");
totalBuilder.Append("\"payrmb\":" + PayRmbTotal.ToString() + ",");
totalBuilder.Append("\"payusd\":" + PayUsdTotal.ToString() + ",");
totalBuilder.Append("\"totalrmb\":" + RmbTotal.ToString() + ",");
totalBuilder.Append("\"totalusd\":" + UsdTotal.ToString() + ",");
totalBuilder.Append("\"state\":" + tempState.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
DataTable totalTable = null;
if (Session[strTotalCacheName] != null)
{
totalTable = (DataTable)Session[strTotalCacheName];
}
else
{
totalTable = CreateTotalTable();
DataRow newRow = totalTable.NewRow();
totalTable.Rows.Add(newRow);
}
totalTable.Rows[0]["RECVRMB"] = RecvRmbTotal.ToString();
totalTable.Rows[0]["RECVUSD"] = RecvUsdTotal.ToString();
totalTable.Rows[0]["PAYRMB"] = PayRmbTotal.ToString();
totalTable.Rows[0]["PAYUSD"] = PayUsdTotal.ToString();
totalTable.Rows[0]["TOTALRMB"] = RmbTotal.ToString();
totalTable.Rows[0]["TOTALUSD"] = UsdTotal.ToString();
Session[strTotalCacheName] = totalTable;
}
else
{
//如果当前是状态为全部取消选中状态,则将合计数据置零并清除Session信息
if (tempCheckAll)
{
if (Session[strTotalCacheName] != null)
{
Session.Remove(strTotalCacheName);
}
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"recvrmb\":0,");
totalBuilder.Append("\"recvusd\":0,");
totalBuilder.Append("\"payrmb\":0,");
totalBuilder.Append("\"payusd\":0,");
totalBuilder.Append("\"totalrmb\":0,");
totalBuilder.Append("\"totalusd\":0,");
totalBuilder.Append("\"state\":" + tempState.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
}
else
{
for (int i = 0; i < tempFeeTable.Rows.Count; i++)
{
string tempCurrency = tempFeeTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper();
decimal tempFee = decimal.Parse(tempFeeTable.Rows[i]["CTL"].ToString());
int tempFeeType = int.Parse(tempFeeTable.Rows[i]["FEETYPE"].ToString());
if (tempFeeType == 1 && tempCurrency == "RMB" && tempFee != 0)//tempFee > 0
{
RecvRmbTotal += tempFee;
}
else if (tempFeeType == 1 && tempCurrency == "USD" && tempFee != 0)//tempFee > 0
{
RecvUsdTotal += tempFee;
}
else if (tempFeeType == 2 && tempCurrency == "RMB" && tempFee != 0)//tempFee > 0
{
PayRmbTotal += tempFee;
}
else if (tempFeeType == 2 && tempCurrency == "USD" && tempFee != 0)//tempFee > 0
{
PayUsdTotal += tempFee;
}
}
if (strDoTypeName == "paysettle" || strDoTypeName == "paysettleapp")
{
RmbTotal = PayRmbTotal - RecvRmbTotal;
UsdTotal = PayUsdTotal - RecvUsdTotal;
}
else
{
RmbTotal = RecvRmbTotal - PayRmbTotal;
UsdTotal = RecvUsdTotal - PayUsdTotal;
}
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"recvrmb\":" + RecvRmbTotal.ToString() + ",");
totalBuilder.Append("\"recvusd\":" + RecvUsdTotal.ToString() + ",");
totalBuilder.Append("\"payrmb\":" + PayRmbTotal.ToString() + ",");
totalBuilder.Append("\"payusd\":" + PayUsdTotal.ToString() + ",");
totalBuilder.Append("\"totalrmb\":" + RmbTotal.ToString() + ",");
totalBuilder.Append("\"totalusd\":" + UsdTotal.ToString() + ",");
totalBuilder.Append("\"state\":" + tempState.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
DataTable totalTable = null;
if (Session[strTotalCacheName] != null)
{
totalTable = (DataTable)Session[strTotalCacheName];
}
else
{
totalTable = CreateTotalTable();
DataRow newRow = totalTable.NewRow();
totalTable.Rows.Add(newRow);
}
totalTable.Rows[0]["RECVRMB"] = RecvRmbTotal.ToString();
totalTable.Rows[0]["RECVUSD"] = RecvUsdTotal.ToString();
totalTable.Rows[0]["PAYRMB"] = PayRmbTotal.ToString();
totalTable.Rows[0]["PAYUSD"] = PayUsdTotal.ToString();
totalTable.Rows[0]["TOTALRMB"] = RmbTotal.ToString();
totalTable.Rows[0]["TOTALUSD"] = UsdTotal.ToString();
Session[strTotalCacheName] = totalTable;
}
}
}
else
{
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"recvrmb\":" + RecvRmbTotal.ToString() + ",");
totalBuilder.Append("\"recvusd\":" + RecvUsdTotal.ToString() + ",");
totalBuilder.Append("\"payrmb\":" + PayRmbTotal.ToString() + ",");
totalBuilder.Append("\"payusd\":" + PayUsdTotal.ToString() + ",");
totalBuilder.Append("\"totalrmb\":" + RmbTotal.ToString() + ",");
totalBuilder.Append("\"totalusd\":" + UsdTotal.ToString() + ",");
totalBuilder.Append("\"state\":" + tempState.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
}
}
else
{
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"recvrmb\":" + RecvRmbTotal.ToString() + ",");
totalBuilder.Append("\"recvusd\":" + RecvUsdTotal.ToString() + ",");
totalBuilder.Append("\"payrmb\":" + PayRmbTotal.ToString() + ",");
totalBuilder.Append("\"payusd\":" + PayUsdTotal.ToString() + ",");
totalBuilder.Append("\"totalrmb\":" + RmbTotal.ToString() + ",");
totalBuilder.Append("\"totalusd\":" + UsdTotal.ToString() + ",");
totalBuilder.Append("\"state\":" + tempState.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
}
return totalBuilder.ToString();
}
#endregion
#region 动态计算当前选中行的人民币、美元应收应付合计金额
/// <summary>
/// 动态计算当前选中行的人民币、美元应收应付合计金额
/// </summary>
/// <param name="tempFeeTable">数据表</param>
/// <param name="tempState">返回状态信息</param>
/// <param name="tempCheckType">是否是选中状态1-选中状态 2-取消选中状态</param>
/// <param name="tempCheckAll">是否是全选操作</param>
/// <returns>返回JSON状态信息</returns>
private string GetCheckSumfeeJson(string strDoTypeName, string strFeeID)
{
StringBuilder totalBuilder = new StringBuilder();
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
decimal Rmb = 0;
decimal Usd = 0;
string sSQL = "";
string sels = " and 1<0";
if (strFeeID.Trim() != "")
{
string feeids = strFeeID.Replace(",", "','");
sels = " and gid in ('" + feeids + "')";
}
//
if (strDoTypeName == "paysettleapp")//新增付费申请,当前费用列表选中行合计
{
#region 新增付费申请,当前费用列表选中行合计
sSQL = "select isnull(sum(case when (FEETYPE=1 and isnull(CURRENCY,'RMB')='RMB') then -AMOUNT when (FEETYPE=2 and isnull(CURRENCY,'RMB')='RMB') then AMOUNT else 0 end),0) as PayRMBHj,isnull(sum(case when (FEETYPE=1 and isnull(CURRENCY,'RMB')='USD') then -AMOUNT when (FEETYPE=2 and isnull(CURRENCY,'RMB')='USD') then AMOUNT else 0 end),0) as PayUSDHj from ch_fee where 1=1" + sels;
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
Rmb = decimal.Parse(ds.Tables[0].Rows[0]["PayRMBHj"].ToString());
Usd = decimal.Parse(ds.Tables[0].Rows[0]["PayUSDHj"].ToString());
}
}
#endregion
}
//
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"rmb\":" + Rmb.ToString() + ",");
totalBuilder.Append("\"usd\":" + Usd.ToString() + "");
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
return totalBuilder.ToString();
}
#endregion
#region 获取数据集的SQL语句
/// <summary>
/// 获取数据集的SQL语句
/// </summary>
/// <param name="tempSearch">查询条件</param>
/// <param name="tempValidateOrder">要包含的委托信息组</param>
/// <returns>返回获取数据集的SQL语句</returns>
private string GetSearchSql(string tempSearch, string tempValidateOrder)
{
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
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("\"", ""));
strFeeCondition += 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}%')", 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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
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;
default:
break;
}
}
}
//string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT, "
// + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as CTL, "
// + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as UCTL FROM ch_fee "
// + " WHERE ((ISINVOICE = 1 AND ISNULL(INVOICE,0) <> AMOUNT) OR (ISINVOICE = 0 AND ISNULL(ORDERINVOICE,0) <> AMOUNT)) AND BSNO IN ({0}) " + strFeeCondition, tempValidateOrder);
//string strSql = String.Format(" SELECT GID,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END, "
// + " CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END "
// + " FROM ch_fee WHERE GID NOT IN "
// + " (SELECT DISTINCT B.FEEID FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B "
// + " ON A.BILLNO = B.BILLNO WHERE A.BILLSTATUS < 4) AND AMOUNT <> SETTLEMENT AND ORDERAMOUNT <= AMOUNT AND BSNO IN ({0}) " + strFeeCondition, tempValidateOrder);
//string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
//+ " CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL "
//+ ",EXCHANGERATE "
//+ " FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) AND BSNO IN ({0}) " + strFeeCondition, tempValidateOrder);
//2014-05-12 修改(包含负数)
string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL"
+ ",EXCHANGERATE,REMARK "
+ " FROM ch_fee WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) AND BSNO IN ({0}) " + strFeeCondition, tempValidateOrder);
return strSql;
}
#endregion
#region 执行同一委托下费用全选操作
/// <summary>
/// 执行同一委托下费用全选操作
/// </summary>
/// <param name="tempBSNO">委托编号</param>
/// <param name="tempCheckType">选中类型 值check表示全部选中 值uncheck表示取消全部选中</param>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回合计费用结果JSON</returns>
private string ExcuteCheckAllFee(string tempBSNO, string tempCheckType, string tempCacheName, string tempBsnoCacheName, string tempTotalCacheName)
{
string strResult = "";
int iAuthorityStatus = 0;
DataTable feeTable = (DataTable)Session[tempCacheName] ?? CreateFeeTable();
DataTable bsnoTable = (DataTable)Session[tempBsnoCacheName] ?? CreateBsnoTable();
DataTable totalTable = (DataTable)Session[tempTotalCacheName] ?? CreateTotalTable();
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, tempBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
//string strTempSql = getSqlCondtionString(strSearch);
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
if (tempCheckType.Trim().ToLower().Equals("check"))
{
DataTable checkFeeTable = GetFeeByOrderBsnoTable(strSearch, tempBSNO);
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
int iCount = 0;
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
feeTable.Rows[j]["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
feeTable.Rows[j]["BSNO"] = checkFeeTable.Rows[i]["BSNO"].ToString();
feeTable.Rows[j]["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
feeTable.Rows[j]["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
feeTable.Rows[j]["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
feeTable.Rows[j]["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
feeTable.Rows[j]["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
feeTable.Rows[j]["CTL"] = checkFeeTable.Rows[i]["CTL"].ToString();
feeTable.Rows[j]["UCTL"] = checkFeeTable.Rows[i]["UCTL"].ToString();
feeTable.Rows[j]["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
iCount++;
break;
}
}
if (iCount == 0)
{
//缓存新的费用信息
DataRow newRow = feeTable.NewRow();
newRow["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
newRow["BSNO"] = checkFeeTable.Rows[i]["BSNO"].ToString();
newRow["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
newRow["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
newRow["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
newRow["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
newRow["CTL"] = checkFeeTable.Rows[i]["CTL"].ToString();
newRow["UCTL"] = checkFeeTable.Rows[i]["UCTL"].ToString();
newRow["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
feeTable.Rows.Add(newRow);
}
}
DataTable checkBsnoTable = GetOrderTable(strSearch, tempBSNO);
int iBsnoCount = 0;
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
bsnoTable.Rows[j]["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
bsnoTable.Rows[j]["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
bsnoTable.Rows[j]["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
bsnoTable.Rows[j]["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
bsnoTable.Rows[j]["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
iBsnoCount++;
break;
}
}
if (iBsnoCount == 0)
{
//BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO
//缓存新的委托信息
DataRow newRow = bsnoTable.NewRow();
newRow["BSNO"] = checkBsnoTable.Rows[0]["BSNO"].ToString();
newRow["CUSTOMERNAME"] = checkBsnoTable.Rows[0]["CUSTOMERNAME"].ToString();
newRow["CUSTNO"] = checkBsnoTable.Rows[0]["CUSTNO"].ToString();
newRow["MBLNO"] = checkBsnoTable.Rows[0]["MBLNO"].ToString();
newRow["HBLNO"] = checkBsnoTable.Rows[0]["HBLNO"].ToString();
bsnoTable.Rows.Add(newRow);
}
Session[tempBsnoCacheName] = bsnoTable;
Session[tempCacheName] = feeTable;
strResult = GetSumFeeJson(feeTable, 1, 1, false);
}
else if (tempCheckType.Trim().ToLower().Equals("uncheck"))
{
DataTable checkFeeTable = GetFeeByOrderBsnoTable(strSearch, tempBSNO);
for (int i = 0; i < checkFeeTable.Rows.Count; i++)
{
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(checkFeeTable.Rows[i]["GID"].ToString().Trim()))
{
feeTable.Rows.Remove(feeTable.Rows[j]);
break;
}
}
}
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
bsnoTable.Rows.RemoveAt(j);
break;
}
}
if (bsnoTable.Rows.Count > 0)
{
Session[tempBsnoCacheName] = bsnoTable;
}
else
{
Session.Remove(tempBsnoCacheName);
}
if (feeTable.Rows.Count > 0)
{
Session[tempCacheName] = feeTable;
}
else
{
Session.Remove(tempCacheName);
}
strResult = GetSumFeeJson(feeTable, 1, 2, false);
}
return strResult;
}
#endregion
#region 验证提交的开票信息
/// <summary>
/// 验证提交的开票信息
/// </summary>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回JSON状态</returns>
private string ValidatePostInfo(string tempCacheName)
{
string strResult = "";
if (Session[tempCacheName] != null)
{
//获取缓存数据
DataTable feeTable = (DataTable)Session[tempCacheName];
//查看是否有不同的结算单位
int iTempDiffCust = IsDifferentCustomer(feeTable);
//查看是否有不同的结算币别
int iTempDiffCurr = IsDifferentCurrency(feeTable);
#region
//查看是否超过发票最大行数
//object configObj = ConfigManager.ConfigManager.Instance().GetConfigInfo(ConfigType.INVOICECONFIG);
//IList<InvoiceConfigEntity> invoiceConfigEntities = new List<InvoiceConfigEntity>();
//invoiceConfigEntities = (IList<InvoiceConfigEntity>)configObj;
//int iTempIsMaxLine = 0;
//int iInvoiceMaxLine = 0;
//if (invoiceConfigEntities.Count > 0)
//{
// foreach (InvoiceConfigEntity invoicConfigEntity in invoiceConfigEntities)
// {
// if (invoicConfigEntity.ItemName.ToLower().Equals("maxline"))
// {
// iInvoiceMaxLine = int.Parse(invoicConfigEntity.ItemValue);
// break;
// }
// }
//}
//if (iInvoiceMaxLine > 0)
//{
// if (feeTable.Rows.Count > iInvoiceMaxLine)
// {
// iTempIsMaxLine = 1;
// }
// else
// {
// iTempIsMaxLine = 0;
// }
//}
//else
//{
// iTempIsMaxLine = 0;
//}
#endregion
int iTempVerifyClient = 0;
int iTempVerifyCurrency = 0;
if (strVerifyCacheName != null)
{
if (Session[strVerifyCacheName] != null)
{
DataTable verifyTable = (DataTable)Session[strVerifyCacheName];
IList<ReceiveAmountEntity> receiveAmountEntities = new List<ReceiveAmountEntity>();
ReceiveAmountDA receiveAmountDA = new ReceiveAmountDA();
decimal totalRecvAmount = 0;
for (int i = 0; i < verifyTable.Rows.Count; i++)
{
ReceiveAmountEntity receiveAmountEntity = receiveAmountDA.GetRecvAmountByGID(verifyTable.Rows[i]["GID"].ToString());
if (receiveAmountEntity != null)
{
totalRecvAmount = receiveAmountEntity.ReceiveAmount;
if (!strCurrency.Equals(receiveAmountEntity.Currency))
{
iTempVerifyCurrency = 1;
}
CRMClientDA crmClientDA = new CRMClientDA();
CRMClientEntity crmClientEntity = crmClientDA.GetCrmClientInfoByGID(receiveAmountEntity.ClientID);
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (crmClientEntity.ShortName != feeTable.Rows[j]["CUSTOMERNAME"].ToString().Trim())
{
iTempVerifyClient = 1;//存在不同结算单位信息
break;
}
}
receiveAmountEntities.Add(receiveAmountEntity);
}
}
}
}
strResult = GetValidateResult(iTempDiffCust, iTempDiffCurr, 0, 0, iTempVerifyClient, iTempVerifyCurrency);
}
else
{
strResult = GetValidateResult(-2, -2, -2, -2,-2,-2);
}
return strResult;
}
#endregion
/// <summary>
/// 提交申请时验证是否存在不同的业务类型名称
/// </summary>
/// <param name="bsnoCachName"></param>
/// <returns></returns>
protected string ValiBsnoTypeName(string bsnoCachName)
{
DataTable bsnoTable = (DataTable)Session[bsnoCachName];
string result = "same";
string bsnotypeName = GetOplbnameByBsno(bsnoTable.Rows[0]["BSNO"].ToString().Trim());
for (int i = 1; i < bsnoTable.Rows.Count; i++)
{
if (bsnotypeName !=GetOplbnameByBsno(bsnoTable.Rows[i]["BSNO"].ToString().Trim()))
{
result = "disff";
break;
}
else
{
continue;
}
}
return result;
}
/// <summary>
/// 获取业务类型
/// </summary>
/// <param name="bsno"></param>
/// <returns></returns>
protected string GetOplbnameByBsno(string bsno)
{
T_ALL_DA tallda = new T_ALL_DA();
return tallda.GetStrSQL("OPLBNAME", "SELECT OPLBNAME FROM VW_Settlement WHERE BSNO='"+bsno.Trim()+"'");
}
#region 获取JSON值
/// <summary>
/// 获取JSON值
/// </summary>
/// <param name="tempCompanyID">公司GID</param>
/// <param name="tempSourceID">报表资源GID</param>
/// <param name="tempUserID">用户GID</param>
/// <returns>返回JSON字符串</returns>
private string GetValidateResult(int tempIsDiffCust, int tempIsDiffCurr, int tempIsMaxLine, int tempMaxLine,int tempVerifyCurrency,int tempVerifyClient)
{
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.Append("{");
jsonBuilder.Append("\"validates\":");
jsonBuilder.Append("[");
jsonBuilder.Append("{");
jsonBuilder.Append("\"diffcust\":" + tempIsDiffCust.ToString() + ",");
jsonBuilder.Append("\"diffcurr\":" + tempIsDiffCurr.ToString() + ",");
jsonBuilder.Append("\"ismaxline\":" + tempIsMaxLine.ToString() + ",");
jsonBuilder.Append("\"maxline\":" + tempMaxLine.ToString() + ",");
jsonBuilder.Append("\"verclient\":" + tempVerifyClient.ToString() + ",");
jsonBuilder.Append("\"vercurr\":" + tempVerifyCurrency.ToString() + "");
jsonBuilder.Append("}");
jsonBuilder.Append("]");
jsonBuilder.Append("}");
return jsonBuilder.ToString();
}
#endregion
#region 是否有不同的结算单位
/// <summary>
/// 是否有不同的结算单位
/// </summary>
/// <param name="tempDataTable">数据源</param>
/// <returns>值0表示不存在不同的结算单位 值1表示存在不同的结算单位 值小于0表示获取缓存数据异常</returns>
private int IsDifferentCustomer(DataTable tempDataTable)
{
int iResult = 0;
if (tempDataTable.Rows.Count > 0)
{
string strCustomerName = tempDataTable.Rows[0]["CUSTOMERNAME"].ToString().Trim();
int iCount = 0;
for (int i = 1; i < tempDataTable.Rows.Count; i++)
{
if (!tempDataTable.Rows[i]["CUSTOMERNAME"].ToString().Trim().Equals(strCustomerName))
{
iCount++;
break;
}
}
if (iCount > 0)
{
iResult = 1;//存在不同的结算单位
}
else
{
iResult = 0;//验证通过,不存在不同的结算单位
}
}
else
{
iResult = -1;//未取到缓存信息
}
return iResult;
}
#endregion
#region 查看是否有不同币别
/// <summary>
/// 查看是否有不同币别
/// </summary>
/// <param name="tempDataTable">数据源</param>
/// <returns>值0表示不存在不同的币别 值1表示存在不同的币别 值小于0表示获取缓存数据异常</returns>
private int IsDifferentCurrency(DataTable tempDataTable)
{
int iResult = 0;
if (strCurrency != null)
{
if (strCurrency.ToUpper().Equals("ALL"))
{
iResult = 0;
}
else
{
if (tempDataTable.Rows.Count > 0)
{
//string strTempCurrency = tempDataTable.Rows[0]["CURRENCY"].ToString().Trim();
int iCount = 0;
for (int i = 0; i < tempDataTable.Rows.Count; i++)
{
if (!tempDataTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper().Equals(strCurrency))
{
iCount++;
break;
}
}
if (iCount > 0)
{
iResult = 1;//存在不同的币别
}
else
{
iResult = 0;//验证通过,不存在不同的币别
}
}
else
{
iResult = -1;//未取到缓存信息
}
}
}
else
{
if (tempDataTable.Rows.Count > 0)
{
string strTempCurrency = tempDataTable.Rows[0]["CURRENCY"].ToString().Trim();
int iCount = 0;
for (int i = 1; i < tempDataTable.Rows.Count; i++)
{
if (!tempDataTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper().Equals(strTempCurrency))
{
iCount++;
break;
}
}
if (iCount > 0)
{
iResult = 1;//存在不同的币别
}
else
{
iResult = 0;//验证通过,不存在不同的币别
}
}
else
{
iResult = -1;//未取到缓存信息
}
}
return iResult;
}
#endregion
#region 提交收费结算
/// <summary>
/// 提交收费结算
/// </summary>
/// <param name="tempPostSessionName">提交Session名称</param>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回string 值1表示提交成功 值不等于1表示提交失败</returns>
private string PostRecvSettlementSession(string tempPostSessionName, string tempCacheName)
{
string strResult = "";
StringBuilder appBuilder = new StringBuilder();
StringBuilder cacheBuilder = new StringBuilder();
if (Session[tempCacheName] != null)
{
DataTable feeTable = (DataTable)Session[tempCacheName];
appBuilder.Append("{\"caches\":[");
double exchangeRate = double.Parse(dExchangeRate.ToString());
for (int i = 0; i < feeTable.Rows.Count; i++)
{
double dCSTLFee = 0.0;
double dUSTLFee = 0.0;
string tempCurrency = feeTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper();
double tempFee = double.Parse(feeTable.Rows[i]["CTL"].ToString());
double tempUFee = double.Parse(feeTable.Rows[i]["UCTL"].ToString());
int tempFeeType = int.Parse(feeTable.Rows[i]["FEETYPE"].ToString());
if (tempCurrency.ToUpper().Equals("RMB") && strCurrency.ToUpper().Equals("USD"))
{
dCSTLFee = C1Round(tempFee * exchangeRate, 2);
dUSTLFee = C1Round(tempUFee * exchangeRate, 2);
}
else if (tempCurrency.ToUpper().Equals("USD") && strCurrency.ToUpper().Equals("RMB"))
{
dCSTLFee = C1Round(tempFee * exchangeRate, 2);
dUSTLFee = C1Round(tempUFee * exchangeRate, 2);
}
else
{
dCSTLFee = tempFee;
dUSTLFee = tempUFee;
}
cacheBuilder.Append("{");
cacheBuilder.Append("\"id\":\"" + feeTable.Rows[i]["GID"].ToString() + "\",");
//int iFeeType = int.Parse(feeTable.Rows[i]["FEETYPE"].ToString()) == ? 1 : 2;
cacheBuilder.Append("\"type\":" + feeTable.Rows[i]["FEETYPE"].ToString() + ",");
cacheBuilder.Append("\"bsno\":\"" + feeTable.Rows[i]["BSNO"].ToString() + "\",");
cacheBuilder.Append("\"cus\":\"" + feeTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
cacheBuilder.Append("\"fname\":\"" + feeTable.Rows[i]["FEENAME"].ToString() + "\",");
string settleCurrency = strCurrency.ToUpper() == "ALL" ? feeTable.Rows[i]["CURRENCY"].ToString() : strCurrency.ToUpper();
cacheBuilder.Append("\"cur\":\"" + settleCurrency + "\",");
cacheBuilder.Append("\"stl\":" + feeTable.Rows[i]["AMOUNT"].ToString() + ",");
cacheBuilder.Append("\"cstl\":" + dCSTLFee.ToString() + ",");
cacheBuilder.Append("\"ustl\":" + dUSTLFee.ToString() + ",");
cacheBuilder.Append("\"orig\":1,");
cacheBuilder.Append("\"oname\":\"" + feeTable.Rows[i]["FEENAME"].ToString() + "\",");
cacheBuilder.Append("\"ocstl\":" + feeTable.Rows[i]["CTL"].ToString() + ",");
cacheBuilder.Append("\"ocurr\":\"" + feeTable.Rows[i]["CURRENCY"].ToString() + "\"");
cacheBuilder.Append("},");
}
}
if (cacheBuilder.ToString().EndsWith(","))
{
appBuilder.Append(cacheBuilder.ToString().Substring(0, cacheBuilder.Length - 1));
appBuilder.Append("]}");
Session[tempPostSessionName] = appBuilder.ToString();
strResult = GetPostResult(PostNoticeTypeApp.POSTSUCCESS);
}
else
{
appBuilder.Append(cacheBuilder.ToString());
appBuilder.Append("]}");
Session[tempPostSessionName] = appBuilder.ToString();
strResult = GetPostResult(PostNoticeTypeApp.POSTSUCCESS);
}
return strResult;
}
#endregion
#region 提交付费结算申请或付费结算
/// <summary>
/// 提交付费结算申请或付费结算
/// </summary>
/// <param name="tempPostSessionName">提交Session名称</param>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回string 值1表示提交成功 值不等于1表示提交失败</returns>
private string PostPaySettlementSession(string tempPostSessionName, string tempBsnoCacheName,string tempCacheName,string tempTotalCacheName)
{
#region ####
//string strResult = "";
//StringBuilder appBuilder = new StringBuilder();
//StringBuilder cacheBuilder = new StringBuilder();
//if (Session[tempCacheName] != null)
//{
// DataTable feeTable = (DataTable)Session[tempCacheName];
// appBuilder.Append("{\"caches\":[");
// double exchangeRate = double.Parse(dExchangeRate.ToString());
// for (int i = 0; i < feeTable.Rows.Count; i++)
// {
// double dCSTLFee = 0.0;
// double dUSTLFee = 0.0;
// string tempCurrency = feeTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper();
// double tempFee = double.Parse(feeTable.Rows[i]["CTL"].ToString());
// double tempUFee = double.Parse(feeTable.Rows[i]["UCTL"].ToString());
// int tempFeeType = int.Parse(feeTable.Rows[i]["FEETYPE"].ToString());
// if (tempCurrency.ToUpper().Equals("RMB") && strCurrency.ToUpper().Equals("USD"))
// {
// dCSTLFee = C1Round(tempFee * exchangeRate, 2);
// dUSTLFee = C1Round(tempUFee * exchangeRate, 2);
// }
// else if (tempCurrency.ToUpper().Equals("USD") && strCurrency.ToUpper().Equals("RMB"))
// {
// dCSTLFee = C1Round(tempFee * exchangeRate, 2);
// dUSTLFee = C1Round(tempUFee * exchangeRate, 2);
// }
// else
// {
// dCSTLFee = tempFee;
// dUSTLFee = tempUFee;
// }
// cacheBuilder.Append("{");
// cacheBuilder.Append("\"id\":\"" + feeTable.Rows[i]["GID"].ToString() + "\",");
// //int iFeeType = int.Parse(feeTable.Rows[i]["FEETYPE"].ToString()) == ? 1 : 2;
// cacheBuilder.Append("\"type\":" + feeTable.Rows[i]["FEETYPE"].ToString() + ",");
// cacheBuilder.Append("\"bsno\":\"" + feeTable.Rows[i]["BSNO"].ToString() + "\",");
// cacheBuilder.Append("\"cus\":\"" + feeTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
// cacheBuilder.Append("\"fname\":\"" + feeTable.Rows[i]["FEENAME"].ToString() + "\",");
// string settleCurrency = strCurrency.ToUpper() == "ALL" ? feeTable.Rows[i]["CURRENCY"].ToString() : strCurrency.ToUpper();
// cacheBuilder.Append("\"cur\":\"" + settleCurrency + "\",");
// cacheBuilder.Append("\"stl\":" + feeTable.Rows[i]["AMOUNT"].ToString() + ",");
// cacheBuilder.Append("\"cstl\":" + dCSTLFee.ToString() + ",");
// cacheBuilder.Append("\"ustl\":" + dUSTLFee.ToString() + ",");
// cacheBuilder.Append("\"orig\":1,");
// cacheBuilder.Append("\"oname\":\"" + feeTable.Rows[i]["FEENAME"].ToString() + "\",");
// cacheBuilder.Append("\"ocstl\":" + feeTable.Rows[i]["CTL"].ToString() + "");
// cacheBuilder.Append("},");
// }
//}
//if (cacheBuilder.ToString().EndsWith(","))
//{
// appBuilder.Append(cacheBuilder.ToString().Substring(0, cacheBuilder.Length - 1));
// appBuilder.Append("]}");
// Session[tempPostSessionName] = appBuilder.ToString();
// strResult = GetPostResult(PostNoticeTypeApp.POSTSUCCESS);
//}
//else
//{
// appBuilder.Append(cacheBuilder.ToString());
// appBuilder.Append("]}");
// Session[tempPostSessionName] = appBuilder.ToString();
// strResult = GetPostResult(PostNoticeTypeApp.POSTSUCCESS);
//}
#endregion
string strResult = "";
DataTable bsnoTable = null;
DataTable feeTable = null;
DataTable totalTable = null;
if (Session[tempBsnoCacheName] != null)
{
bsnoTable = (DataTable)Session[tempBsnoCacheName];
}
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
}
if (Session[tempTotalCacheName] != null)
{
totalTable = (DataTable)Session[tempTotalCacheName];
}
if (bsnoTable != null && feeTable != null && totalTable != null)
{
DataSet postSet = new DataSet();
postSet.Tables.Add(bsnoTable.Copy());
feeTable.TableName = "feeTableCopy";
postSet.Tables.Add(feeTable.Copy());
totalTable.TableName = "totalTableCopy";
postSet.Tables.Add(totalTable.Copy());
//postSet.Tables["bsno"]. = bsnoTable;
//postSet.Tables["fee"] = feeTable;
//postSet.Tables["total"] = totalTable;
Session[tempPostSessionName] = postSet;
strResult = GetPostResult(PostNoticeTypeApp.POSTSUCCESS);
}
else
{
strResult = GetPostResult(PostNoticeTypeApp.SESSIONFAILURE);
}
return strResult;
}
#endregion
#region 金额四舍五入
/// <summary>
/// 金额四舍五入
/// </summary>
/// <param name="value">金额值</param>
/// <param name="digit">小数点后位数</param>
/// <returns>返回Double型四舍五入金额</returns>
public double C1Round(double value, int digit)
{
double vt = Math.Pow(10, digit);
double vx = value * vt;
vx += 0.5;
return (Math.Floor(vx) / vt);
}
#endregion
#region 获取返回状态
/// <summary>
/// 获取返回状态
/// </summary>
/// <param name="tempPostNoticeTypeApp">错误类型</param>
/// <returns>返回String类型状态</returns>
private string GetPostResult(PostNoticeTypeApp tempPostNoticeTypeApp)
{
string strResult = "";
switch (tempPostNoticeTypeApp)
{
case PostNoticeTypeApp.DIFFCUSTOMER://同时有多个结算单位
strResult = "-1";
break;
case PostNoticeTypeApp.DIFFCURRENCY://有不同币别,需要调用汇率
strResult = "-2";
break;
case PostNoticeTypeApp.BEYONDMAXLINE://发票明细超过最大显示条数
strResult = "-3";
break;
case PostNoticeTypeApp.SESSIONFAILURE://缓存数据异常
strResult = "-4";
break;
case PostNoticeTypeApp.POSTSUCCESS://提交申请成功
strResult = "1";
break;
default:
break;
}
return strResult;
}
#endregion
#region 更改本次结算费用金额
/// <summary>
/// 更改本次结算费用金额
/// </summary>
/// <param name="tempOrderCacheName">缓存名称</param>
/// <param name="tempFeeID">费用GID</param>
/// <param name="tempCSTL">本次结算金额</param>
/// <param name="tempUSTL">未结算金额</param>
/// <returns>返回金额合计总数</returns>
private string ChangeFeeCstl(string tempCacheName, string tempFeeID, decimal tempCSTL, decimal tempUSTL, string tempBsnoCacheName, string tempTotalCacheName,string tempBSNO)
{
string strResult = "";
DataTable feeTable = (DataTable)Session[tempCacheName] ?? CreateFeeTable();
DataTable bsnoTable = (DataTable)Session[tempBsnoCacheName] ?? CreateBsnoTable();
DataTable totalTable = (DataTable)Session[tempTotalCacheName] ?? CreateTotalTable();
int iAuthorityStatus = 0;
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
//if (Session[tempOrderCacheName] != null)
//{
// feeTable = (DataTable)Session[tempOrderCacheName];
//}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLESEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
//if (Session[tempOrderCacheName] != null)
//{
// feeTable = (DataTable)Session[tempOrderCacheName];
//}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.PAYSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID,"VW_Settlement");
}
if (iAuthorityStatus != 1)
{
//if (Session[tempOrderCacheName] != null)
//{
// feeTable = (DataTable)Session[tempOrderCacheName];
//}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
iAuthorityStatus = userAuthorityManage.CheckOperateRange(ModuleType.RECVSETTLEAPPSEARCH, userAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID, "VW_Settlement");
}
if (iAuthorityStatus != 1)
{
//if (Session[tempOrderCacheName] != null)
//{
// feeTable = (DataTable)Session[tempOrderCacheName];
//}
strResult = GetSumFeeJson(feeTable, -1, 0, false);
return strResult;
}
}
#region ####
//if (Session[tempOrderCacheName] != null)
//{
// feeTable = (DataTable)Session[tempOrderCacheName];
// int iCount = 0;
// if (feeTable.Rows.Count > 0)
// {
// for (int i = 0; i < feeTable.Rows.Count; i++)
// {
// if (feeTable.Rows[i]["GID"].ToString().Equals(tempFeeID))
// {
// feeTable.Rows[i]["CTL"] = tempCSTL.ToString();
// feeTable.Rows[i]["UCTL"] = tempUSTL.ToString();
// iCount++;
// break;
// }
// }
// }
// if (iCount > 0)
// {
// Session[tempOrderCacheName] = feeTable;
// }
// else
// {
// //string strSql = String.Format("SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT, "
// // + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// // + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as CTL, "
// // + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// // + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as UCTL FROM ch_fee WHERE GID = '{0}'", tempFeeID);
// string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
// + " CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL "
// + " FROM ch_fee WHERE GID = '{0}'", tempFeeID);
// DataTable sourceTable = new DataTable();
// FeeDA feeDA = new FeeDA();
// sourceTable = feeDA.GetFeeListByCondition(strSql).Tables[0];
// if (sourceTable.Rows.Count > 0)
// {
// sourceTable.Rows[0]["CTL"] = tempCSTL.ToString();
// sourceTable.Rows[0]["UCTL"] = tempUSTL.ToString();
// }
// DataRow newRow = feeTable.NewRow();
// newRow["GID"] = sourceTable.Rows[0]["GID"].ToString();
// newRow["BSNO"] = sourceTable.Rows[0]["BSNO"].ToString();
// newRow["FEETYPE"] = sourceTable.Rows[0]["FEETYPE"].ToString();
// newRow["CUSTOMERNAME"] = sourceTable.Rows[0]["CUSTOMERNAME"].ToString();
// newRow["FEENAME"] = sourceTable.Rows[0]["FEENAME"].ToString();
// newRow["CURRENCY"] = sourceTable.Rows[0]["CURRENCY"].ToString();
// newRow["AMOUNT"] = sourceTable.Rows[0]["AMOUNT"].ToString();
// newRow["CTL"] = sourceTable.Rows[0]["CTL"].ToString();
// newRow["UCTL"] = sourceTable.Rows[0]["UCTL"].ToString();
// feeTable.Rows.Add(newRow);
// Session[tempOrderCacheName] = feeTable;
// }
// strResult = GetSumFeeJson(feeTable, 1,1,false);
//}
//else
//{
// //string strSql = String.Format("SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT, "
// // + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// // + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as CTL, "
// // + " CASE WHEN ISINVOICE = 1 THEN CASE WHEN ISNULL(INVOICE,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERINVOICE,0) >= ISNULL(INVOICE,0) THEN AMOUNT - ISNULL(ORDERINVOICE,0) ELSE AMOUNT - ISNULL(INVOICE,0) END "
// // + " ELSE AMOUNT - ISNULL(INVOICE,0) END ELSE AMOUNT - ISNULL(ORDERINVOICE,0) END as UCTL FROM ch_fee WHERE GID = '{0}'", tempFeeID);
// string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
// + " CASE WHEN AMOUNT > SETTLEMENT THEN "
// + " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL "
// + " FROM ch_fee WHERE GID = '{0}'", tempFeeID);
// DataTable sourceTable = new DataTable();
// FeeDA feeDA = new FeeDA();
// sourceTable = feeDA.GetFeeListByCondition(strSql).Tables[0];
// if (sourceTable.Rows.Count > 0)
// {
// sourceTable.Rows[0]["CTL"] = tempCSTL.ToString();
// sourceTable.Rows[0]["UCTL"] = tempUSTL.ToString();
// }
// Session[tempOrderCacheName] = sourceTable;
// strResult = GetSumFeeJson(sourceTable, 1,1,false);
//}
#endregion
int iCount = 0;
if (feeTable.Rows.Count > 0)
{
for (int i = 0; i < feeTable.Rows.Count; i++)
{
if (feeTable.Rows[i]["GID"].ToString().Equals(tempFeeID))
{
feeTable.Rows[i]["CTL"] = tempCSTL.ToString();
feeTable.Rows[i]["UCTL"] = tempUSTL.ToString();
iCount++;
break;
}
}
}
if (iCount > 0)
{
Session[tempCacheName] = feeTable;
}
else
{
DataTable sourceTable = GetSimpleFeeByGID(tempFeeID);
if (sourceTable.Rows.Count > 0)
{
sourceTable.Rows[0]["CTL"] = tempCSTL.ToString();
sourceTable.Rows[0]["UCTL"] = tempUSTL.ToString();
}
DataRow newRow = feeTable.NewRow();
newRow["GID"] = sourceTable.Rows[0]["GID"].ToString();
newRow["BSNO"] = sourceTable.Rows[0]["BSNO"].ToString();
newRow["FEETYPE"] = sourceTable.Rows[0]["FEETYPE"].ToString();
newRow["CUSTOMERNAME"] = sourceTable.Rows[0]["CUSTOMERNAME"].ToString();
newRow["FEENAME"] = sourceTable.Rows[0]["FEENAME"].ToString();
newRow["CURRENCY"] = sourceTable.Rows[0]["CURRENCY"].ToString();
newRow["AMOUNT"] = sourceTable.Rows[0]["AMOUNT"].ToString();
newRow["CTL"] = sourceTable.Rows[0]["CTL"].ToString();
newRow["UCTL"] = sourceTable.Rows[0]["UCTL"].ToString();
newRow["EXCHANGERATE"] = sourceTable.Rows[0]["EXCHANGERATE"].ToString();
feeTable.Rows.Add(newRow);
Session[tempCacheName] = feeTable;
strResult = GetSumFeeJson(feeTable, 1, 1, false);
}
int iBsnoCount = 0;
for (int j = 0; j < bsnoTable.Rows.Count; j++)
{
if (bsnoTable.Rows[j]["BSNO"].ToString().Trim().Equals(tempBSNO))
{
iBsnoCount++;
break;
}
}
if (iBsnoCount == 0)
{
//BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO
DataTable sourceTable = GetOrderTable(strSearch, tempBSNO);
DataRow newRow = bsnoTable.NewRow();
newRow["BSNO"] = sourceTable.Rows[0]["BSNO"].ToString();
newRow["CUSTOMERNAME"] = sourceTable.Rows[0]["CUSTOMERNAME"].ToString();
newRow["CUSTNO"] = sourceTable.Rows[0]["CUSTNO"].ToString();
newRow["MBLNO"] = sourceTable.Rows[0]["MBLNO"].ToString();
newRow["HBLNO"] = sourceTable.Rows[0]["HBLNO"].ToString();
bsnoTable.Rows.Add(newRow);
Session[tempBsnoCacheName] = bsnoTable;
}
return strResult;
}
#endregion
#region 获取收费结算费用信息
/// <summary>
/// 获取收费结算费用信息
/// </summary>
/// <param name="tempSettlementID">收费结算GID</param>
/// <param name="tempBSNO">委托编号</param>
/// <returns>JSON数据集</returns>
private string GetInvoiceMakeOutEditFeeByGID(string tempSettlementID, string tempBSNO)
{
InvoiceDA invoiceDA = new InvoiceDA();
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.INVOICE,0) as INVOICE,C.AMOUNT - ISNULL(C.INVOICE,0) as UNINVOICE,C.REMARK "
+ " FROM ch_fee_do as A INNER JOIN ch_fee_invoice as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON A.FEEID = C.GID WHERE B.GID = '" + tempSettlementID + "' " + strConditionBSNO;
DataTable invoiceTable = new DataTable();
invoiceTable = invoiceDA.GetExcuteSql(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 DataTable CreateTotalTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("RECVRMB");
tempTable.Columns.Add("RECVUSD");
tempTable.Columns.Add("PAYRMB");
tempTable.Columns.Add("PAYUSD");
tempTable.Columns.Add("TOTALRMB");
tempTable.Columns.Add("TOTALUSD");
return tempTable;
}
private DataTable CreateBsnoTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("BSNO");
tempTable.Columns.Add("CUSTOMERNAME");
tempTable.Columns.Add("CUSTNO");
tempTable.Columns.Add("MBLNO");
tempTable.Columns.Add("HBLNO");
return tempTable;
}
private DataTable CreateFeeTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("GID");
tempTable.Columns.Add("BSNO");
tempTable.Columns.Add("FEETYPE");
tempTable.Columns.Add("CUSTOMERNAME");
tempTable.Columns.Add("FEENAME");
tempTable.Columns.Add("CURRENCY");
tempTable.Columns.Add("AMOUNT");
tempTable.Columns.Add("CTL");
tempTable.Columns.Add("UCTL");
tempTable.Columns.Add("EXCHANGERATE");
return tempTable;
}
private string CheckAllOrder(string tempSearch,string tempBSNOCacheName,string tempOrderCacheName,string tempTotalCacheName,string tempCheckType)
{
string strResult = "";
int itempoplb = 0;//业务类别
if (tempCheckType == "check")
{
#region 先获取全选的委托信息
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
string strAuthorityCondition = "";
if (strDoTypeName != null)
{
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
}
else
{
strAuthorityCondition = " AND 1< 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
strFeeCondition += String.Format(" AND CUSTOMERNAME = '{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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "bty":
itempoplb = int.Parse(strArg[1].Replace("\"", ""));
break;
case "amount1"://
strFeeCondition += String.Format(" AND AMOUNT >= '{0}'", strArg[1].Replace("\"", ""));
break;
case "amount2"://
strFeeCondition += String.Format(" AND AMOUNT <= '{0}'", strArg[1].Replace("\"", ""));
break;
case "op"://
strFeeCondition += String.Format(" AND op = '{0}'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + strFeeCondition + strAuthorityCondition + " ) " + strSeaeCondition + " ORDER BY CUSTOMERNAME DESC ";
string strSql = "";
//switch (itempoplb)
//{
// case 0:
// strSql = String.Format(" SELECT BSNO,'海运出口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} "
// + " union all "
// + " SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 1:
// strSql = String.Format(" SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 2:
// strSql = String.Format(" SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
// break;
// case 3-4:
// break;
// default:
// break;
//}
//2013-02-05 修改 begin
string sOPLBCondition = "";
switch (itempoplb)
{
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;
default:
break;
}
strSql = String.Format(" SELECT BSNO,OPLBNAME, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO,CUSTOMNO FROM VW_Settlement WHERE BSNO IN "
+ " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) {0} {1} ) {2} {3} ORDER BY CUSTOMERNAME DESC ", strFeeCondition, strAuthorityCondition, strSeaeCondition, sOPLBCondition);
//end
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
StringBuilder bsnoBuilder = new StringBuilder();
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (i == sourceTable.Rows.Count - 1)
{
bsnoBuilder.Append(sourceTable.Rows[i]["BSNO"].ToString());
}
else
{
bsnoBuilder.Append(sourceTable.Rows[i]["BSNO"].ToString() + ",");
}
}
if (Session[strBsnoCacheName] != null)
{
Session[strBsnoCacheName] = sourceTable;
}
else
{
Session[strBsnoCacheName] = sourceTable;
}
#endregion
#region 再缓存所有选中的委托相关的费用明细信息
//string strFeeSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
//+ " CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL "
//+ ",EXCHANGERATE "
//+ " FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) " + strFeeCondition);
//2014-05-12 修改(包含负数)
string strFeeSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL"
+ ",EXCHANGERATE,REMARK "
+ " FROM ch_fee WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) " + strFeeCondition);
DataTable feeTable = feeSettlementDA.GetExcuteSql(strFeeSql).Tables[0];
if (Session[strOrderCacheName] != null)
{
Session[strOrderCacheName] = feeTable;
}
else
{
Session[strOrderCacheName] = feeTable;
}
#endregion
strResult = GetSumFeeJson(feeTable, 1, 1, true);
}
else
{
DataTable feeTable = null;
//如果是取消全部选中,则自动将缓存的委托、费用明细清除
if (Session[strOrderCacheName] != null)
{
Session.Remove(strOrderCacheName);
}
if (Session[strBsnoCacheName] != null)
{
Session.Remove(strBsnoCacheName);
}
strResult = GetSumFeeJson(feeTable, 1, 2, true);
}
return strResult;
}
private string RefreshOrder(string tempSearch, string tempBSNOCacheName, string tempOrderCacheName, string tempTotalCacheName, string tempCheckType)
{
DataTable orderTable = new DataTable();
if (Session[tempBSNOCacheName] != null)
{
orderTable = (DataTable)Session[tempBSNOCacheName];
}
if (tempCheckType == "check")
{
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < orderTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + orderTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"1\",");
for (int j = 1; j < orderTable.Columns.Count; j++)
{
if (j == orderTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + orderTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + orderTable.Rows[i][j].ToString() + "\",");
}
}
if (i == orderTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
else
{
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
string strAuthorityCondition = "";
if (strDoTypeName != null)
{
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
else if (strDoTypeName == "recvsettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID, strbstype);//"VW_Settlement"
}
}
}
else
{
strAuthorityCondition = " AND 1< 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
strFeeCondition += String.Format(" AND CUSTOMERNAME = '{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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "amount1"://
strFeeCondition += String.Format(" AND AMOUNT >= '{0}'", strArg[1].Replace("\"", ""));
break;
case "amount2"://
strFeeCondition += String.Format(" AND AMOUNT <= '{0}'", strArg[1].Replace("\"", ""));
break;
case "op"://
strFeeCondition += String.Format(" AND op = '{0}'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + strFeeCondition + strAuthorityCondition + " ) " + strSeaeCondition + " ORDER BY CUSTOMERNAME DESC ";
//string strSql =String.Format( " SELECT BSNO,'海运出口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} "
// + " union all "
// + " SELECT BSNO,'海运进口' OPLB, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
//2013-02-05 修改
string strSql = String.Format(" SELECT BSNO,OPLBNAME, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO,CUSTOMNO FROM VW_Settlement WHERE BSNO IN "
+ " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC ", strFeeCondition, strAuthorityCondition, strSeaeCondition);
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();
}
}
#region 根据查询条件获取委托列表信息
/// <summary>
/// 根据查询条件获取委托列表信息
/// </summary>
/// <param name="tempSearch">查询条件</param>
/// <returns>返回DataTable</returns>
private DataTable GetOrderTable(string tempSearch,string tempBSNO)
{
DataTable sourceTable;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
string strAuthorityCondition = "";
if (strDoTypeName != null)
{
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
}
else
{
strAuthorityCondition = " AND 1< 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
strFeeCondition += String.Format(" AND CUSTOMERNAME = '{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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
case "op":
strSeaeCondition += String.Format(" AND op = '{0}' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
if (strBSNO != null)
{
strSeaeCondition += String.Format(" AND BSNO = '{0}' ", tempBSNO);
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
//string strSql = " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + strFeeCondition + strAuthorityCondition + " ) " + strSeaeCondition + " ORDER BY CUSTOMERNAME DESC ";
//string strSql = String.Format(" SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seae WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} "
// + " union all "
// + " SELECT BSNO, CUSTOMERNAME,CUSTNO,MBLNO,HBLNO FROM op_seai WHERE BSNO IN "
// + " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
// + " {0} {1} ) {2} ORDER BY CUSTOMERNAME DESC "
// , strFeeCondition, strAuthorityCondition, strSeaeCondition);
//2013-02-05 修改
//string strSql = String.Format(" SELECT BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO,CUSTOMNO,CUSTOMNO2 FROM VW_Settlement WHERE BSNO IN "
//+ " (SELECT BSNO FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) {0}"
////+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
//+ " ) {1} {2} ORDER BY CUSTOMERNAME DESC "
//, strFeeCondition, strAuthorityCondition, strSeaeCondition);
//2014-05-12 修改(包含负数)
string strSql = String.Format(" SELECT BSNO,CUSTOMERNAME,CUSTNO,MBLNO,HBLNO,CUSTOMNO,CUSTOMNO2 FROM VW_Settlement WHERE BSNO IN "
+ " (SELECT BSNO FROM ch_fee WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) {0}"
//+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
+ " ) {1} {2} ORDER BY CUSTOMERNAME DESC "
, strFeeCondition, strAuthorityCondition, strSeaeCondition);
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
return sourceTable;
}
#endregion
#region 根据查询数据获取委托相关费用明细数据信息
/// <summary>
/// 根据查询数据获取委托相关费用明细数据信息
/// </summary>
/// <param name="tempSearch">查询条件</param>
/// <param name="tempBSNO">委托编号</param>
/// <returns>返回DataTable</returns>
private DataTable GetFeeByOrderBsnoTable(string tempSearch,string tempBSNO)
{
DataTable sourceTable;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
string strFeeCondition = "";
string strAuthorityCondition = "";
if (strDoTypeName != null)
{
if (strDoTypeName == "paysettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
else if (strDoTypeName == "paysettleapp")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPSEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
else if (strDoTypeName == "recvsettle")
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleSearch");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLESEARCH, strShowName, strCompanyID, strDeptName, strUserID);
}
}
}
else
{
strAuthorityCondition = " AND 1< 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
strFeeCondition += String.Format(" AND CUSTOMERNAME = '{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 "fnm"://FeeName
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
int iFeeName = -1;
try
{
iFeeName = int.Parse(strArg[1].Replace("\"", "").Trim());
}
catch { }
if (iFeeName == -1)
{
strFeeCondition += String.Format(" AND FEENAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
}
}
break;
case "fty"://FeeType
int iFeeType = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iFeeType > 0)
{
strFeeCondition += String.Format(" AND FEETYPE = {0}", iFeeType);
}
break;
case "cur"://Currency
int iCurrency = int.Parse(strArg[1].Replace("\"", "").Trim());
if (iCurrency == 1)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "RMB");
}
else if (iCurrency == 2)
{
strFeeCondition += String.Format(" AND CURRENCY LIKE '%{0}%' ", "USD");
}
break;
default:
break;
}
}
}
if (strBSNO != null)
{
strFeeCondition += String.Format(" AND BSNO = '{0}' ", tempBSNO);
}
//string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT,CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL, "
//+ " CASE WHEN AMOUNT > SETTLEMENT THEN "
//+ " CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL "
//+ ",EXCHANGERATE "
//+ " FROM ch_fee WHERE (ISNULL(SETTLEMENT,0) < AMOUNT AND ISNULL(ORDERAMOUNT,0) < AMOUNT AND (FEESTATUS = 0 OR FEESTATUS = 8)) "
////+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
//+ strFeeCondition);
//2014-05-12 修改(包含负数)
string strSql = String.Format(" SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL "
+ ",EXCHANGERATE,REMARK "
+ " FROM ch_fee WHERE ((FEESTATUS = 0 OR FEESTATUS = 8) and (case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end) and (case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) "
//+ " and gid not in(select feeid from ch_fee_do where (ISDELETED<>1 or ISDELETED is null)) "//自由收费结算,不需要屏蔽其他流程的数据
+ strFeeCondition);
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
return sourceTable;
}
#endregion
#region 根据费用GID获取结算费用明细
/// <summary>
/// 根据费用GID获取结算费用明细
/// </summary>
/// <param name="tempFeeGID">费用GID</param>
/// <returns>返回DataTable费用数据集</returns>
private DataTable GetSimpleFeeByGID(string tempFeeGID)
{
DataTable sourceTable = null;
//string strSql = String.Format("SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
//+ ",CASE WHEN AMOUNT > SETTLEMENT THEN CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as CTL"
//+ ",CASE WHEN AMOUNT > SETTLEMENT THEN CASE WHEN SETTLEMENT < ORDERAMOUNT THEN AMOUNT - ORDERAMOUNT ELSE AMOUNT - SETTLEMENT END ELSE 0 END as UCTL"
//+ ",EXCHANGERATE "
//+ " FROM ch_fee WHERE GID = '{0}' ", tempFeeGID);
//2014-05-12 修改(包含负数)
string strSql = String.Format("SELECT GID,BSNO,FEETYPE,CUSTOMERNAME,FEENAME,CURRENCY,AMOUNT"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as CTL"
+ ",(CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when AMOUNT<0 then (-AMOUNT) else AMOUNT end)) THEN CASE WHEN ((case when ISNULL(SETTLEMENT,0)<0 then (-ISNULL(SETTLEMENT,0)) else ISNULL(SETTLEMENT,0) end)<(case when ISNULL(ORDERAMOUNT,0)<0 then (-ISNULL(ORDERAMOUNT,0)) else ISNULL(ORDERAMOUNT,0) end)) THEN (AMOUNT - ORDERAMOUNT) ELSE (AMOUNT - SETTLEMENT) END ELSE 0 END) as UCTL "
+ ",EXCHANGERATE,REMARK "
+ " FROM ch_fee WHERE GID = '{0}' ", tempFeeGID);
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
return sourceTable;
}
#endregion
}
public enum PostNoticeTypeApp
{
DIFFCUSTOMER = 0,
DIFFCURRENCY = 1,
BEYONDMAXLINE = 2,
SESSIONFAILURE = 3,
POSTSUCCESS = 4
}
}