public static MucDialogue_CreateOrEdit UpdateCreateOrEditPage(T boVM, bool isNew, List <ValidatorResult> vItems) { var preString = "编辑:"; var preIcon = "icon-pencil"; if (isNew) { preString = "新建:"; preIcon = "icon-new"; } var boType = typeof(T); Attribute[] boVMAttributes = Attribute.GetCustomAttributes(boType); var editorSpecification = boVMAttributes.Where(n => n.GetType().Name == "EditorSpecification").FirstOrDefault() as EditorSpecification; var dialog = new MucDialogue_CreateOrEdit(); dialog.CaptionName = preString + editorSpecification.Title; dialog.IconName = preIcon; dialog.Width = 500; dialog.Height = 300; var htmlString = new StringBuilder(); htmlString.Append(_GetEditor(boVM, vItems)); dialog.InnerHtmlContent = htmlString.ToString(); return(dialog); }
/// <summary> /// 以页面方式呈现业务对象编辑场景 /// </summary> /// <param name="boVM"></param> /// <param name="isNew"></param> /// <param name="typeID"></param> /// <returns></returns> public static MucDialogue_CreateOrEdit CreateOrEditPage(T boVM, bool isNew) { var preString = "编辑:"; var preIcon = "icon-pencil"; if (isNew) { preString = "新建:"; preIcon = "icon-new"; } var boType = typeof(T); var boName = typeof(T).Name; Attribute[] boVMAttributes = Attribute.GetCustomAttributes(boType); var editorSpecification = boVMAttributes.Where(n => n.GetType().Name == "EditorSpecification").FirstOrDefault() as EditorSpecification; var dialog = new MucDialogue_CreateOrEdit(); dialog.CaptionName = preString + editorSpecification.Title; dialog.IconName = preIcon; dialog.Width = 500; dialog.Height = 300; var htmlString = new StringBuilder(); htmlString.Append("<p class='subheader'>" + preString + editorSpecification.Title + "</p>"); htmlString.Append("<script>"); htmlString.Append("var options = {"); htmlString.Append("dataType: 'json',"); htmlString.Append("success: function (data) {"); htmlString.Append("};"); htmlString.Append("$('#EditorForm_" + editorSpecification.ControllerName + "').ajaxForm(options);"); htmlString.Append("</script>"); htmlString.Append("<form action='../../" + editorSpecification.ControllerName + "/" + editorSpecification.SaveAction + "' method='post' id='EditorForm_" + editorSpecification.ControllerName + "'data-ajax-update='#Editor_" + editorSpecification.ControllerName + "' data-ajax-mode='replace' data-ajax='true' >");// data-ajax-update='#Editor_" + editorAttribute.ControllerName + "' data-ajax-mode='replace' data-ajax='true'>"); htmlString.Append("<div id='Editor_" + editorSpecification.ControllerName + "' name='Editor_" + editorSpecification.ControllerName + "'>"); htmlString.Append(_GetEditor(boVM)); htmlString.Append("</div>"); htmlString.Append("<div class='form-actions' style='text-align:right'><br/>"); htmlString.Append("<button class='button primary' style='height:30px' value=''>确定</button>"); htmlString.Append("</div>"); htmlString.Append("</form>"); dialog.InnerHtmlContent = htmlString.ToString(); return(dialog); }
/// <summary> /// 以对话框方式呈现业务对象编辑场景 /// </summary> /// <param name="boVM"></param> /// <param name="isNew"></param> /// <param name="typeID"></param> /// <returns></returns> public static MucDialogue_CreateOrEdit CreateOrEditDialog(T boVM, bool isNew) { var preString = "编辑:"; var preIcon = "icon-pencil"; if (isNew) { preString = "新建:"; preIcon = "icon-new"; } var boType = typeof(T); Attribute[] boVMAttributes = Attribute.GetCustomAttributes(boType); var editorSpecification = boVMAttributes.Where(n => n.GetType().Name == "EditorSpecification").FirstOrDefault() as EditorSpecification; var dialog = new MucDialogue_CreateOrEdit(); dialog.CaptionName = preString + editorSpecification.Title; dialog.IconName = preIcon; dialog.Width = editorSpecification.Width * editorSpecification.HorizontalZoneAmount + 30; dialog.Height = editorSpecification.Height; var divName = boType.Name + editorSpecification.ControllerName; var htmlString = new StringBuilder(); htmlString.Append("<script>"); htmlString.Append("var options" + boType.Name + " = {"); htmlString.Append("dataType: 'json',"); htmlString.Append("success: function (data) {"); htmlString.Append("if(data.IsOK){"); htmlString.Append("$.Dialog.close();"); htmlString.Append("if(data.ExtenssionFunctionString!=''){"); htmlString.Append("refreshDepartmentTreeView('" + editorSpecification.ControllerName + "',data.ExtenssionFunctionString);"); htmlString.Append("};"); htmlString.Append("boGotoPage(data.PageIndex,'" + editorSpecification.ControllerName + "','" + editorSpecification.ListString + "',data.TypeID);"); htmlString.Append("}else{"); htmlString.Append("document.getElementById('Editor_" + divName + "').innerHTML = data;"); htmlString.Append("}}"); htmlString.Append("};"); htmlString.Append("$('#EditorForm_" + divName + "').ajaxForm(options" + boType.Name + ");"); htmlString.Append("</script>"); htmlString.Append("<form action='" + editorSpecification.ControllerName + "/" + editorSpecification.SaveAction + "' method='post' id='EditorForm_" + divName + "' >");// data-ajax-update='#Editor_" + editorAttribute.ControllerName + "' data-ajax-mode='replace' data-ajax='true'>"); htmlString.Append("<div id='Editor_" + divName + "' name='Editor_" + divName + "'>"); htmlString.Append(_GetEditor(boVM)); htmlString.Append("</div>"); htmlString.Append("<div class='form-actions' style='text-align:right'><br/>"); htmlString.Append("<input type='submit' class='button primary' style='height:30px' value='确定' /> "); htmlString.Append("<button class='button' type='button' onclick='$.Dialog.close()' style='height:30px'>取消</button>"); htmlString.Append("</div>"); htmlString.Append("</form>"); dialog.InnerHtmlContent = htmlString.ToString(); return(dialog); }