//private string getRadios(List<RoadFlow.Data.Model.Dictionary> childs, string name, OptionValueField valueField = OptionValueField.Value, string value = "", string attr = "") //{ // StringBuilder options = new StringBuilder(childs.Count * 100); // foreach (var child in childs) // { // string value1 = getOptionsValue(valueField, child); // options.Append("<input type=\"radio\" style=\"vertical-align:middle;\" "); // options.AppendFormat("id=\"{0}_{1}\" ", name, child.ID.ToString("N")); // options.AppendFormat("name=\"{0}\" ", name); // options.AppendFormat("value=\"{0}\" ", value1); // options.Append(string.Compare(value, value1, true) == 0 ? "checked=\"checked\" " : ""); // options.Append(attr); // options.Append("/>"); // options.AppendFormat("<label style=\"vertical-align:middle;margin-right:3px;\" for=\"{0}_{1}\">{2}</label>", name, child.ID.ToString("N"), child.Title); // } // return options.ToString(); //} /// <summary> /// 根据ID得到多选项 /// </summary> /// <param name="code"></param> /// <param name="name">名称</param> /// <param name="valueField"></param> /// <param name="value"></param> /// <param name="attr">其它属性</param> /// <returns></returns> //public string GetCheckboxsByID(Guid id, string name, OptionValueField valueField = OptionValueField.Value, string value = "", string attr = "") //{ // var childs = GetChilds(id, true); // return getCheckboxs(childs, name, valueField, value, attr); //} /// <summary> /// 根据代码得到多选项 /// </summary> /// <param name="code"></param> /// <param name="name">名称</param> /// <param name="valueField"></param> /// <param name="value"></param> /// <param name="attr">其它属性</param> /// <returns></returns> //public string GetCheckboxsByCode(string code, string name, OptionValueField valueField = OptionValueField.Value, string value = "", string attr = "") //{ // if (code.IsNullOrEmpty()) return ""; // var childs = GetChilds(code.Trim(), true); // return getCheckboxs(childs, name, valueField, value, attr); //} //private string getCheckboxs(List<RoadFlow.Data.Model.Dictionary> childs, string name, OptionValueField valueField = OptionValueField.Value, string value = "", string attr = "") //{ // StringBuilder options = new StringBuilder(childs.Count * 100); // foreach (var child in childs) // { // string value1 = getOptionsValue(valueField, child); // options.Append("<input type=\"checkbox\" style=\"vertical-align:middle;\" "); // options.AppendFormat("id=\"{0}_{1}\" ", name, child.ID.ToString("N")); // options.AppendFormat("name=\"{0}\" ", name); // options.AppendFormat("value=\"{0}\" ", value1); // options.Append(value.Contains(value1) ? "checked=\"checked\"" : ""); // options.Append(attr); // options.Append("/>"); // options.AppendFormat("<label style=\"vertical-align:middle;margin-right:3px;\" for=\"{0}_{1}\">{2}</label>", name, child.ID.ToString("N"), child.Title); // } // return options.ToString(); //} private string getOptionsValue(OptionValueField valueField, RoadFlow.Data.Model.DictionaryModel dict) { string value = string.Empty; switch (valueField) { case OptionValueField.Code: value = dict.Code; break; case OptionValueField.ID: value = dict.ID.ToString(); break; case OptionValueField.Note: value = dict.Note; break; case OptionValueField.Other: value = dict.Other; break; case OptionValueField.Title: value = dict.Title; break; case OptionValueField.Value: value = dict.Value; break; } return(value); }
/// <summary> /// 得到一个字典项的上级节点数 /// </summary> /// <param name="dictList"></param> /// <param name="dict"></param> /// <returns></returns> private int getParentCount(List <RoadFlow.Data.Model.DictionaryModel> dictList, RoadFlow.Data.Model.DictionaryModel dict) { int parent = 0; RoadFlow.Data.Model.DictionaryModel parentDict = dictList.Find(p => p.ID == dict.ParentID); while (parentDict != null) { parentDict = dictList.Find(p => p.ID == parentDict.ParentID); parent++; } return(parent); }
/// <summary> /// 更新 /// </summary> public int Update(RoadFlow.Data.Model.DictionaryModel model) { //return dataDictionary.Update(model); var id = model.ID; model.ID = null; var result = BaseDb.UpdateByPara(model, new { id }); if (result.Success) { return(result.Data); } return(0); }
/// <summary> /// 新增 /// </summary> public int Add(RoadFlow.Data.Model.DictionaryModel model) { //return dataDictionary.Add(model); return(BaseDb.Add(model)); }