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.

1513 lines
75 KiB
C#

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.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
using JsonHelper;
using DSWeb.Models;
using DSWeb.EntityDA;
using DSWeb.Log;
using DSWeb.Authority;
namespace DSWeb.Shipping
{
public partial class FeeEdit : PageBase
{
private string recvJSON;
private string payJSON;
//private const string strSeaBSNO = "topseaeusername129481962859531250";
private string strSeaBSNO;
private string strUserID;
private int iImportTemplateDetailType;
private string strCacheName;
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private bool bEnable;//是否可操作
private string strImportHistoryCacheName;
private string strHistoryOpType;//值1表示全部引入 值2表示只引入标准、单价、数量、币别、汇率、FRT、是否垫付
private int iHistoryType;//1-应收 2-应付
protected void Page_Load(object sender, EventArgs e)
{
this.h_oplb.Value="op_Seae";
this.h_wmsoutbsno.Value = "";
this.h_IsFeeGain.Value = "1";
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["id"] != null)
{
strSeaBSNO = Request.QueryString["id"].ToString().Trim();
this.h_bsno.Value = strSeaBSNO;
}
if (Request.QueryString["type"] != null)
{
iImportTemplateDetailType = int.Parse(Request.QueryString["type"].ToString());
}
else
{
iImportTemplateDetailType = 0;
}
if (Request.QueryString["cachename"] != null)
{
strCacheName = Request.QueryString["cachename"].ToString();
}
if (Request.QueryString["historycache"] != null)
{
strImportHistoryCacheName = Request.QueryString["historycache"].ToString();
}
if (Request.QueryString["historycache"] != null)
{
strImportHistoryCacheName = Request.QueryString["historycache"].ToString();
}
if (Request.QueryString["historytype"] != null)
{
iHistoryType = int.Parse(Request.QueryString["historytype"].ToString());
}
else
{
iHistoryType = 0;
}
if (Request.QueryString["hdenabled"] != null)
{
bEnable = Request.QueryString["hdenabled"].ToString().Trim().ToLower().Equals("false") ? false : true;
h_enable.Value = bEnable ? "1" : "0";
}
else
{
bEnable = true;
h_enable.Value = bEnable ? "1" : "0";
}
if (Request.QueryString["op"] != null)
{
strHistoryOpType = Request.QueryString["op"].ToString().Trim();
h_historyoptype.Value = strHistoryOpType;
}
//int iAuthorityStatus = 0;
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modOrderManagement");
//int iRecvAuthorityStatus = 0;
//int iPayAuthorityStatus = 0;
//UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modRecvFeeManagement");
//if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
//{
// iRecvAuthorityStatus = userRecvAuthorityManage.CheckOperateRange(ModuleType.RECVFEE, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
// h_recvauthority.Value = iRecvAuthorityStatus.ToString();
//}
//else
//{
// h_recvauthority.Value = "1";
//}
//UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modPayFeeManagement");
//if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
//{
// iPayAuthorityStatus = userPayAuthorityManage.CheckOperateRange(ModuleType.PAYFEE, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
// h_payauthority.Value = iPayAuthorityStatus.ToString();
//}
//else
//{
// h_payauthority.Value = "1";
//}
recvJSON = "";
payJSON = "";
recvJSON = this.recvContainer.Value.Trim();
payJSON = this.payContainer.Value.Trim();
//获取引入费用模板缓存信息
if (recvJSON.Trim().Equals("") && payJSON.Trim().Equals("") && strCacheName != null && iImportTemplateDetailType > 0)
{
DataTable templateTable = (DataTable)Session[strCacheName];
StringBuilder templateBuilder = new StringBuilder();
if (templateTable != null)
{
if (templateTable.Rows.Count > 0)
{
templateBuilder.Append("{\"templates\":[");
for (int i = 0; i < templateTable.Rows.Count; i++)
{
templateTable.Rows[i]["GID"] = Guid.NewGuid().ToString();
if (i == templateTable.Rows.Count - 1)
{
templateBuilder.Append("{");
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
templateBuilder.Append("\"client\":" + templateTable.Rows[i]["CLIENT"].ToString() + ",");
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
templateBuilder.Append("}");
}
else
{
templateBuilder.Append("{");
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
templateBuilder.Append("\"client\":" + templateTable.Rows[i]["CLIENT"].ToString() + ",");
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
templateBuilder.Append("},");
}
}
templateBuilder.Append("]}");
this.h_importtype.Value = iImportTemplateDetailType.ToString();
this.h_cachename.Value = strCacheName;
this.h_cachetemplate.Value = templateBuilder.ToString();
}
else
{
this.h_importtype.Value = iImportTemplateDetailType.ToString();
this.h_cachename.Value = "";
this.h_cachetemplate.Value = "";
}
}
}
//获取引入历史费用缓存信息
if (recvJSON.Trim().Equals("") && payJSON.Trim().Equals("") && strImportHistoryCacheName != null && iHistoryType > 0)
{
DataTable templateTable = (DataTable)Session[strImportHistoryCacheName];
StringBuilder templateBuilder = new StringBuilder();
if (templateTable != null)
{
if (templateTable.Rows.Count > 0)
{
templateBuilder.Append("{\"history\":[");
for (int i = 0; i < templateTable.Rows.Count; i++)
{
templateTable.Rows[i]["GID"] = Guid.NewGuid().ToString();
if (i == templateTable.Rows.Count - 1)
{
templateBuilder.Append("{");
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
templateBuilder.Append("\"quantity\":" + templateTable.Rows[i]["QUANTITY"].ToString() + ",");
templateBuilder.Append("\"comm\":" + templateTable.Rows[i]["COMMISSIONRATE"].ToString() + ",");
templateBuilder.Append("\"amount\":" + templateTable.Rows[i]["AMOUNT"].ToString() + ",");
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
templateBuilder.Append("\"frt\":\"" + templateTable.Rows[i]["FEEFRT"].ToString() + "\",");
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
templateBuilder.Append("\"isadv\":" + (templateTable.Rows[i]["ISADVANCEDPAY"].ToString().ToLower().Equals("true") ? 1 : 0) + ",");
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
templateBuilder.Append("}");
}
else
{
templateBuilder.Append("{");
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
templateBuilder.Append("\"quantity\":" + templateTable.Rows[i]["QUANTITY"].ToString() + ",");
templateBuilder.Append("\"comm\":" + templateTable.Rows[i]["COMMISSIONRATE"].ToString() + ",");
templateBuilder.Append("\"amount\":" + templateTable.Rows[i]["AMOUNT"].ToString() + ",");
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
templateBuilder.Append("\"frt\":\"" + templateTable.Rows[i]["FEEFRT"].ToString() + "\",");
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
templateBuilder.Append("\"isadv\":" + (templateTable.Rows[i]["ISADVANCEDPAY"].ToString().ToLower().Equals("true") ? 1 : 0) + ",");
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
templateBuilder.Append("},");
}
}
templateBuilder.Append("]}");
this.h_historytype.Value = iHistoryType.ToString();
this.h_historycachename.Value = strImportHistoryCacheName;
this.h_cachehistory.Value = templateBuilder.ToString();
}
else
{
this.h_historytype.Value = iHistoryType.ToString();
this.h_historycachename.Value = "";
this.h_cachehistory.Value = "";
}
}
}
if (this.h_post.Value.Trim() != "")
{
//保存操作
if (this.h_post.Value.Trim() == "1")
{
if (!recvJSON.Trim().Equals("") || !payJSON.Trim().Equals(""))
{
SaveFeeAction();
}
}
}
GetSeaInfo();
}
private void SaveFeeAction()
{
IList<FeeEntity> feeEntities = new List<FeeEntity>();
if (!recvJSON.Trim().Equals(""))
{
feeEntities = ResolveFeeJSON(recvJSON.Trim(), feeEntities);
recvContainer.Value = "";
}
if (!payJSON.Trim().Equals(""))
{
feeEntities = ResolveFeeJSON(payJSON.Trim(), feeEntities);
payContainer.Value = "";
}
FeeDA feeDA = new FeeDA();
//如果是当前操作人权限范围只能查看应收或者应付时,单独更新费用利润
//if (!this.h_recvauthority.Value.Trim().Equals("1") || !this.h_recvauthority.Value.Trim().Equals("1"))
if (!ValidateUserFeeAuthority(1) || !ValidateUserFeeAuthority(2))
{
int iRecvState = feeDA.DoFee(feeEntities,strSeaBSNO,strUserID);
if (iRecvState == 1)
{
gainContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
}
else
{
FeeProfitEntity feeProfitEntity = new FeeProfitEntity();
feeProfitEntity = GetRequestProfit();
int iRecvState = feeDA.DoFee(feeEntities, feeProfitEntity, strSeaBSNO);
if (iRecvState == 1)
{
gainContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
}
h_post.Value = "";//请求状态清空
}
#region 页面加载主委托信息
/// <summary>
/// 页面加载主委托信息
/// </summary>
private void GetSeaInfo()
{
SeaExportInfoDA seaExportDA = new SeaExportInfoDA();
TopSeaeEntity topSeaEntity = seaExportDA.GetID(strSeaBSNO);
if (topSeaEntity.BSNO != null)
{
//委托业务编号
dvOrderNumVal.Value = topSeaEntity.BSNO;
//委托编号
dvCUSTNO.InnerHtml = topSeaEntity.CUSTNO;
//主提单号
dvOrderPrimaryVal.InnerHtml = topSeaEntity.MBLNO;
h_mblno.Value = dvOrderPrimaryVal.InnerHtml;
//箱型箱量
//dvContainerVal.InnerHtml = topSeaEntity.CNTRTOTAL;
dvContainerVal.InnerHtml = TotalCtns(topSeaEntity.CNTRTOTAL);
//付费方式
dvPaymentVal.InnerHtml = topSeaEntity.BLFRT;
//揽货人
dvChannelSaleVal.InnerHtml = topSeaEntity.SALE;
//委托单位
dvOrderCellVal.InnerHtml = topSeaEntity.CUSTOMERNAME;
//卸货港
dvDischargePortVal.InnerHtml = topSeaEntity.PORTDISCHARGE;
//MBL付费方式
dvPaymentMBLVAL.InnerHtml = topSeaEntity.MBLFRT;
//业务来源
dvBssourceVal.InnerHtml = topSeaEntity.BSSOURCE;
//航线
dvLaneVal.InnerHtml = topSeaEntity.LANE;
//船名
dvVesselVal.InnerHtml = topSeaEntity.VESSEL;
//航次
dvVoynoVal.InnerHtml = topSeaEntity.VOYNO;
//是否熏蒸
ck_isfumigation.Checked = topSeaEntity.ISFUMIGATION;
//是否仓储
ck_isstorage.Checked = topSeaEntity.ISSTORAGE;
//是否陆运
ck_island.Checked = topSeaEntity.ISLAND;
//是否报关
ck_iscustoms.Checked = topSeaEntity.ISCUSTOMS;
//是否报检
ck_isinspection.Checked = topSeaEntity.ISINSPECTION;
//是否订舱
ck_isbooking.Checked = topSeaEntity.ISBOOKING;
//使用代理
ck_isagent.Checked = topSeaEntity.ISAGENT;
//分单签单
ck_ishblno.Checked = topSeaEntity.ISHBLNO;
}
}
#endregion
#region 保存应收费用列表更改结果
/// <summary>
/// 保存应收费用列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvFee(JsonFeeGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonFeeEntity> feeEntities = new List<JsonFeeEntity>();
feeEntities = tempGroupEntity.JsonFeeEntities;
FeeDA feeDA = new FeeDA();
DataTable feeTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonFeeEntities.Count > 0)
{
string bsno = tempGroupEntity.JsonFeeEntities[0].fee15.Trim();
strInitSql = " SELECT GID, FEETYPE, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, COMMISSIONRATE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 AND BSNO = '" + bsno + "'";
}
else
{
return;
}
feeTable = feeDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < feeTable.Rows.Count; i++)
{
foreach (JsonFeeEntity fee in feeEntities)
{
if (feeTable.Rows[i]["GID"].ToString().Trim().Equals(fee.fee1.Trim()))
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//费用名称
string strFeeName = fee.fee3.Trim().ToLower().Equals("null") ? "" : fee.fee3.Trim();
if (!feeTable.Rows[i]["FEENAME"].ToString().Trim().Equals(strFeeName))
{
strSql += String.Format(" FEENAME = '{0}'", strFeeName);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收费用名称", feeTable.Rows[i]["FEENAME"].ToString().Trim(), strFeeName);
}
//结算单位
string strCustomer = fee.fee4.Trim().ToLower().Equals("null") ? "" : fee.fee4.Trim();
if (!feeTable.Rows[i]["CUSTOMERNAME"].ToString().Trim().Equals(strCustomer))
{
strSql += String.Format(" ,CUSTOMERNAME = '{0}'", strCustomer);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "结算单位", feeTable.Rows[i]["CUSTOMERNAME"].ToString().Trim(), strCustomer);
}
//计费标准
string strUnit = fee.fee5.Trim().ToLower().Equals("null") ? "" : fee.fee5.Trim();
if (!feeTable.Rows[i]["UNIT"].ToString().Trim().Equals(strUnit))
{
strSql += String.Format(" ,UNIT = '{0}'", strUnit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费标准", feeTable.Rows[i]["UNIT"].ToString().Trim(), strUnit);
}
//计费单价
decimal unitPrice = decimal.Parse(feeTable.Rows[i]["UNITPRICE"].ToString().Trim());
if (unitPrice != fee.fee6)
{
strSql += String.Format(" ,UNITPRICE = {0}", fee.fee6.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费单价", unitPrice.ToString(), fee.fee6.ToString());
}
//数量
decimal Quantity = decimal.Parse(feeTable.Rows[i]["QUANTITY"].ToString().Trim());
if (Quantity != fee.fee7)
{
strSql += String.Format(" ,QUANTITY = {0}", fee.fee7.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "数量", Quantity.ToString(), fee.fee7.ToString());
}
//佣金比率
decimal CommissionRate = decimal.Parse(feeTable.Rows[i]["COMMISSIONRATE"].ToString().Trim());
if (CommissionRate != fee.fee8)
{
strSql += String.Format(" ,COMMISSIONRATE = {0}", fee.fee8.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "佣金比率", CommissionRate.ToString(), fee.fee8.ToString());
}
//金额
decimal Amount = decimal.Parse(feeTable.Rows[i]["AMOUNT"].ToString().Trim());
if (Amount != fee.fee9)
{
strSql += String.Format(" ,AMOUNT = {0}", fee.fee9.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "金额", Amount.ToString(), fee.fee9.ToString());
}
//币别
if (!feeTable.Rows[i]["CURRENCY"].ToString().Trim().Equals(fee.fee10.Trim()))
{
strSql += String.Format(" ,CURRENCY = '{0}'", fee.fee10.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "金额", feeTable.Rows[i]["CURRENCY"].ToString().Trim(), fee.fee10.Trim());
}
//汇率
decimal ExchangeRate = decimal.Parse(feeTable.Rows[i]["EXCHANGERATE"].ToString().Trim());
if (ExchangeRate != fee.fee11)
{
strSql += String.Format(" ,EXCHANGERATE = {0}", fee.fee11.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "汇率", ExchangeRate.ToString(), fee.fee11.ToString());
}
//FRT运费支付方式
if (!feeTable.Rows[i]["FEEFRT"].ToString().Trim().Equals(fee.fee12.Trim()))
{
strSql += String.Format(" ,FEEFRT = '{0}'", fee.fee12.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "FRT", feeTable.Rows[i]["FEEFRT"].ToString().Trim(), fee.fee12.Trim());
}
//备注
string strRemark = fee.fee13.Trim() == "null" ? "" : fee.fee13.Trim();
if (!feeTable.Rows[i]["REMARK"].ToString().Trim().Equals(strRemark))
{
strSql += String.Format(" ,REMARK = '{0}'", fee.fee13.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", feeTable.Rows[i]["REMARK"].ToString().Trim(), fee.fee13.Trim());
}
//是否垫付
bool IsAdvancePay = feeTable.Rows[i]["ISADVANCEDPAY"].ToString().Trim().ToLower().Equals("true") ? true : false;
if (IsAdvancePay != fee.fee14)
{
strSql += String.Format(" ,ISADVANCEDPAY = {0}", fee.fee14 ? 1 : 0);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否垫付", IsAdvancePay ? "是" : "否", fee.fee14 ? "是" : "否");
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
string strUpdateSql = String.Format("UPDATE {0} SET {1} WHERE GID = '{2}'", "ch_fee", strSql, fee.fee1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新费用标识 {0} {1}", fee.fee1.Trim(), LogContent));
}
feeEntities.Remove(fee);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = feeDA.UpdateFeeFromGrid(sqlList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
#region 日志记录操作
// INSERT-"INSERT INTO {0} ({1}) VALUES ({2})" @{0}-所要插入记录的表;{1}记录字段值;{2}-记录新值@
if (logList.Count > 0)
{
for (int i = 0; i < logList.Count; i++)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "更新应收费用列表";
logEntity.LogType = "UPDATE 更新操作";
logEntity.CreateUserID = strUserID;//测试使用数据,正式发布请删除
logEntity.LogContent = logList[i].ToString();
log.WriteLog(logEntity);
}
}
#endregion
}
}
//如果遍历完所有费用表数据,没有相对应的费用信息,则将剩余的费用信息插入到费用表中
if (feeEntities.Count > 0)
{
//插入新的应收费用信息
InsertFee(feeEntities, 1);
}
recvJSON = "";
this.recvContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
return;
}
}
#endregion
#region 保存应付费用列表更改结果
/// <summary>
/// 保存应付费用列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SavePayFee(JsonFeeGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonFeeEntity> feeEntities = new List<JsonFeeEntity>();
feeEntities = tempGroupEntity.JsonFeeEntities;
FeeDA feeDA = new FeeDA();
DataTable feeTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonFeeEntities.Count > 0)
{
string bsno = tempGroupEntity.JsonFeeEntities[0].fee15.Trim();
strInitSql = " SELECT GID, FEETYPE, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, COMMISSIONRATE, QUANTITY, AMOUNT, CURRENCY, "
+ " EXCHANGERATE, FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 AND BSNO = '" + bsno + "'";
}
else
{
return;
}
feeTable = feeDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < feeTable.Rows.Count; i++)
{
foreach (JsonFeeEntity fee in feeEntities)
{
if (feeTable.Rows[i]["GID"].ToString().Trim().Equals(fee.fee1.Trim()))
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//费用名称
string strFeeName = fee.fee3.Trim().ToLower().Equals("null") ? "" : fee.fee3.Trim();
if (!feeTable.Rows[i]["FEENAME"].ToString().Trim().Equals(strFeeName))
{
strSql += String.Format(" FEENAME = '{0}'", strFeeName);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收费用名称", feeTable.Rows[i]["FEENAME"].ToString().Trim(), strFeeName);
}
//结算单位
string strCustomer = fee.fee4.Trim().ToLower().Equals("null") ? "" : fee.fee4.Trim();
if (!feeTable.Rows[i]["CUSTOMERNAME"].ToString().Trim().Equals(strCustomer))
{
strSql += String.Format(" ,CUSTOMERNAME = '{0}'", strCustomer);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "结算单位", feeTable.Rows[i]["CUSTOMERNAME"].ToString().Trim(), strCustomer);
}
//计费标准
string strUnit = fee.fee5.Trim().ToLower().Equals("null") ? "" : fee.fee5.Trim();
if (!feeTable.Rows[i]["UNIT"].ToString().Trim().Equals(strUnit))
{
strSql += String.Format(" ,UNIT = '{0}'", strUnit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费标准", feeTable.Rows[i]["UNIT"].ToString().Trim(), strUnit);
}
//计费单价
decimal unitPrice = decimal.Parse(feeTable.Rows[i]["UNITPRICE"].ToString().Trim());
if (unitPrice != fee.fee6)
{
strSql += String.Format(" ,UNITPRICE = {0}", fee.fee6.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费单价", unitPrice.ToString(), fee.fee6.ToString());
}
//数量
decimal Quantity = decimal.Parse(feeTable.Rows[i]["QUANTITY"].ToString().Trim());
if (Quantity != fee.fee7)
{
strSql += String.Format(" ,QUANTITY = {0}", fee.fee7.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "数量", Quantity.ToString(), fee.fee7.ToString());
}
//佣金比率
decimal CommissionRate = decimal.Parse(feeTable.Rows[i]["COMMISSIONRATE"].ToString().Trim());
if (CommissionRate != fee.fee8)
{
strSql += String.Format(" ,COMMISSIONRATE = {0}", fee.fee8.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "佣金比率", CommissionRate.ToString(), fee.fee8.ToString());
}
//金额
decimal Amount = decimal.Parse(feeTable.Rows[i]["AMOUNT"].ToString().Trim());
if (Amount != fee.fee9)
{
strSql += String.Format(" ,AMOUNT = {0}", fee.fee9.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "金额", Amount.ToString(), fee.fee9.ToString());
}
//币别
if (!feeTable.Rows[i]["CURRENCY"].ToString().Trim().Equals(fee.fee10.Trim()))
{
strSql += String.Format(" ,CURRENCY = '{0}'", fee.fee10.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "金额", feeTable.Rows[i]["CURRENCY"].ToString().Trim(), fee.fee10.Trim());
}
//汇率
decimal ExchangeRate = decimal.Parse(feeTable.Rows[i]["EXCHANGERATE"].ToString().Trim());
if (ExchangeRate != fee.fee11)
{
strSql += String.Format(" ,EXCHANGERATE = {0}", fee.fee11.ToString());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "汇率", ExchangeRate.ToString(), fee.fee11.ToString());
}
//FRT运费支付方式
if (!feeTable.Rows[i]["FEEFRT"].ToString().Trim().Equals(fee.fee12.Trim()))
{
strSql += String.Format(" ,FEEFRT = '{0}'", fee.fee12.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "FRT", feeTable.Rows[i]["FEEFRT"].ToString().Trim(), fee.fee12.Trim());
}
//备注
string strRemark = fee.fee13.Trim() == "null" ? "" : fee.fee13.Trim();
if (!feeTable.Rows[i]["REMARK"].ToString().Trim().Equals(strRemark))
{
strSql += String.Format(" ,REMARK = '{0}'", fee.fee13.Trim());
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", feeTable.Rows[i]["REMARK"].ToString().Trim(), fee.fee13.Trim());
}
//是否垫付
bool IsAdvancePay = feeTable.Rows[i]["ISADVANCEDPAY"].ToString().Trim().ToLower().Equals("true") ? true : false;
if (IsAdvancePay != fee.fee14)
{
strSql += String.Format(" ,ISADVANCEDPAY = {0}", fee.fee14 ? 1 : 0);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否垫付", IsAdvancePay ? "是" : "否", fee.fee14 ? "是" : "否");
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
string strUpdateSql = String.Format("UPDATE {0} SET {1} WHERE GID = '{2}'", "ch_fee", strSql, fee.fee1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新费用标识 {0} {1}", fee.fee1.Trim(), LogContent));
}
feeEntities.Remove(fee);
break;
}
}
}
//遍历完所有数据有,进行统一更新
if (sqlList.Count > 0)
{
int iResult = feeDA.UpdateFeeFromGrid(sqlList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
#region 日志记录操作
// INSERT-"INSERT INTO {0} ({1}) VALUES ({2})" @{0}-所要插入记录的表;{1}记录字段值;{2}-记录新值@
if (logList.Count > 0)
{
for (int i = 0; i < logList.Count; i++)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "更新应付费用列表";
logEntity.LogType = "UPDATE 更新操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = logList[i].ToString();
log.WriteLog(logEntity);
}
}
#endregion
}
}
if (feeEntities.Count > 0)
{
//插入新的应收费用信息
InsertFee(feeEntities, 2);
}
payJSON = "";
this.payContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
else
{
payJSON = "";
this.payContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
return;
}
}
#endregion
#region 插入费用信息记录
/// <summary>
/// 插入费用信息记录
/// </summary>
/// <param name="feeEntities">需要插入费用表的费用实体类</param>
/// <param name="iType">如果iType值为1则记录费用类型为收/否则记录为付</param>
public void InsertFee(List<JsonFeeEntity> feeEntities, int iType)
{
ArrayList sqlInsertList = new ArrayList();
FeeDA feeDA = new FeeDA();
foreach (JsonFeeEntity fee in feeEntities)
{
string strItemSql = "";
string strValueSql = "";
string strInsertSql = "";
//GID
strItemSql += "GID";
strValueSql += String.Format("'{0}'", fee.fee1.Trim().Equals("null") ? "" : fee.fee1.Trim());
//费用状态
string strFeeStatus = fee.fee2.Trim();
int iFeeStatus = 1;
switch (strFeeStatus)
{
case "审核通过":
iFeeStatus = 0;
break;
case "录入状态":
iFeeStatus = 1;
break;
case "提交审核":
iFeeStatus = 2;
break;
case "申请修改":
iFeeStatus = 3;
break;
case "申请删除":
iFeeStatus = 4;
break;
case "取消申请":
iFeeStatus = 5;
break;
case "驳回提交":
iFeeStatus = 6;
break;
case "驳回申请":
iFeeStatus = 7;
break;
case "部分结算":
iFeeStatus = 8;
break;
case "结算完毕":
iFeeStatus = 9;
break;
default:
break;
}
strItemSql += ",FEESTATUS";
strValueSql += String.Format(",'{0}'", fee.fee2.Trim().Equals("null") ? "" : iFeeStatus.ToString());
//费用名称
strItemSql += ",FEENAME";
strValueSql += String.Format(",'{0}'", fee.fee3.Trim().Equals("null") ? "" : fee.fee3.Trim());
//结算单位
strItemSql += ",CUSTOMERNAME";
strValueSql += String.Format(",'{0}'", fee.fee4.Trim().Equals("null") ? "" : fee.fee4.Trim());
//计费标准
strItemSql += ",UNIT";
strValueSql += String.Format(",'{0}'", fee.fee5.Trim().Equals("null") ? "" : fee.fee5.Trim());
//计费单价
strItemSql += ",UNITPRICE";
strValueSql += String.Format(",{0}", fee.fee6);
//数量
strItemSql += ",QUANTITY";
strValueSql += String.Format(",{0}", fee.fee7);
//佣金比率
strItemSql += ",COMMISSIONRATE";
strValueSql += String.Format(",{0}", fee.fee8);
//金额
strItemSql += ",AMOUNT";
strValueSql += String.Format(",{0}", fee.fee9);
//币别
strItemSql += ",CURRENCY";
strValueSql += String.Format(",'{0}'", fee.fee10.Trim().Equals("null") ? "" : fee.fee10.Trim());
//汇率
strItemSql += ",EXCHANGERATE";
strValueSql += String.Format(",{0}", fee.fee11);
//FRT运费支付方式
strItemSql += ",FEEFRT";
strValueSql += String.Format(",'{0}'", fee.fee12);
//备注
strItemSql += ",REMARK";
strValueSql += String.Format(",'{0}'", fee.fee13.Trim().Equals("null") ? "" : fee.fee13.Trim());
//是否垫付
strItemSql += ",ISADVANCEDPAY";
strValueSql += String.Format(",{0}", fee.fee14 ? 1 : 0);
//如果iType值为1则记录费用类型为收/否则记录为付
if (iType == 1)
{
strItemSql += ",FEETYPE";
strValueSql += String.Format(",'{0}'", "1");
}
else
{
strItemSql += ",FEETYPE";
strValueSql += String.Format(",'{0}'", "2");
}
//委托编号
strItemSql += ",BSNO";
strValueSql += String.Format(",'{0}'", fee.fee15);
if (!strItemSql.Trim().Equals("") && !strValueSql.Trim().Equals(""))
{
if (strItemSql.Trim().StartsWith(","))
{
strItemSql = strItemSql.Trim().Substring(1);
}
if (strValueSql.Trim().StartsWith(","))
{
strValueSql = strValueSql.Trim().Substring(1);
}
strInsertSql = String.Format("INSERT INTO {0} ({1}) VALUES({2})", "ch_fee", strItemSql, strValueSql);
sqlInsertList.Add(strInsertSql);
}
}
if (sqlInsertList.Count > 0)
{
int iResult = feeDA.InsertFeeFromGrid(sqlInsertList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
//if (iResult == 1)
//{
//}
}
}
#endregion
#region 获取费用客户保存的费用信息
/// <summary>
/// 获取费用客户保存的费用信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonFeeGroupEntity GetPostEntity(string tempValue)
{
JsonFeeGroupEntity feeGroupEntity = (JsonFeeGroupEntity)JSON.Instance.ToObject(tempValue);
return feeGroupEntity;
}
#endregion
private void RecordFeeGain(string tempBSNO)
{
//费用利润实体类
FeeProfitEntity feeProfitEntity = new FeeProfitEntity();
FeeProfitDA feeProfitDA = new FeeProfitDA();
feeProfitEntity = feeProfitDA.GetFeeProfitByBSNO(tempBSNO);
//先判断费用利润表是否有与委托编号相关联的信息
if (feeProfitEntity != null)
{
FeeProfitEntity newProfitEntity = GetRequestProfit();
string strSql = "";
string LogContent = "";
//日志记录
Logger log = Logger.Instance;
if (feeProfitEntity.RMBDR != newProfitEntity.RMBDR)
{
strSql += String.Format(" RMBDR = {0}", newProfitEntity.RMBDR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收RMB", feeProfitEntity.RMBDR.ToString(), newProfitEntity.RMBDR.ToString());
}
if (feeProfitEntity.USDDR != newProfitEntity.USDDR)
{
strSql += String.Format(" ,USDDR = {0}", newProfitEntity.USDDR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收USD", feeProfitEntity.USDDR.ToString(), newProfitEntity.USDDR.ToString());
}
if (feeProfitEntity.OTHERDR != newProfitEntity.OTHERDR)
{
strSql += String.Format(" ,OTDR = {0}", newProfitEntity.OTHERDR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收其他币别", feeProfitEntity.OTHERDR.ToString(), newProfitEntity.OTHERDR.ToString());
}
if (feeProfitEntity.RMBCR != newProfitEntity.RMBCR)
{
strSql += String.Format(" ,RMBCR = {0}", newProfitEntity.RMBCR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应付RMB", feeProfitEntity.RMBCR.ToString(), newProfitEntity.RMBCR.ToString());
}
if (feeProfitEntity.USDCR != newProfitEntity.USDCR)
{
strSql += String.Format(" ,USDCR = {0}", newProfitEntity.USDCR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应付USD", feeProfitEntity.USDCR.ToString(), newProfitEntity.USDCR.ToString());
}
if (feeProfitEntity.OTHERCR != newProfitEntity.OTHERCR)
{
strSql += String.Format(" ,OTCR = {0}", newProfitEntity.OTHERCR);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应付其他币别", feeProfitEntity.OTHERCR.ToString(), newProfitEntity.OTHERCR.ToString());
}
if (feeProfitEntity.DRTTL != newProfitEntity.DRTTL)
{
strSql += String.Format(" ,DRTTL = {0}", newProfitEntity.DRTTL);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收合计", feeProfitEntity.DRTTL.ToString(), newProfitEntity.DRTTL.ToString());
}
if (feeProfitEntity.CRTTL != newProfitEntity.CRTTL)
{
strSql += String.Format(" ,CRTTL = {0}", newProfitEntity.CRTTL);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收合计", feeProfitEntity.CRTTL.ToString(), newProfitEntity.CRTTL.ToString());
}
if (feeProfitEntity.RMBProfit != newProfitEntity.RMBProfit)
{
strSql += String.Format(" ,RMBPROFIT = {0}", newProfitEntity.RMBProfit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "RMB利润", feeProfitEntity.RMBProfit.ToString(), newProfitEntity.RMBProfit.ToString());
}
if (feeProfitEntity.USDProfit != newProfitEntity.USDProfit)
{
strSql += String.Format(" ,USDPROFIT = {0}", newProfitEntity.USDProfit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "USD利润", feeProfitEntity.USDProfit.ToString(), newProfitEntity.USDProfit.ToString());
}
if (feeProfitEntity.OTHERProfit != newProfitEntity.OTHERProfit)
{
strSql += String.Format(" ,OTPROFIT = {0}", newProfitEntity.OTHERProfit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "其他币别利润", feeProfitEntity.OTHERProfit.ToString(), newProfitEntity.OTHERProfit.ToString());
}
if (feeProfitEntity.TTLProfit != newProfitEntity.TTLProfit)
{
strSql += String.Format(" ,TTLPROFIT = {0}", newProfitEntity.TTLProfit);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "合计利润", feeProfitEntity.TTLProfit.ToString(), newProfitEntity.TTLProfit.ToString());
}
if (feeProfitEntity.ProfitRate != newProfitEntity.ProfitRate)
{
strSql += String.Format(" ,PROFITRATE = '{0}'", newProfitEntity.ProfitRate);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "利润率", feeProfitEntity.ProfitRate, newProfitEntity.ProfitRate);
}
if (strSql.Trim().Length > 1)
{
strSql += String.Format(" ,MODIFIEDUSER = '{0}',MODIFIEDTIME = GETDATE() ", strUserID);//测试使用数据,正式发布请删除
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
strSql = String.Format(" UPDATE fee_gain SET {0} WHERE BSNO = '{1}'", strSql, strSeaBSNO);
int iResult = feeProfitDA.UpdateFeeProfit(strSql);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "更新利润信息";
logEntity.LogType = "UPDATE 更新操作";
logEntity.CreateUserID = strUserID;//测试使用数据,正式发布请删除
logEntity.LogContent = String.Format(" 更新委托 {0} {1}", tempBSNO, LogContent);
log.WriteLog(logEntity);
}
}
}
else
{
FeeProfitEntity newProfitEntity = GetRequestProfit();
newProfitEntity.GID = Guid.NewGuid().ToString();
newProfitEntity.BSNO = strSeaBSNO;
newProfitEntity.CreateUser = strUserID;//测试使用数据,正式发布请删除
int iResult = feeProfitDA.InsertFeeProfit(newProfitEntity);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
//if (iResult == 1)
//{
//}
}
}
#region 将页面post获取的利润值读入到利润实体类中
/// <summary>
/// 将页面post获取的利润值读入到利润实体类中
/// </summary>
/// <returns>返回利润实体类 FeeProfitEntity</returns>
private FeeProfitEntity GetRequestProfit()
{
FeeProfitEntity tempFeeProfitEntity = new FeeProfitEntity();
#region 保留
//tempFeeProfitEntity.RMBDR = Decimal.Parse(dvRecvRMBVal.InnerText.Trim());
//tempFeeProfitEntity.USDDR = Decimal.Parse(dvUSRecvVal.InnerHtml.Trim());
//tempFeeProfitEntity.OTHERDR = Decimal.Parse(dvOtherCurrencyRecvVal.InnerHtml.Trim());
//tempFeeProfitEntity.RMBCR = Decimal.Parse(dvPayRMBVal.InnerHtml.Trim());
//tempFeeProfitEntity.USDCR = Decimal.Parse(dvUSPayVal.InnerHtml.Trim());
//tempFeeProfitEntity.OTHERCR = Decimal.Parse(dvOtherCurrencyPayVal.InnerHtml.Trim());
//tempFeeProfitEntity.DRTTL = Decimal.Parse(dvRecvTotalVal.InnerHtml.Trim());
//tempFeeProfitEntity.CRTTL = Decimal.Parse(dvPaySumVal.InnerHtml.Trim());
//tempFeeProfitEntity.RMBProfit = Decimal.Parse(dvRMBProfitVal.InnerHtml.Trim());
//tempFeeProfitEntity.USDProfit = Decimal.Parse(dvUSProfitVal.InnerHtml.Trim());
//tempFeeProfitEntity.OTHERProfit = Decimal.Parse(dvOtherCurrencyProfitVal.InnerHtml.Trim());
//tempFeeProfitEntity.TTLProfit = Decimal.Parse(dvProfitTotalVal.InnerHtml.Trim());
//tempFeeProfitEntity.ProfitRate = dvProfitRateVal.InnerHtml.Trim();
#endregion
if (!gainContainer.Value.Trim().Equals(""))
{
string[] gainList = gainContainer.Value.Trim().Split(new char[] { ',' });
if (!gainList[0].ToString().Trim().Equals(""))
{
tempFeeProfitEntity.RMBDR = Decimal.Parse(gainList[0].ToString().Trim());
tempFeeProfitEntity.USDDR = Decimal.Parse(gainList[1].ToString().Trim());
tempFeeProfitEntity.OTHERDR = Decimal.Parse(gainList[2].ToString().Trim());
tempFeeProfitEntity.RMBCR = Decimal.Parse(gainList[3].ToString().Trim());
tempFeeProfitEntity.USDCR = Decimal.Parse(gainList[4].ToString().Trim());
tempFeeProfitEntity.OTHERCR = Decimal.Parse(gainList[5].ToString().Trim());
tempFeeProfitEntity.DRTTL = Decimal.Parse(gainList[6].ToString().Trim());
tempFeeProfitEntity.CRTTL = Decimal.Parse(gainList[7].ToString().Trim());
tempFeeProfitEntity.RMBProfit = Decimal.Parse(gainList[8].ToString().Trim());
tempFeeProfitEntity.USDProfit = Decimal.Parse(gainList[9].ToString().Trim());
tempFeeProfitEntity.OTHERProfit = Decimal.Parse(gainList[10].ToString().Trim());
tempFeeProfitEntity.TTLProfit = Decimal.Parse(gainList[11].ToString().Trim());
tempFeeProfitEntity.ProfitRate = gainList[12].ToString().Trim();
tempFeeProfitEntity.CreateUser = this.strUserID;
tempFeeProfitEntity.ModifiedUser = this.strUserID;
}
else
{
tempFeeProfitEntity.RMBDR = 0;
tempFeeProfitEntity.USDDR = 0;
tempFeeProfitEntity.OTHERDR = 0;
tempFeeProfitEntity.RMBCR = 0;
tempFeeProfitEntity.USDCR = 0;
tempFeeProfitEntity.OTHERCR = 0;
tempFeeProfitEntity.DRTTL = 0;
tempFeeProfitEntity.CRTTL = 0;
tempFeeProfitEntity.RMBProfit = 0;
tempFeeProfitEntity.USDProfit = 0;
tempFeeProfitEntity.OTHERProfit = 0;
tempFeeProfitEntity.TTLProfit = 0;
tempFeeProfitEntity.ProfitRate = "0%";
tempFeeProfitEntity.CreateUser = this.strUserID;
tempFeeProfitEntity.ModifiedUser = this.strUserID;
}
}
return tempFeeProfitEntity;
}
#endregion
private IList<FeeEntity> ResolveFeeJSON(string tempJSON,IList<FeeEntity> tempFeeEntities)
{
string strFilter = "";
if (tempJSON.IndexOf("[") >= 0 && tempJSON.IndexOf("]") > 0)
{
strFilter = tempJSON.Substring(tempJSON.IndexOf("[") + 1, tempJSON.IndexOf("]") - tempJSON.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)
{
FeeEntity feeEntity = new FeeEntity();
for (int j = 0; j < strCell.Length; j++)
{
string[] strArg = strCell[j].Split(new char[] { ':' });
switch (strArg[0].Replace("\"", ""))
{
case "id":
feeEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "type":
feeEntity.FeeType = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "bsno":
feeEntity.BSNO = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "status":
//feeEntity.FeeStatus = int.Parse(strArg[1].ToString().Replace("\"", "").ToString());
break;
case "fname":
feeEntity.FeeName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "cust":
feeEntity.CustomerName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "unit":
string tempUnit = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
if (tempUnit.Equals("null") || tempUnit.Equals(""))
{
feeEntity.Unit = "";
}
else
{
feeEntity.Unit = tempUnit;
}
break;
case "price":
feeEntity.UnitPrice = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "quant":
feeEntity.Quantity = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "com":
feeEntity.CommissionRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "amount":
feeEntity.Amount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "cur":
feeEntity.Currency = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "rate":
feeEntity.ExchangeRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
case "frt":
feeEntity.FeeFrt = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "remark":
//feeEntity.Remark = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
UnicodeEncoding unicode = new UnicodeEncoding();
string lsremark = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
feeEntity.Remark = lsremark.Trim();
break;
case "isadv":
feeEntity.IsAdvancePay = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "linenum":
feeEntity.LINENUM = strArg[1].ToString().Replace("\"", "").Trim() == "" ? 0 : int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
default:
break;
}
}
feeEntity.EnterOperator = this.strUserID;
feeEntity.FeeStatus = 1;
feeEntity.WMSOUTBSNO = "";
tempFeeEntities.Add(feeEntity);
}
}
}
}
return tempFeeEntities;
}
#region Unicode-GB Code转换
/// <summary>
/// Unicode-GB Code转换
/// </summary>
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
/// <returns>GB Code字符串</returns>
public string UnicodeToGB(string text)
{
UnicodeEncoding unicode = new UnicodeEncoding();
text = unicode.GetString(unicode.GetBytes(Regex.Unescape(text.Trim())));
return text;
}
/// <summary>
/// Unicode-GB Code转换
/// </summary>
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
/// <returns>GB Code字符串</returns>
public string UnicodeToGB_Old(string text)
{
MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))");
if (mc != null && mc.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach (Match m2 in mc)
{
string v = m2.Value;
if (v.IndexOf("\\") >= 0)
{
string word = v.Substring(2);
byte[] codes = new byte[2];
int code = Convert.ToInt32(word.Substring(0, 2), 16);
int code2 = Convert.ToInt32(word.Substring(2), 16);
codes[0] = (byte)code2;
codes[1] = (byte)code;
sb.Append(Encoding.Unicode.GetString(codes));
}
else
{
sb.Append(v);
}
}
return sb.ToString();
}
else
{
return text;
}
}
#endregion
#region 重新计算箱型箱量统计信息
/// <summary>
/// 重新计算箱型箱量统计信息
/// </summary>
/// <param name="tempOpSeaeCtns">原始箱型箱量信息</param>
/// <returns>返回重新统计后的箱型箱量合计信息</returns>
private string TotalCtns(string tempOpSeaeCtns)
{
string result = "";
ArrayList totalArg = new ArrayList();
if (tempOpSeaeCtns.Trim() != "")
{
if (tempOpSeaeCtns.IndexOf(tempOpSeaeCtns) >= 0)
{
if (tempOpSeaeCtns.IndexOf("|") >= 0)
{
string[] ctnArg = tempOpSeaeCtns.Split(new char[] { '|' });
for (int i = 0; i < ctnArg.Length; i++)
{
string[] coupleArg = ctnArg[i].Split(new char[] { '*' });
if (totalArg.Count < 1)
{
totalArg.Add(coupleArg[0].ToString());
totalArg.Add(coupleArg[1].ToString());
}
else
{
int iCount = 0;
for (int j = 0; j < totalArg.Count; j++)
{
if (totalArg[j].ToString().Trim().Equals(coupleArg[0].ToString().Trim()))
{
int tempTotalCtnCount = int.Parse(totalArg[j + 1].ToString().Trim());
int tempCtnCount = int.Parse(coupleArg[1].ToString().Trim());
totalArg[j + 1] = (tempTotalCtnCount + tempCtnCount).ToString();
iCount++;
break;
}
}
if (iCount == 0)
{
totalArg.Add(coupleArg[0].ToString());
totalArg.Add(coupleArg[1].ToString());
}
}
}
}
else
{
string[] ctnArg = tempOpSeaeCtns.Split(new char[] { '/' });
for (int i = 0; i < ctnArg.Length; i++)
{
if (!ctnArg[i].ToString().Trim().Equals(""))
{
string[] coupleArg = ctnArg[i].Split(new char[] { '*' });
if (totalArg.Count < 1)
{
totalArg.Add(coupleArg[0].ToString());
totalArg.Add(coupleArg[1].ToString());
}
else
{
int iCount = 0;
for (int j = 0; j < totalArg.Count; j++)
{
if (totalArg[j].ToString().Trim().Equals(coupleArg[0].ToString().Trim()))
{
int tempTotalCtnCount = int.Parse(totalArg[j + 1].ToString().Trim());
int tempCtnCount = int.Parse(coupleArg[1].ToString().Trim());
totalArg[j + 1] = (tempTotalCtnCount + tempCtnCount).ToString();
iCount++;
break;
}
}
if (iCount == 0)
{
totalArg.Add(coupleArg[0].ToString());
totalArg.Add(coupleArg[1].ToString());
}
}
}
}
}
}
if (totalArg.Count > 0)
{
for (int i = 0; i < totalArg.Count; i++)
{
if ((i % 2) > 0)
{
if (totalArg.Count == 2)
{
result += totalArg[i].ToString();
}
else
{
result += totalArg[i].ToString() + "/";
}
}
else
{
result += totalArg[i].ToString() + "*";
}
}
}
}
return result;
}
#endregion
#region 获取用户应收、应付权限信息
/// <summary>
/// 获取用户应收、应付权限信息
/// </summary>
/// <param name="tempFeeType">费用类型</param>
/// <returns>返回 true 有权限操作数据 false 没有权限操作数据</returns>
private bool ValidateUserFeeAuthority(int tempFeeType)
{
int iResult = 0;
if (tempFeeType == 1)
{
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modOrderManagement");
UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modRecvFeeManagement");
if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
{
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAELIST, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
}
}
else
{
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modOrderManagement");
UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modPayFeeManagement");
if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
{
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAELIST, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
}
}
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
#endregion
}
}