using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using DSWeb.Authority;
using DSWeb.Log;
using DSWeb.WorkFlow;
namespace DSWeb.Settlements
{
public partial class PaySettlementGridSource : System.Web.UI.Page
{
private string strHandle;//值为payapp表示获取付费申请列表值
private string strBillNO;//申请业务编号
//private string strAppGID;//申请付费GID
private string strSearch;//查询条件
private int iCurrentPage;//当前页数
private int iShowPage;//显示最大页数
private string strUserID;
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string strRunSettleGID;//运行结算表GID
private string strPaySettleAppGID;//付费申请GID
private string strPaySettleGID;//付费结算GID
private string stroplb;//业务类别
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
//if (Request.QueryString["uid"] != null)
//{
// strUserID = Request.QueryString["uid"].ToString();
//}
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["billno"] != null)
//{
// strBillNO = Request.QueryString["billno"].ToString();
//}
//if (Request.QueryString["id"] != null)
//{
// strAppGID = Request.QueryString["id"].ToString();
//}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString();
}
if (Request.QueryString["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
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["runsettleid"] != null)
{
strRunSettleGID = Request.QueryString["runsettleid"].ToString();
}
if (Request.QueryString["id"] != null)
{
strPaySettleAppGID = Request.QueryString["id"].ToString();
}
if(Request.QueryString["paysettleid"] != null)
{
strPaySettleGID = Request.QueryString["paysettleid"].ToString();
}
if (strHandle != null)
{
//获取付费信息
if (strHandle.Equals("payapp"))
{
Response.Write(GetPayApplicationList());
return;
}
//获取付费信息
if (strHandle.Equals("payapppage"))
{
Response.Write(GetPaySettlementApplicationPageCount());
return;
}
if (strHandle.Equals("savedapp"))
{
Response.Write(GetSavedUnPostApplicationList());
return;
}
if (strHandle.Equals("savedapppage"))
{
Response.Write(GetSavedUnPostApplicationPageCount());
return;
}
//获取已保存为结算的付费
if (strHandle.Equals("paysettlesavedlist"))
{
Response.Write(GetSavedUnSettlePayList());
return;
}
//获取已保存为结算的付费导出
if (strHandle.Equals("paysettlesavedlistexcel"))
{
Response.Write(GetSavedUnSettlePayListExcel());
return;
}
//获取已保存为结算的付费总页数
if (strHandle.Equals("paysettlesavedlistpage"))
{
Response.Write(GetSavedUnSettlePayPageCount());
return;
}
//获取付费申请结算信息
if (strHandle.Equals("paysettle"))
{
Response.Write(GetPaySettleApplicationList());
return;
}
//获取付费结算信息
if (strHandle.Equals("paysettlelist"))
{
Response.Write(GetPaySettlementList());
return;
}
if (strHandle == "paysettlelistpage")
{
//获取付费结算分页总页数
Response.Write(GetPaySettlementPageCount());
}
//获取付费结算信息导出
if (strHandle.Equals("paysettlelistexcel"))
{
Response.Write(GetPaySettlementListExcel());
return;
}
//获取付费申请信息
if (strHandle.Equals("payappsettlelist"))
{
Response.Write(GetPayApplicationSettleList());
return;
}
//获取付款申请审核信息
if (strHandle.Equals("payappauditlist") && strUserID != null)
{
Response.Write(GetPayApplyAuditList());
return;
}
if (strHandle.Equals("payappauditlistpage"))
{
Response.Write(GetPayApplyAuditListPageCount());
return;
}
if (strHandle == "validatepaysettlement")
{
Response.Write(ValidateUserPaySettleAuthority());
}
if (strHandle == "validatepaysettleapp")
{
Response.Write(ValidateUserPaySettleApplicationAuthority());
}
//if (strHandle.Equals("ispayable"))
//{
// Response.Write(IsPayApplicationPayable(strBillNO,strAppGID));
//}
if (strHandle == "postsavedapp" && strRunSettleGID != null)
{
Response.Write(PostSavedPaySettleApplication(strRunSettleGID));
}
if (strHandle == "repostpayapp" && strPaySettleAppGID != null)
{
Response.Write(RePostRejectPaySettleApplication(strPaySettleAppGID));
}
//删除被驳回的付费申请
if (strHandle == "deleterejectapp" && strPaySettleAppGID != null)
{
Response.Write(DeleteRejectPaySettleApplication(strPaySettleAppGID));
}
if (strHandle == "deletesavedapp" && strRunSettleGID != null)
{
Response.Write(DeleteSavedPaySettleApplication(strRunSettleGID));
}
//删除未结算付费信息
if (strHandle == "deleteunsavedpaysettle" && strRunSettleGID != null)
{
Response.Write(DeleteSavedUnSettlePay(strRunSettleGID));
}
if (strHandle == "postunsavedpaysettle" && strRunSettleGID != null)
{
Response.Write(PostSavePaySettle(strRunSettleGID));
}
if (strHandle == "cancelpaysettle" && strPaySettleGID != null)
{
Response.Write(CacelPaySettle(strPaySettleGID));
}
}
}
#region 获取付费申请审核总页数
///
/// 获取付费申请审核总页数
///
/// 返回总页数
public int GetPayApplyAuditListPageCount()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = String.Format("SELECT COUNT(*) FROM ch_fee_payapplication as A WHERE BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{0}') ", strUserID);
string strCondition = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
//strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
strCondition += String.Format(" AND (A.BILLNO LIKE '%{0}%' or A.BILLNO in (SELECT AA.BILLNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID where C.bsno in (SELECT bsno FROM VW_Settlement where mblno like '%{0}%')))", strArg[1].Replace("\"", ""));
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
}
else
{
strCondition += " AND A.billstatus=3 ";
}
}
else
{
strCondition += " AND A.billstatus=3 ";
}
strSql += strCondition;
//
int iTotal = int.Parse(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 验证用户是否操作付费结算的权限
///
/// 验证用户是否操作付费结算的权限
///
/// 值1表示有权限操作付费结算 值不等于1表示没有权限操作付费结算
private int ValidateUserPaySettleApplicationAuthority()
{
int iResult = 0;
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
if (userAuthorityManage.OperateType != AuthorityType.NULL && userAuthorityManage.OperateType != AuthorityType.NONE)
{
iResult = 1;
}
else
{
iResult = -1;
}
return iResult;
}
#endregion
#region 验证用户是否操作付费结算的权限
///
/// 验证用户是否操作付费结算的权限
///
/// 值1表示有权限操作付费结算 值不等于1表示没有权限操作付费结算
private int ValidateUserPaySettleAuthority()
{
int iResult = 0;
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementList");
if (userAuthorityManage.OperateType != AuthorityType.NULL && userAuthorityManage.OperateType != AuthorityType.NONE)
{
iResult = 1;
}
else
{
iResult = -1;
}
return iResult;
}
#endregion
//private string IsPayApplicationPayable(string tempBillNO,string tempAppGID)
//{
// int iResult = 0;
// //先获取付费申请信息
// FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
// FeePayApplicationEntity feePayApplicationEntity = new FeePayApplicationEntity();
// feePayApplicationEntity = feePaySettleApplicationDA.GetFeePayApplicationByBillNO(tempBillNO);
// if (feePayApplicationEntity.GID != null)
// {
// //查看是否有相关流程信息,如果已经进入流程,则不能结算
// WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
// IList workFlowDoEntities = new List();
// workFlowDoEntities = workFlowDoDA.GetWorkFlowDoByBillNO(tempBillNO);
// if (workFlowDoEntities.Count > 0)
// {
// //先获取流程步骤,查看当前处理
// WorkFlowStepDA workFlowStepDA = new WorkFlowStepDA();
// WorkFlowStepEntity workFlowStepEntity = new WorkFlowStepEntity();
// workFlowStepEntity = workFlowStepDA.GetWorkFlowSteps(
// }
// }
// return iResult.ToString();
//}
#region 获取已保存未申请的付费申请分页总页数
///
/// 获取已保存未申请的付费申请分页总页数
///
/// 返回总页数
private int GetSavedUnPostApplicationPageCount()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = "SELECT COUNT(*) FROM run_fee_settlement as A WHERE TYPE = 1 AND CREATEUSER = '" + strUserID + "' ";
string strCondition = "";
string strSearchSettle = "";//" AND A.BILLSTATUS <> 4 ";
//string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, 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"://Customer
strCondition += String.Format(" AND convert(char(10),CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
//strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://ETD EndDate
//strCondition += String.Format(" AND (A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where (CUSTNO LIKE '%{0}%' or MBLNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%'))))", strArg[1].Replace("\"", ""));
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
strSearchSettle = "";
}
}
strSql += strSearchSettle + strCondition;
int iTotal = int.Parse(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 获取付费申请结算分页总页数
///
/// 获取付费申请结算分页总页数
///
/// 返回总页数
private int GetPaySettlementApplicationPageCount()
{
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "AC";
//FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
//string strSql = "SELECT COUNT(*) FROM ch_fee_payapplication as A WHERE BILLNO LIKE '%AC%' ";
//string strCondition = "";
//string strAuthorityCondition = "";
//string strSearchSettle = " AND A.BILLSTATUS <> 4 ";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, 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"://Customer
// strCondition += String.Format(" AND convert(char(10),APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
// break;
// case "etime"://BillNO
// strCondition += String.Format(" AND convert(char(10),APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
// break;
// case "cus"://ETD BeginDate
// strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
// break;
// case "no"://ETD EndDate
// //strCondition += String.Format(" AND (A.BILLNO LIKE '%{0}%' or E.CUSTNO LIKE '%{0}%' or E.MBLNO LIKE '%{0}%' or E.HBLNO LIKE '%{0}%' or E.CUSTOMNO LIKE '%{0}%' OR E.CUSTOMNO2 LIKE '%{0}%')", strArg[1].Replace("\"", ""));
// strCondition += String.Format(" AND (A.BILLNO LIKE '%{0}%' or (A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where (CUSTNO LIKE '%{0}%' or MBLNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%')))))", strArg[1].Replace("\"", ""));
// break;
// case "billstatus":
// string strbillstatus = strArg[1].Replace("\"", "");
// if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
// {
// strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
// }
// break;
// default:
// break;
// }
// }
// }
// strSearchSettle = "";
// }
//}
//strSql += strSearchSettle + strCondition;
//2014-05-27 修改
string strCondition = "";
string strSearchSettle = " AND BILLSTATUS <> 4 ";
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.APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%'))", strArg[1].Replace("\"", ""));
break;
case "other"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where (CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%')))", strArg[1].Replace("\"", ""));//CUSTNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
}
strSearchSettle = "";
}
//
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
}
//
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = String.Format(" SELECT count(*) FROM ch_fee_payapplication as A WHERE 1>0 {0} {1} {2} ", strSearchSettle, strAuthorityCondition, strCondition);
int iTotal = int.Parse(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
#region 获取付费结算分页总页数
///
/// 获取付费结算分页总页数
///
/// 返回总页数
private int GetPaySettlementPageCount()
{
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "CR";
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = "SELECT COUNT(*) FROM ch_fee_settlement as A WHERE BILLNO LIKE '%CR%' AND ISNULL(ISDELETE,0) <> 1 ";
string strAmount1 = "";
string strAmount2 = "";
string strCondition = "";
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLELIST, 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":
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime":
strCondition += String.Format(" AND convert(char(10),SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus":
strCondition += String.Format(" AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')) and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%') and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "amount1":
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2":
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
//
strSql += strCondition;
}
}
int iTotal = int.Parse(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
public string GetPayApplicationSettleList()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
string strCondition = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus":
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND (A.BILLNO LIKE '%{0}%' or A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%')) or A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')))) ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
//string strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + ",OPLB=(SELECT top 1 'op_seae' OPLB FROM op_seae WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO) union all (SELECT top 1 'op_seai' OPLB FROM op_seai WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO)))"
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID WHERE A.BILLSTATUS <> 3 AND A.BILLSTATUS <> 6 AND"
// + "(BILLNO not in(select BILLNO from ch_fee_do where FEEID in(select feeid from ch_fee_do where BILLNO like 'CR%' and (ISDELETED=0 or ISDELETED is null)))) "//A.BILLSTATUS <> 4 or
// + " ORDER BY A.APPLYTIME DESC ";
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "CR";
//2013-02-05 修改
//string strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + ",OPLB=(SELECT top 1 OPLB FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID WHERE A.BILLSTATUS <> 3 AND A.BILLSTATUS <> 6 AND A.BILLSTATUS <> 4 "
// //+ " AND (BILLNO not in(select BILLNO from ch_fee_do where FEEID in(select feeid from ch_fee_do where BILLNO like '%CR%' and AMOUNT=DOAMOUNT and (ISDELETED=0 or ISDELETED is null)))) "//A.BILLSTATUS <> 4 or //此语句需最少58秒才能查出,会造成查询超时。
// + " AND (BILLNO in(select BILLNO from ch_fee_do where FEEID not in(select feeid from ch_fee_do where BILLNO like '%CR%' and AMOUNT=DOAMOUNT and (ISDELETED=0 or ISDELETED is null)))) "//A.BILLSTATUS <> 4 or //
// + strCondition
// + " ORDER BY A.APPLYTIME DESC ";
//2014-01-18 修改
string strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD-isnull(A.SETTLEUSD,0) as AMOUNTUSD,(A.AMOUNTRMB-isnull(A.SETTLERMB,0)) as AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ ",OPLB=(SELECT top 1 OPLB FROM VW_Settlement WHERE BSNO=(SELECT top 1 C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID WHERE A.BILLSTATUS <> 3 AND A.BILLSTATUS <> 6 AND A.BILLSTATUS <> 4 "
//1-Begin 修改2014-02-20
//+ " AND ( EXISTS (select 1 from ch_fee_do d1 where "
//+ " NOT EXISTS (select 1 from ch_fee_do d2 where d2.BILLNO like '%CR%' and d2.AMOUNT=d2.DOAMOUNT and (d2.ISDELETED=0 or d2.ISDELETED is null) and d1.FEEID=d2.FEEID) "
//+ " and A.BILLNO=d1.BILLNO "
//+ " and billno NOT in (select billno from ch_fee_do as d3 where feeid in (select feeid from ch_fee_do as d2 where (d2.BILLNO like '%CR%' or d2.BILLNO like '%DR%') and d2.AMOUNT=d2.DOAMOUNT and (d2.ISDELETED=0 or d2.ISDELETED is null) and (CATEGORY=2 or CATEGORY=8)))"
//+ ")) "
//1-End
//1-Begin 修改2014-03-03
+ " AND (EXISTS (select gid from ch_fee_do d1 where NOT EXISTS (select f.gid from (select feeid,sum(AMOUNT) as AMOUNT from (select feeid,AMOUNT from ch_fee_do where (billno like '%CR%' or billno like '%DR%') and (ISDELETED is null or ISDELETED=0) and AMOUNT=DOAMOUNT) as a group by a.feeid) as d LEFT OUTER JOIN ch_fee as f on f.gid=d.feeid where f.AMOUNT=d.AMOUNT and d1.FEEID=f.gid) and A.BILLNO=d1.BILLNO)) "
//1-End
+ strCondition
+ " ORDER BY A.APPLYTIME DESC ";
sourceTable = getStatusNameTableBillStatus(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
public string GetPayApplyAuditList()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
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.APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
//strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
strCondition += String.Format(" AND (A.BILLNO LIKE '%{0}%' or A.BILLNO in (SELECT AA.BILLNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID where C.bsno in (SELECT bsno FROM VW_Settlement where mblno like '%{0}%')))", strArg[1].Replace("\"", ""));
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if(strbillstatus.Trim()!="7" && strbillstatus.Trim()!="")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
}
else
{
strCondition += " AND A.billstatus=3 ";
}
}
else
{
strCondition += " AND A.billstatus=3 ";
}
//
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " WHERE BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{1}') "
// + strCondition + " ORDER BY BILLNO DESC ", "top " + iShowPage.ToString(), strUserID);
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{1}') {2} "
// //+ " ORDER BY BILLNO DESC "
// + " union all "
// + " SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{1}') {2} "
// + " ORDER BY BILLNO DESC "
// , "top " + iShowPage.ToString(), strUserID,strCondition);
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + ",OPLB=(SELECT top 1 'op_seae' OPLB FROM op_seae WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO) union all (SELECT top 1 'op_seai' OPLB FROM op_seai WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO)))"
// + " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
// + " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{1}') {2} ORDER BY APPLYTIME DESC"
// , "top " + iShowPage.ToString(), strUserID, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME"
//+ ",MBLNO=(SELECT top 1 MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ ",OPLB=(SELECT top 1 OPLB FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
+ " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{1}') {2} ORDER BY APPLYTIME DESC"
, "top " + iShowPage.ToString(), strUserID, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID "
// + " WHERE C.AUDITOR = '{1}') AND A.GID NOT IN "
// + " (SELECT {2} A.GID FROM ch_fee_payapplication A WHERE A.BILLNO IN (SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{1}') {3} "
// + " ORDER BY A.BILLNO DESC ) {3} "
// //+ " ORDER BY BILLNO DESC "
// + " union all "
// + " SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID "
// + " WHERE C.AUDITOR = '{1}') AND C.GID NOT IN "
// + " (SELECT {2} A.GID FROM ch_fee_payapplication as A WHERE A.BILLNO IN (SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{1}') {3} "
// + " ORDER BY A.BILLNO DESC ) {3} "
// + " ORDER BY BILLNO DESC "
// , strTopInclude, strUserID, strTopNotInclude, strCondition);
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.SETTLETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + " FROM ch_fee_settlement as A LEFT JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE 'CR%' AND ISNULL(A.ISDELETE,0) <> 1 AND A.GID NOT IN "
// + " (SELECT {1} GID FROM ch_fee_settlement WHERE BILLNO LIKE 'CR%' AND ISNULL(ISDELETE,0) <> 1 " + strAuthorityCondition + strCondition + " ORDER BY BILLNO DESC ) " + strAuthorityCondition + strCondition
// + " ORDER BY BILLNO DESC ", strTopInclude, strTopNotInclude);
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + ",OPLB=(SELECT top 1 'op_seae' OPLB FROM op_seae WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO) union all (SELECT top 1 'op_seai' OPLB FROM op_seai WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO)))"
// + " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.gid NOT IN "
// + " (SELECT {2} A.GID FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
// + " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{1}') {3} ORDER BY APPLYTIME DESC) {3} ORDER BY APPLYTIME DESC"
// , strTopInclude, strUserID, strTopNotInclude, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME"
//+ ",MBLNO=(SELECT top 1 MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ ",OPLB=(SELECT top 1 OPLB FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.gid NOT IN "
+ " (SELECT {2} A.GID FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
+ " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{1}') {3} ORDER BY APPLYTIME DESC) {3} ORDER BY APPLYTIME DESC"
, strTopInclude, strUserID, strTopNotInclude, strCondition);
}
}
else
{
//strSql = String.Format(" SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{0}') {1} "
// //+ " ORDER BY BILLNO DESC "
// + " union all "
// + " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE A.BILLNO IN ( SELECT B.BILLNO FROM workflow_do as B INNER JOIN workflow_step as C ON B.STEPID = C.GID WHERE C.AUDITOR = '{0}') {1} "
// + " ORDER BY BILLNO DESC "
// , strUserID, strCondition);
//strSql = String.Format(" SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + ",OPLB=(SELECT top 1 'op_seae' OPLB FROM op_seae WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO) union all (SELECT top 1 'op_seai' OPLB FROM op_seai WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO)))"
// + " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
// + " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{0}') {1} ORDER BY APPLYTIME DESC"
// , strUserID, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME"
//+ ",MBLNO=(SELECT top 1 MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME as APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ ",OPLB=(SELECT top 1 OPLB FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as AA INNER JOIN ch_fee_do as B ON AA.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE AA.BILLNO =A.BILLNO))"
+ " FROM ch_fee_payapplication A inner JOIN [user] B ON A.APPLICANT = B.GID where A.BILLNO in "
+ " ( select A.BILLNO from workflow_do A inner join workflow_step B on A.STEPID=B.GID where B.AUDITOR='{0}') {1} ORDER BY APPLYTIME DESC"
, strUserID, strCondition);
}
sourceTable = getStatusNameTableBillStatus(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
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();
}
#region 获取付费申请单信息
///
/// 获取付费申请单信息
///
///
public string GetPaySettleApplicationList()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
string strSql = "SELECT GID,BILLNO,BILLSTATUS,CUSTOMERNAME,AMOUNTUSD,AMOUNTRMB,APPLICANT,APPLYTIME,REMARK FROM ch_fee_settlement ORDER BY BILLNO DESC ";
sourceTable = getStatusNameTableBillStatus(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取付费结算信息
///
/// 获取付费结算信息
///
///
public string GetPaySettlementList()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime":
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime":
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus":
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')) and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%') and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "amount1":
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2":
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
}
string strSql = "";
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
}
////获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "CR";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", CHEQUENUM=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY='RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ", CHEQUENUMUSD=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY<>'RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM ch_fee_settlement as A LEFT JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%CR%' AND ISNULL(A.ISDELETE,0) <> 1 " + strAuthorityCondition + strCondition + " ORDER BY BILLNO DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", CHEQUENUM=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY='RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ", CHEQUENUMUSD=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY<>'RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM ch_fee_settlement as A LEFT JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%CR%' AND ISNULL(A.ISDELETE,0) <> 1 AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_settlement WHERE BILLNO LIKE '%CR%' AND ISNULL(ISDELETE,0) <> 1 " + strAuthorityCondition + strCondition + " ORDER BY BILLNO DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY BILLNO DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE"
+ ", CHEQUENUM=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY='RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ", CHEQUENUMUSD=isnull((select top 1 CHEQUENUM from ch_fee where CURRENCY<>'RMB' and gid in (select feeid from ch_fee_do where billno=A.billno)),'')"
+ ",A.AMOUNTUSD,A.AMOUNTRMB,A.AHSR_MONEY,B.SHOWNAME,A.SETTLETIME,"
+ " dbo.F_SQDH(A.BILLNO) as SQDH,"
+ " replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM ch_fee_settlement as A LEFT JOIN [user] as B ON A.SETTLEUSER = B.GID "
+ " WHERE BILLNO LIKE '%CR%' AND ISNULL(A.ISDELETE,0) <> 1 " + strAuthorityCondition + strCondition + " ORDER BY A.BILLNO DESC ";
}
sourceTable = getFeeSettlementBillStatus(feeSettlementDA.GetExcuteSql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取付费结算信息导出
///
/// 获取付费结算信息导出
///
///
public string GetPaySettlementListExcel()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
string strCondition = "";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND A.SETTLETIME <= '{0} 23:59:59' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')) and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%') and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "amount1"://
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2"://
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
}
string strSql = "";
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettlementList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
}
//获取分公司的票号头字符
//T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
//string strFeeType = tempBANKSHEAD + "CR";
//
strSql = " SELECT A.BILLNO,case A.BILLSTATUS when 1 then '锁定' when 2 then '未锁定' when 3 then '结算撤销' else '' end as BILLSTATUS,case A.SETTLEMODE when 1 then '申请' when 2 then '自由' when 3 then '发票' when 4 then '流程' else '' end as SETTLEMODE,A.CUSTOMERNAME,case A.SETTLETYPE when 1 then '现金' when 2 then '支票' when 3 then '电汇' when 4 then '转账' when 5 then '承兑汇票' else '' end as SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.SETTLETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM ch_fee_settlement as A LEFT JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE BILLNO LIKE '%CR%' AND ISNULL(A.ISDELETE,0) <> 1 " + strAuthorityCondition + strCondition + " ORDER BY BILLNO DESC ";
return strSql.Trim();
}
#endregion
public string GetPayApplicationList()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSearchSettle = " AND BILLSTATUS <> 4 ";
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.APPLYTIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.APPLYTIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%'))", strArg[1].Replace("\"", ""));
break;
case "other"://ETD EndDate
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where (CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%')))", strArg[1].Replace("\"", ""));//CUSTNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
}
strSearchSettle = "";
}
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{ //付费申请列表
#region
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {1} {2} {3} "
// //+ " ORDER BY BILLNO DESC "
// + " union all "
// + " SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {1} {2} {3} "
// + " ORDER BY A.BILLNO DESC "
// , "top " + iShowPage.ToString(), strSearchSettle, strAuthorityCondition, strCondition);
//2013-02-05 修改
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join VW_Settlement as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {1} {2} {3} "
// + " ORDER BY A.BILLNO DESC "
// , "top " + iShowPage.ToString(), strSearchSettle, strAuthorityCondition, strCondition);
//2013-07-12 修改
#endregion
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB"
+ ",(select top 1 SHOWNAME from [user] where gid=a.APPLICANT) AS APPLICANT"
+ ",A.APPLYTIME,dbo.F_JSDH(A.BILLNO) JSDH,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK"
+ ",(select top 1 OPLB from VW_Settlement where bsno in (select bsno from ch_fee_do where billno=a.billno)) AS OPLB"
+ " FROM ch_fee_payapplication as A "
+ " WHERE 1>0 {1} {2} {3} "
+ " ORDER BY A.BILLNO DESC "
, "top " + iShowPage.ToString(), strSearchSettle, strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
#region
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " WHERE 1>0 " + strSearchSettle + " AND A.GID NOT IN "
// + " (SELECT {1} GID FROM ch_fee_payapplication WHERE 1>0 " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY BILLNO DESC ) " + strAuthorityCondition + strCondition
// + " ORDER BY BILLNO DESC ", strTopInclude, strTopNotInclude);
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {2} AND A.GID NOT IN "
// + " (SELECT {1} GID FROM ch_fee_payapplication WHERE 1>0 {2} {3} {4} ORDER BY BILLNO DESC ) {3} {4} "
// //+ " ORDER BY BILLNO DESC "
// + " union all "
// + " SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {2} AND A.GID NOT IN "
// + " (SELECT {1} GID FROM ch_fee_payapplication WHERE 1>0 {2} {3} {4} ORDER BY BILLNO DESC ) {3} {4} "
// + " ORDER BY A.BILLNO DESC "
// , strTopInclude, strTopNotInclude, strSearchSettle, strAuthorityCondition, strCondition);
//2013-02-05 修改
//strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join VW_Settlement as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {2} AND A.GID NOT IN "
// + " (SELECT {1} GID FROM ch_fee_payapplication WHERE 1>0 {2} {3} {4} ORDER BY BILLNO DESC ) {3} {4} "
// + " ORDER BY A.BILLNO DESC "
// , strTopInclude, strTopNotInclude, strSearchSettle, strAuthorityCondition, strCondition);
#endregion
//2013-07-12 修改
strSql = String.Format(" SELECT {0} A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB"
+ ",(select top 1 SHOWNAME from [user] where gid=a.APPLICANT) AS APPLICANT"
+ ",A.APPLYTIME,dbo.F_JSDH(A.BILLNO) JSDH,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK"
+ ",(select top 1 OPLB from VW_Settlement where bsno in (select bsno from ch_fee_do where billno=a.billno)) AS OPLB"
+ " FROM ch_fee_payapplication as A "
+ " WHERE 1>0 {2} AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_payapplication A WHERE 1>0 {2} {3} {4} ORDER BY BILLNO DESC ) {3} {4} "
+ " ORDER BY A.BILLNO DESC "
, strTopInclude, strTopNotInclude, strSearchSettle, strAuthorityCondition, strCondition);
}
}
else
{
//strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID WHERE 1>0 " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY A.BILLNO DESC ";
//strSql = String.Format(" SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seae' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seae as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {0} {1} {2} "
// //+ " ORDER BY A.BILLNO DESC "
// + " union all "
// + " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.APPLYTIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,'op_Seai' OPLB "
// + " FROM ch_fee_payapplication as A LEFT JOIN [user] as B ON A.APPLICANT = B.GID "
// + " INNER JOIN ch_fee_do as C ON A.BILLNO = C.BILLNO "
// + " inner join op_seai as E on C.BSNO =E.BSNO "
// + " WHERE 1>0 {0} {1} {2} "
// + " ORDER BY A.BILLNO DESC "
// ,strSearchSettle , strAuthorityCondition, strCondition);
//2013-02-05 修改
strSql = " SELECT A.GID,A.BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB"
+ ",(select top 1 SHOWNAME from [user] where gid=a.APPLICANT) AS APPLICANT"
+ ",A.APPLYTIME,dbo.F_JSDH(A.BILLNO) JSDH,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK"
+ ",(select top 1 OPLB from VW_Settlement where bsno in (select bsno from ch_fee_do where billno=a.billno)) AS OPLB"
+ " FROM ch_fee_payapplication as A WHERE 1<0";
}
sourceTable = getStatusNameTableBillStatus(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
public string GetSavedUnPostApplicationList()
{
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSearchSettle = "";//" AND A.BILLSTATUS <> 4 ";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
//strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://ETD EndDate
//strCondition += String.Format(" AND (A.BILLNO in (select BILLNO from ch_fee_do where bsno in (select bsno from VW_Settlement where (CUSTNO LIKE '%{0}%' or MBLNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%'))))", strArg[1].Replace("\"", ""));
break;
case "billstatus":
string strbillstatus = strArg[1].Replace("\"", "");
if (strbillstatus.Trim() != "7" && strbillstatus.Trim() != "")
{
strCondition += String.Format(" AND A.billstatus={0} ", strbillstatus);
}
break;
default:
break;
}
}
}
}
strSearchSettle = "";
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
//strSql = String.Format(" SELECT {0} A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select 'op_Seae' as OPLB from op_seae where BSNO =C.BSNO union all select 'op_Seae' as OPLB from op_seai where BSNO =C.BSNO) "
// + " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
// + " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
// + " WHERE A.TYPE = 1 AND A.CREATEUSER = '{1}' {2} {3} {4}"
// + " ORDER BY A.CREATETIME DESC "
// , "top " + iShowPage.ToString(), strUserID, strSearchSettle, strAuthorityCondition, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT {0} A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select OPLB from VW_Settlement where BSNO =C.BSNO) "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
+ " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
+ " WHERE A.TYPE = 1 AND A.CREATEUSER = '{1}' {2} {3} {4}"
+ " ORDER BY A.CREATETIME DESC "
, "top " + iShowPage.ToString(), strUserID, strSearchSettle, strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
//strSql = String.Format(" SELECT {0} A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select 'op_Seae' as OPLB from op_seae where BSNO =C.BSNO union all select 'op_Seae' as OPLB from op_seai where BSNO =C.BSNO) "
// + " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
// + " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
// + " WHERE A.TYPE = 1 AND A.CREATEUSER = '{2}' {3} AND A.GID NOT IN "
// + " (SELECT {1} GID FROM run_fee_settlement WHERE TYPE = 1 AND CREATEUSER = '{2}' {3} {4} {5} "
// + " ORDER BY CREATETIME DESC ) {4} {5} "
// + " ORDER BY CREATETIME DESC "
// , strTopInclude, strTopNotInclude, strUserID, strSearchSettle, strAuthorityCondition, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT {0} A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select OPLB from VW_Settlement where BSNO =C.BSNO) "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
+ " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
+ " WHERE A.TYPE = 1 AND A.CREATEUSER = '{2}' {3} AND A.GID NOT IN "
+ " (SELECT {1} GID FROM run_fee_settlement WHERE TYPE = 1 AND CREATEUSER = '{2}' {3} {4} {5} "
+ " ORDER BY CREATETIME DESC ) {4} {5} "
+ " ORDER BY CREATETIME DESC "
, strTopInclude, strTopNotInclude, strUserID, strSearchSettle, strAuthorityCondition, strCondition);
}
}
else
{
//strSql = String.Format(" SELECT A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select 'op_Seae' as OPLB from op_seae where BSNO =C.BSNO union all select 'op_Seae' as OPLB from op_seai where BSNO =C.BSNO) "
// + " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
// + " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
// + " WHERE A.TYPE = 1 AND A.CREATEUSER = '{0}' {1} {2} {3} "
// + " ORDER BY A.CREATETIME DESC "
// , strUserID, strSearchSettle, strAuthorityCondition, strCondition);
//2013-02-05 修改
strSql = String.Format(" SELECT A.GID,'' AS BILLNO,A.BILLSTATUS,A.CUSTOMERNAME,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME AS APPLICANT,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK,OPLB=(select OPLB from VW_Settlement where BSNO =C.BSNO) "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID "
+ " INNER JOIN run_fee_do as C ON A.GID = C.RUNSETTLEID "
+ " WHERE A.TYPE = 1 AND A.CREATEUSER = '{0}' {1} {2} {3} "
+ " ORDER BY A.CREATETIME DESC "
, strUserID, strSearchSettle, strAuthorityCondition, strCondition);
}
sourceTable = getStatusNameTableBillStatus(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
///
/// 付费申请列表保存未结算查询
///
///
public string GetSavedUnSettlePayList()
{
FeePaySettleDA feePaySettleDA = new FeePaySettleDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSearchSettle = "";//" AND A.BILLSTATUS <> 4 ";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime":
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime":
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus":
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')) and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%') and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "amount1":
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2":
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
strSearchSettle = "";
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,SERIALNO AS BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.CHEQUENO,A.CHEQUENOUSD,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.TYPE = 2 AND A.CREATEUSER = '" + strUserID + "' " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY CREATETIME DESC ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,SERIALNO AS BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.CHEQUENO,A.CHEQUENOUSD,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.TYPE = 2 AND A.CREATEUSER = '" + strUserID + "' " + strSearchSettle + " AND A.GID NOT IN "
+ " (SELECT {1} GID FROM run_fee_settlement WHERE TYPE = 2 AND CREATEUSER = '" + strUserID + "' " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY CREATETIME DESC ) " + strAuthorityCondition + strCondition
+ " ORDER BY CREATETIME DESC ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = " SELECT A.GID,SERIALNO AS BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.CHEQUENO,A.CHEQUENOUSD,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.TYPE = 2 AND A.CREATEUSER = '" + strUserID + "' " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY A.CREATETIME DESC ";
}
sourceTable = getStatusNameTableBillStatus(feePaySettleDA.GetDataSetBySql(strSql).Tables[0]);
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
///
/// 付费申请列表保存未结算查询导出
///
///
public string GetSavedUnSettlePayListExcel()
{
FeePaySettleDA feePaySettleDA = new FeePaySettleDA();
string strCondition = "";
string strSearchSettle = "";//" AND A.BILLSTATUS <> 4 ";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no":
strCondition += String.Format(" AND A.BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "mblno":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where bsno in (select bsno from VW_Settlement where MBLNO LIKE '%{0}%')) and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "other":
strCondition += String.Format(" AND A.BILLNO in (select BILLNO from ch_fee_do where feeid in (select gid from ch_fee where CHEQUENUM LIKE '%{0}%') and BILLNO LIKE '%CR%') ", strArg[1].Replace("\"", ""));
break;
case "amount1"://
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2"://
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
strSearchSettle = "";
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
string strSql = "";
strSql = String.Format(" SELECT SERIALNO AS BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.CREATETIME,replace(replace(A.REMARK,char(13),'|'),char(10),'') REMARK "
+ " FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.TYPE = 2 AND A.CREATEUSER = '" + strUserID + "' " + strSearchSettle + strAuthorityCondition + strCondition + " ORDER BY CREATETIME DESC ");
return strSql.Trim();
}
#region 获取已保存未结算的付费分页总页数
///
/// 获取已保存未结算的付费分页总页数
///
/// 返回总页数
private int GetSavedUnSettlePayPageCount()
{
FeePaySettleDA feePaySettleDA = new FeePaySettleDA();
string strCondition = "";
string strSearchSettle = "";
string strAmount1 = "";
string strAmount2 = "";
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
case "btime"://Customer
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.CREATETIME,120) <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://ETD BeginDate
strCondition += String.Format(" AND A.CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "no"://ETD EndDate
strCondition += String.Format(" AND A.SERIALNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "amount1"://
//strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strArg[1].Replace("\"", ""));
strAmount1 = strArg[1].Replace("\"", "");
break;
case "amount2"://
//strCondition += String.Format(" AND (A.AMOUNTRMB <= '{0}' or A.AMOUNTUSD <= '{0}')", strArg[1].Replace("\"", ""));
strAmount2 = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
//
if (strAmount1.Trim() != "" && strAmount2.Trim() != "")
{
strCondition += String.Format(" AND ((A.AMOUNTRMB >= '{0}' and A.AMOUNTRMB <= '{1}') or (A.AMOUNTUSD >= '{0}' and A.AMOUNTUSD <= '{1}'))", strAmount1.Trim(), strAmount2.Trim());
}
else
{
if (strAmount1.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB >= '{0}' or A.AMOUNTUSD >= '{0}')", strAmount1.Trim());
}
else if (strAmount2.Trim() != "")
{
strCondition += String.Format(" AND (A.AMOUNTRMB <= '{1}' or A.AMOUNTUSD <= '{1}')", strAmount2.Trim());
}
}
}
strSearchSettle = "";
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPaySettleAppList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYSETTLEAPPLIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
string strSql = " SELECT COUNT(*) FROM run_fee_settlement as A LEFT JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.TYPE = 2 AND A.CREATEUSER = '" + strUserID + "' " + strSearchSettle + strAuthorityCondition + strCondition;
int iTotal = int.Parse(feePaySettleApplicationDA.GetDataSetBySql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal;
}
#endregion
public string GetSeaeOrderBySearch(string tempSearch)
{
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string[] searchArg = tempSearch.Split(new char[] { ',' });
string strSeaeCondition = "";
for (int i = 0; i < searchArg.Length; i++)
{
string[] strArg = searchArg[i].Split(new char[] { ':' });
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
switch (strArg[0].Replace("\"", ""))
{
//case "cus"://Customer
// strSeaeCondition += String.Format("AND CUSTOMERNAME LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
// break;
case "bno"://BillNO
strSeaeCondition += String.Format(" AND (CUSTNO LIKE '%{0}%' OR MBLNO LIKE '%{0}%' OR HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "bt"://ETD BeginDate
strSeaeCondition += String.Format(" AND ETD >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "et"://ETD EndDate
strSeaeCondition += String.Format(" AND ETD <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "ves"://Vessel
strSeaeCondition += String.Format(" AND VESSEL LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "voy"://Voyno
strSeaeCondition += String.Format(" AND VOYNO LIKE '%{0}%' ", strArg[1].Replace("\"", ""));
break;
//case "deno"://DebitNO
// //strSqlCondition += String.Format(" VOYNO LIKE '%{0}%' ", strArg[1]);
// break;
//case "ise"://IsSettled
// break;
//case "fty"://FeeType
// strSqlCondition += String.Format(" FEETYPE = {0} ", strArg[1]);
// break;
//case "cur"://Currency
// strSqlCondition += String.Format(" FEETYPE = {0} ", strArg[1]);
// break;
default:
break;
}
}
}
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
//string strSql = "SELECT BSNO, CUSTOMERNAME,MBLNO,HBLNO FROM op_seae WHERE 1 > 0 AND BSNO IN ( "
// + "SELECT BSNO FROM ch_fee WHERE GID IN"
// + "(SELECT A.GID FROM ch_fee as A LEFT JOIN ch_fee_do as B ON A.GID = B.FEEID WHERE FEEID IS NULL) AND (FEESTATUS = 8 OR FEESTATUS = 0))"
// + strSeaeCondition;
//2013-02-05 修改
string strSql = "SELECT BSNO, CUSTOMERNAME,MBLNO,HBLNO FROM VW_Settlement WHERE 1 > 0 AND BSNO IN ( "
+ "SELECT BSNO FROM ch_fee WHERE GID IN"
+ "(SELECT A.GID FROM ch_fee as A LEFT JOIN ch_fee_do as B ON A.GID = B.FEEID WHERE FEEID IS NULL) AND (FEESTATUS = 8 OR FEESTATUS = 0))"
+ strSeaeCondition;
sourceTable = feeSettlementDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
private DataTable getFeeSettlementBillStatus(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("SETTLEMODE"))
{
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("SETTLETYPE"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = sourceTable.Columns[j].DataType;
cloneTable.Columns.Add(newColumn);
}
}
iSwitch = 1;
}
DataRow cloneRow = cloneTable.NewRow();
for (int k = 0; k < sourceTable.Columns.Count; k++)
{
if (sourceTable.Columns[k].ColumnName.Equals("BILLSTATUS"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "锁定";
break;
case 2:
strFeeStatus = "未锁定";
break;
case 3:
strFeeStatus = "结算撤销";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("SETTLEMODE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "申请";
break;
case 2:
strFeeStatus = "自由";
break;
case 3:
strFeeStatus = "发票";
break;
case 4:
strFeeStatus = "流程";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("SETTLETYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "现金";
break;
case 2:
strFeeStatus = "支票";
break;
case 3:
strFeeStatus = "电汇";
break;
case 4:
strFeeStatus = "转账";
break;
case 5:
strFeeStatus = "承兑汇票";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
return cloneTable;
}
private DataTable getStatusNameTableBillStatus(DataTable tempTable)
{
DataTable sourceTable = tempTable;
DataTable cloneTable = new DataTable();
int iSwitch = 0;
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (iSwitch == 0)
{
for (int j = 0; j < sourceTable.Columns.Count; j++)
{
if (sourceTable.Columns[j].ColumnName.Equals("BILLSTATUS"))
{
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("SETTLEMODE"))
{
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("SETTLETYPE"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = sourceTable.Columns[j].DataType;
cloneTable.Columns.Add(newColumn);
}
}
iSwitch = 1;
}
DataRow cloneRow = cloneTable.NewRow();
for (int k = 0; k < sourceTable.Columns.Count; k++)
{
if (sourceTable.Columns[k].ColumnName.Equals("BILLSTATUS"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 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;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("SETTLEMODE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "申请";
break;
case 2:
strFeeStatus = "自由";
break;
case 3:
strFeeStatus = "发票";
break;
case 4:
strFeeStatus = "流程";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("SETTLETYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "现金";
break;
case 2:
strFeeStatus = "支票";
break;
case 3:
strFeeStatus = "电汇";
break;
case 4:
strFeeStatus = "转账";
break;
case 5:
strFeeStatus = "承兑汇票";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
return cloneTable;
}
///
/// 提交包保存的申请
///
///
///
private int PostSavedPaySettleApplication(string tempRunSettleGID)
{
int iResult = 0;
T_ALL_DA t_all_da = new T_ALL_DA();
int bsnoCount = 0;
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
DataSet ds = t_all_da.GetAllSQL("select gid,OPLBNAME=(select top 1 OPLBNAME from VW_Settlement where bsno=run_fee_do.bsno),bsno,mblno from [run_fee_do] where runsettleid='" + tempRunSettleGID.Trim() + "'");//获取费用运行明细表中的数据(根据RUNSETTLEID)
if (ds!=null&&ds.Tables[0].Rows.Count > 1)
{
string topBsno = ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim();
for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
{
if (topBsno != ds.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim())
{
bsnoCount++;
}
else
{
continue;
}
}
}
string strFeePayApplicationID = Guid.NewGuid().ToString();
iResult = feePaySettleApplicationDA.PostSavedPaySettleRequest(strFeePayApplicationID, tempRunSettleGID, strUserID, "", strCompanyID);
if (iResult == 1)
{
strBillNO = feePaySettleApplicationDA.GetBillNoByPaySettleAppID(strFeePayApplicationID);
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb.ToLower() == "op_seae")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_seai")
{
//
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.tMsWlPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.WmszxPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "import_main")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
else if (stroplb.ToLower() == "op_apply")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_bulk")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
IList workFlowDoEntities = new List();
if (workFlowEntity != null)
{
//消息系统
IList messageEntities = new List();
MessageDA messageDA = new MessageDA();
WorkFlowDoEntity workFlowDoEntity = null;
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strBillNO);
if (workFlowDoEntity == null)
{
if (workFlowDoEntity.GID == null)
{
//workFlowDoEntity = new WorkFlowDoEntity();
//遍历所有工作流下步骤,获取第一步骤GID信息
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
if (step.StepNO == 1)
{
WorkFlowDoEntity paySettleWorkFlowDoEntity = new WorkFlowDoEntity();
paySettleWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
paySettleWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
paySettleWorkFlowDoEntity.StepID = step.GID;
paySettleWorkFlowDoEntity.StepNO = step.StepNO;
paySettleWorkFlowDoEntity.Auditor = step.Auditor;
paySettleWorkFlowDoEntity.BillNO = strBillNO;
paySettleWorkFlowDoEntity.IsFinish = false;
paySettleWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(paySettleWorkFlowDoEntity);
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
messageEntity.Description = "付费申请审核";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 业务编号:" + strBillNO + " 提交待审核 [付费申请] ";
messageEntity.TaskID = strBillNO;
messageEntity.Receiver = step.Auditor;
messageEntity.TaskUrl = messageEntity.TaskUrl = "settlements/feepayaudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAYAPP);
messageEntity.RecvType = 2;//申请审核类型
messageEntities.Add(messageEntity);
}
}
workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
feePaySettleApplicationDA.UpdatePayApplicationStatus(strBillNO, 3, strCompanyID);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
}
}
else
{
if (workFlowDoEntity.GID == null)
{
//workFlowDoEntity = new WorkFlowDoEntity();
//遍历所有工作流下步骤,获取第一步骤GID信息
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
if (step.StepNO == 1)
{
WorkFlowDoEntity paySettleWorkFlowDoEntity = new WorkFlowDoEntity();
paySettleWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
paySettleWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
paySettleWorkFlowDoEntity.StepID = step.GID;
paySettleWorkFlowDoEntity.StepNO = step.StepNO;
paySettleWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
paySettleWorkFlowDoEntity.FeeID = "";
paySettleWorkFlowDoEntity.BSNO = "";
paySettleWorkFlowDoEntity.FeeStatus = 0;
paySettleWorkFlowDoEntity.DoQuerySql = "";
paySettleWorkFlowDoEntity.BillNO = strBillNO;
paySettleWorkFlowDoEntity.IsFinish = false;
paySettleWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(paySettleWorkFlowDoEntity);
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
messageEntity.Description = "付费申请审核";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 业务编号:" + strBillNO + " 提交待审核 [付费申请] ";
messageEntity.TaskID = strBillNO;
messageEntity.Receiver = step.Auditor;
messageEntity.TaskUrl = messageEntity.TaskUrl = "settlements/feepayaudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAYAPP);
messageEntity.RecvType = 2;//申请审核类型
messageEntities.Add(messageEntity);
}
}
workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
feePaySettleApplicationDA.UpdatePayApplicationStatus(strBillNO, 3, strCompanyID);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
}
}
}
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "添加付费申请信息";
logEntity.LogType = "INSERT 插入操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.INSERT), "付费申请", "申请编号:" + strBillNO);
Logger.Instance.WriteLog(logEntity);
}
return iResult;
}
///
/// 重新提交申请
///
///
///
private int RePostRejectPaySettleApplication(string tempPaySettleAppGID)
{
int iResult = 0;
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
T_ALL_DA t_all_da = new T_ALL_DA();
int bsnoCount = 0;
FeePayApplicationEntity feePayApplicationEntity = feePaySettleApplicationDA.GetFeePayApplicationByGID(tempPaySettleAppGID);
if (feePayApplicationEntity != null)
{
if (feePayApplicationEntity.GID != null)
{
if (feePayApplicationEntity.BillStatus == 6)
{
iResult = feePaySettleApplicationDA.PostRejectPaySettleApplication(tempPaySettleAppGID);
if (iResult == 1)
{
strBillNO = feePaySettleApplicationDA.GetBillNoByPaySettleAppID(tempPaySettleAppGID);
DataSet ds = t_all_da.GetAllSQL("SELECT BSNO,OPLBNAME,CUSTOMERNAME,MBLNO FROM VW_Settlement WHERE BSNO IN (SELECT C.BSNO FROM ch_fee_payapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN ch_fee as C ON B.FEEID = C.GID WHERE A.BILLNO ='"+strBillNO.Trim()+"')");
if (ds != null && ds.Tables[0].Rows.Count > 1)
{
string topBsno = ds.Tables[0].Rows[0]["OPLBNAME"].ToString().Trim();
for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
{
if (topBsno != ds.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim())
{
bsnoCount++;
}
else
{
continue;
}
}
}
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb.ToLower() == "op_seae")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.PAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_seai")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "tmswlbshead" || stroplb.ToLower() == "tmswlpchead")//51 陆运
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.tMsWlPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "wms_fee" || stroplb.ToLower() == "wms" || stroplb.ToLower() == "wms_out")//61
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.WmszxPAYSETTLEAUDIT, strCompanyID);
}
else if (stroplb.ToLower() == "import_main")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
else if (stroplb.ToLower() == "op_apply")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
else if (stroplb.ToLower() == "op_bulk")
{
if (bsnoCount == 0)
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKPAYSETTLEAUDIT, strCompanyID);
}
else
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeSeaAllPaySettleAudit, strCompanyID);
}
}
IList workFlowDoEntities = new List();
if (workFlowEntity != null)
{
//消息系统
IList messageEntities = new List();
MessageDA messageDA = new MessageDA();
WorkFlowDoEntity workFlowDoEntity = null;
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strBillNO);
if (workFlowDoEntity == null)
{
if (workFlowDoEntity.GID == null)
{
//workFlowDoEntity = new WorkFlowDoEntity();
//遍历所有工作流下步骤,获取第一步骤GID信息
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
if (step.StepNO == 1)
{
WorkFlowDoEntity paySettleWorkFlowDoEntity = new WorkFlowDoEntity();
paySettleWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
paySettleWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
paySettleWorkFlowDoEntity.StepID = step.GID;
paySettleWorkFlowDoEntity.StepNO = step.StepNO;
paySettleWorkFlowDoEntity.Auditor = step.Auditor;
paySettleWorkFlowDoEntity.BillNO = strBillNO;
paySettleWorkFlowDoEntity.IsFinish = false;
paySettleWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(paySettleWorkFlowDoEntity);
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
messageEntity.Description = "付费申请审核";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 业务编号:" + strBillNO + " 提交待审核 [付费申请] ";
messageEntity.TaskID = strBillNO;
messageEntity.Receiver = step.Auditor;
messageEntity.TaskUrl = messageEntity.TaskUrl = "settlements/feepayaudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAYAPP);
messageEntity.RecvType = 2;//申请审核类型
messageEntities.Add(messageEntity);
}
}
workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
feePaySettleApplicationDA.UpdatePayApplicationStatus(strBillNO, 3, strCompanyID);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
}
}
else
{
if (workFlowDoEntity.GID == null)
{
//workFlowDoEntity = new WorkFlowDoEntity();
//遍历所有工作流下步骤,获取第一步骤GID信息
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
if (step.StepNO == 1)
{
WorkFlowDoEntity paySettleWorkFlowDoEntity = new WorkFlowDoEntity();
paySettleWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
paySettleWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
paySettleWorkFlowDoEntity.StepID = step.GID;
paySettleWorkFlowDoEntity.StepNO = step.StepNO;
paySettleWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
paySettleWorkFlowDoEntity.FeeID = "";
paySettleWorkFlowDoEntity.BSNO = "";
paySettleWorkFlowDoEntity.FeeStatus = 0;
paySettleWorkFlowDoEntity.DoQuerySql = "";
paySettleWorkFlowDoEntity.BillNO = strBillNO;
paySettleWorkFlowDoEntity.IsFinish = false;
paySettleWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(paySettleWorkFlowDoEntity);
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
if (bsnoCount == 0)
{
messageEntity.Name = "FeePayAudit";
}
else
{
messageEntity.Name = "FeeSeaAllPaySettleAudit";
}
messageEntity.Description = "付费申请审核";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
messageEntity.MessageContent = strShowName + " 业务编号:" + strBillNO + " 提交待审核 [付费申请] ";
messageEntity.TaskID = strBillNO;
messageEntity.Receiver = step.Auditor;
messageEntity.TaskUrl = messageEntity.TaskUrl = "settlements/feepayaudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEPAYAPP);
messageEntity.RecvType = 2;//申请审核类型
messageEntities.Add(messageEntity);
}
}
workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
feePaySettleApplicationDA.UpdatePayApplicationStatus(strBillNO, 3, strCompanyID);
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEPAYAPP, messageEntities);
}
}
}
}
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "添加付费申请信息";
logEntity.LogType = "INSERT 插入操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.INSERT), "付费申请", "申请编号:" + strBillNO);
Logger.Instance.WriteLog(logEntity);
}
}
else
{
iResult = -5;//只能提交状态为驳回的付费申请
}
}
else
{
iResult = -4;//不存在付费申请
}
}
else
{
iResult = -4;//不存在付费申请
}
return iResult;
}
#region 删除运行结算表信息
///
/// 删除运行结算表信息
///
/// 运行结算表GID
/// 值1表示删除成功 值不等于1表示删除失败
private int DeleteSavedPaySettleApplication(string tempRunFeeSettleID)
{
int iResult = 0;
RunFeeSettlementDA runFeeSettlementDA = new RunFeeSettlementDA();
iResult = runFeeSettlementDA.DeleteRunFeeSettlementByGID(tempRunFeeSettleID);
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "删除付费申请保存信息";
logEntity.LogType = "DELETE 删除操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.DELETE), "付费申请保存信息", "");
Logger.Instance.WriteLog(logEntity);
}
return iResult;
}
#endregion
#region 删除付费申请表
///
/// 删除付费申请表
///
/// 付费申请GID
/// 值1表示删除成功 值不等于1表示删除失败
private int DeleteRejectPaySettleApplication(string tempPaySettleAppID)
{
int iResult = 0;
FeePaySettleApplicationDA feePaySettleApplicationDA = new FeePaySettleApplicationDA();
FeePayApplicationEntity feePayApplicationEntity = feePaySettleApplicationDA.GetFeePayApplicationByGID(tempPaySettleAppID);
if (feePayApplicationEntity != null)
{
if (feePayApplicationEntity.GID != null)
{
if (feePayApplicationEntity.BillStatus == 6)
{
iResult = feePaySettleApplicationDA.DeletePaySettleApplicationUnCover(tempPaySettleAppID);
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "删除付费申请信息";
logEntity.LogType = "DELETE 删除操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.DELETE), "付费申请", "申请编号:" + feePayApplicationEntity.BillNO);
Logger.Instance.WriteLog(logEntity);
}
}
else
{
iResult = -4;//只能删除驳回的付费申请
}
}
else
{
iResult = -3;//数据不存在
}
}
else
{
iResult = -3;//数据不存在
}
return iResult;
}
#endregion
#region 删除已保存未结算的付费信息
///
/// 删除已保存未结算的付费信息
///
/// 运行结算表GID
/// 值1表示删除成功 值不等于1表示删除失败
private int DeleteSavedUnSettlePay(string tempRunSettlementID)
{
int iResult = 0;
RunFeeSettlementDA runFeeSettlementDA = new RunFeeSettlementDA();
RunFeeSettlementEntity runFeeSettlementEntity = runFeeSettlementDA.GetRunFeeSettlementByGID(tempRunSettlementID);
if (runFeeSettlementEntity != null)
{
if (runFeeSettlementEntity.GID != null)
{
iResult = runFeeSettlementDA.DeleteRunFeeSettlementByGID(tempRunSettlementID);
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "删除已保存未结算付费信息";
logEntity.LogType = "DELETE 删除操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.DELETE), "已保存未结算付费", "");
Logger.Instance.WriteLog(logEntity);
}
}
else
{
iResult = -3;//数据不存在
}
}
else
{
iResult = -3;//数据不存在
}
return iResult;
}
#endregion
#region 将已保存为结算的付费进行结算操作
///
/// 将已保存为结算的付费进行结算操作
///
///
///
private int PostSavePaySettle(string tempRunSettleID)
{
int iResult = 0;
string strBillNO = "";
string strFeePaySettleID = Guid.NewGuid().ToString();
FeePaySettleDA feePaySettleDA = new FeePaySettleDA();
iResult = feePaySettleDA.PostSavePaySettle(strFeePaySettleID, tempRunSettleID, strUserID, "", strCompanyID);
if (iResult == 1)
{
strBillNO = feePaySettleDA.GetBillNoByPaySettleID(strFeePaySettleID);
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "添加付费结算信息";
logEntity.LogType = "INSERT 插入操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.INSERT), "付费结算", "结算单号:" + strBillNO);
Logger.Instance.WriteLog(logEntity);
}
return iResult;
}
#endregion
#region 撤销付费结算
///
/// 撤销付费结算
///
/// 付费结算GID
/// 值1表示结算成功 值不等于1表示结算失败
private int CacelPaySettle(string strPaySettleID)
{
int iResult = 0;
FeePaySettleDA feePaySettleDA = new FeePaySettleDA();
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity();
feeSettlementEntity = feeSettlementDA.GetFeeSettlementByGID(strPaySettleID);
if (feeSettlementEntity != null)
{
if (feeSettlementEntity.GID != null)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string ssql = "select count(*) as nums from ch_fee_advance_payment_detail where BILLNO='" + feeSettlementEntity.BillNO.ToString() + "' and (ISDELETE=0 or ISDELETE is null)";
int nums = int.Parse(T_ALL_DA.GetStrSQL("nums", ssql));
if (nums != 0)//判断是否存在预收预付主表中的预付支资料
{
return -3;
}
//
ssql = "select count(*) as nums from ch_fee_settlement where BILLNO='" + feeSettlementEntity.BillNO.ToString() + "' and (ISDELETE=0 or ISDELETE is null) and (VOUNO is not null and VOUNO<>'')";
nums = int.Parse(T_ALL_DA.GetStrSQL("nums", ssql));
if (nums != 0)//判断是否存在预收预付主表中的预付支资料
{
return -4;
}
//
iResult = feePaySettleDA.CacelPaySettle(strPaySettleGID, feeSettlementEntity.BillNO, strUserID, feeSettlementEntity.CompanyID);
if (iResult == 1)
{
LogEntity logEntity = new LogEntity();
logEntity.GID = Guid.NewGuid().ToString();
logEntity.Name = "撤销付费结算信息";
logEntity.LogType = "CANCEL 撤销操作";
logEntity.CreateUserID = strUserID;
logEntity.LogContent = strShowName + String.Format(Logger.Instance.GetLogContentTemplate(Logger.LogTypes.CANCEL), "付费结算", "结算单号:" + feeSettlementEntity.BillNO);
Logger.Instance.WriteLog(logEntity);
}
}
}
return iResult;
}
#endregion
}
}