You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

786 lines
37 KiB
C#

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
using DSWeb.Authority;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using WebSqlHelper;
using System.Collections.Generic;
namespace DSWeb.Shipping
{
public partial class FeeGridSource : System.Web.UI.Page
{
private int iType;//费用类型 应收类型值1 应付类型值 2
private string strReadXmlType = "";//读取xml串方式 "init"-初始化获取所有费用信息;"add"-添加新的费用信息;"delete"-删除费用信息;"exist"查看是否有与委托相关费用
private int iShowCount;//每页显示数据量
private string strBSNO;//委托编号
private string strUserID;//用户GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string stroplb = "";//业务类别
private string strfeename = "";//费用名称
private string strwmsoutbsno;//出库单gid
protected void Page_Load(object sender, EventArgs e)
{
#region 判断参数是否正确
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["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString().Trim();
}
if (Request.QueryString["wmsoutbsno"] != null)
{
strwmsoutbsno = Request.QueryString["wmsoutbsno"].ToString().Trim();
}
if (Request.QueryString["type"] != null)
{
iType = int.Parse(Request.QueryString["type"].ToString().Trim());
}
if (Request.QueryString["read"] != null)
{
strReadXmlType = Request.QueryString["read"].ToString().Trim();
}
if (Request.QueryString["showcount"] != null)
{
iShowCount = int.Parse(Request.QueryString["showcount"].ToString());
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["feename"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strfeename = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["feename"].ToString())));
}
#endregion
if (iType > 0 && !strReadXmlType.Equals(""))
{
string strOutputXml = "";
//获取ch_fee费用信息返回xml格式数据
strOutputXml = GetCells(iShowCount, iType, strReadXmlType);
//输出XML字符串
Response.ContentType = "text/xml";
strOutputXml.Replace("&", "&");
Response.Write(strOutputXml);
}
else
{
if (strReadXmlType.Equals("isfeename"))
{
Response.Write(getisfeename());
return;
}
else if (strReadXmlType.Equals("getgain"))
{
Response.Write(getgain());
return;
}
//访问参数不正确
Response.ContentType = "text/xml";
Response.Write("-2");
}
}
private string getgain()
{
#region 保存利润信息
int iResult = 0;
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
SqlParameter[] updateProfitParms = new SqlParameter[] {
new SqlParameter("@bsno",SqlDbType.VarChar,100),//委托编号
new SqlParameter("@modified_user",SqlDbType.VarChar,36)//创建人
};
updateProfitParms[0].Value = strBSNO;
updateProfitParms[1].Value = strUserID;
//
string SQL_UPDATE_FEE_GAIN = " UPDATE fee_gain SET RMBDR = B.RMBDR,RMBCR = B.RMBCR,USDDR = B.USDDR,USDCR = B.USDCR,RMBPROFIT = A.RMBPROFIT,"
+ " USDPROFIT = A.USDPROFIT,TTLPROFIT = A.TTLPROFIT,DRTTL = A.DRTTL,CRTTL = A.CRTTL,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE(),PROFITRATE = A.PROFITRATE "
+ " FROM (SELECT SUM(RMBDR) AS RMBDR,SUM(RMBCR) AS RMBCR,SUM(USDDR) AS USDDR,SUM(USDCR) AS USDCR "
+ " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
+ " FEETYPE FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS D) AS B, "
+ " (SELECT SUM(RMBDR) - SUM(RMBCR) AS RMBPROFIT,SUM(USDDR) - SUM(USDCR) AS USDPROFIT,SUM(RMBDR+USDTORMBDR) as DRTTL, "
+ " SUM(RMBCR+USDTORMBCR) as CRTTL,SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR) as TTLPROFIT, "
//+ " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND((case when SUM(RMBDR+USDTORMBDR)=0 then 0 else (SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBDR+USDTORMBDR) END),2))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE "
+ " (CAST(CAST(CASE WHEN SUM(RMBCR+USDTORMBCR) = 0 THEN 100 ELSE (ROUND(((SUM(RMBDR+USDTORMBDR)- SUM(RMBCR+USDTORMBCR))/SUM(RMBCR+USDTORMBCR)),4))*100 END as decimal(18,2)) as varchar(20))+'%') AS PROFITRATE "
+ " FROM (SELECT CURRENCY,SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as RMBDR,"
+ " SUM(CASE WHEN CURRENCY='RMB' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as RMBCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT ELSE 0 END) as USDDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT ELSE 0 END) as USDCR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 1 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBDR, "
+ " SUM(CASE WHEN CURRENCY='USD' AND FEETYPE = 2 THEN AMOUNT*EXCHANGERATE ELSE 0 END) as USDTORMBCR,FEETYPE "
+ " FROM ch_fee WHERE BSNO = @bsno and FEENAME in (select [name] from code_fee where FEETYPE='普通') GROUP BY CURRENCY,EXCHANGERATE,FEETYPE ) AS C) AS A"
+ " WHERE fee_gain.BSNO = @bsno ";
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_GAIN, updateProfitParms);
//
//事务提交
sqlTran.Commit();
iResult = 1;//状态为1表示插入成功
}
catch (Exception)
{
//iResult = -1;//有异常,插入失败
//sqlTran.Rollback();
//iResult = -2;//插入异常,事务已回滚成功
//throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return iResult.ToString();
#endregion
}
private string getisfeename()
{
string alt = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sSQL = "";
sSQL = "select count(*) num from code_fee where [name]='" + strfeename + "' and FEETYPE<>'普通'";
alt = T_ALL_DA.GetStrSQL("num", sSQL);
return alt.Trim();
}
#region 获取ch_fee费用信息返回xml格式数据
/// <summary>
/// 获取ch_fee费用信息
/// </summary>
/// <returns>返回xml格式数据</returns>
private string GetCells(int iShowCount, int Type, string strReadXmlType)
{
FeeEntity feeEntity = new FeeEntity();
FeeDA feeDA = new FeeDA();
FeeEntity existFeeEntity = new FeeEntity();
if (!strwmsoutbsno.Equals(""))
{
existFeeEntity = feeDA.GetFeeByBSNOAndType(strBSNO, Type, strwmsoutbsno);
}
else
{
existFeeEntity = feeDA.GetFeeByBSNOAndType(strBSNO, Type);
}
//通过委托编号BSNO与费用类型1应收2应付获取费用信息返回FeeEntity
if (existFeeEntity != null && !strReadXmlType.Equals("exist"))
{
//获取所有费用信息,用做Grid显示
DataTable feeTable = new DataTable();
string strInitSql = "";
if (!strwmsoutbsno.Equals(""))
{
//费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID
strInitSql = " SELECT {0} A.GID,A.FEESTATUS, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY{4} FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID WHERE A.WMSOUTBSNO='{5}' {1} {2} {3}";
}
else
{
strInitSql = " SELECT {0} A.GID,A.FEESTATUS, A.FEENAME, A.CUSTOMERNAME, A.UNIT, A.UNITPRICE, A.QUANTITY,A.COMMISSIONRATE,A.AMOUNT, A.CURRENCY, "
+ " A.EXCHANGERATE,A.FEEFRT,A.REMARK,A.ISADVANCEDPAY{4} FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID WHERE 1> 0 {1} {2} {3}";
}
string strSql = "";
if (iType == 1)
{
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvFeeManagement");
if (userAuthorityManage.VisibleType != AuthorityType.NULL)
{
//strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
if (stroplb == "op_Seae")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
else if (stroplb == "op_Seai")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
else if (stroplb == "op_Sean")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEANRECVFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
}
if (iShowCount > 0)
{
//strSql = string.Format(strInitSql, "top " + iShowCount, " AND FEETYPE like '%收%' ", " ORDER BY ENTERDATE DESC ");
strSql = string.Format(strInitSql, "", " AND A.FEETYPE = 1 ", "AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, " ORDER BY A.BSNO,A.LINENUM,A.ENTERDATE ASC ", ",ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE,'0' AS TID,isnull(A.WMSOUTBSNO,'') WMSOUTBSNO,LINENUM ", strwmsoutbsno);
}
else
{
strSql = string.Format(strInitSql, "", " AND A.FEETYPE = 1 ", "AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, " ORDER BY A.BSNO,A.LINENUM,A.ENTERDATE ASC ", ",ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE,'0' AS TID,isnull(A.WMSOUTBSNO,'') WMSOUTBSNO,LINENUM ", strwmsoutbsno);
}
}
else
{
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modPayFeeManagement");
if (userAuthorityManage.VisibleType != AuthorityType.NULL)
{
//strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYFEE, strShowName, strCompanyID, strDeptName, strUserID);
if (stroplb == "op_Seae")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.PAYFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
else if (stroplb == "op_Seai")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID);
}
else if (stroplb == "op_Sean")
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType,ModuleType.SEANPAYFEE,strShowName,strCompanyID,strDeptName,strUserID);
}
}
if (iShowCount > 0)
{
//strSql = string.Format(strInitSql, "top " + iShowCount, " AND FEETYPE like '%付%' ", " ORDER BY ENTERDATE DESC ");
strSql = string.Format(strInitSql, "", " AND A.FEETYPE = 2 ", "AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, " ORDER BY A.BSNO,A.LINENUM,A.ENTERDATE ASC ", ",ISNULL(A.SETTLEMENT,0),ISNULL(A.ORDERAMOUNT,0),ISNULL(A.CHEQUENUM,''),B.SHOWNAME,A.ENTERDATE,'0' AS TID,isnull(A.WMSOUTBSNO,'') WMSOUTBSNO,LINENUM ", strwmsoutbsno);
}
else
{
strSql = string.Format(strInitSql, "", " AND A.FEETYPE = 2 ", "AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition, " ORDER BY A.BSNO,A.LINENUM,A.ENTERDATE ASC ", ",ISNULL(A.SETTLEMENT,0),ISNULL(A.ORDERAMOUNT,0),ISNULL(A.CHEQUENUM,''),B.SHOWNAME,A.ENTERDATE,'0' AS TID,isnull(A.WMSOUTBSNO,'') WMSOUTBSNO,LINENUM ", strwmsoutbsno);
}
}
feeTable = getStatusNameTable(feeDA.GetExcuteSql(strSql).Tables[0]);
//编排字符串 xml串
StringBuilder dataBuilder = new StringBuilder();
dataBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
dataBuilder.Append("<rows>");
int iCount = feeTable.Rows.Count;
for (int i = 0; i < iCount; i++)
{
int jCount = feeTable.Columns.Count;
dataBuilder.Append("<row id=\"" + feeTable.Rows[i]["GID"].ToString() + "\">");
dataBuilder.Append("<cell>0</cell>");
for (int j = 1; j < jCount; j++)
{
switch (j)
{
case 2://FEENAME
dataBuilder.Append(GetFeeCodeCells(feeTable.Rows[i][j].ToString().Trim()));
break;
case 3://CUSTOMERNAME
dataBuilder.Append(GetCRMClientCells(feeTable.Rows[i][j].ToString().Trim()));
break;
case 4:
dataBuilder.Append(GetUnitCells(feeTable.Rows[i][j].ToString().Trim()));
break;
case 9:
dataBuilder.Append(GetCurrencyCells(feeTable.Rows[i][j].ToString().Trim()));
break;
case 10:
dataBuilder.Append("<cell>" + feeTable.Rows[i][j].ToString() + "</cell>");
break;
case 11:
dataBuilder.Append(GetFRTCells(feeTable.Rows[i][j].ToString()));
break;
case 13:
string strIsAdvancedPay = feeTable.Rows[i][j].ToString().Trim().ToLower();
if (strIsAdvancedPay.Equals("true"))
{
dataBuilder.Append("<cell>1</cell>");
}
else
{
dataBuilder.Append("<cell>0</cell>");
}
break;
default:
dataBuilder.Append("<cell>" + feeTable.Rows[i][j].ToString() + "</cell>");
break;
}
}
dataBuilder.Append("</row>");
}
dataBuilder.Append("</rows>");
return dataBuilder.ToString();
}
else if (existFeeEntity != null && strReadXmlType.Equals("exist"))
{
return "1";//存在费用
}
else if (existFeeEntity == null && strReadXmlType.Equals("add"))
{
StringBuilder dataBuilder = new StringBuilder();
dataBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
dataBuilder.Append("<rows>");
dataBuilder.Append("<row id=\"" + Guid.NewGuid().ToString() + "\">");
dataBuilder.Append("<cell>录入状态</cell>");
dataBuilder.Append(GetFeeCodeCells(""));
dataBuilder.Append(GetCRMClientCells(""));
dataBuilder.Append(GetUnitCells(""));
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append(GetCurrencyCells("RMB"));
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append(GetFRTCells("PP"));
dataBuilder.Append("<cell></cell>");
dataBuilder.Append("<cell>0</cell>");
dataBuilder.Append("<cell></cell>");
dataBuilder.Append("</row>");
dataBuilder.Append("</rows>");
return dataBuilder.ToString();
}
else
{
return "-3";//没有相关的费用
}
}
#endregion
#region 获取CRM系统客户信息下拉列表
/// <summary>
/// 获取CRM系统客户信息下拉列表
/// </summary>
/// <param name="strClientValue">当前列表客户信息值</param>
/// <returns></returns>
public string GetCRMClientCells(string strClientValue)
{
CRMClientDA crmClientDA = new CRMClientDA();
//DataTable clientTable = crmClientDA.GetCRMClientList().Tables[0];
StringBuilder clientBuilder = new StringBuilder();
clientBuilder.Append("<cell xmlcontent=\"1\" editable=\"1\">" + strClientValue);
//for (int i = 0; i < clientTable.Rows.Count; i++)
//{
// if (!clientTable.Rows[i]["SHORTNAME"].ToString().Trim().Equals(""))
// {
// clientBuilder.Append("<option value=\"" + clientTable.Rows[i]["SHORTNAME"].ToString() + "\">" + clientTable.Rows[i]["CODENAME"].ToString().ToUpper() + " " + clientTable.Rows[i]["SHORTNAME"].ToString() + "</option>");
// }
//}
clientBuilder.Append("</cell>");
return clientBuilder.ToString();
}
#endregion
#region 获取币别信息下拉列表
/// <summary>
/// 获取币别信息下拉列表
/// </summary>
/// <returns></returns>
public string GetCurrencyCells(string strCurrencyValue)
{
CurrencyDA currencyDA = new CurrencyDA();
//DataTable currencyTable = currencyDA.GetCurrencyList().Tables[0];
StringBuilder currencyBuilder = new StringBuilder();
currencyBuilder.Append("<cell xmlcontent=\"1\">" + strCurrencyValue);
//for (int i = 0; i < currencyTable.Rows.Count; i++)
//{
// if (!currencyTable.Rows[i]["DESCRIPTION"].ToString().Trim().Equals(""))
// {
// currencyBuilder.Append("<option value=\"" + currencyTable.Rows[i]["CODENAME"].ToString() + "\">" + currencyTable.Rows[i]["CODENAME"].ToString() + "</option>");
// }
//}
currencyBuilder.Append("</cell>");
return currencyBuilder.ToString();
}
#endregion
#region 获取费用代码信息下拉列表
/// <summary>
/// 获取费用代码信息下拉列表
/// </summary>
/// <param name="strFeeCodeValue"></param>
/// <returns></returns>
public string GetFeeCodeCells(string strFeeCodeValue)
{
FeeCodeDA feeCodeDA = new FeeCodeDA();
//DataTable feeCodeTable = feeCodeDA.GetFeeCodeList().Tables[0];
StringBuilder feeCodeBuilder = new StringBuilder();
feeCodeBuilder.Append("<cell xmlcontent=\"1\">" + strFeeCodeValue);
//for (int i = 0; i < feeCodeTable.Rows.Count; i++)
//{
// if (!feeCodeTable.Rows[i]["NAME"].ToString().Trim().Equals(""))
// {
// feeCodeBuilder.Append("<option value=\"" + feeCodeTable.Rows[i]["NAME"].ToString() + "\">" + feeCodeTable.Rows[i]["FULLNAME"].ToString() + "</option>");
// }
//}
feeCodeBuilder.Append("</cell>");
return feeCodeBuilder.ToString();
}
#endregion
#region 获取标准信息下拉列表
/// <summary>
/// 获取标准信息下拉列表
/// </summary>
/// <param name="strUnitValue"></param>
/// <returns></returns>
public string GetUnitCells(string strUnitValue)
{
StringBuilder unitBuilder = new StringBuilder();
unitBuilder.Append("<cell xmlcontent=\"1\">" + strUnitValue);
unitBuilder.Append("<option value=\"单票\">单票</option>");
unitBuilder.Append("<option value=\"重量\">重量</option>");
//unitBuilder.Append("<option value=\"净重\">净重</option>");
unitBuilder.Append("<option value=\"尺码\">尺码</option>");
unitBuilder.Append("<option value=\"TEU\">TEU</option>");
unitBuilder.Append("<option value=\"箱型\">箱型</option>");
unitBuilder.Append("<option value=\"CBM\">CBM</option>");
unitBuilder.Append("<option value=\"BILL\">BILL</option>");
unitBuilder.Append("</cell>");
return unitBuilder.ToString();
}
#endregion
#region 获取引入类型信息下拉列表
/// <summary>
/// 获取引入类型信息下拉列表
/// </summary>
/// <param name="strFRTValue"></param>
/// <returns></returns>
public string GetFRTCells(string strFRTValue)
{
StringBuilder frtBuilder = new StringBuilder();
frtBuilder.Append("<cell xmlcontent=\"1\">" + strFRTValue);
frtBuilder.Append("<option value=\"PP\">PP</option>");
frtBuilder.Append("<option value=\"CC\">CC</option>");
frtBuilder.Append("</cell>");
return frtBuilder.ToString();
}
#endregion
#region 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// <summary>
/// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字
/// </summary>
/// <param name="tempTable">原数据源DataTable</param>
/// <returns>返回新数据源DataTable</returns>
private DataTable getStatusNameTable(DataTable tempTable)
{
DataTable sourceTable = tempTable;
DataTable cloneTable = new DataTable();
int iSwitch = 0;
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
if (iSwitch == 0)
{
for (int j = 0; j < sourceTable.Columns.Count; j++)
{
if (sourceTable.Columns[j].ColumnName.Equals("FEESTATUS"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = sourceTable.Columns[j].DataType;
cloneTable.Columns.Add(newColumn);
}
}
iSwitch = 1;
}
DataRow cloneRow = cloneTable.NewRow();
for (int k = 0; k < sourceTable.Columns.Count; k++)
{
if (sourceTable.Columns[k].ColumnName.Equals("FEESTATUS"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 0:
strFeeStatus = "审核通过";
break;
case 1:
strFeeStatus = "录入状态";
break;
case 2:
strFeeStatus = "提交审核";
break;
case 3:
strFeeStatus = "申请修改";
break;
case 4:
strFeeStatus = "申请删除";
break;
case 5:
strFeeStatus = "取消申请";
break;
case 6:
strFeeStatus = "驳回提交";
break;
case 7:
strFeeStatus = "驳回申请";
break;
case 8:
strFeeStatus = "部分结算";
break;
case 9:
strFeeStatus = "结算完毕";
break;
case 10:
strFeeStatus = "申请通过";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
else
{
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
}
}
cloneTable.Rows.Add(cloneRow);
}
//cloneTable.Columns.Remove("FEESTATUS");
//cloneTable.Columns.Add(new DataColumn("FEESTATUS", System.Type.GetType("System.String")));
return cloneTable;
}
#endregion
#region 用Session缓存数据
//如果页面请求add,则执行从Session中读取之前的table数据信息,将新添加的行数据追加到table末尾
//if (strReadXmlType == "add" && iType == 1)
//{
// if (Session["CacheRecvTable"] != null)
// {
// DataTable cacheTable = (DataTable)Session["CacheRecvTable"];
// if (cacheTable.Rows.Count > 0)
// {
// //添加缓存表
// DataRow newRow = cacheTable.NewRow();
// newRow["GID"] = Guid.NewGuid().ToString();
// newRow["FEESTATUS"] = "输入状态";
// newRow["FEENAME"] = "";
// newRow["CUSTOMERNAME"] = "";
// newRow["UNIT"] = "";
// newRow["UNITPRICE"] = 0;
// newRow["QUANTITY"] = 0;
// newRow["COMMISSIONRATE"] = 0;
// newRow["AMOUNT"] = 0;
// newRow["CURRENCY"] = 0;
// newRow["EXCHANGERATE"] = 0;
// newRow["REMARK"] = 0;
// newRow["ISADVANCEDPAY"] = 0;
// cacheTable.Rows.Add(newRow);
// //添加数据源表
// DataRow newFeeRow = feeTable.NewRow();
// newFeeRow["GID"] = Guid.NewGuid().ToString();
// newFeeRow["FEESTATUS"] = "输入状态";
// newFeeRow["FEENAME"] = "";
// newFeeRow["CUSTOMERNAME"] = "";
// newFeeRow["UNIT"] = "";
// newFeeRow["UNITPRICE"] = 0;
// newFeeRow["QUANTITY"] = 0;
// newFeeRow["COMMISSIONRATE"] = 0;
// newFeeRow["AMOUNT"] = 0;
// newFeeRow["CURRENCY"] = 0;
// newFeeRow["EXCHANGERATE"] = 0;
// newFeeRow["REMARK"] = 0;
// newFeeRow["ISADVANCEDPAY"] = 0;
// feeTable.Rows.Add(newFeeRow);
// }
// Session["CacheRecvTable"] = cacheTable;
// }
// else
// {
// DataTable cacheTable = feeTable.Clone();
// DataRow newRow = cacheTable.NewRow();
// newRow["GID"] = Guid.NewGuid().ToString();
// newRow["FEESTATUS"] = "输入状态";
// newRow["FEENAME"] = "";
// newRow["CUSTOMERNAME"] = "";
// newRow["UNIT"] = "";
// newRow["UNITPRICE"] = 0;
// newRow["QUANTITY"] = 0;
// newRow["COMMISSIONRATE"] = 0;
// newRow["AMOUNT"] = 0;
// newRow["CURRENCY"] = 0;
// newRow["EXCHANGERATE"] = 0;
// newRow["REMARK"] = 0;
// newRow["ISADVANCEDPAY"] = 0;
// cacheTable.Rows.Add(newRow);
// //添加数据源表
// DataRow newFeeRow = feeTable.NewRow();
// newFeeRow["GID"] = Guid.NewGuid().ToString();
// newFeeRow["FEESTATUS"] = "输入状态";
// newFeeRow["FEENAME"] = "";
// newFeeRow["CUSTOMERNAME"] = "";
// newFeeRow["UNIT"] = "";
// newFeeRow["UNITPRICE"] = 0;
// newFeeRow["QUANTITY"] = 0;
// newFeeRow["COMMISSIONRATE"] = 0;
// newFeeRow["AMOUNT"] = 0;
// newFeeRow["CURRENCY"] = 0;
// newFeeRow["EXCHANGERATE"] = 0;
// newFeeRow["REMARK"] = 0;
// newFeeRow["ISADVANCEDPAY"] = 0;
// feeTable.Rows.Add(newFeeRow);
// Session["CacheRecvTable"] = cacheTable;
// }
//}
//else if (strReadXmlType == "add" && iType == 2)//应付费用
//{
// if (Session["CachePayTable"] != null)
// {
// DataTable cacheTable = (DataTable)Session["CachePayTable"];
// if (cacheTable.Rows.Count > 0)
// {
// DataRow newRow = cacheTable.NewRow();
// newRow["GID"] = Guid.NewGuid().ToString();
// newRow["FEESTATUS"] = "输入状态";
// newRow["FEENAME"] = "";
// newRow["CUSTOMERNAME"] = "";
// newRow["UNIT"] = "";
// newRow["UNITPRICE"] = 0;
// newRow["QUANTITY"] = 0;
// newRow["COMMISSIONRATE"] = 0;
// newRow["AMOUNT"] = 0;
// newRow["CURRENCY"] = 0;
// newRow["EXCHANGERATE"] = 0;
// newRow["REMARK"] = 0;
// newRow["ISADVANCEDPAY"] = 0;
// cacheTable.Rows.Add(newRow);
// //添加数据源表
// DataRow newFeeRow = feeTable.NewRow();
// newFeeRow["GID"] = Guid.NewGuid().ToString();
// newFeeRow["FEESTATUS"] = "输入状态";
// newFeeRow["FEENAME"] = "";
// newFeeRow["CUSTOMERNAME"] = "";
// newFeeRow["UNIT"] = "";
// newFeeRow["UNITPRICE"] = 0;
// newFeeRow["QUANTITY"] = 0;
// newFeeRow["COMMISSIONRATE"] = 0;
// newFeeRow["AMOUNT"] = 0;
// newFeeRow["CURRENCY"] = 0;
// newFeeRow["EXCHANGERATE"] = 0;
// newFeeRow["REMARK"] = 0;
// newFeeRow["ISADVANCEDPAY"] = 0;
// feeTable.Rows.Add(newFeeRow);
// }
// Session["CachePayTable"] = cacheTable;
// }
// else
// {
// DataTable cacheTable = feeTable.Clone();
// DataRow newRow = cacheTable.NewRow();
// newRow["GID"] = Guid.NewGuid().ToString();
// newRow["FEESTATUS"] = "输入状态";
// newRow["FEENAME"] = "";
// newRow["CUSTOMERNAME"] = "";
// newRow["UNIT"] = "";
// newRow["UNITPRICE"] = 0;
// newRow["QUANTITY"] = 0;
// newRow["COMMISSIONRATE"] = 0;
// newRow["AMOUNT"] = 0;
// newRow["CURRENCY"] = 0;
// newRow["EXCHANGERATE"] = 0;
// newRow["REMARK"] = 0;
// newRow["ISADVANCEDPAY"] = 0;
// cacheTable.Rows.Add(newRow);
// //添加数据源表
// DataRow newFeeRow = feeTable.NewRow();
// newFeeRow["GID"] = Guid.NewGuid().ToString();
// newFeeRow["FEESTATUS"] = "输入状态";
// newFeeRow["FEENAME"] = "";
// newFeeRow["CUSTOMERNAME"] = "";
// newFeeRow["UNIT"] = "";
// newFeeRow["UNITPRICE"] = 0;
// newFeeRow["QUANTITY"] = 0;
// newFeeRow["COMMISSIONRATE"] = 0;
// newFeeRow["AMOUNT"] = 0;
// newFeeRow["CURRENCY"] = 0;
// newFeeRow["EXCHANGERATE"] = 0;
// newFeeRow["REMARK"] = 0;
// newFeeRow["ISADVANCEDPAY"] = 0;
// feeTable.Rows.Add(newFeeRow);
// Session["CachePayTable"] = cacheTable;
// }
//}
#endregion
}
}