public bool ValidAttr(string attrId, string Result) { Flow_FormAttr stepModel = attrRep.GetById(attrId); if (stepModel.AttrType == "数字") { try { Convert.ToInt32(Result); return(true); } catch { return(false); } } if (stepModel.AttrType == "日期") { try { Convert.ToDateTime(Result); return(true); } catch { return(false); } } return(true); }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <Flow_FormAttrModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Flow_FormAttr entity = new Flow_FormAttr(); entity.Id = ResultHelper.NewId; 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 = ResultHelper.NowTime; entity.OptionList = model.OptionList; db.Flow_FormAttr.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
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); } }
//获取已经添加的字段 private List <Flow_FormAttr> GetAttrList(Flow_Form model) { List <Flow_FormAttr> list = new List <Flow_FormAttr>(); Flow_FormAttr attrModel = new Flow_FormAttr(); #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.m_Rep.Find(Convert.ToInt32(o)); list.Add(attrModel); } } #endregion return(list); }
//[SupportFilter] public ActionResult Edit(string id) { Flow_FormAttr model = m_BLL.m_Rep.Find(Convert.ToInt32(id)); ViewBag.FlowType = new SelectList(typeBLL.m_Rep.FindPageList(ref setNoPagerAscBySort, ""), "Id", "Name", model.Id); return(View(model)); }
public int Create(Flow_FormAttr entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_FormAttr.Add(entity); return(db.SaveChanges()); } }
public int Edit(Flow_FormAttr entity) { using (DBContainer db = new DBContainer()) { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public int Create(Flow_FormAttr entity) { using (DBContainer db = new DBContainer()) { db.Flow_FormAttr.Add(entity); return(db.SaveChanges()); } }
//获取已经添加的字段 private string GetAttr(string id, string str) { Flow_FormAttr model = attrBLL.m_Rep.Find(Convert.ToInt32(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>"); }
public int Edit(Flow_FormAttr entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_FormAttr.Attach(entity); db.Entry <Flow_FormAttr>(entity).State = System.Data.Entity.EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
//获取指定名称的HTML表单 private string GetHtml(string id, string no, ref StringBuilder sbJS) { StringBuilder sb = new StringBuilder(); Flow_FormAttr attrModel = formAttrBLL.m_Rep.Find(Convert.ToInt32(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_FormAttr attrModel = formAttrBLL.m_Rep.Find(Convert.ToInt32(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()); }
public bool IsExist(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_FormAttr entity = GetById(id); if (entity != null) { return(true); } return(false); } }
public int Delete(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_FormAttr entity = db.Flow_FormAttr.SingleOrDefault(a => a.Id == id); if (entity != null) { db.Flow_FormAttr.Remove(entity); } return(db.SaveChanges()); } }
public int Delete(string id) { using (DBContainer db = new DBContainer()) { Flow_FormAttr entity = db.Flow_FormAttr.SingleOrDefault(o => o.Id == id); if (entity != null) { db.Flow_FormAttr.Remove(entity); } return(db.SaveChanges()); } }
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_FormAttr model) { if (model != null) { model.TypeName = typeBLL.m_Rep.Find(Convert.ToInt32(model.TypeId)).Name; if (m_BLL.m_Rep.Update(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))); } }
//[SupportFilter] //[ValidateInput(false)] public JsonResult Create(Flow_FormAttr model) { if (model != null) { model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); model.TypeName = typeBLL.m_Rep.Find(Convert.ToInt32(model.TypeId)).Name; if (m_BLL.m_Rep.Create(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); } }
//[SupportFilter] public ActionResult Details(string id) { Flow_FormAttr entity = m_BLL.m_Rep.Find(Convert.ToInt32(id)); return(View(entity)); }