public ActionResult Details(string id) { ViewBag.Perm = GetPermission(); Flow_FormAttrModel entity = m_BLL.GetById(id); return(View(entity)); }
//获取已经添加的字段 private List <Flow_FormAttrModel> GetAttrList(Flow_FormModel model) { List <Flow_FormAttrModel> list = new List <Flow_FormAttrModel>(); Flow_FormAttrModel attrModel = new Flow_FormAttrModel(); #region 处理字段 //获得对象的类型,model Type formType = model.GetType(); //查找名称为"A-Z"的属性 string[] arrStr = { "AttrA", "AttrB", "AttrC", "AttrD", "AttrE", "AttrF", "AttrG", "AttrH", "AttrI", "AttrJ", "AttrK" , "AttrL", "AttrM", "AttrN", "AttrO", "AttrP", "AttrQ", "AttrR", "AttrS", "AttrT", "AttrU" , "AttrV", "AttrW", "AttrX", "AttrY", "AttrZ" }; foreach (string str in arrStr) { object o = formType.GetProperty(str).GetValue(model, null); if (o != null) { //查找model类的Class对象的"str"属性的值 attrModel = attrBLL.GetById(o.ToString()); list.Add(attrModel); } } #endregion return(list); }
public ActionResult Edit(string id) { Flow_FormAttrModel model = m_BLL.GetById(id); ViewBag.FlowType = new SelectList(typeBLL.GetList(ref setNoPagerAscBySort, ""), "Id", "Name", model.Id); return(View(model)); }
public bool Create(ref ValidationErrors errors, Flow_FormAttrModel model) { try { Flow_FormAttr entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new Flow_FormAttr(); entity.AttrType = model.AttrType; entity.CheckJS = model.CheckJS; entity.CreateTime = model.CreateTime; entity.Id = model.Id; entity.IsValid = model.IsValid; entity.Name = model.Name; entity.OptionList = model.OptionList; entity.Title = model.Title; entity.TypeId = model.TypeId; if (m_Rep.Create(entity) == 1) { return(true); } errors.Add(Suggestion.InsertFail); return(false); } catch (Exception ex) { errors.Add(ex.Message); ExceptionHandler.WriteException(ex); return(false); } }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <Flow_FormAttrModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <Flow_FormAttrModel>(x => x.Title, "字段标题"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.Name, "字段英文名称"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.AttrType, "文本,日期,数字,多行文本"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.CheckRule, "校验规则"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.CheckJS, "辅助JS脚本"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.TypeId, "所属类别"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.CreateTime, "创建时间"); excelFile.AddMapping <Flow_FormAttrModel>(x => x.OptionList, "下拉框的值"); //SheetName var excelContent = excelFile.Worksheet <Flow_FormAttrModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new Flow_FormAttrModel(); entity.Id = row.Id; entity.Title = row.Title; entity.Name = row.Name; entity.AttrType = row.AttrType; entity.CheckRule = row.CheckRule; entity.CheckJS = row.CheckJS; entity.TypeId = row.TypeId; entity.CreateTime = row.CreateTime; entity.OptionList = row.OptionList; //============================================================================= if (errorMessage.Length > 0) { errors.Add(string.Format( "第 {0} 列发现错误:{1}{2}", rowIndex, errorMessage, "<br/>")); } list.Add(entity); rowIndex += 1; } if (errors.Count > 0) { return(false); } return(true); }
//获取已经添加的字段 private string GetAttr(string id, string str) { Flow_FormAttrModel model = attrBLL.GetById(id); return("<tr id='tr" + str + "'><td style='text-align:right'>" + model.Title + ":</td>" + "<td>" + getExample(model.AttrType) + "<input id='" + str + "' name='" + str + "' type='hidden' value='" + model.Id + "' /></td>" + "<td><a href=\"javascript:deleteCurrentTR('tr" + str + "');\">[删除]</a></td></tr>"); }
//获取指定名称的HTML表单 private string GetHtml(string id, string no, ref StringBuilder sbJS) { StringBuilder sb = new StringBuilder(); Flow_FormAttrModel attrModel = formAttrBLL.GetById(id); sb.AppendFormat("<tr><td style='width:100px; text-align:right;'>{0} :</td>", attrModel.Title); //获取指定类型的HTML表单 sb.AppendFormat("<td>{0}</td></tr>", new FlowHelper().GetInput(attrModel.AttrType, attrModel.Name, no)); sbJS.Append(attrModel.CheckJS); return(sb.ToString()); }
private string GetHtml(string id, string no, ref StringBuilder sbJS) { StringBuilder sb = new StringBuilder(); Flow_FormAttrModel attrModel = formAttrBLL.GetById(id); sb.AppendFormat("<div class='easyui-draggable' data-option='onDrag:onDrag'><table class='inputtable'><tr><td style='vertical-align:middle' class='inputtitle'>{0}</td>", attrModel.Title); //获取指定类型的HTML表单 sb.AppendFormat("<td class='inputcontent'>{0}</td></tr></table></div>", new FlowHelper().GetInput(attrModel.AttrType, attrModel.Name, no)); sbJS.Append(attrModel.CheckJS); return(sb.ToString()); }
//获取指定名称的HTML表单 private string GetHtml(string id, string no, ref StringBuilder sbJS) { StringBuilder sb = new StringBuilder(); Flow_FormAttrModel attrModel = formAttrBLL.GetById(id); sb.AppendFormat("<tr><th>{0} :</th>", attrModel.Title); //获取指定类型的HTML表单 sb.AppendFormat("<td>{0}</td></tr>", new FlowHelper().GetInput(attrModel.AttrType, attrModel.Name, no, attrModel.OptionList, true)); sbJS.Append(attrModel.CheckJS); if (!string.IsNullOrEmpty(attrModel.CheckRule)) { //非空 if (attrModel.CheckRule.Contains("NotNull")) { sbJS.Append(@"if($('#" + attrModel.Name + @"').val()=='') { $.messageBox5s('提示', '" + attrModel.Title + @"不能为空!') $('#" + attrModel.Name + @"').focus(); return false; }"); } //日期 if (attrModel.CheckRule.Contains("IsDate")) { sbJS.Append(@"if($('#" + attrModel.Name + @"').val()!='') { if(!checkDate($('#" + attrModel.Name + @"').val())) { $.messageBox5s('提示', '确保输入正确的日期!') $('#" + attrModel.Name + @"').focus(); return false; } }"); } //数字 if (attrModel.CheckRule.Contains("IsNaN")) { sbJS.Append(@"if($('#" + attrModel.Name + @"').val()!='') { if(isNaN(val)){ $.messageBox5s('提示', '确保输入正确的数字!') $('#" + attrModel.Name + @"').focus(); return false; } }"); } } return(sb.ToString()); }
public override bool Create(ref ValidationErrors errors, Flow_FormAttrModel model) { try { if (m_Rep.GetAttrCountByName(model.Name) > 0) { errors.Add("英文名称被使用过,请重新输入!"); return(false); } Flow_FormAttr entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new Flow_FormAttr(); entity.Id = model.Id; entity.Title = model.Title; entity.Name = model.Name; entity.AttrType = model.AttrType; entity.CheckRule = model.CheckRule; entity.CheckJS = model.CheckJS; entity.TypeId = model.TypeId; entity.CreateTime = model.CreateTime; entity.OptionList = model.OptionList; if (m_Rep.Create(entity)) { return(true); } else { errors.Add(Resource.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public Flow_FormAttrModel GetById(string id) { if (IsExist(id)) { Flow_FormAttr entity = m_Rep.GetById(id); Flow_FormAttrModel model = new Flow_FormAttrModel(); model.AttrType = entity.AttrType; model.CheckJS = entity.CheckJS; model.CreateTime = entity.CreateTime ?? DateTime.Now; model.Id = entity.Id; model.IsValid = entity.IsValid ?? true; model.Name = entity.Name; model.OptionList = entity.OptionList; model.Title = entity.Title; model.TypeId = entity.TypeId; return(model); } return(null); }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Flow_FormAttrModel model) { ValidationErrors errors = new ValidationErrors(); try { Flow_FormAttr entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new Flow_FormAttr(); entity.Id = model.Id; entity.Title = model.Title; entity.Name = model.Name; entity.AttrType = model.AttrType; entity.CheckRule = model.CheckRule; entity.CheckJS = model.CheckJS; entity.TypeId = model.TypeId; entity.CreateTime = model.CreateTime; entity.OptionList = model.OptionList; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public override bool Edit(ref ValidationErrors errors, Flow_FormAttrModel model) { try { if (m_Rep.GetAttrCountByName(model.Name) > 1) { errors.Add("英文名称被使用过,请重新输入!"); return(false); } Flow_FormAttr entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.Title = model.Title; entity.Name = model.Name; entity.AttrType = model.AttrType; entity.CheckJS = model.CheckJS; entity.CheckRule = model.CheckRule; entity.TypeId = model.TypeId; entity.CreateTime = model.CreateTime; entity.OptionList = model.OptionList; if (m_Rep.Edit(entity)) { return(true); } else { errors.Add(Resource.NoDataChange); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public JsonResult Edit(Flow_FormAttrModel model) { if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Tile" + model.Name, "成功", "修改", "Flow_FormAttr"); return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Tile" + model.Name + "," + ErrorCol, "失败", "修改", "Flow_FormAttr"); return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ":" + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.EditFail))); } }
public JsonResult Create(Flow_FormAttrModel model) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; if (model != null && ModelState.IsValid) { if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Tile" + model.Name, "成功", "创建", "Flow_FormAttr"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed))); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Tile" + model.Name + "," + ErrorCol, "失败", "创建", "Flow_FormAttr"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol))); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail))); } }
public virtual Flow_FormAttrModel GetById(object id) { if (IsExists(id)) { Flow_FormAttr entity = m_Rep.GetById(id); Flow_FormAttrModel model = new Flow_FormAttrModel(); model.Id = entity.Id; model.Title = entity.Title; model.Name = entity.Name; model.AttrType = entity.AttrType; model.CheckRule = entity.CheckRule; model.CheckJS = entity.CheckJS; model.TypeId = entity.TypeId; model.CreateTime = entity.CreateTime; model.OptionList = entity.OptionList; return(model); } else { return(null); } }
public bool Edit(ref ValidationErrors errors, Flow_FormAttrModel model) { try { Flow_FormAttr entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Suggestion.Disable); return(false); } entity.AttrType = model.AttrType; entity.CheckJS = model.CheckJS; entity.CreateTime = model.CreateTime; entity.Id = model.Id; entity.IsValid = model.IsValid; entity.Name = model.Name; entity.OptionList = model.OptionList; entity.Title = model.Title; entity.TypeId = model.TypeId; if (m_Rep.Edit(entity) == 1) { return(true); } else { errors.Add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public ActionResult Details(string id) { Flow_FormAttrModel entity = m_BLL.GetById(id); return(View(entity)); }