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.
DS7/DSWeb/CW/CwVouchersChFeeSettlementLi...

755 lines
36 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using DSWeb.Authority;
namespace DSWeb.CW
{
public partial class CwVouchersChFeeSettlementListGridSource : System.Web.UI.Page
{
public string strHandle;//操作方式
public string strSearch;//查询条件
public int iCurrentPage;//当前页数
public int iShowPage;//显示最大页数
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
public string strUserID;//登录人GID
public string strGids;//
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)
{
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
}
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["gids"] != null)
{
strGids = Request.QueryString["gids"].ToString();
}
if (strHandle != null)
{
if (strHandle == "settlelist")
{
Response.Write(GetSettleList());
return;
}
else if (strHandle == "settlelistpage")
{
Response.Write(GetSettleListPage());
}
else if (strHandle.Trim().ToLower().Equals("isvouchers"))
{
Response.Write(GetIsVouchers().ToString());
}
}
}
private string GetIsVouchers()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sSQL = "";
string alt = "";
string sResult = "";
string sgids = "'" + strGids.Trim().Replace(",", "','") + "'";
//
sSQL = "select top 1 GID from ch_fee_settlement where GID in(" + sgids + ") and (VOUNO is not null and VOUNO<>'')";
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
sResult += "有已生成的凭证,不能重复生成!";
}
//
sSQL = "select count(gid) as hj from ch_fee_do where BILLNO in (select BILLNO from ch_fee_settlement where GID in(" + sgids + "))";
alt = T_ALL_DA.GetStrSQL("hj", sSQL);
if (alt.Trim() == "0")
{
sResult += "没有相关的费用,不能生成凭证!";
}
//帐套设置
sSQL = "SELECT top 1 * from cw_design";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds == null)
{
sResult += "请先设置系统帐套信息!";
}
else
{
string strISFCY = "";//是否核算外币
string strISDEPTACC = "";//是否核算部门
string strISEMPLACC = "";//是否核算人员
string strISCORPACC = "";//是否算客户门
//银行账户判断是否设置
//sSQL = "SELECT top 1 ACCOUNT FROM ((SELECT ACCOUNTRMB as ACCOUNT FROM ch_fee_settlement where GID in(" + sgids + ")) UNION (SELECT ACCOUNTUSD as ACCOUNT FROM ch_fee_settlement where GID in(" + sgids + "))) AS a order by ACCOUNT";
//alt = T_ALL_DA.GetStrSQL("GID", sSQL);
//if (alt.Trim() == "")
//{
// strISCORPACC = "有结算账户为空的数据,请先维护!";
//}
//其他常用科目设置 应收
//ISITEMACC 是否核算项目
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AR"].ToString().Trim() + "'";
DataSet ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
if (ds1.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
{
if (strISCORPACC.Trim() == "")
{
//客户财务编码 (应收的客户财务编码必须核算,应付可以根据配置决定是否核算)
sSQL = "select top 1 GID from info_client where SHORTNAME in (select CUSTOMERNAME from ch_fee_settlement where gid in(" + sgids + ") and BILLTYPE = 1) and (FAPCODE is null or FAPCODE='')";
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
strISCORPACC = "有财务应收帐款代码为空的数据,请先维护!";
}
}
}
//if (ds1.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
//{
// //部门财务编码
// sSQL = "select top 1 GID from sys_dept where DEPTNAME in (select SALEDEPT from op_seae where gid in(" + sgids + ")) and LINKID='" + strCompanyID + "' and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";
// alt = T_ALL_DA.GetStrSQL("GID", sSQL);
// if (alt.Trim() != "")
// {
// strISDEPTACC = "有部门财务软件代码为空的数据,请先维护!";
// }
//}
//if (ds1.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
//{
// //人员财务编码
// sSQL = "select top 1 GID from user_baseinfo where USERID in (select gid from [user] where ISDELETED=0 and SHOWNAME in (select SALE from op_seae where gid in(" + sgids + "))) and COMPANYNAME=(select [NAME] from [company] where GID='" + strCompanyID + "') and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";
// alt = T_ALL_DA.GetStrSQL("GID", sSQL);
// if (alt.Trim() != "")
// {
// strISEMPLACC = "有人员财务软件代码为空的数据,请先维护!";
// }
//}
if (ds1.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
{
//外币财务编码
sSQL = "select top 1 GID from code_currency where CODENAME in (select (case when AMOUNTUSD<>0 then 'USD' else 'RMB' end) as CURRENCY from ch_fee_settlement where gid in(" + sgids + ") and BILLTYPE = 1) and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";// and CURRENCY<>'RMB'
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
strISFCY = "有币别财务软件代码为空的数据,请先维护!";
}
}
}
//其他常用科目设置 应付
sSQL = "SELECT top 1 * from cw_accitems where ACCID='" + ds.Tables[0].Rows[0]["AP"].ToString().Trim() + "'";
ds1 = T_ALL_DA.GetAllSQL(sSQL);
if (ds1 != null)
{
if (ds1.Tables[0].Rows[0]["ISCORPACC"].ToString().Trim() == "True")
{
if (strISCORPACC.Trim() == "")
{
//是否默认付费结算借方科目代码
sSQL = "SELECT top 1 GID from cw_design where ISAPMBSPENDING=0 and ISAPTMSFC=0";
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
//客户财务编码 (应收的客户财务编码必须核算,应付可以根据配置决定是否核算)
sSQL = "select top 1 GID from info_client where SHORTNAME in (select CUSTOMERNAME from ch_fee_settlement where gid in(" + sgids + ") and BILLTYPE = 2) and (FAPCODE is null or FAPCODE='')";
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
strISCORPACC = "有财务应付帐款代码为空的数据,请先维护!";
}
}
}
}
//if (ds1.Tables[0].Rows[0]["ISDEPTACC"].ToString().Trim() == "True")
//{
// //部门财务编码
// sSQL = "select top 1 GID from sys_dept where DEPTNAME in (select SALEDEPT from op_seae where gid in(" + sgids + ")) and LINKID='" + strCompanyID + "' and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";
// alt = T_ALL_DA.GetStrSQL("GID", sSQL);
// if (alt.Trim() != "")
// {
// strISDEPTACC = "有部门财务软件代码为空的数据,请先维护!";
// }
//}
//if (ds1.Tables[0].Rows[0]["ISEMPLACC"].ToString().Trim() == "True")
//{
// //人员财务编码
// sSQL = "select top 1 GID from user_baseinfo where USERID in (select gid from [user] where ISDELETED=0 and SHOWNAME in (select SALE from op_seae where gid in(" + sgids + ")) and COMPANYNAME=(select [NAME] from [company] where GID='" + strCompanyID + "') and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";
// alt = T_ALL_DA.GetStrSQL("GID", sSQL);
// if (alt.Trim() != "")
// {
// strISEMPLACC = "有人员财务软件代码为空的数据,请先维护!";
// }
//}
if (ds1.Tables[0].Rows[0]["ISFCY"].ToString().Trim() == "True")
{
//外币财务编码
sSQL = "select top 1 GID from code_currency where CODENAME in (select CURRENCY from ch_fee_do where BILLNO in (select BILLNO from ch_fee_settlement where GID in(" + sgids + ") and BILLTYPE = 2)) and (FINANCESOFTCODE is null or FINANCESOFTCODE='')";// and CURRENCY<>'RMB'
alt = T_ALL_DA.GetStrSQL("GID", sSQL);
if (alt.Trim() != "")
{
strISFCY = "有币别财务软件代码为空的数据,请先维护!";
}
}
}
sResult += strISCORPACC + strISDEPTACC + strISEMPLACC + strISFCY;
}
//
return sResult;
}
public string GetSettleList()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
DataTable sourceTable;
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
//
string strcbisv = " and (VOUNO is null or VOUNO='')";
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,20) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),A.SETTLETIME,20) <= '{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 ContractNo from VW_Settlement where HTH like '%{0}%'))", strArg[1].Replace("\"", ""));
strCondition += String.Format(" AND exists (select BILLNO from ch_fee_do as v2 where exists (select bsno from VW_Settlement as v1 where (CUSTNO LIKE '%{0}%' or MBLNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%') and v1.bsno=v2.bsno) and v2.billno=A.billno)", strArg[1].Replace("\"", ""));
break;
case "vouno"://ETD EndDate
strCondition += String.Format(" AND A.VOUNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "cbisv"://ETD EndDate
string cbisv = strArg[1].Replace("\"", "");
if (cbisv.Trim() == "true")
{
strcbisv = "";
}
break;
default:
break;
}
}
}
}
}
strCondition += strcbisv;
//
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
}
string strSql = "";
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} A.GID,A.VOUNO,CASE WHEN A.BILLTYPE = 1 THEN '收' ELSE '付' END as BILLTYPE,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.SETTLETIME,A.REMARK "
+ " FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and BILLSTATUS=1 " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY SETTLETIME,BILLNO", "top " + iShowPage.ToString());//BILLNO LIKE 'DR%'收cr付 ORDER BY BILLTYPE DESC DESC
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} A.GID,A.VOUNO,CASE WHEN A.BILLTYPE = 1 THEN '收' ELSE '付' END as BILLTYPE,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.SETTLETIME,A.REMARK "
+ " FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and BILLSTATUS=1 AND A.GID NOT IN "
+ " (SELECT {1} GID FROM ch_fee_settlement WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and BILLSTATUS=1 " + strAuthorityCondition + strCondition + " AND ISNULL(ISDELETE,0) <> 1 ORDER BY SETTLETIME,BILLNO ) " + strAuthorityCondition + strCondition//ORDER BY BILLTYPE DESC DESC
+ " AND ISNULL(ISDELETE,0) <> 1 ORDER BY SETTLETIME,BILLNO ", strTopInclude, strTopNotInclude);//ORDER BY BILLTYPE DESC DESC
}
}
else
{
strSql = " SELECT A.GID,A.VOUNO,CASE WHEN A.BILLTYPE = 1 THEN '收' ELSE '付' END as BILLTYPE,A.BILLNO,A.BILLSTATUS,A.SETTLEMODE,A.CUSTOMERNAME,A.SETTLETYPE,A.AMOUNTUSD,A.AMOUNTRMB,B.SHOWNAME,A.SETTLETIME,A.REMARK FROM ch_fee_settlement as A INNER JOIN [user] as B ON A.SETTLEUSER = B.GID WHERE 1<0";
}
sourceTable = getStatusNameTableBillStatus(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();
if (j == 12)
{
ls = ls.Replace(" ", "");
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();
}
/// <summary>
/// 获取分页总页数
/// </summary>
/// <returns>返回总页数</returns>
private string GetSettleListPage()
{
FeeSettlementDA feeSettlementDA = new FeeSettlementDA();
string strSql = "SELECT COUNT(*) FROM ch_fee_settlement as A WHERE 1=1 and (ISDELETE=0 or ISDELETE is null) and BILLSTATUS=1 AND ISNULL(ISDELETE,0) <> 1 ";
string strAuthorityCondition = "";
UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modRecvSettleList");
if (userAuthorityManage.OperateType != AuthorityType.NULL)
{
strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.RECVSETTLELIST, strShowName, strCompanyID, strDeptName, strUserID);
strSql += strAuthorityCondition;
}
string strCondition = "";
string strcbisv = " and (VOUNO is null or VOUNO='')";
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),SETTLETIME,20) >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "etime"://BillNO
strCondition += String.Format(" AND convert(char(10),SETTLETIME,20) <= '{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 ContractNo from Import_main where HTH like '%{0}%'))", strArg[1].Replace("\"", ""));
strCondition += String.Format(" AND exists (select BILLNO from ch_fee_do as v2 where exists (select bsno from VW_Settlement as v1 where (CUSTNO LIKE '%{0}%' or MBLNO LIKE '%{0}%' or HBLNO LIKE '%{0}%' or CUSTOMNO LIKE '%{0}%' OR CUSTOMNO2 LIKE '%{0}%') and v1.bsno=v2.bsno) and v2.billno=A.billno)", strArg[1].Replace("\"", ""));
break;
case "vouno"://ETD EndDate
strCondition += String.Format(" AND A.VOUNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
break;
case "cbisv"://ETD EndDate
string cbisv = strArg[1].Replace("\"", "");
if (cbisv.Trim() == "true")
{
strcbisv = "";
}
break;
default:
break;
}
}
}
strSql += strCondition;
}
}
strSql += strcbisv;
int iTotal = int.Parse(feeSettlementDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
return iTotal.ToString();
}
/// <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("FEETYPE"))
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = System.Type.GetType("System.String");
cloneTable.Columns.Add(newColumn);
}
else
{
DataColumn newColumn = new DataColumn();
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
newColumn.DataType = sourceTable.Columns[j].DataType;
cloneTable.Columns.Add(newColumn);
}
}
iSwitch = 1;
}
DataRow cloneRow = cloneTable.NewRow();
for (int k = 0; k < sourceTable.Columns.Count; k++)
{
if (sourceTable.Columns[k].ColumnName.Equals("FEETYPE"))
{
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
string strFeeStatus = "";
switch (iFeeStatus)
{
case 1:
strFeeStatus = "收";
break;
case 2:
strFeeStatus = "付";
break;
default:
break;
}
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
}
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;
}
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") || sourceTable.Columns[j].ColumnName.Equals("SETTLEMODE") || 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;
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);
}
//cloneTable.Columns.Remove("FEESTATUS");
//cloneTable.Columns.Add(new DataColumn("FEESTATUS", System.Type.GetType("System.String")));
return cloneTable;
}
#region 金额四舍五入
/// <summary>
/// 金额四舍五入
/// </summary>
/// <param name="value">金额值</param>
/// <param name="digit">小数点后位数</param>
/// <returns>返回Double型四舍五入金额</returns>
public double C1Round(double value, int digit)
{
double vt = Math.Pow(10, digit);
double vx = value * vt;
vx += 0.5;
return (Math.Floor(vx) / vt);
}
#endregion
#region 获取返回状态
/// <summary>
/// 获取返回状态
/// </summary>
/// <param name="tempPostNoticeType">错误类型</param>
/// <returns>返回String类型状态</returns>
private string GetPostResult(PostNoticeType tempPostNoticeType)
{
string strResult = "";
switch (tempPostNoticeType)
{
case PostNoticeType.DIFFCUSTOMER://同时有多个结算单位
strResult = "-1";
break;
case PostNoticeType.DIFFCURRENCY://有不同币别,需要调用汇率
strResult = "-2";
break;
case PostNoticeType.BEYONDMAXLINE://发票明细超过最大显示条数
strResult = "-3";
break;
case PostNoticeType.SESSIONFAILURE://缓存数据异常
strResult = "-4";
break;
case PostNoticeType.POSTSUCCESS://提交申请成功
strResult = "1";
break;
default:
break;
}
return strResult;
}
#endregion
private DataTable CreateTotalTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("RECVRMB");
tempTable.Columns.Add("RECVUSD");
tempTable.Columns.Add("PAYRMB");
tempTable.Columns.Add("PAYUSD");
tempTable.Columns.Add("TOTALRMB");
tempTable.Columns.Add("TOTALUSD");
return tempTable;
}
private DataTable CreategidTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("gid");
tempTable.Columns.Add("CUSTOMERNAME");
tempTable.Columns.Add("CUSTNO");
tempTable.Columns.Add("MBLNO");
tempTable.Columns.Add("HBLNO");
return tempTable;
}
private DataTable CreateFeeTable()
{
DataTable tempTable = new DataTable();
tempTable.Columns.Add("GID");
tempTable.Columns.Add("gid");
tempTable.Columns.Add("FEETYPE");
tempTable.Columns.Add("CUSTOMERNAME");
tempTable.Columns.Add("FEENAME");
tempTable.Columns.Add("CURRENCY");
tempTable.Columns.Add("AMOUNT");
tempTable.Columns.Add("CTL");
tempTable.Columns.Add("UCTL");
return tempTable;
}
}
public enum PostNoticeType
{
DIFFCUSTOMER = 0,
DIFFCURRENCY = 1,
BEYONDMAXLINE = 2,
SESSIONFAILURE = 3,
POSTSUCCESS = 4
}
}