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 DSWeb.Authority; namespace DSWeb.BaseInfo { public partial class OpSeaiBaseInfoGridSource : System.Web.UI.Page { private string strHandle; private int iFeeType;//费用类型 private string strBSNO;//委托业务BSNO private string strShowName;//用户显示名 private string strDeptName;//部门名称 private string strUserID;//登录人GID private string strCompanyID;//公司GID private int iCurrentPage;//当前页数 private int iShowPage;//显示最大页数 protected void Page_Load(object sender, EventArgs e) { #region Session 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(); } #endregion #region Reques String if (Request.QueryString["handle"] != null) { strHandle = Request.QueryString["handle"].ToString().Trim().ToLower(); } if (Request.QueryString["bsno"] != null) { strBSNO = Request.QueryString["bsno"].ToString(); } if (Request.QueryString["feetype"] != null) { iFeeType = int.Parse(Request.QueryString["feetype"].ToString()); } else { iFeeType = 0; } 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; } #endregion if (strHandle != null) { if (strHandle == "getfee" && strBSNO != null) { Response.Write(GetFeeDataSource(iFeeType, strBSNO)); } if (strHandle == "getfeepage" && strBSNO != null) { Response.Write(GetFeeListPage(strBSNO, iFeeType)); } } } #region 获取费用的总页数 /// /// 获取费用的总页数 /// /// 委托业务BSNO /// 费用类型 /// 返回总页数 private int GetFeeListPage(string tempBSNO, int tempType) { FeeDA feeDA = new FeeDA(); string strSql = "SELECT COUNT(*) FROM ch_fee as A WHERE 1 > 0 "; string strAuthorityCondition = ""; if (iFeeType == 1) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID); } strSql += " AND A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition; } else if (iFeeType == 2) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiPayFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID); } strSql += " AND A.FEETYPE = 2 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition; } int iTotal = int.Parse(feeDA.GetExcuteSql(strSql).Tables[0].Rows[0][0].ToString()); return iTotal; } #endregion #region 获取费用列表信息 /// /// 获取费用列表信息 /// /// 费用类型 /// 委托业务BSNO /// 返回JSON数据 private string GetFeeDataSource(int tempFeeType, string tempBSNO) { FeeDA feeDA = new FeeDA(); DataTable sourceTable; string strTopInclude = ""; string strTopNotInclude = ""; string strSql = ""; string strAuthorityCondition = ""; if (iCurrentPage > 0 && iShowPage > 0) { if (iCurrentPage == 1) { if (iFeeType == 1) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID); } strSql = String.Format(" 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,ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE " + " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID " + " WHERE A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " ORDER BY ENTERDATE,GID DESC", "top " + iShowPage.ToString()); } else if (iFeeType == 2) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiPayFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID);//SEAIPAYFEE } strSql = String.Format(" 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,ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE " + " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID " + " WHERE A.FEETYPE = 2 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " ORDER BY A.ENTERDATE DESC ", "top " + iShowPage.ToString()); } } else { strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum strTopInclude = "top " + iShowPage.ToString(); if (iFeeType == 1) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIRECVFEE, strShowName, strCompanyID, strDeptName, strUserID); } strSql = String.Format(" 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,ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE " + " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID " + " WHERE A.FEETYPE = 1 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " AND A.GID NOT IN ( SELECT {1} GID FROM ch_fee WHERE FEETYPE = 1 AND BSNO = '" + strBSNO + "' " + strAuthorityCondition + " ORDER BY ENTERDATE,GID DESC) " + " ORDER BY A.ENTERDATE DESC,A.GID ", strTopInclude, strTopNotInclude); } else if (iFeeType == 2) { UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement"); if (userAuthorityManage.OperateType != AuthorityType.NULL) { strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.SEAIPAYFEE, strShowName, strCompanyID, strDeptName, strUserID); } strSql = String.Format(" 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,ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE " + " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID " + " WHERE A.FEETYPE = 2 AND A.BSNO = '" + strBSNO + "' " + strAuthorityCondition + " AND A.GID NOT IN ( SELECT {1} GID FROM ch_fee WHERE FEETYPE = 2 AND BSNO = '" + strBSNO + "' " + strAuthorityCondition + " ORDER BY ENTERDATE DESC,GID) " + " ORDER BY A.ENTERDATE DESC,A.GID ", strTopInclude, strTopNotInclude); } } } else { strSql = "SELECT 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,ISNULL(A.SETTLEMENT,0),ISNULL(A.INVOICE,0),ISNULL(A.INVOICENUM,''),B.SHOWNAME,A.ENTERDATE " + " FROM ch_fee as A LEFT JOIN [user] as B ON A.ENTEROPERATOR = B.GID " + " WHERE 1<0"; } sourceTable = getBillStatusNameTable(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++) { string ls = sourceTable.Rows[i][j].ToString(); 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(); } #endregion #region 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字 /// /// 将数据集表中费用状态FeeStatus和应收应付类型FeeType的数字状态位转换成文字 /// /// 原数据源DataTable /// 返回新数据源DataTable private DataTable getBillStatusNameTable(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 { 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; } 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); } return cloneTable; } #endregion } }