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; namespace DSWeb.Shipping { public partial class FeeModifySource : System.Web.UI.Page { private string strHandle;//值为"fee"获取显示数据 private string strFeeID;//费用GID private int iApplyType;//值1表示 申请的旧值 值2表示申请的新值 private int iApplyState;//申请状态 值1表示已经提交申请 值2表示初次加载 private int iCheckState;//查询历史信息条件 值1表示查询未处理的费用更改申请 值2表示查询已完成处理的费用更改申请 值3表示查询所有申请更改的信息 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["oplb"] != null) { stroplb = Request.QueryString["oplb"].ToString(); } if (Request.QueryString["id"] != null) { strFeeID = Request.QueryString["id"].ToString().Trim().ToLower(); } if (Request.QueryString["applytype"] != null) { iApplyType = int.Parse(Request.QueryString["applytype"].ToString().Trim()); } if (Request.QueryString["applystate"] != null) { iApplyState = int.Parse(Request.QueryString["applystate"].ToString().Trim()); } if (Request.QueryString["checkstate"] != null) { iCheckState = int.Parse(Request.QueryString["checkstate"].ToString().Trim()); } if (strHandle.Equals("apply")) { string strOutputXml = ""; strOutputXml = GetCells(strFeeID, iApplyType, iApplyState, iCheckState); //输出XML字符串 Response.ContentType = "text/xml"; strOutputXml.Replace("&", "&"); Response.Write(strOutputXml); } else if (strHandle.Equals("exist")) { Response.Write(IsExistFee(strFeeID)); } else { //访问参数不正确 Response.ContentType = "text/xml"; Response.Write("-2"); } } /// /// 获取费用更改信息 /// /// 费用GID /// 值1表示 申请的旧值 值2表示申请的新值 /// 查看申请类型 值0表示首次提交申请 值1表示操作人查看申请更改信息 值2表示审核人查看申请更改信息 /// 查看范围类型 值1表示查看未处理的申请信息 值2表示查看已经处理的申请信息 值3表示查看所有费用相关的处理信息 /// private string GetCells(string tempFeeID,int tempApplyType,int tempApplyState,int tempCheckState) { FeeDA feeDA = new FeeDA(); FeeModifyDA feeModifyDA = new FeeModifyDA(); if (tempApplyState == 0)//值1表示首次申请 { #region 首次申请 //如果是首次申请,则将读取ch_fee表数据记录 //获取所有费用信息,用做Grid显示 DataTable feeTable = new DataTable(); //初始化 string strInitSql = " SELECT {0} GID, FEESTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY, " + " EXCHANGERATE,FEEFRT,REMARK,ISADVANCEDPAY FROM ch_fee WHERE 1> 0 {1} {2}"; string strSql = ""; strSql = string.Format(strInitSql, "", " AND GID = '" + tempFeeID + "'", " ORDER BY ENTERDATE ASC "); feeTable = getStatusNameTable(feeDA.GetExcuteSql(strSql).Tables[0]); //编排字符串 xml串 StringBuilder dataBuilder = new StringBuilder(); dataBuilder.Append(""); dataBuilder.Append(""); int iCount = feeTable.Rows.Count; for (int i = 0; i < iCount; i++) { int jCount = feeTable.Columns.Count; dataBuilder.Append(""); 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("" + feeTable.Rows[i][j].ToString() + ""); 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("1"); } else { dataBuilder.Append("0"); } break; default: dataBuilder.Append("" + feeTable.Rows[i][j].ToString() + ""); break; } } dataBuilder.Append(""); } dataBuilder.Append(""); return dataBuilder.ToString(); #endregion } else { #region 获取申请信息 string strSql = ""; if (tempApplyType == 1)//查看旧值 { switch (tempCheckState) { case 1://查询未处理的更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} AND APPLYSTATUS = {2} ", tempFeeID, tempApplyType, 1); break; case 2://查看已处理的更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} AND ( APPLYSTATUS = 2 OR APPLYSTATUS = 3) ", tempFeeID, tempApplyType); break; case 3://查看全部更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} ", tempFeeID, tempApplyType); break; } } else if (tempApplyType == 2)//查看新值 { switch (tempCheckState) { case 1://查询未处理的更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY,REASON FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} AND APPLYSTATUS = {2} ", tempFeeID, tempApplyType, 1); break; case 2://查看已处理的更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY,REASON FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} AND ( APPLYSTATUS = 2 OR APPLYSTATUS = 3) ", tempFeeID, tempApplyType); break; case 3://查看全部更改申请信息 strSql = String.Format("SELECT GID,APPLYSTATUS, FEENAME, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY,COMMISSIONRATE,AMOUNT, CURRENCY," + "EXCHANGERATE,FRT,REMARK,ISADVANCEDPAY,REASON FROM ch_fee_modify WHERE FEEID = '{0}' AND APPLYTYPE = {1} ", tempFeeID, tempApplyType); break; } } DataTable feeTable = new DataTable(); feeTable = getApplyStatusNameTable(feeDA.GetExcuteSql(strSql).Tables[0]); //编排字符串 xml串 StringBuilder dataBuilder = new StringBuilder(); dataBuilder.Append(""); dataBuilder.Append(""); int iCount = feeTable.Rows.Count; for (int i = 0; i < iCount; i++) { int jCount = feeTable.Columns.Count; dataBuilder.Append(""); 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("" + feeTable.Rows[i][j].ToString() + ""); 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("1"); } else { dataBuilder.Append("0"); } break; default: dataBuilder.Append("" + feeTable.Rows[i][j].ToString() + ""); break; } } dataBuilder.Append(""); } dataBuilder.Append(""); return dataBuilder.ToString(); #endregion } } #region 查看是否有相应的费用信息 /// /// 查看是否有相应的费用信息 /// /// /// 值为1表示存在相关费用信息,值小于等于0则表示没有相关费用信息 private string IsExistFee(string tempFeeID) { int iResult = 0; FeeEntity feeEntity; FeeDA feeDA = new FeeDA(); feeEntity = feeDA.GetFeeByID(tempFeeID); if (feeEntity != null) { if (feeEntity.GID != null) { iResult = 1; } else { iResult = -4; } } else { iResult = -4; } return iResult.ToString(); } #endregion /// /// 获取CRM系统客户信息下拉列表 /// /// 当前列表客户信息值 /// public string GetCRMClientCells(string strClientValue) { CRMClientDA crmClientDA = new CRMClientDA(); DataTable clientTable = crmClientDA.GetCRMClientList().Tables[0]; StringBuilder clientBuilder = new StringBuilder(); clientBuilder.Append("" + strClientValue); for (int i = 0; i < clientTable.Rows.Count; i++) { if (!clientTable.Rows[i]["SHORTNAME"].ToString().Trim().Equals("")) { clientBuilder.Append(""); } } clientBuilder.Append(""); return clientBuilder.ToString(); } /// /// 获取币别信息下拉列表 /// /// public string GetCurrencyCells(string strCurrencyValue) { CurrencyDA currencyDA = new CurrencyDA(); DataTable currencyTable = currencyDA.GetCurrencyList().Tables[0]; StringBuilder currencyBuilder = new StringBuilder(); currencyBuilder.Append("" + strCurrencyValue); for (int i = 0; i < currencyTable.Rows.Count; i++) { if (!currencyTable.Rows[i]["DESCRIPTION"].ToString().Trim().Equals("")) { currencyBuilder.Append(""); } } currencyBuilder.Append(""); return currencyBuilder.ToString(); } /// /// 获取费用代码信息下拉列表 /// /// /// public string GetFeeCodeCells(string strFeeCodeValue) { FeeCodeDA feeCodeDA = new FeeCodeDA(); DataTable feeCodeTable = feeCodeDA.GetFeeCodeList().Tables[0]; StringBuilder feeCodeBuilder = new StringBuilder(); feeCodeBuilder.Append("" + strFeeCodeValue); for (int i = 0; i < feeCodeTable.Rows.Count; i++) { if (!feeCodeTable.Rows[i]["NAME"].ToString().Trim().Equals("")) { feeCodeBuilder.Append(""); } } feeCodeBuilder.Append(""); return feeCodeBuilder.ToString(); } /// /// 获取标准信息下拉列表 /// /// /// public string GetUnitCells(string strUnitValue) { StringBuilder unitBuilder = new StringBuilder(); unitBuilder.Append("" + strUnitValue); unitBuilder.Append(""); unitBuilder.Append(""); //unitBuilder.Append(""); unitBuilder.Append(""); unitBuilder.Append(""); unitBuilder.Append(""); unitBuilder.Append(""); unitBuilder.Append(""); unitBuilder.Append(""); return unitBuilder.ToString(); } /// /// 获取引入类型信息下拉列表 /// /// /// public string GetFRTCells(string strFRTValue) { StringBuilder frtBuilder = new StringBuilder(); frtBuilder.Append("" + strFRTValue); frtBuilder.Append(""); frtBuilder.Append(""); frtBuilder.Append(""); return frtBuilder.ToString(); } #region 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字 /// /// 将数据集表中费用状态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 { 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 将数据集表中费用状态APPLYSTATUS和应收应付类型FeeType的数字状态位转换成文字 /// /// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字 /// /// 原数据源DataTable /// 返回新数据源DataTable private DataTable getApplyStatusNameTable(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("APPLYSTATUS")) { 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("APPLYSTATUS")) { 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 { 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 } }