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/cheque/ChCheckListGridSource.aspx.cs

1415 lines
64 KiB
C#

2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
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 System.Text.RegularExpressions;
using DSWeb.Models;
using DSWeb.EntityDA;
using DSWeb.ConfigManager;
using DSWeb.Authority;
namespace DSWeb.Cheque
{
public partial class ChCheckListGridSource : System.Web.UI.Page
{
private string strHandle;
private string strSearch;//委托信息查询条件
private string strBSNO;//海运出口委托编号
private string strFeeSearch;//费用查询条件
private string strApplicationGID;//开票申请GID
private string strChequeGID;//支票GID
private string strUserID;//登录人GID
private string strBillNO;//支票申请编号
private string strCurrency;//币别名称
private string strCustomerName;//结算单位名称
private int iCurrentPage;//当前页数
private int iShowPage;//显示最大页数
private string strOrderCacheName;//缓存名称
private string strSelectedOrder;//已经选择的委托信息
private string strCheckType;//全选类型 值"check"选中的值 值"uncheck"去除选择的值
private string strFeeID;//费用GID
private string strPostSessionID;//提交支票申请Session
private string strRename;//是否是自定义名称
private decimal dExchangeRate;//折算汇率
private decimal dCSTL;//本次结算
private decimal dUSTL;//未结金额
private string strChequeAppID;//支票申请GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string strDoTypeName;//调用页面标识
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
#region 请求处理
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
if (Request.QueryString["billno"] != null)
{
strBillNO = Request.QueryString["billno"].ToString().Trim().ToLower();
}
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["customer"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strCustomerName = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["customer"].ToString())));
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["appid"] != null)
{
strApplicationGID = Request.QueryString["appid"].ToString().Trim();
}
if (Request.QueryString["Chequeid"] != null)
{
strChequeGID = Request.QueryString["Chequeid"].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["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["rename"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strRename = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["rename"].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["Chequeappid"] != null)
{
strChequeAppID = Request.QueryString["Chequeappid"].ToString();
}
if (Request.QueryString["do"] != null)
{
strDoTypeName = Request.QueryString["do"].ToString().ToLower();
}
if (strHandle != null)
{
//获取开票申请列表信息
if (strHandle == "orderfee" && strBSNO != null)
{
Response.Write(GetSelectedOrderFee(strBSNO));
}
else if (strHandle == "chchecklist")
{
Response.Write(GetChCheckList());
}
else if (strHandle == "voidCheque" && strChequeGID != null)
{
Response.Write(VoidCheque(strChequeGID));
}
else if (strHandle == "print" && strChequeGID != null)
{
Response.Write(PrintCheque(strChequeGID));
}
else if (strHandle == "bankinfo" && strCurrency != null)
{
Response.Write(GetBankInfo(strUserID, strCurrency));
}
else if (strHandle == "cuspayable" && strCustomerName != null)
{
Response.Write(GetCustomerPayable(strCustomerName));
}
else if (strHandle == "postChequeapp" && strPostSessionID != null && strOrderCacheName != null)
{
//提交开票申请SESSION信息
Response.Write(PostChequeApplicationSession(strPostSessionID, strOrderCacheName));
}
else if (strHandle == "validateChCheck")
{
Response.Write(ValidateUserChCheckAuthority().ToString());
}
else if (strHandle == "validateChequeapp")
{
Response.Write(ValidateUserChequeApplicationAuthority().ToString());
}
}
#endregion
}
#region 验证用户是否有提交支票申请的权限
/// <summary>
/// 验证用户是否有开支票的权限
/// </summary>
/// <returns>值1表示有权限支票 值不等于1表示没有权限开支票</returns>
private int ValidateUserChequeApplicationAuthority()
{
int iResult = 0;
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modChequeAppList");
if (userAuthorityManage.OperateType != AuthorityType.NULL && userAuthorityManage.OperateType != AuthorityType.NONE)
{
iResult = 1;
}
else
{
iResult = -1;
}
return iResult;
}
#endregion
#region 验证用户是否有开支票的权限
/// <summary>
/// 验证用户是否有开支票的权限
/// </summary>
/// <returns>值1表示有权限支票 值不等于1表示没有权限开支票</returns>
private int ValidateUserChCheckAuthority()
{
int iResult = 0;
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modChequeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL && userAuthorityManage.OperateType != AuthorityType.NONE)
{
iResult = 1;
}
else
{
iResult = -1;
}
return iResult;
}
#endregion
#region 获取结算单位的支付信息
/// <summary>
/// 获取结算单位的支付信息
/// </summary>
/// <param name="tempCustomerName">结算单位简称</param>
/// <returns></returns>
private string GetCustomerPayable(string tempCustomerName)
{
CRMClientDA crmClientDA = new CRMClientDA();
string strSql = String.Format("SELECT GID,BILLRISES1,BILLRISES2 FROM info_client WHERE SHORTNAME = '{0}'", tempCustomerName);
DataTable sourceTable = crmClientDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("clients:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("\"pay1\":\"" + sourceTable.Rows[i][1].ToString() + "\",");
sourceBuilder.Append("\"pay2\":\"" + sourceTable.Rows[i][2].ToString() + "\"}");
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取当前用户的公司的支付信息
/// <summary>
/// 获取当前用户的公司的支付信息通过币别区分类型
/// </summary>
/// <param name="strUserID">用户GID</param>
/// <param name="strCurrency">币别名称</param>
/// <returns>所有支付信息</returns>
private string GetBankInfo(string strUserID, string strCurrency)
{
CRMClientDA crmClientDA = new CRMClientDA();
string strSql = String.Format(" SELECT GID,BANKNAME,ACCOUNT,CURRENCY FROM sys_bank WHERE LINKID IN "
+ " (SELECT C.GID FROM [user] as A INNER JOIN user_company as B on A.GID = B.USERID INNER JOIN [company] as C "
+ " ON B.COMPANYID = C.GID WHERE A.GID = '{0}' and A.ISDELETED=0) AND CURRENCY = '{1}'", strUserID, strCurrency);
DataTable sourceTable = crmClientDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("banks:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("\"bank\":\"" + sourceTable.Rows[i][1].ToString() + "\",");
sourceBuilder.Append("\"account\":\"" + sourceTable.Rows[i][2].ToString() + "\",");
sourceBuilder.Append("\"currency\":\"" + sourceTable.Rows[i][3].ToString() + "\"}");
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 打印支票
/// <summary>
/// 打印支票
/// </summary>
/// <param name="tempChequeGID"></param>
/// <returns></returns>
private int PrintCheque(string tempChequeGID)
{
int iResult = 0;
ChFeeChequeDA ChFeeChequeDA = new ChFeeChequeDA();
ChFeeChequeEntity ChFeeChequeEntity = new ChFeeChequeEntity();
ChFeeChequeEntity = ChFeeChequeDA.GetID(tempChequeGID);
if (ChFeeChequeEntity.GID != null)
{
if (!ChFeeChequeEntity.ISDELETE)
{
//iResult = ChFeeChequeDA.PrintChequeByGID(tempChequeGID);//????????
if (iResult < 1)
{
iResult = -1;//打印异常
}
}
else
{
iResult = -2;//支票已经废除不能打印
}
}
return iResult;
}
#endregion
#region 作废支票
/// <summary>
/// 作废支票
/// </summary>
/// <param name="tempChequeGID"></param>
/// <returns></returns>
private int VoidCheque(string tempChequeGID)
{
int iResult = 0;
ChFeeChequeDA ChFeeChequeDA = new ChFeeChequeDA();
ChFeeChequeEntity ChFeeChequeEntity = new ChFeeChequeEntity();
ChFeeChequeEntity = ChFeeChequeDA.GetID(tempChequeGID);
if (ChFeeChequeEntity.GID != null)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string strCHEQUENO = T_ALL_DA.GetStrSQL("CHEQUENO", "select CHEQUENO from ch_fee_cheque where GID='" + tempChequeGID + "'");
iResult = ChFeeChequeDA.RepealInfo(tempChequeGID, "", strUserID, strCHEQUENO);
if (iResult < 1)
{
iResult = -1;//废除异常
}
}
return iResult;
}
#endregion
private string GetChCheckList()
{
ChFeeChequeDA ChFeeChequeDA = new ChFeeChequeDA();
DataSet ds;
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.PRINTTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.PRINTTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CHEQUECUSTNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.CHEQUENO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modChequeManagement");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
//strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.CHEQUEAMOUNT, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
//支票类别","是否打印","是否废除","支票号码","客户名称","支票抬头","金额","币别","出票人","出票日期","开出人","开出时间
strSql = String.Format(" SELECT {0} A.GID,CASE WHEN A.CHEQUETYPE = 1 THEN '现金支票' ELSE '转账支票' END,CASE WHEN A.ISPRINT = 1 THEN 1 ELSE 0 END,CASE WHEN A.ISDELETE = 1 THEN 1 ELSE 0 END,A.CHEQUENO,A.CUSTOMERNAME,A.CHEQUECUSTNAME,A.CHEQUEAMOUNT,A.CHEQUECURRENCY,MODIFIEDUSER=(select SHOWNAME from [user] where GID=A.MODIFIEDUSER),A.MODIFIEDTIME,PRINTUSER=(select SHOWNAME from [user] where GID=A.PRINTUSER),A.PRINTTIME "
+ " FROM ch_fee_cheque as A WHERE 1=1 " + strAuthorityCondition + strCondition + " ORDER BY CHEQUENO DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,CASE WHEN A.CHEQUETYPE = 1 THEN '现金支票' ELSE '转账支票' END,CASE WHEN A.ISPRINT = 1 THEN 1 ELSE 0 END,CASE WHEN A.ISDELETE = 1 THEN 1 ELSE 0 END,A.CHEQUENO,A.CUSTOMERNAME,A.CHEQUECUSTNAME,A.CHEQUEAMOUNT,A.CHEQUECURRENCY,MODIFIEDUSER=(select SHOWNAME from [user] where GID=A.MODIFIEDUSER),A.MODIFIEDTIME,PRINTUSER=(select SHOWNAME from [user] where GID=A.PRINTUSER),A.PRINTTIME "
+ " FROM ch_fee_cheque as A WHERE A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_cheque WHERE =1 " + strAuthorityCondition + strCondition + " ORDER BY CHEQUENO DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY CHEQUENO DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,CASE WHEN A.CHEQUETYPE = 1 THEN '现金支票' ELSE '转账支票' END,CASE WHEN A.ISPRINT = 1 THEN 1 ELSE 0 END,CASE WHEN A.ISDELETE = 1 THEN 1 ELSE 0 END,A.CHEQUENO,A.CUSTOMERNAME,A.CHEQUECUSTNAME,A.CHEQUEAMOUNT,A.CHEQUECURRENCY,MODIFIEDUSER=(select SHOWNAME from [user] where GID=A.MODIFIEDUSER),A.MODIFIEDTIME,PRINTUSER=(select SHOWNAME from [user] where GID=A.PRINTUSER),A.PRINTTIME "
+ " FROM ch_fee_cheque as A WHERE 1=1 " + strAuthorityCondition + strCondition + " ORDER BY CHEQUENO DESC ";
}
//sourceTable = getBillStatusNameTable(ChFeeChequeDA.GetID(strSql).Tables[0]);
ds = ChFeeChequeDA.GetSeaExportListByCondition(strSql);
sourceTable = ds.Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
private string 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 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);
//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 ISCheque = 1 THEN CASE WHEN ISNULL(Cheque,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERCheque,0) >= ISNULL(Cheque,0) THEN AMOUNT - ISNULL(ORDERCheque,0) ELSE AMOUNT - ISNULL(Cheque,0) END "
+ " ELSE AMOUNT - ISNULL(Cheque,0) END ELSE AMOUNT - ISNULL(ORDERCheque,0) END, "
+ " CASE WHEN ISCheque = 1 THEN CASE WHEN ISNULL(Cheque,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERCheque,0) >= ISNULL(Cheque,0) THEN AMOUNT - ISNULL(ORDERCheque,0) ELSE AMOUNT - ISNULL(Cheque,0) END "
+ " ELSE AMOUNT - ISNULL(Cheque,0) END ELSE AMOUNT - ISNULL(ORDERCheque,0) END FROM ch_fee "
+ " WHERE ((ISCheque = 1 AND ISNULL(Cheque,0) <> AMOUNT) OR (ISCheque = 0 AND ISNULL(ORDERCheque,0) <> AMOUNT)) AND BSNO IN ('{0}') " + strCondition, 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>
/// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// </summary>
/// <param name="tempTable">原数据源DataTable</param>
/// <returns>返回新数据源DataTable</returns>
private DataTable getBillStatusNameTable(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"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else if (sourceTable.Columns[j].ColumnName.Equals("ChequeTYPE"))
{
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;
case 3:
strFeeStatus = "已开出";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("ChequeTYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "申请支票";
break;
case 2:
strFeeStatus = "自由支票";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
//cloneTable.Columns.Remove("FEESTATUS");
//cloneTable.Columns.Add(new DataColumn("FEESTATUS", System.Type.GetType("System.String")));
return cloneTable;
}
#endregion
/// <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;
}
#region 动态计算人民币、美元应收应付合计金额
/// <summary>
/// 动态计算人民币、美元应收应付合计金额
/// </summary>
/// <param name="tempFeeTable"></param>
/// <returns></returns>
private string GetSumFeeJson(DataTable tempFeeTable, int tempState)
{
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)
{
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;
}
}
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("}");
}
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 获取数据集的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 ISCheque = 1 THEN CASE WHEN ISNULL(Cheque,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERCheque,0) >= ISNULL(Cheque,0) THEN AMOUNT - ISNULL(ORDERCheque,0) ELSE AMOUNT - ISNULL(Cheque,0) END "
+ " ELSE AMOUNT - ISNULL(Cheque,0) END ELSE AMOUNT - ISNULL(ORDERCheque,0) END as CTL, "
+ " CASE WHEN ISCheque = 1 THEN CASE WHEN ISNULL(Cheque,0) <> AMOUNT THEN CASE WHEN ISNULL(ORDERCheque,0) >= ISNULL(Cheque,0) THEN AMOUNT - ISNULL(ORDERCheque,0) ELSE AMOUNT - ISNULL(Cheque,0) END "
+ " ELSE AMOUNT - ISNULL(Cheque,0) END ELSE AMOUNT - ISNULL(ORDERCheque,0) END as UCTL FROM ch_fee "
+ " WHERE ((ISCheque = 1 AND ISNULL(Cheque,0) <> AMOUNT) OR (ISCheque = 0 AND ISNULL(ORDERCheque,0) <> AMOUNT)) AND BSNO IN ({0}) " + strFeeCondition, tempValidateOrder);
return strSql;
}
#endregion
#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)
{
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("}");
jsonBuilder.Append("]");
jsonBuilder.Append("}");
return jsonBuilder.ToString();
}
#endregion
#region 提交开票申请
/// <summary>
/// 提交开票申请
/// </summary>
/// <param name="tempPostSessionName">提交Session名称</param>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>返回string 值1表示提交成功 值不等于1表示提交失败</returns>
private string PostChequeApplicationSession(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\":[");
if (strRename != null)
{
//如果定义了自定义名称,则将
decimal RecvRmbTotal = 0;
decimal PayRmbTotal = 0;
decimal RecvUsdTotal = 0;
decimal PayUsdTotal = 0;
decimal RmbTotal = 0;
decimal UsdTotal = 0;
decimal Total = 0;
for (int i = 0; i < feeTable.Rows.Count; i++)
{
string tempCurrency = feeTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper();
decimal tempFee = decimal.Parse(feeTable.Rows[i]["CTL"].ToString());
int tempFeeType = int.Parse(feeTable.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 == 3 && tempCurrency == "USD" && tempFee != 0)//tempFee > 0
{
PayUsdTotal += tempFee;
}
}
RmbTotal = RecvRmbTotal - PayRmbTotal;
UsdTotal = RecvUsdTotal - PayUsdTotal;
if (strCurrency.ToUpper().Equals("RMB"))
{
Total = RmbTotal + (UsdTotal * dExchangeRate);
}
else
{
Total = UsdTotal + (RmbTotal * dExchangeRate);
}
cacheBuilder.Append("{");
cacheBuilder.Append("\"id\":\"" + Guid.NewGuid().ToString() + "\",");
cacheBuilder.Append("\"type\":0,");
cacheBuilder.Append("\"bsno\":\"\",");
cacheBuilder.Append("\"cus\":\"" + feeTable.Rows[0]["CUSTOMERNAME"].ToString() + "\",");
cacheBuilder.Append("\"fname\":\"" + strRename + "\",");
cacheBuilder.Append("\"cur\":\"" + strCurrency + "\",");
cacheBuilder.Append("\"stl\":" + Total.ToString() + ",");
cacheBuilder.Append("\"cstl\":" + Total.ToString() + ",");
cacheBuilder.Append("\"ustl\":" + 0 + ",");
cacheBuilder.Append("\"orig\":3,");
cacheBuilder.Append("\"oname\":\"" + strRename + "\",");
cacheBuilder.Append("\"ocstl\":" + Total.ToString() + "");
cacheBuilder.Append("},");
for (int i = 0; i < feeTable.Rows.Count; i++)
{
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() + "\",");
cacheBuilder.Append("\"cur\":\"" + feeTable.Rows[i]["CURRENCY"].ToString() + "\",");
cacheBuilder.Append("\"stl\":" + feeTable.Rows[i]["AMOUNT"].ToString() + ",");
cacheBuilder.Append("\"cstl\":" + feeTable.Rows[i]["CTL"].ToString() + ",");
cacheBuilder.Append("\"ustl\":" + feeTable.Rows[i]["UCTL"].ToString() + ",");
cacheBuilder.Append("\"orig\":1,");
cacheBuilder.Append("\"oname\":\"" + feeTable.Rows[i]["FEENAME"].ToString() + "\",");
cacheBuilder.Append("\"ocstl\":" + feeTable.Rows[i]["CTL"].ToString() + "");
cacheBuilder.Append("},");
}
}
else
{
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() + "\",");
cacheBuilder.Append("\"cur\":\"" + strCurrency.ToUpper() + "\",");
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 = strResult = GetPostResult(PostNoticeType.POSTSUCCESS);
}
else
{
appBuilder.Append(cacheBuilder.ToString());
appBuilder.Append("]}");
Session[tempPostSessionName] = appBuilder.ToString();
strResult = strResult = GetPostResult(PostNoticeType.POSTSUCCESS);
}
}
return strResult;
}
#endregion
#region 获取返回状态
/// <summary>
/// 获取返回状态
/// </summary>
/// <param name="tempPostNoticeType">错误类型</param>
/// <returns>返回String类型状态</returns>
private string GetPostResult(PostNoticeType tempPostNoticeType)
{
string strResult = "";
switch (tempPostNoticeType)
{
case PostNoticeType.DIFFCUSTOMER://同时有多个结算单位
strResult = "-1";
break;
case PostNoticeType.DIFFCURRENCY://有不同币别,需要调用汇率
strResult = "-2";
break;
case PostNoticeType.BEYONDMAXLINE://支票明细超过最大显示条数
strResult = "-3";
break;
case PostNoticeType.SESSIONFAILURE://缓存数据异常
strResult = "-4";
break;
case PostNoticeType.POSTSUCCESS://提交申请成功
strResult = "1";
break;
default:
break;
}
return strResult;
}
#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, string tempCurrency)
{
int iResult = 0;
if (tempDataTable.Rows.Count > 0)
{
string strCurrentCurrency = tempDataTable.Rows[0]["CURRENCY"].ToString().Trim();
int iEqualCount = 0;
if (strCurrency != tempCurrency)
{
iEqualCount++;
}
else
{
for (int i = 1; i < tempDataTable.Rows.Count; i++)
{
if (!tempDataTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper().Equals(strCurrentCurrency))
{
iEqualCount++;
break;
}
if (!tempDataTable.Rows[i]["CURRENCY"].ToString().Trim().ToUpper().Equals(tempCurrency))
{
iEqualCount++;
break;
}
}
}
if (iEqualCount > 0)
{
iResult = 1;//存在不同的币别
}
else
{
iResult = 0;//验证通过,不存在不同的币别
}
}
else
{
iResult = -1;//未取到缓存信息
}
return iResult;
}
#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
}
public enum PostNoticeType
{
DIFFCUSTOMER = 0,
DIFFCURRENCY = 1,
BEYONDMAXLINE = 2,
SESSIONFAILURE = 3,
POSTSUCCESS = 4
}
}