阅读:2009
回复:2
|
后台C#如何停止提交
版本 .net 10.4
在前台用js 代码 如下,判断为false时,可以停止提交 $.MvcSheet.Validate = function () { if ($.MvcSheetUI.SheetInfo.ActivityCode == "Activity2") { if (this.Action == "Submit") { var result=valiAmount(); if (result == false) { var levelAmount= $.MvcSheetUI.GetControlValue("LevelAmount"); alert("您每天的报销金额不能超过"+levelAmount+"元!"); return false; } } } } 我想请教下,在后台怎么用C#代码完成同样的功能? |
1楼#
发布于:2019-03-18 08:54
在后台代码中重载SaveDataFields方法
MvcResult.Message = "错误信息提示"; MvcResult.Successful = false; |
|
2楼#
发布于:2019-03-19 16:44
武汉技术支持团队:在后台代码中重载SaveDataFields方法你好,我试了下,可以停止提交,但是不能弹出提示信息!下面是我的代码 using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using OThinker.H3.Controllers; using OThinker.H3.DataModel; using System.Collections.Generic; using OThinker.Data.Database; using System.Data.SqlClient; namespace OThinker.H3.Portal.Sheets.DefaultEngine { public partial class SAdjustBudgetApp : OThinker.H3.Controllers.MvcPage { protected void Page_Load(object sender, EventArgs e) { } public override void SaveDataFields(MvcPostValue MvcPostValue, MvcResult MvcResult) { base.SaveDataFields(MvcPostValue, MvcResult); //判断节点编码和操作动作 if (this.ActionContext.ActivityCode == "Activity2" && MvcPostValue.Command == "Submit") { var strYear=this.ActionContext.InstanceData["BudgetYear"].Value; var DepartID = this.ActionContext.InstanceData["BudgetDepart"].Value; var SumAmount = this.ActionContext.InstanceData["SumAmount"].Value; //读取子表数据 var list = (BizObject[])this.ActionContext.InstanceData["AdjustBudgetAppDetails"].Value; foreach (BizObject rec in list) { //获取子表中字段的值 var SubjectID = rec.ValueTable["SubjectNumber"].ToString(); var SubjectName = rec.ValueTable["SubjectName"].ToString(); decimal F1 = Convert.ToDecimal(rec.ValueTable["F1Amount"]); decimal F2 = Convert.ToDecimal(rec.ValueTable["F2Amount"]); decimal F3 = Convert.ToDecimal(rec.ValueTable["F3Amount"]); decimal F4 = Convert.ToDecimal(rec.ValueTable["F4Amount"]); decimal F5 = Convert.ToDecimal(rec.ValueTable["F5Amount"]); decimal F6 = Convert.ToDecimal(rec.ValueTable["F6Amount"]); decimal F7 = Convert.ToDecimal(rec.ValueTable["F7Amount"]); decimal F8 = Convert.ToDecimal(rec.ValueTable["F8Amount"]); decimal F9 = Convert.ToDecimal(rec.ValueTable["F9Amount"]); decimal F10 = Convert.ToDecimal(rec.ValueTable["F10Amount"]); decimal F11 = Convert.ToDecimal(rec.ValueTable["F11Amount"]); decimal F12 = Convert.ToDecimal(rec.ValueTable["F12Amount"]); decimal F1QC = Convert.ToDecimal(rec.ValueTable["F1AmountQC"]); decimal F2QC = Convert.ToDecimal(rec.ValueTable["F2AmountQC"]); decimal F3QC = Convert.ToDecimal(rec.ValueTable["F3AmountQC"]); decimal F4QC = Convert.ToDecimal(rec.ValueTable["F4AmountQC"]); decimal F5QC = Convert.ToDecimal(rec.ValueTable["F5AmountQC"]); decimal F6QC = Convert.ToDecimal(rec.ValueTable["F6AmountQC"]); decimal F7QC = Convert.ToDecimal(rec.ValueTable["F7AmountQC"]); decimal F8QC = Convert.ToDecimal(rec.ValueTable["F8AmountQC"]); decimal F9QC = Convert.ToDecimal(rec.ValueTable["F9AmountQC"]); decimal F10QC = Convert.ToDecimal(rec.ValueTable["F10AmountQC"]); decimal F11QC = Convert.ToDecimal(rec.ValueTable["F11AmountQC"]); decimal F12QC = Convert.ToDecimal(rec.ValueTable["F12AmountQC"]); decimal jd1 = Convert.ToDecimal(rec.ValueTable["jd1"]); decimal jd2 = Convert.ToDecimal(rec.ValueTable["jd2"]); decimal jd3 = Convert.ToDecimal(rec.ValueTable["jd3"]); decimal jd4 = Convert.ToDecimal(rec.ValueTable["jd4"]); string result="true"; if(F1+F1QC<0 || F2+F2QC<0 || F3+F3QC<0|| F4+F4QC<0|| F5+F5QC<0|| F6+F6QC<0|| F7+F7QC<0|| F8+F8QC<0|| F9+F9QC<0|| F10+F10QC<0|| F11+F11QC<0|| F12+F12QC<0) { result="false"; } if(F1+F2+F3+jd1<0 || F4+F5+F6+jd2<0 || F7+F8+F9+jd3<0 || F10+F11+F12+jd4<0) { result="false"; } if(result=="false") { //Response.Write("<script>alert('不合理!')</script>"); MvcResult.Message = "预算调整不合理"; MvcResult.Successful = false; } } } |
|