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.
398 lines
17 KiB
C#
398 lines
17 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 System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using DSWeb.Models;
|
|
using DSWeb.EntityDA;
|
|
|
|
namespace DSWeb.ParameterSet
|
|
{
|
|
public partial class FeeCodeGridSource : System.Web.UI.Page
|
|
{
|
|
private string strHandle;
|
|
private int iCurrentPage;//当前页数
|
|
private int iShowPage;//显示最大页数
|
|
private string strSearch;//查询搜索条件
|
|
private string strUserID;//登录人GID
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if(Session["USERID"] != null)
|
|
{
|
|
strUserID = Session["USERID"].ToString();
|
|
}
|
|
if (Request.QueryString["handle"] != null)
|
|
{
|
|
strHandle = Request.QueryString["handle"].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["search"] != null)
|
|
{
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
|
|
}
|
|
|
|
if (strHandle != null)
|
|
{
|
|
if (strHandle == "codelist")
|
|
{
|
|
Response.Write(GetFeeCodeList());
|
|
}
|
|
if (strHandle == "codelistpage")
|
|
{
|
|
Response.Write(GetFeeCodeListPage());
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 获取费用代码列表信息
|
|
/// <summary>
|
|
/// 获取费用代码列表信息
|
|
/// </summary>
|
|
/// <returns>返回JSON数据源信息</returns>
|
|
public string GetFeeCodeList()
|
|
{
|
|
FeeCodeDA feeCodeDA = new FeeCodeDA();
|
|
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.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.NAME LIKE '%{0}%' OR A.DESCRIPTION LIKE '%{0}%') ", strArg[1].Replace("\"", ""));
|
|
break;
|
|
case "no"://ETD EndDate
|
|
strCondition += String.Format(" AND A.FEECODE LIKE '%{0}%'", strArg[1].Replace("\"", ""));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
string strSql = "";
|
|
if (iCurrentPage > 0 && iShowPage > 0)
|
|
{
|
|
if (iCurrentPage == 1)
|
|
{
|
|
strSql = String.Format(" SELECT {0} A.GID, A.FEECODE, A.NAME, A.DESCRIPTION, A.DEFAULTCURR, A.ISSEA, A.ISAIR, ISNULL(A.DEFAULTUNIT,0), ISNULL(A.DEFAULTDEBIT,0), ISNULL(A.DEFAULTCREDIT,0), B.SHOWNAME as CREATEUSER, A.CREATETIME "
|
|
+ " FROM code_fee as A INNER JOIN [user] as B ON A.CREATEUSER = B.GID WHERE 1 > 0 " + strCondition + " ORDER BY A.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, A.FEECODE, A.NAME, A.DESCRIPTION, A.DEFAULTCURR, A.ISSEA, A.ISAIR, ISNULL(A.DEFAULTUNIT,0), ISNULL(A.DEFAULTDEBIT,0), ISNULL(A.DEFAULTCREDIT,0), B.SHOWNAME as CREATEUSER, A.CREATETIME "
|
|
+ " FROM code_fee as A INNER JOIN [user] as B ON A.CREATEUSER = B.GID WHERE A.GID NOT IN "
|
|
+ " (SELECT {1} GID FROM code_fee WHERE 1>0 " + strCondition + " ORDER BY CREATETIME DESC ) " + strCondition
|
|
+ " ORDER BY A.CREATETIME DESC ", strTopInclude, strTopNotInclude);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strSql = " SELECT A.GID, A.FEECODE, A.NAME, A.DESCRIPTION, A.DEFAULTCURR, A.ISSEA, A.ISAIR, ISNULL(A.DEFAULTUNIT,0), ISNULL(A.DEFAULTDEBIT,0), ISNULL(A.DEFAULTCREDIT,0), B.SHOWNAME as CREATEUSER, A.CREATETIME "
|
|
+ " FROM code_fee as A INNER JOIN [user] as B ON A.CREATEUSER = B.GID WHERE 1>0 " + strCondition + " ORDER BY A.CREATETIME DESC ";
|
|
}
|
|
sourceTable = getStatusNameTable(feeCodeDA.GetExcuteSql(strSql).Tables[0]);
|
|
|
|
StringBuilder sourceBuilder = new StringBuilder();
|
|
sourceBuilder.Append("{");
|
|
sourceBuilder.Append("rows:[");
|
|
for (int i = 0; i < sourceTable.Rows.Count; i++)
|
|
{
|
|
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
|
|
sourceBuilder.Append("data:[");
|
|
sourceBuilder.Append("\"0\",");
|
|
for (int j = 1; j < sourceTable.Columns.Count; j++)
|
|
{
|
|
if (j == sourceTable.Columns.Count - 1)
|
|
{
|
|
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
|
|
}
|
|
else
|
|
{
|
|
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
|
|
}
|
|
}
|
|
if (i == sourceTable.Rows.Count - 1)
|
|
{
|
|
sourceBuilder.Append("]}");
|
|
}
|
|
else
|
|
{
|
|
sourceBuilder.Append("]},");
|
|
}
|
|
|
|
}
|
|
sourceBuilder.Append("]");
|
|
sourceBuilder.Append("}");
|
|
|
|
return sourceBuilder.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region 获取费用代码信息总页数
|
|
/// <summary>
|
|
/// 获取费用代码信息总页数
|
|
/// </summary>
|
|
/// <returns>返回费用代码总页数</returns>
|
|
private int GetFeeCodeListPage()
|
|
{
|
|
FeeTemplateDA feeTemplateDA = new FeeTemplateDA();
|
|
string strSql = "SELECT COUNT(*) FROM code_fee WHERE 1 > 0 ";
|
|
|
|
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),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 BILLNO LIKE '%{0}%'", strArg[1].Replace("\"", ""));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
strSql += strCondition;
|
|
}
|
|
}
|
|
|
|
int iTotal = int.Parse(feeTemplateDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString());
|
|
|
|
return iTotal;
|
|
}
|
|
#endregion
|
|
#region 将数据集表中费用状态DEFAULTUNIT、DEFAULTDEBIT、DEFAULTCREDIT的数字状态位转换成文字
|
|
/// <summary>
|
|
/// 将数据集表中费用状态DEFAULTUNIT、DEFAULTDEBIT、DEFAULTCREDIT的数字状态位转换成文字
|
|
/// </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("DEFAULTUNIT"))
|
|
{
|
|
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("DEFAULTDEBIT"))
|
|
{
|
|
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("DEFAULTCREDIT"))
|
|
{
|
|
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("DEFAULTUNIT"))
|
|
{
|
|
int iFeeStatus = int.Parse(sourceTable.Rows[i][k].ToString());
|
|
string strFeeStatus = "";
|
|
switch (iFeeStatus)
|
|
{
|
|
case 1:
|
|
strFeeStatus = "单票";
|
|
break;
|
|
case 2:
|
|
strFeeStatus = "重量";
|
|
break;
|
|
//case 6:
|
|
// strFeeStatus = "净重";
|
|
// break;
|
|
case 3:
|
|
strFeeStatus = "尺码";
|
|
break;
|
|
case 4:
|
|
strFeeStatus = "计费吨";
|
|
break;
|
|
case 5:
|
|
strFeeStatus = "TEU";
|
|
break;
|
|
case 7:
|
|
strFeeStatus = "总价";
|
|
break;
|
|
case 8:
|
|
strFeeStatus = "计价重量";
|
|
break;
|
|
case 10:
|
|
strFeeStatus = "CBM";//
|
|
break;
|
|
case 11:
|
|
strFeeStatus = "BILL";//
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
cloneRow[sourceTable.Columns[k].ColumnName] = strFeeStatus;
|
|
}
|
|
else if (sourceTable.Columns[k].ColumnName.Equals("DEFAULTDEBIT") || sourceTable.Columns[k].ColumnName.Equals("DEFAULTCREDIT"))
|
|
{
|
|
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;
|
|
case 6:
|
|
strFeeStatus = "报关行";
|
|
break;
|
|
case 7:
|
|
strFeeStatus = "代理";
|
|
break;
|
|
case 8:
|
|
strFeeStatus = "航空公司";
|
|
break;
|
|
case 9:
|
|
strFeeStatus = "发货人";
|
|
break;
|
|
case 10:
|
|
strFeeStatus = "收货人";
|
|
break;
|
|
case 11:
|
|
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
|
|
}
|
|
}
|