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 WebSqlHelper; using DSWeb.Models; using DSWeb.EntityDA; using System.Text; namespace DSWeb.Shipping { public partial class FeeHistoryGridSource : System.Web.UI.Page { private string strUserID;//用户GID private string strHandle; private int iFeeType;//费用类型 值1应收 值2应付 private string strBSNO;//委托编号 private string strFeeID;//费用GID private string stroplb = "";//业务类别 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().Trim().ToLower(); } if (Request.QueryString["oplb"] != null) { stroplb = Request.QueryString["oplb"].ToString(); } if (Request.QueryString["bsno"] != null) { strBSNO = Request.QueryString["bsno"].ToString(); } if (Request.QueryString["feeid"] != null) { strFeeID = Request.QueryString["feeid"].ToString().Trim(); } if(Request.QueryString["feetype"] != null) { try { iFeeType = int.Parse(Request.QueryString["feetype"].ToString()); } catch { iFeeType = 0; } } if (strHandle != null) { //获取费用信息 if (strHandle == "feelist" && strBSNO != null && iFeeType != 0) { Response.Write(GetFeeList()); } //获取结算信息 if (strHandle == "settlelist" && strFeeID != null) { Response.Write(GetFeeSettlementList()); } //获取开出发票信息 if (strHandle == "invoicemake" && strFeeID != null) { Response.Write(GetInvoiceMakeOutList()); } //获取开票申请信息 if (strHandle == "invoicapp" && strFeeID != null) { Response.Write(GetInvoiceApplicationList()); } //获取费用申请修改信息 if (strHandle == "modifylist" && strFeeID != null) { Response.Write(GetFeeModifyList()); } } } #region 获取费用申请修改信息 /// /// 获取费用申请修改信息 /// /// 费用申请修改信息JSON private string GetFeeModifyList() { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strSql = " SELECT A.GID,APPLYTYPE,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,CURRENCY,EXCHANGERATE, " + " REASON,B.SHOWNAME as APPLYUSER,APPLYTIME,C.SHOWNAME as AUDITUSER,AUDITTIME " + " FROM ch_fee_modify as A LEFT JOIN [user] as B ON A.APPLYUSER = B.GID " + " LEFT JOIN [user] as C ON A.AUDITUSER = C.GID WHERE A.FEEID = '" + strFeeID + "'"; sourceTable = getStatusNameTable(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:["); //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 获取开出发票信息 /// /// 获取开出发票信息 /// /// 开出发票信息JSON private string GetInvoiceMakeOutList() { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strSql = " SELECT A.GID,B.FEENAME,A.CUSTOMERNAME,A.CURRENCY,B.DOAMOUNT,B.AMOUNT,B.BILLNO,A.INVOICENO,A.INVOICEMAKETIME,C.SHOWNAME as OPERATOR " + " FROM ch_fee_invoice as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN [user] as C ON A.OPERATOR = C.GID " + " WHERE B.FEEID = '" + strFeeID + "'"; 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:["); //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 获取开票申请信息 /// /// 获取开票申请信息 /// /// 开票申请信息JSON private string GetInvoiceApplicationList() { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strSql = " SELECT A.GID,B.FEENAME,A.CUSTOMERNAME,A.CURRENCY,B.DOAMOUNT,B.AMOUNT,B.BILLNO,A.INVOICENO,A.APPLYTIME,C.SHOWNAME as APPLICANT " + " FROM ch_fee_invoiceapplication as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN [user] as C ON A.APPLICANT = C.GID " + " WHERE B.FEEID = '" + strFeeID + "'"; 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:["); //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 获取费用列表信息 /// /// 获取费用列表信息 /// /// 费用列表信息JSON private string GetFeeList() { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strSql = String.Format("SELECT GID,FEETYPE,FEESTATUS,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,CURRENCY,EXCHANGERATE FROM ch_fee WHERE BSNO = '{0}' AND FEETYPE = {1}", strBSNO, iFeeType); sourceTable = getStatusNameTable(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:["); //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 获取费用结算信息 /// /// 获取费用结算信息 /// /// 费用结算列表JSON public string GetFeeSettlementList() { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strSql = " SELECT B.GID,B.FEENAME,A.CUSTOMERNAME,B.CURRENCY,B.DOAMOUNT,B.AMOUNT,A.BILLNO,A.SETTLETIME,A.SETTLETYPE,C.SHOWNAME as SETTLEUSER " + " FROM ch_fee_settlement as A INNER JOIN ch_fee_do as B ON A.BILLNO = B.BILLNO INNER JOIN [user] as C ON A.SETTLEUSER = C.GID WHERE B.FEEID = '" + strFeeID + "'"; sourceTable = getStatusNameTable(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:["); //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 将数据集表中费用状态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("FEETYPE")) { 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("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("SETTLETYPE")) { 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("APPLYTYPE")) { 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 if (sourceTable.Columns[k].ColumnName.Equals("APPLYTYPE")) { 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 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("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; } #endregion } }