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.EntityDA;
using DSWeb.Models;
using System.Text;
using System.Text.RegularExpressions;
using DSWeb.Authority;
using DSWeb.WorkFlow;
namespace DSWeb.AuditProcess
{
public partial class FeeAuditGridSource : System.Web.UI.Page
{
private string strUserID;//用户GID
private int iType;//type值为1表示获取检索提交审核的数据;值为2获取应收费用信息;值为3获取应付费用信息;
private string strCondition;//获取检索条件 将检索条件根据检索字段和检索值为对值的方式 例如(字段名:检索值|字段名:检索值)
private string strBSNO;//委托业务 BSNO
private string strHandler;//值为profit获取利润信息
private string strSearch;//条件查询
private int iInitType;//值1表示初次加载页面只显示待审核的信息
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string stroplb;//业务类别
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandler = Request.QueryString["handle"].ToString();
}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString();
}
if (Request.QueryString["type"] != null)
{
iType = int.Parse(Request.QueryString["type"].ToString());
}
if (Request.QueryString["condition"] != null)
{
strCondition = Request.QueryString["condition"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
if (Request.QueryString["init"] != null)
{
iInitType = int.Parse(Request.QueryString["init"].ToString());
}
else
{
iInitType = 0;
}
if (iType > 0 && iType < 4)
{
if (strBSNO == null)
{
Response.Write(getGridSource(iType, strCondition, ""));
}
else
{
Response.Write(getGridSource(iType, strCondition, strBSNO));
}
}
else if (iType == 4)
{
//根据委托表BSNO读取费用利润信息fee_gain,返回json数据
Response.Write(getProfit(strBSNO));
}
}
#region 根据委托表BSNO读取费用利润信息fee_gain,返回json数据
///
/// fee_gain根据委托表BSNO读取费用利润信息fee_gain,返回json数据
///
///
/// 根据委托表BSNO读取费用利润信息fee_gain,返回json数据
private string getProfit(string tempBSNO)
{
string strSql = " SELECT GID, BSNO, RMBDR, USDDR, OTDR, RMBCR, USDCR, OTCR, DRTTL, CRTTL, STLDRRMB, STLDRUSD, STLDROT, STLCRRMB, STLCRUSD, STLCROT, "
+ " STLDRTTL, STLCRTTL, RMBPROFIT, USDPROFIT, OTPROFIT, TTLPROFIT, PROFITRATE,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME "
+ " FROM fee_gain WHERE BSNO = '"+tempBSNO+"'";
FeeProfitDA feeProfitDA = new FeeProfitDA();
//根据委托表BSNO读取费用利润信息
DataTable profitTable = feeProfitDA.GetProfitistByCondition(strSql).Tables[0];
StringBuilder profitBuilder = new StringBuilder();
if (profitTable.Rows.Count > 0)
{
profitBuilder.Append("{");
profitBuilder.Append("\"columns\":");
profitBuilder.Append("[");
profitBuilder.Append("{");
for (int i = 0; i < profitTable.Columns.Count; i++)
{
if (i == profitTable.Columns.Count - 1)
{
profitBuilder.Append("\"" + profitTable.Columns[i].ColumnName.ToLower() + "\":\"" + profitTable.Rows[0][i].ToString() + "\"");
}
else
{
profitBuilder.Append("\"" + profitTable.Columns[i].ColumnName.ToLower() + "\":\"" + profitTable.Rows[0][i].ToString() + "\",");
}
}
profitBuilder.Append("}");
profitBuilder.Append("]");
profitBuilder.Append("}");
}
else
{
profitBuilder.Append("{");
profitBuilder.Append("\"columns\":");
profitBuilder.Append("[");
profitBuilder.Append("{");
for (int i = 0; i < profitTable.Columns.Count; i++)
{
if (i == profitTable.Columns.Count - 1)
{
profitBuilder.Append("\"" + profitTable.Columns[i].ColumnName.ToLower() + "\":0");
}
else
{
profitBuilder.Append("\"" + profitTable.Columns[i].ColumnName.ToLower() + "\":0,");
}
}
profitBuilder.Append("}");
profitBuilder.Append("]");
profitBuilder.Append("}");
}
return profitBuilder.ToString();
}
#endregion
#region getGridSource
///
/// getGridSource
///
///
///
///
///
private string getGridSource(int iTempType, string strTempCondition,string tempBSNO)
{
string strSql = "";
if (strSearch != null)
{
#region strSearch != null
if (!strSearch.Trim().Equals(""))
{
string tempSearch = strSearch;
tempSearch = tempSearch.Replace("{", "");
tempSearch = tempSearch.Replace("}", "");
tempSearch = tempSearch.Replace("[", "");
tempSearch = tempSearch.Replace("]", "");
string strCustno = "";
int iCustnoType = -1;
string strMblno = "";
int iMblnoType = -1;
string strHblno = "";
int iHblnoType = -1;
string strCustomer = "";
int iCustomerType = -1;
string strVessel = "";
int iVesselType = -1;
string strDestination = "";
int iDestinationType = -1;
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 "cusno":
strCustno = strArg[1].Replace("\"", "").Trim();
break;
case "cusno2":
iCustnoType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "mblno":
strMblno = strArg[1].Replace("\"", "").Trim();
break;
case "mblno2":
iMblnoType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "hblno":
strHblno = strArg[1].Replace("\"", "").Trim();
break;
case "hblno2":
iHblnoType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "cus":
strCustomer = strArg[1].Replace("\"", "").Trim();
break;
case "cus2":
iCustomerType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "vessel":
strVessel = strArg[1].Replace("\"", "").Trim();
break;
case "vessel2":
iVesselType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "dest":
strDestination = strArg[1].Replace("\"", "").Trim();
break;
case "dest2":
iDestinationType = int.Parse(strArg[1].Replace("\"", "").Trim());
break;
case "etdb":
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
strCondition += String.Format(" AND ETD >= '{0} 00:00:00' ", strArg[1].Replace("\"", ""));
}
break;
case "etde":
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
strCondition += String.Format(" AND ETD <= '{0} 23:59:59' ", strArg[1].Replace("\"", ""));
}
break;
case "accb":
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
strCondition += String.Format(" AND ACCDATE >= '{0} 00:00:00' ", strArg[1].Replace("\"", ""));
}
break;
case "acce":
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
{
strCondition += String.Format(" AND ACCDATE <= '{0} 23:59:59' ", strArg[1].Replace("\"", ""));
}
break;
default:
break;
}
}
}
if (!strCustno.Equals(""))
{
strCondition += String.Format(" AND CUSTNO {0}", iCustnoType == 0 ? " LIKE '%" + strCustno + "%'" : " = '%" + strCustno + "%'");
}
if (!strMblno.Equals(""))
{
strCondition += String.Format(" AND MBLNO {0}", iMblnoType == 0 ? " LIKE '%" + strMblno + "%'" : " = '%" + strMblno + "%'");
}
if (!strHblno.Equals(""))
{
strCondition += String.Format(" AND HBLNO {0}", iHblnoType == 0 ? " LIKE '%" + strHblno + "%'" : " = '%" + strHblno + "%'");
}
if (!strCustomer.Equals(""))
{
strCondition += String.Format(" AND CUSTOMERNAME {0}", iCustomerType == 0 ? " LIKE '%" + strCustomer + "%'" : " = '%" + strCustomer + "%'");
}
if (!strVessel.Equals(""))
{
strCondition += String.Format(" AND (VESSEL {0} OR VOYNO {0}) ", iVesselType == 0 ? " LIKE '%" + strVessel + "%'" : " = '%" + strVessel + "%'");
}
if (!strDestination.Equals(""))
{
strCondition += String.Format(" AND DESTINATION {0}", iDestinationType == 0 ? " LIKE '%" + strDestination + "%'" : " = '%" + strDestination + "%'");
}
strSql += strCondition;
}
#endregion
}
#region 注释
//string strAuthorityCondition = "";
//WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//if (workFlowEntity != null)
//{
// WorkFlowDoEntity workFlowDoEntity = null;
// WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
// workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
//}
// workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow("modSeaReceivablePayableFees");
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modFeeAudit");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.FEEAUDIT, strShowName, strCompanyID, strDeptName,strUserID);
//}
#endregion
FeeDA feeDA = new FeeDA();
switch (iTempType)
{
case 1://query audit
if (iInitType == 1)
{
//strSql = " SELECT BSNO,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seae "
// + " WHERE 1 > 0 AND BSNO IN (SELECT BSNO FROM ch_fee WHERE FEESTATUS = 2 OR FEESTATUS = 3 OR FEESTATUS = 4) " + strCondition;
//strSql = String.Format(" SELECT BSNO,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seae WHERE 1 > 0 "
// + " AND BSNO IN (SELECT BSNO FROM ch_fee WHERE FEESTATUS = 2 AND GID IN "
// + " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
// + " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC )"
// + " OR ((FEESTATUS = 3 OR FEESTATUS = 4) AND GID IN "
// + " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
// + " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC "
// + " ))) " + strCondition, strUserID);
strSql = String.Format(" SELECT BSNO,'海运出口' 类别, CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seae WHERE 1 > 0 "
+ " AND BSNO IN (SELECT BSNO FROM ch_fee WHERE FEESTATUS = 2 AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
+ " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC )"
+ " OR ((FEESTATUS = 3 OR FEESTATUS = 4) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
+ " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC "
+ " ))) {1} "
+ " union all "
+ " SELECT BSNO,'海运进口' 类别,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seai WHERE 1 > 0 "
+ " AND BSNO IN (SELECT BSNO FROM ch_fee WHERE FEESTATUS = 2 AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 11 "
+ " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC )"
+ " OR ((FEESTATUS = 3 OR FEESTATUS = 4) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 13 "
+ " AND A.AUDITOR = '{0}' AND ISFINISH = 0 ORDER BY A.AUDITTIME DESC "
+ " ))) {1} "
, strUserID, strCondition);
}
else
{
//strSql = " SELECT BSNO,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seae "
// + " WHERE 1 > 0 AND BSNO IN (SELECT BSNO FROM ch_fee WHERE FEESTATUS = 3 OR FEESTATUS = 4 OR FEESTATUS = 2 OR FEESTATUS = 0 OR FEESTATUS = 8 OR FEESTATUS = 9) " + strCondition;
strSql = String.Format(" SELECT BSNO,'海运出口' 类别,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seae WHERE 1 > 0 "
+ " AND BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
+ " AND A.AUDITOR = '{0}' ORDER BY A.AUDITTIME DESC )"
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
+ " AND A.AUDITOR = '{0}' ORDER BY A.AUDITTIME DESC "
+ " ))) {1} "
+ "union all "
+ " SELECT BSNO,'海运进口' 类别,CUSTNO,CASE WHEN FEESTATUS = 1 THEN '锁定' ELSE '未锁定' END as FEESTATUS,MBLNO,HBLNO,CUSTOMERNAME,VESSEL+' '+VOYNO,ETD,ACCDATE,DESTINATION FROM op_seai WHERE 1 > 0 "
+ " AND BSNO IN (SELECT BSNO FROM ch_fee WHERE (FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 11 "
+ " AND A.AUDITOR = '{0}' ORDER BY A.AUDITTIME DESC )"
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND GID IN "
+ " (SELECT top 100 PERCENT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 13 "
+ " AND A.AUDITOR = '{0}' ORDER BY A.AUDITTIME DESC "
+ " ))) {1} "
,strUserID, strCondition);
}
break;
case 2://query fee_recv
//strSql = String.Format("SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY, "
// + " EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 {0} {1} AND (FEESTATUS = 3 OR FEESTATUS = 4 OR FEESTATUS = 2 OR FEESTATUS = 0 OR FEESTATUS = 8 OR FEESTATUS = 9) {2} ", " AND FEETYPE = 1", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ");
if (iInitType == 2)
{
if (strHandler == "op_Seae")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
+ " AND A.AUDITOR = '{3}') "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
+ " AND A.AUDITOR = '{3}'))) "
+ " {2} ", " AND FEETYPE = 1", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
else if (strHandler == "op_Seai")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 11 "
+ " AND A.AUDITOR = '{3}') "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 13 "
+ " AND A.AUDITOR = '{3}'))) "
+ " {2} ", " AND FEETYPE = 1", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
}
else
{
if (strHandler == "op_Seae")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 1 or B.TYPE = 1) "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0) "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 3 or B.TYPE = 3) "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0))) "
+ " {2} ", " AND FEETYPE = 1", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
else if (strHandler == "op_Seai")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 1 or B.TYPE = 11) "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0) "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE (B.TYPE = 3 or B.TYPE = 13) "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0))) "
+ " {2} ", " AND FEETYPE = 1", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
}
break;
case 3://query fee_pay
//strSql = String.Format("SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY, "
// + " EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 {0} {1} AND (FEESTATUS = 3 OR FEESTATUS = 4 OR FEESTATUS = 2 OR FEESTATUS = 0 OR FEESTATUS = 8 OR FEESTATUS = 9) {2} ", " AND FEETYPE = 2", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ");
if (iInitType == 2)
{
if (strHandler == "op_Seae")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
+ " AND A.AUDITOR = '{3}') "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
+ " AND A.AUDITOR = '{3}'))) "
+ " {2} ", " AND FEETYPE = 2", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
else if (strHandler == "op_Seai")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 11 "
+ " AND A.AUDITOR = '{3}') "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 13 "
+ " AND A.AUDITOR = '{3}'))) "
+ " {2} ", " AND FEETYPE = 2", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
}
else
{
if (strHandler == "op_Seae")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 1 "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0) "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 3 "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0))) "
+ " {2} ", " AND FEETYPE = 2", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
else if (strHandler == "op_Seai")
{
strSql = String.Format(" SELECT GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY,EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 "
+ " {0} {1} "
+ " AND ((FEESTATUS = 0 OR FEESTATUS = 2 OR FEESTATUS = 6) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 11 "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0) "
+ " OR ((FEESTATUS = 0 OR FEESTATUS = 7 OR FEESTATUS = 3 OR FEESTATUS = 4) AND "
+ " GID IN (SELECT A.BILLNO FROM workflow_do as A INNER JOIN workflow as B ON A.WORKFLOWID = B.GID WHERE B.TYPE = 13 "
+ " AND A.AUDITOR = '{3}' AND ISFINISH = 0))) "
+ " {2} ", " AND FEETYPE = 2", "AND BSNO = '" + tempBSNO + "'", " ORDER BY ENTERDATE ASC ", strUserID);
}
}
break;
case 4://get
break;
default:
break;
}
DataTable sourceTable;
//如果是加载费用信息则自动将状态进行过滤 讲数字状态改为文字显示
if (iTempType != 1)
{
sourceTable = getStatusNameTable(feeDA.GetExcuteSql(strSql).Tables[0]);
}
else
{
sourceTable = feeDA.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:[");
if (iTempType == 2 || iTempType == 3)
{
sourceBuilder.Append("\"1\",");
}
else
{
sourceBuilder.Append("\"0\",");
}
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
///
/// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
///
/// 原数据源DataTable
/// 返回新数据源DataTable
private DataTable getStatusNameTable(DataTable tempTable)
{
DataTable sourceTable = tempTable;
DataTable cloneTable = new DataTable();
int iSwitch = 0;
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (iSwitch == 0)
{
for (int j = 0; j < sourceTable.Columns.Count; j++)
{
if (sourceTable.Columns[j].ColumnName.Equals("FEESTATUS"))
{
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("ISADVANCEDPAY"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.Int32");
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("FEESTATUS"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 0:
strFeeStatus = "审核通过";
break;
case 1:
strFeeStatus = "录入状态";
break;
case 2:
strFeeStatus = "提交审核";
break;
case 3:
strFeeStatus = "申请修改";
break;
case 4:
strFeeStatus = "申请删除";
break;
case 5:
strFeeStatus = "取消申请";
break;
case 6:
strFeeStatus = "驳回提交";
break;
case 7:
strFeeStatus = "驳回申请";
break;
case 8:
strFeeStatus = "部分结算";
break;
case 9:
strFeeStatus = "结算完毕";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else if (sourceTable.Columns[k].ColumnName.Equals("ISADVANCEDPAY"))
{
int iIsAdvancedPay = 0;
if (sourceTable.Rows[i][k].ToString().ToLower().Equals("true"))
{
iIsAdvancedPay = 1;
}
cloneRow[sourceTable.Columns[k].ColumnName] = iIsAdvancedPay;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
//cloneTable.Columns.Remove("FEESTATUS");
//cloneTable.Columns.Add(new DataColumn("FEESTATUS", System.Type.GetType("System.String")));
return cloneTable;
}
}
}