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.

1626 lines
73 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
using DSWeb.Authority;
using System.Text.RegularExpressions;
namespace DSWeb.SeaiInfoLCL
{
public partial class SeaiFeeLCLService : System.Web.UI.Page
{
private string strFeeGid;//费用信息GID
private string strHandle;//费用操作说明
private string strBSNO;//委托编号
private string strCrmOrderFeeID;//销售订舱费用GID
private decimal dAmount;//费用金额
private int iFeeType;//费用类型 1-应收 2-应付
private const int iResult = -99;//参数错误
private string strUserID;//用户GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string strOperateName;//操作权限
private string strTemplateID;//引入费用模板GID
private string strTemplateCacheName;//引入费用模板Session的Key值
private int iCurrentPage;//当前页数
private int iShowPage;//显示最大页数
private string strSearch;//委托信息查询条件
private string strCacheName;//Session 缓存名称
private string strOldCacheName;//原Session缓存名称
private string strCheckType;//全选类型 值"check"选中的值 值"uncheck"去除选择的值
protected void Page_Load(object sender, EventArgs e)
{
//strFeeGid = (String)Request.QueryString["gid"] as String;
//strHandle = (String)Request.QueryString["handle"] as String;
//strBSNO = (String)Request.QueryString["bsno"] as String;
//strCrmOrderFeeID = (String)Request.QueryString["crmfee"] as String;
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["gid"] != null)
{
strFeeGid = Request.QueryString["gid"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["crmfee"] != null)
{
strCrmOrderFeeID = Request.QueryString["crmfee"].ToString();
}
if (Request.QueryString["feetype"] != null)
{
iFeeType = int.Parse(Request.QueryString["feetype"].ToString());
}
else
{
iFeeType = 0;
}
if (Request.QueryString["amount"] != null)
{
dAmount = decimal.Parse(Request.QueryString["amount"].ToString());
}
else
{
dAmount = 0;
}
if (Request.QueryString["opname"] != null)
{
strOperateName = Request.QueryString["opname"].ToString().Trim().ToLower();
}
if (Request.QueryString["tempcache"] != null)
{
strTemplateCacheName = Request.QueryString["tempcache"].ToString().Trim();
}
if (Request.QueryString["tid"] != null)
{
strTemplateID = Request.QueryString["tid"].ToString().Trim();
}
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["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
if (Request.QueryString["cachename"] != null)
{
strCacheName = Request.QueryString["cachename"].ToString();
}
if (Request.QueryString["oldcache"] != null)
{
strOldCacheName = Request.QueryString["oldcache"].ToString();
}
if (Request.QueryString["op"] != null)
{
strCheckType = Request.QueryString["op"].ToString();
}
if (strHandle != null)
{
if (strHandle == "checkopstatus" && strBSNO != null)
{ //验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
Response.Write(ValidateOpStatus(strBSNO));
}
if (strHandle == "deletecrmfee" && strCrmOrderFeeID != null)
{
Response.Write(DeleteCrmOrderFee(strCrmOrderFeeID));
}
if (strHandle == "recovercrmfee" && strCrmOrderFeeID != null)
{
Response.Write(RecoverCrmOrderFee(strCrmOrderFeeID).ToString());
}
if (strHandle == "delete" && strFeeGid != null)
{ //删除委托业务内的费用
Response.Write(DeleteOpSeaeFee(strFeeGid));
}
if (strHandle == "recover" && strFeeGid != null)
{ //恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
Response.Write(RecoveOpSeaeFee(strFeeGid));
}
if (strHandle == "validateop" && strFeeGid != null && strUserID != null && iFeeType != 0)
{ //校验费用操作权限,返回权限值
Response.Write(ValidateFeeOperatePower(strFeeGid, iFeeType));
}
if (strHandle == "removeimport" && strTemplateCacheName != null && strTemplateID != null)
{ //从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
Response.Write(RemoveFeeImportTemplateFromCache(strTemplateID, strTemplateCacheName));
}
if (strHandle == "getfee" && iFeeType > 0 && strBSNO != null)
{
Response.Write(GetFeeDataSource(iFeeType, strBSNO));
}
if (strHandle == "getfeepage" && strBSNO != null)
{
Response.Write(GetFeeListPage(strBSNO, iFeeType));
}
if (strHandle == "getopseae")
{
Response.Write(GetOpSeaeList());
}
if (strHandle == "getopseaepage")
{
Response.Write(GetOpSeaiListPage());
}
if (strHandle == "checkopseae" && strBSNO != null && strCacheName != null && strCheckType != null)
{
Response.Write(CacheOpSeae(strCacheName, strBSNO, strCheckType).ToString());
}
if (strHandle == "checkfee" && strFeeGid != null && strCacheName != null && strCheckType != null)
{
Response.Write(CacheFee(strCacheName, strFeeGid, strCheckType).ToString());
}
if (strHandle == "importhistory" && strCacheName != null)
{
Response.Write(ImportHistoryFee(strCacheName).ToString());
}
if (strHandle == "inithistory" && strCacheName != null)
{
Response.Write(InitImportFeeHistoryCache(strCacheName));
}
}
}
#region 从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
/// <summary>
/// 从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
/// </summary>
/// <param name="tempTemplateID">费用模板GID</param>
/// <param name="tempCacheName">费用模板缓存名称</param>
/// <returns>值1表示移除成功 值2表示未获取到缓存</returns>
private int RemoveFeeImportTemplateFromCache(string tempTemplateID, string tempCacheName)
{
int iResult = 0;
DataTable cacheTable = new DataTable();
if (Session[tempCacheName] != null)
{
cacheTable = (DataTable)Session[tempCacheName];
}
if (cacheTable != null)
{
for (int i = 0; i < cacheTable.Rows.Count; i++)
{
if (cacheTable.Rows[i]["GID"].ToString().Trim().Equals(tempTemplateID))
{
cacheTable.Rows.RemoveAt(i);
break;
}
}
if (cacheTable.Rows.Count > 0)
{
Session[tempCacheName] = cacheTable;
iResult = 1;
}
else
{
Session.Remove(tempCacheName);
iResult = 1;
}
}
else
{
iResult = 2;
}
return iResult;
}
#endregion
#region 校验费用操作权限,返回权限值
/// <summary>
/// 校验费用操作权限,返回权限值
/// </summary>
/// <param name="strFeeID">费用 GID</param>
/// <param name="tempFeeType">费用类型</param>
/// <returns>值大于1表示具有权限 值等于小于1表示没有操作费用权限</returns>
private int ValidateFeeOperatePower(string strFeeID, int tempFeeType)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
//通过费用GID获取ch_fee费用信息返回FeeEntity
FeeEntity feeEntity = feeDA.GetFeeByID(strFeeID);
if (tempFeeType == 1)
{
//校验应收费用操作权限
if (feeEntity != null)
{
if (feeEntity.GID != null)
{ //依据UserID和ModuleName初始化实体类UserAuthorityManage
UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
{ //
iResult = userRecvAuthorityManage.CheckOperateRange(ModuleType.SEAIRECVFEE, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, "", strFeeID, strUserID);
}
}
else
{
iResult = 1;
}
}
else
{
if (strOperateName != null)
{
if (strOperateName == "add" || strOperateName == "gain" || strOperateName == "print" || strOperateName == "import" || strOperateName == "save" || strOperateName == "select" || strOperateName == "")
{
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
{
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID);
}
}
}
}
}
else
{
if (feeEntity != null)
{
if (feeEntity.GID != null)
{
UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLPayFeeManagement");
if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
{
iResult = userPayAuthorityManage.CheckOperateRange(ModuleType.SEAIPAYFEE, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, "", strFeeID, strUserID);
}
}
else
{
iResult = 1;
}
}
else
{
if (strOperateName != null)
{
if (strOperateName == "add" || strOperateName == "gain" || strOperateName == "print" || strOperateName == "import" || strOperateName == "save" || strOperateName == "select" || strOperateName == "")
{
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLPayFeeManagement");
if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
{
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strBSNO, "", strUserID);
}
}
}
}
}
return iResult;
}
#endregion
#region 根据销售订舱费用GID删除销售订舱费用
/// <summary>
/// 根据销售订舱费用GID删除销售订舱费用
/// </summary>
/// <param name="tempCrmOrderFeeID">销售订舱费用GID</param>
/// <returns>值1表示删除成功 值不等于1表示删除失败</returns>
private int DeleteCrmOrderFee(string tempCrmOrderFeeID)
{
int iResult = 0;
CrmOrderFeeEntity crmOrderFeeEntity = new CrmOrderFeeEntity();
CrmOrderFeeDA crmOrderFeeDA = new CrmOrderFeeDA();
crmOrderFeeEntity = crmOrderFeeDA.GetFeeByID(tempCrmOrderFeeID);
if (crmOrderFeeEntity != null)
{
if (crmOrderFeeEntity.GID != null)
{
iResult = crmOrderFeeDA.DeleteFeeByGid(crmOrderFeeEntity.GID, crmOrderFeeEntity.Currency, crmOrderFeeEntity.FeeType, crmOrderFeeEntity.Amount, crmOrderFeeEntity.ExchangeRate, crmOrderFeeEntity.BSNO);
}
}
return iResult;
}
#endregion
#region 还原销售订舱费用
/// <summary>
/// 还原销售订舱费用
/// </summary>
/// <param name="tempCrmOrderFeeID">销售订舱费用GID</param>
/// <returns>根据GID返回所有销售订舱费用明细</returns>
private string RecoverCrmOrderFee(string tempCrmOrderFeeID)
{
string strResult = "0";
CrmOrderFeeEntity crmOrderFeeEntity = new CrmOrderFeeEntity();
CrmOrderFeeDA crmOrderFeeDA = new CrmOrderFeeDA();
crmOrderFeeEntity = crmOrderFeeDA.GetFeeByID(tempCrmOrderFeeID);
if (crmOrderFeeEntity != null)
{
if (crmOrderFeeEntity.GID != null)
{
StringBuilder feeBuilder = new StringBuilder();
feeBuilder.Append(crmOrderFeeEntity.GID + ",");
feeBuilder.Append(",");
feeBuilder.Append(crmOrderFeeEntity.FeeName + ",");
feeBuilder.Append(crmOrderFeeEntity.CustomerName + ",");
feeBuilder.Append(crmOrderFeeEntity.Unit + ",");
feeBuilder.Append(crmOrderFeeEntity.UnitPrice.ToString() + ",");
feeBuilder.Append(crmOrderFeeEntity.Quantity.ToString() + ",");
feeBuilder.Append(crmOrderFeeEntity.CommissionRate.ToString() + ",");
feeBuilder.Append(crmOrderFeeEntity.Amount.ToString() + ",");
feeBuilder.Append(crmOrderFeeEntity.Currency + ",");
feeBuilder.Append(crmOrderFeeEntity.ExchangeRate.ToString() + ",");
feeBuilder.Append(",");
feeBuilder.Append(crmOrderFeeEntity.Remark + ",");
feeBuilder.Append(crmOrderFeeEntity.IsAdvancePay ? 1 : 0);
strResult = feeBuilder.ToString();
}
}
return strResult;
}
#endregion
#region 恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
/// <summary>
/// 恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
/// </summary>
/// <returns>返回字符串</returns>
private string RecoveOpSeaeFee(string tempFeeID)
{
string strResult = "";
FeeDA feeDA = new FeeDA();
FeeEntity feeEntity = new FeeEntity();
//通过费用GID获取ch_fee费用信息返回FeeEntity
feeEntity = feeDA.GetFeeByID(tempFeeID);
if (feeEntity != null)
{
StringBuilder feeBuilder = new StringBuilder();
//feeBuilder.Append("[");
feeBuilder.Append(feeEntity.GID + ",");
feeBuilder.Append(",");
feeBuilder.Append(feeEntity.FeeName + ",");
feeBuilder.Append(feeEntity.CustomerName + ",");
feeBuilder.Append(feeEntity.Unit + ",");
feeBuilder.Append(feeEntity.UnitPrice.ToString() + ",");
feeBuilder.Append(feeEntity.Quantity.ToString() + ",");
feeBuilder.Append(feeEntity.CommissionRate.ToString() + ",");
feeBuilder.Append(feeEntity.Amount.ToString() + ",");
feeBuilder.Append(feeEntity.Currency + ",");
feeBuilder.Append(feeEntity.ExchangeRate.ToString() + ",");
feeBuilder.Append(",");
feeBuilder.Append(feeEntity.Remark + ",");
feeBuilder.Append(feeEntity.IsAdvancePay ? 1 : 0);
//feeBuilder.Append("]");
strResult = feeBuilder.ToString();
}
else
{
strResult = "-3";
}
return strResult;
}
#endregion
#region 删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
/// <summary>
/// 删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
/// </summary>
/// <param name="tempFeeID"></param>
/// <returns>返回删除操作结果</returns>
private int DeleteOpSeaeFee(string tempFeeID)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
//通过费用GID获取ch_fee费用信息返回FeeEntity
FeeEntity feeEntity = new FeeEntity();
feeEntity = feeDA.GetFeeByID(tempFeeID);
if (feeEntity != null)
{
if (feeEntity.GID != null)
{
//只有费用状态为
if (feeEntity.FeeStatus == 1 || feeEntity.FeeStatus == 6)
{
//通过费用GID删除ch_fee单条费用更新fee_gain重算利润
iResult = feeDA.DeleteFeeByGid(feeEntity.GID, feeEntity.Currency, feeEntity.FeeType, feeEntity.Amount, feeEntity.ExchangeRate, feeEntity.BSNO);
}
}
else
{
iResult = 2;//未获取相关费用信息
//iResult = -3; //未获取相关费用信息
}
}
else
{
iResult = 2;//未获取相关费用信息
//iResult = -3; //未获取相关费用信息
}
return iResult;
}
#endregion
//#region 删除费用与恢复修改
///// <summary>
///// 删除费用与恢复修改
///// </summary>
///// <param name="tempGid">费用GID</param>
///// <param name="tempHandle">操作类型 delete删除单条费用</param>
///// <returns>值1-删除成功;值-1 -删除操作异常 值-2 -回滚失败 值-3 -未获取相关费用信息</returns>
//private string DoExcute(string tempGid, string tempHandle)
//{
// string strVal = "";
// FeeDA feeDA = new FeeDA();
// //操作类型为删除
// if (tempHandle == "delete")
// {
// int iResult = 0;
// //先判断当前要删除的费用是否存在
// if (!tempGid.Trim().Equals(""))
// {
// FeeEntity feeEntity = new FeeEntity();
// feeEntity = feeDA.GetFeeByID(tempGid);
// if (feeEntity.GID != null)
// {
// //只有费用状态为
// if (feeEntity.FeeStatus == 1 || feeEntity.FeeStatus == 6)
// {
// //获取费用金额 重新计算
// iResult = feeDA.DeleteFeeByGid(feeEntity.GID);
// }
// }
// else
// {
// iResult = -3; //未获取相关费用信息
// }
// }
// strVal = iResult.ToString();
// }
// if (tempHandle == "recover")
// {
// if (!tempGid.Trim().Equals(""))
// {
// FeeEntity feeEntity = new FeeEntity();
// feeEntity = feeDA.GetFeeByID(tempGid);
// if (feeEntity != null)
// {
// StringBuilder feeBuilder = new StringBuilder();
// //feeBuilder.Append("[");
// feeBuilder.Append(feeEntity.GID + ",");
// feeBuilder.Append(feeEntity.FeeName + ",");
// feeBuilder.Append(feeEntity.CustomerName + ",");
// feeBuilder.Append(feeEntity.Unit + ",");
// feeBuilder.Append(feeEntity.UnitPrice.ToString() + ",");
// feeBuilder.Append(feeEntity.Quantity.ToString() + ",");
// feeBuilder.Append(feeEntity.CommissionRate.ToString() + ",");
// feeBuilder.Append(feeEntity.Amount.ToString() + ",");
// feeBuilder.Append(feeEntity.Currency + ",");
// feeBuilder.Append(feeEntity.ExchangeRate.ToString() + ",");
// feeBuilder.Append(",");
// feeBuilder.Append(feeEntity.Remark + ",");
// feeBuilder.Append(feeEntity.IsAdvancePay ? 1 : 0);
// //feeBuilder.Append("]");
// strVal = feeBuilder.ToString();
// }
// else
// {
// strVal = "-3";
// }
// }
// else
// {
// strVal = "-3";
// }
// }
// return strVal;
//}
//#endregion
#region 验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
/// <summary>
/// 验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
/// </summary>
/// <param name="tempBSNO"></param>
/// <returns>返回json值</returns>
private string ValidateOpStatus(string tempBSNO)
{
string strResult = "";
int iOpStatus = 0;
int iOpSeaeFeeStatus = 0;
//查看当前委托业务状态是否已经退载
OpStatusDA opStatusDA = new OpStatusDA();
IList<OpStatusEntity> opStatusEntities = new List<OpStatusEntity>();
//通过委托编号BSNO获取委托所有业务状态(op_status)
opStatusEntities = opStatusDA.GetOpStatusByBSNO(tempBSNO);
if (opStatusEntities.Count > 0)
{
foreach (OpStatusEntity opStatusEntity in opStatusEntities)
{
if (opStatusEntity.Status.Trim().Equals("退载"))
{
iOpStatus = -1;//委托业务状态已退载
break;
}
}
if (iOpStatus == 0)
{
iOpStatus = 1;
}
}
else
{
iOpStatus = 1;
}
TopSeaiEntity topSeaiEntity = new TopSeaiEntity();
SeaImportInfoDA seaImportInfoDA = new SeaImportInfoDA();
//根据GID获取委托op_seai信息
topSeaiEntity = seaImportInfoDA.GetID(tempBSNO);
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iOpSeaeFeeStatus = -1;//当前委托业务费用状态已锁定
}
else
{
iOpSeaeFeeStatus = 1;
}
}
else
{
iOpSeaeFeeStatus = 1;
}
}
else
{
iOpSeaeFeeStatus = 1;
}
strResult = GetJosonResult(iOpStatus, iOpSeaeFeeStatus);
return strResult;
}
#endregion
#region 获取JSON值
/// <summary>
/// 获取JSON值
/// </summary>
/// <param name="tempOpStatus">委托业务状态</param>
/// <param name="tempOpSeaeFeeStatus">委托业务费用状态</param>
/// <returns>返回JSON字符串</returns>
private string GetJosonResult(int tempOpStatus, int tempOpSeaeFeeStatus)
{
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.Append("{");
jsonBuilder.Append("\"valid\":");
jsonBuilder.Append("[");
jsonBuilder.Append("{");
jsonBuilder.Append("\"opstatus\":" + tempOpStatus + ",");
jsonBuilder.Append("\"feestatus\":" + tempOpSeaeFeeStatus + "");
jsonBuilder.Append("}");
jsonBuilder.Append("]");
jsonBuilder.Append("}");
return jsonBuilder.ToString();
}
#endregion
#region 获取费用列表信息
/// <summary>
/// 获取费用列表信息
/// </summary>
/// <param name="tempFeeType">费用类型</param>
/// <param name="tempBSNO">委托业务BSNO</param>
/// <returns>返回JSON数据</returns>
private string GetFeeDataSource(int tempFeeType, string tempBSNO)
{
FeeDA feeDA = new FeeDA();
DataTable sourceTable;
string strTopInclude = "";
string strTopNotInclude = "";
string strSql = "";
string strAuthorityCondition = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
if (iFeeType == 1)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql = String.Format(" SELECT {0} A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, "top " + iShowPage.ToString());
}
else if (iFeeType == 2)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLPayFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql = String.Format(" SELECT {0} A.GID,A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = 2 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, "top " + iShowPage.ToString());
}
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
if (iFeeType == 1)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql = String.Format(" SELECT {0} A.GID,A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " AND A.GID NOT IN ( SELECT {1} GID FROM ch_fee WHERE FEETYPE = 1 AND BSNO = '" + strBSNO + "' "
+ strAuthorityCondition + " ORDER BY ENTERDATE DESC) " + " ORDER BY A.ENTERDATE DESC ", strTopInclude, strTopNotInclude);
}
else if (iFeeType == 2)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql = String.Format(" SELECT {0} A.GID,A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " AND A.GID NOT IN ( SELECT {1} GID FROM ch_fee WHERE FEETYPE = 1 AND BSNO = '" + strBSNO + "' "
+ strAuthorityCondition + " ORDER BY ENTERDATE DESC) " + " ORDER BY A.ENTERDATE DESC ", strTopInclude, strTopNotInclude);
}
}
}
else
{
}
sourceTable = feeDA.GetExcuteSql(strSql).Tables[0];
DataTable cacheTable = null;
if (Session[strCacheName] != null)
{
cacheTable = (DataTable)Session[strCacheName];
}
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 (cacheTable != null)
{
if (cacheTable.Rows.Count > 0)
{
int iCount = 0;
for (int k = 0; k < cacheTable.Rows.Count; k++)
{
if (cacheTable.Rows[k]["GID"].ToString() == sourceTable.Rows[i]["GID"].ToString())
{
sourceBuilder.Append("\"1\",");
iCount++;
break;
}
}
if (iCount == 0)
{
sourceBuilder.Append("\"0\",");
}
}
else
{
sourceBuilder.Append("\"0\",");
}
}
else
{
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();
}
#endregion
#region 获取费用的总页数
/// <summary>
/// 获取费用的总页数
/// </summary>
/// <param name="tempBSNO">委托业务BSNO</param>
/// <param name="tempType">费用类型</param>
/// <returns>返回总页数</returns>
private int GetFeeListPage(string tempBSNO, int tempType)
{
FeeDA feeDA = new FeeDA();
string strSql = "SELECT COUNT(*) FROM ch_fee as A WHERE 1 > 0 ";
string strAuthorityCondition = "";
if (iFeeType == 1)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLRecvFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql += " AND A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition;
}
else if (iFeeType == 2)
{
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiLCLPayFeeManagement");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
strSql += " AND A.FEETYPE = 2 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition;
}
int iTotal = int.Parse(feeDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// <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("FEETYPE"))
{
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("FEESTATUS"))
{
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;
}
if (sourceTable.Columns[k].ColumnName.Equals("FEESTATUS"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 0:
strFeeStatus = "审核通过";
break;
case 1:
strFeeStatus = "录入状态";
break;
case 2:
strFeeStatus = "提交审核";
break;
case 3:
strFeeStatus = "申请修改";
break;
case 4:
strFeeStatus = "申请删除";
break;
case 5:
strFeeStatus = "取消申请";
break;
case 6:
strFeeStatus = "驳回提交";
break;
case 7:
strFeeStatus = "驳回申请";
break;
case 8:
strFeeStatus = "部分结算";
break;
case 9:
strFeeStatus = "结算完毕";
break;
case 10:
strFeeStatus = "申请通过";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
return cloneTable;
}
#endregion
#region 获取海运进口委托op_seai总页数
/// <summary>
/// 获取海运进口委托op_seai总页数
/// </summary>
/// <returns>返回总页数</returns>
private int GetOpSeaiListPage()
{
SeaImportInfoDA seaImportInfoDA = new SeaImportInfoDA();
string strSql = "SELECT COUNT(*) FROM op_seai WHERE 1 > 0 ";
string strCondition = "";
string strAuthorityCondition = "";
//依据UserID和ModuleName初始化实体类UserAuthorityManage
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
strSql += strAuthorityCondition;
}
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"://ETD BeginDate
strCondition += String.Format(" AND ETD >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://ETD EndDate
strCondition += String.Format(" AND ETD <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://CUSTOMER
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://NO
strCondition += String.Format(" AND (CUSTNO LIKE '%{0}%' OR MBLNO LIKE '%{0}%' OR HBLNO LIKE '%{0}%' OR ORDERNO like '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "op"://OP
strCondition += String.Format(" AND OP LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "vessel"://VESSEL
strCondition += String.Format(" AND VESSEL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "voyno"://VOYNO
strCondition += String.Format(" AND VOYNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
strSql += strCondition;
}
}
int iTotal = int.Parse(seaImportInfoDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 获取海运出口委托信息
/// <summary>
/// 获取海运出口委托信息
/// </summary>
/// <returns>返回JSON数据</returns>
private string GetOpSeaeList()
{
SeaImportInfoDA seaImportInfoDA = new SeaImportInfoDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
if (strCacheName != null)
{
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
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"://ETD BeginDate
strCondition += String.Format(" AND ETD >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://ETD EndDate
strCondition += String.Format(" AND ETD <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://CUSTOMER
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://NO
strCondition += String.Format(" AND (CUSTNO LIKE '%{0}%' OR MBLNO LIKE '%{0}%' OR HBLNO LIKE '%{0}%' OR ORDERNO like '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "op"://OP
strCondition += String.Format(" AND OP LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "vessel"://VESSEL
strCondition += String.Format(" AND VESSEL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "voyno"://VOYNO
strCondition += String.Format(" AND VOYNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} BSNO,MBLNO,HBLNO,CUSTNO,CUSTOMERNAME,FORWARDER,VESSEL,VOYNO,ETD,PORTLOAD,PORTDISCHARGE,CNTRTOTAL,INPUTBY,BSDATE,OP,SALE "
+ " FROM op_seai where 1>0 " + strAuthorityCondition + strCondition + " ORDER BY ETD DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} BSNO,MBLNO,HBLNO,CUSTNO,CUSTOMERNAME,FORWARDER,VESSEL,VOYNO,ETD,PORTLOAD,PORTDISCHARGE,CNTRTOTAL,INPUTBY,BSDATE,OP,SALE "
+ " FROM op_seai WHERE BSNO NOT IN "
+ " (SELECT {1} BSNO FROM op_seai WHERE 1>0 " + strAuthorityCondition + strCondition + " ORDER BY ETD DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY ETD DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = String.Format(" SELECT BSNO,MBLNO,HBLNO,CUSTNO,CUSTOMERNAME,FORWARDER,VESSEL,VOYNO,ETD,PORTLOAD,PORTDISCHARGE,CNTRTOTAL,INPUTBY,BSDATE,OP,SALE"
+ " FROM op_seai where 1>0 " + strAuthorityCondition + strCondition + " ORDER BY ETD DESC ");
}
sourceTable = seaImportInfoDA.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="tempCacheName">缓存名称</param>
/// <param name="tempBSNO">海运出口委托BSNO</param>
/// <param name="tempCheckType">选中类型 check-选中状态 uncheck-取消选中状态</param>
/// <returns>值1表示缓存成功 值不等于1表示缓存失败</returns>
private int CacheOpSeae(string tempCacheName, string tempBSNO, string tempCheckType)
{
int iRsult = 0;
DataTable feeTable = null;
DataTable oldTable = null;
if (Session[tempCacheName] != null)
{
if (strOldCacheName != null)
{
if (Session[strOldCacheName] != null)
{
oldTable = (DataTable)Session[strOldCacheName];
}
}
feeTable = (DataTable)Session[tempCacheName];
if (oldTable != null)
{
if (oldTable.Rows.Count > 0)
{
for (int i = 0; i < oldTable.Rows.Count; i++)
{
//缓存新的费用信息
DataRow newRow = feeTable.NewRow();
newRow["GID"] = oldTable.Rows[i]["GID"].ToString();
newRow["FEENAME"] = oldTable.Rows[i]["FEENAME"].ToString();
newRow["CUSTOMERNAME"] = oldTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["UNIT"] = oldTable.Rows[i]["UNIT"].ToString();
newRow["UNITPRICE"] = oldTable.Rows[i]["UNITPRICE"].ToString();
newRow["QUANTITY"] = oldTable.Rows[i]["QUANTITY"].ToString();
newRow["QUANTITY"] = oldTable.Rows[i]["QUANTITY"].ToString();
newRow["COMMISSIONRATE"] = oldTable.Rows[i]["COMMISSIONRATE"].ToString();
newRow["AMOUNT"] = oldTable.Rows[i]["AMOUNT"].ToString();
newRow["CURRENCY"] = oldTable.Rows[i]["CURRENCY"].ToString();
newRow["EXCHANGERATE"] = oldTable.Rows[i]["EXCHANGERATE"].ToString();
newRow["FEEFRT"] = oldTable.Rows[i]["FEEFRT"].ToString();
newRow["REMARK"] = oldTable.Rows[i]["REMARK"].ToString();
newRow["ISADVANCEDPAY"] = oldTable.Rows[i]["ISADVANCEDPAY"].ToString();
newRow["SHOWNAME"] = oldTable.Rows[i]["SHOWNAME"].ToString();
newRow["ENTERDATE"] = oldTable.Rows[i]["ENTERDATE"].ToString();
newRow["FEETYPE"] = oldTable.Rows[i]["FEETYPE"].ToString();
feeTable.Rows.Add(newRow);
}
}
}
if (tempCheckType.Trim().ToLower().Equals("check"))
{
string strSql = String.Format(" SELECT A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY,"
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE,A.FEETYPE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = " + iFeeType.ToString() + " AND A.BSNO = '{0}' ORDER BY ENTERDATE ASC ", strBSNO);
DataTable checkFeeTable = new DataTable();
FeeDA feeDA = new FeeDA();
checkFeeTable = feeDA.GetExcuteSql(strSql).Tables[0];
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["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
newRow["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["UNIT"] = checkFeeTable.Rows[i]["UNIT"].ToString();
newRow["UNITPRICE"] = checkFeeTable.Rows[i]["UNITPRICE"].ToString();
newRow["QUANTITY"] = checkFeeTable.Rows[i]["QUANTITY"].ToString();
newRow["QUANTITY"] = checkFeeTable.Rows[i]["QUANTITY"].ToString();
newRow["COMMISSIONRATE"] = checkFeeTable.Rows[i]["COMMISSIONRATE"].ToString();
newRow["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
newRow["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
newRow["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
newRow["FEEFRT"] = checkFeeTable.Rows[i]["FEEFRT"].ToString();
newRow["REMARK"] = checkFeeTable.Rows[i]["REMARK"].ToString();
newRow["ISADVANCEDPAY"] = checkFeeTable.Rows[i]["ISADVANCEDPAY"].ToString();
newRow["SHOWNAME"] = checkFeeTable.Rows[i]["SHOWNAME"].ToString();
newRow["ENTERDATE"] = checkFeeTable.Rows[i]["ENTERDATE"].ToString();
newRow["FEETYPE"] = oldTable.Rows[i]["FEETYPE"].ToString();
feeTable.Rows.Add(newRow);
}
}
Session[tempCacheName] = feeTable;
}
iRsult = 1;
}
else if (tempCheckType.Trim().ToLower().Equals("uncheck"))
{
string strSql = String.Format(" SELECT A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY,"
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE,A.FEETYPE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = " + iFeeType.ToString() + " AND A.BSNO = '{0}' ORDER BY ENTERDATE ASC ", strBSNO);
DataTable checkFeeTable = new DataTable();
FeeDA feeDA = new FeeDA();
checkFeeTable = feeDA.GetExcuteSql(strSql).Tables[0];
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;
}
iRsult = 1;
}
}
else
{
if (tempCheckType.Trim().ToLower().Equals("check"))
{
string strSql = String.Format(" SELECT A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY,"
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE,A.FEETYPE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.FEETYPE = " + iFeeType.ToString() + " AND A.BSNO = '{0}' ORDER BY ENTERDATE ASC ", strBSNO);
DataTable checkFeeTable = new DataTable();
FeeDA feeDA = new FeeDA();
checkFeeTable = feeDA.GetExcuteSql(strSql).Tables[0];
if (strOldCacheName != null)
{
if (Session[strOldCacheName] != null)
{
oldTable = (DataTable)Session[strOldCacheName];
}
}
if (oldTable != null)
{
if (oldTable.Rows.Count > 0)
{
for (int i = 0; i < oldTable.Rows.Count; i++)
{
//缓存新的费用信息
DataRow newRow = checkFeeTable.NewRow();
newRow["GID"] = oldTable.Rows[i]["GID"].ToString();
newRow["FEENAME"] = oldTable.Rows[i]["FEENAME"].ToString();
newRow["CUSTOMERNAME"] = oldTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["UNIT"] = oldTable.Rows[i]["UNIT"].ToString();
newRow["UNITPRICE"] = oldTable.Rows[i]["UNITPRICE"].ToString();
newRow["QUANTITY"] = oldTable.Rows[i]["QUANTITY"].ToString();
newRow["QUANTITY"] = oldTable.Rows[i]["QUANTITY"].ToString();
newRow["COMMISSIONRATE"] = oldTable.Rows[i]["COMMISSIONRATE"].ToString();
newRow["AMOUNT"] = oldTable.Rows[i]["AMOUNT"].ToString();
newRow["CURRENCY"] = oldTable.Rows[i]["CURRENCY"].ToString();
newRow["EXCHANGERATE"] = oldTable.Rows[i]["EXCHANGERATE"].ToString();
newRow["FEEFRT"] = oldTable.Rows[i]["FEEFRT"].ToString();
newRow["REMARK"] = oldTable.Rows[i]["REMARK"].ToString();
newRow["ISADVANCEDPAY"] = oldTable.Rows[i]["ISADVANCEDPAY"].ToString();
newRow["SHOWNAME"] = oldTable.Rows[i]["SHOWNAME"].ToString();
newRow["ENTERDATE"] = oldTable.Rows[i]["ENTERDATE"].ToString();
newRow["FEETYPE"] = oldTable.Rows[i]["FEETYPE"].ToString();
checkFeeTable.Rows.Add(newRow);
}
}
}
Session[tempCacheName] = checkFeeTable;
iRsult = 1;
}
}
return iRsult;
}
#endregion
#region 缓存单个费用信息
/// <summary>
/// 缓存单个费用信息
/// </summary>
/// <param name="tempCacheName">缓存名称</param>
/// <param name="tempFeeID">费用GID</param>
/// <param name="tempCheckType">选中类型 check-选中状态 uncheck-取消选中状态</param>
/// <returns>值1表示缓存成功 值不等于1表示缓存失败</returns>
private int CacheFee(string tempCacheName, string tempFeeID, string tempCheckType)
{
int iResult = 0;
DataTable feeTable = null;
if (Session[tempCacheName] != null)
{
feeTable = (DataTable)Session[tempCacheName];
if (tempCheckType.Trim().ToLower().Equals("check"))
{
string strSql = String.Format(" SELECT A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY,"
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE,A.FEETYPE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.GID = '{0}' ORDER BY ENTERDATE ASC ", tempFeeID);
DataTable checkFeeTable = new DataTable();
FeeDA feeDA = new FeeDA();
checkFeeTable = feeDA.GetExcuteSql(strSql).Tables[0];
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(tempFeeID))
{
iCount++;
break;
}
}
if (iCount == 0)
{
//缓存新的费用信息
DataRow newRow = feeTable.NewRow();
newRow["GID"] = checkFeeTable.Rows[i]["GID"].ToString();
newRow["FEENAME"] = checkFeeTable.Rows[i]["FEENAME"].ToString();
newRow["CUSTOMERNAME"] = checkFeeTable.Rows[i]["CUSTOMERNAME"].ToString();
newRow["UNIT"] = checkFeeTable.Rows[i]["UNIT"].ToString();
newRow["UNITPRICE"] = checkFeeTable.Rows[i]["UNITPRICE"].ToString();
newRow["QUANTITY"] = checkFeeTable.Rows[i]["QUANTITY"].ToString();
newRow["QUANTITY"] = checkFeeTable.Rows[i]["QUANTITY"].ToString();
newRow["COMMISSIONRATE"] = checkFeeTable.Rows[i]["COMMISSIONRATE"].ToString();
newRow["AMOUNT"] = checkFeeTable.Rows[i]["AMOUNT"].ToString();
newRow["CURRENCY"] = checkFeeTable.Rows[i]["CURRENCY"].ToString();
newRow["EXCHANGERATE"] = checkFeeTable.Rows[i]["EXCHANGERATE"].ToString();
newRow["FEEFRT"] = checkFeeTable.Rows[i]["FEEFRT"].ToString();
newRow["REMARK"] = checkFeeTable.Rows[i]["REMARK"].ToString();
newRow["ISADVANCEDPAY"] = checkFeeTable.Rows[i]["ISADVANCEDPAY"].ToString();
newRow["SHOWNAME"] = checkFeeTable.Rows[i]["SHOWNAME"].ToString();
newRow["ENTERDATE"] = checkFeeTable.Rows[i]["ENTERDATE"].ToString();
newRow["FEETYPE"] = checkFeeTable.Rows[i]["FEETYPE"].ToString();
feeTable.Rows.Add(newRow);
}
}
Session[tempCacheName] = feeTable;
}
iResult = 1;
}
else if (tempCheckType.Trim().ToLower().Equals("uncheck"))
{
for (int j = 0; j < feeTable.Rows.Count; j++)
{
if (feeTable.Rows[j]["GID"].ToString().Trim().Equals(tempFeeID))
{
feeTable.Rows.Remove(feeTable.Rows[j]);
break;
}
}
if (feeTable.Rows.Count == 0)
{
Session.Remove(tempCacheName);
}
else
{
Session[tempCacheName] = feeTable;
}
iResult = 1;
}
}
else
{
if (tempCheckType.Trim().ToLower().Equals("check"))
{
string strSql = String.Format(" SELECT A.GID, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY,"
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY,B.SHOWNAME,A.ENTERDATE,A.FEETYPE "
+ " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID "
+ " WHERE A.GID = '{0}' ORDER BY ENTERDATE ASC ", tempFeeID);
DataTable checkFeeTable = new DataTable();
FeeDA feeDA = new FeeDA();
checkFeeTable = feeDA.GetExcuteSql(strSql).Tables[0];
Session[tempCacheName] = checkFeeTable;
iResult = 1;
}
}
return iResult;
}
#endregion
#region 导入费用模板的费用明细
/// <summary>
/// 导入费用模板的费用明细
/// </summary>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>值1已经缓存明细数据 值不等于1表示没有缓存数据</returns>
private int ImportHistoryFee(string tempCacheName)
{
int iResult = 0;
if (Session[tempCacheName] != null)
{
DataTable cacheTable = (DataTable)Session[tempCacheName];
if (cacheTable.Rows.Count > 0)
{
iResult = 1;
}
else
{
iResult = -2;//没有要选择的费用明细
}
}
else
{
iResult = -1;//没有选择费用明细
}
return iResult;
}
#endregion
#region 初始化引入费用历史缓存信息
/// <summary>
/// 初始化引入费用历史缓存信息
/// </summary>
/// <param name="tempCacheName">缓存名称</param>
/// <returns>值1表示初始化成功 值不等于1表示初始化失败</returns>
private int InitImportFeeHistoryCache(string tempCacheName)
{
int iResult = 0;
if (Session[tempCacheName] != null)
{
Session.Remove(tempCacheName);
iResult = 1;
}
else
{
iResult = 1;
}
return iResult;
}
#endregion
}
}