protected void Page_Load(object sender, EventArgs e) { #region 接收参数 bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sLoanID = this.Request.QueryString["LoanID"].ToString(); if (this.Request.QueryString["LoanRuleIDs"] == null) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sLoanRuleIDs = this.Request.QueryString["LoanRuleIDs"].ToString(); if (Regex.IsMatch(sLoanRuleIDs, @"^([1-9]\d*)(,[1-9]\d*)*$") == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Invalid query string.\"}"); this.Response.End(); } #endregion // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"} string sExecResult = string.Empty; string sErrorMsg = string.Empty; try { LPWeb.BLL.LoanRules LoanRules1 = new LPWeb.BLL.LoanRules(); LoanRules1.RemoveRuleFromLoan(Convert.ToInt32(sLoanID), sLoanRuleIDs); sExecResult = "Success"; sErrorMsg = ""; } catch (Exception ex) { sExecResult = "Failed"; sErrorMsg = "Failed to remove selected rule(s)."; } System.Threading.Thread.Sleep(1000); this.Response.Write("{\"ExecResult\":\"" + sExecResult + "\",\"ErrorMsg\":\"" + sErrorMsg + "\"}"); this.Response.End(); }
protected void Page_Load(object sender, EventArgs e) { #region 检查必要参数 bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID); if (bIsValid == false) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_AddRule();", true); return; } this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]); //Get rule num by loan id LPWeb.BLL.LoanRules loanRulesMgr = new LPWeb.BLL.LoanRules(); System.Data.DataSet ds = loanRulesMgr.GetList(" Fileid=" + this.iLoanID.ToString()); int iRuleCount = ds.Tables[0].Rows.Count; this.hdnAddRuleNum.Value = (20 - iRuleCount).ToString(); #endregion #region 初始化Rule列表 this.RuleSqlDataSource.ConnectionString = LPWeb.DAL.DbHelperSQL.connectionString; string sSql = "select * from Template_Rules where Enabled=1 and RuleId not in (select RuleId from LoanRules where Fileid=" + this.iLoanID.ToString() + " and RuleId is not null)" + " AND RuleScope = 0 AND (LoanTarget = 0 OR LoanTarget = 2)"; // //Check prospect loan if (iLoanID != 0) { LPWeb.BLL.Loans loanMgr = new LPWeb.BLL.Loans(); LPWeb.Model.Loans loanModel = loanMgr.GetModel(iLoanID); if (loanModel.Status.Trim().ToLower() == "prospect") { this.hdnProspectLoan.Value = "true"; sSql = "SELECT * FROM Template_Rules WHERE Enabled=1 AND RuleId NOT IN (SELECT RuleId FROM LoanRules WHERE Fileid=" + this.iLoanID.ToString() + " AND RuleId IS NOT NULL)" + " AND RuleScope = 0 AND (LoanTarget = 1 OR LoanTarget = 2)"; } } this.RuleSqlDataSource.SelectCommand = sSql; this.gridRuleList.DataBind(); #endregion }