//多选下拉列表框 private static void DropDownListMultiSelects(HtmlHelper helper, SoftProjectAreaEntity data, StringBuilder sbHtml, Type type, SoftProjectAreaEntity field, ref PropertyInfo property, ref object value, ref string val, string css = "") { #region 拉列表框 property = type.GetProperty(field.name); value = property.GetValue(data, null); if (value != null) { var strval = value.ToString(); val = strval; } var dict = field.name; if (!string.IsNullOrEmpty(field.Dicts)) { dict = field.Dicts; } if (ProjectCache.IsExistyCategory(dict)) { var str = HtmlHelpers.DropDownListMultiSelect(helper, "Item." + field.name + "s", ProjectCache.GetByCategory(dict), "DValue", "DText", val, ""); //var str = HtmlHelpers.DropDownList(helper, "Item." + field.name, ProjectCache.GetByCategory(dict), "DValue", "DText", val, css); sbHtml.AppendLine(str.ToString()); } else { if (ProjectCache.HtmlDropDownListMultiSelects.ContainsKey(field.name)) { var str = ProjectCache.HtmlDropDownListMultiSelects[field.name](val, field.NameCn, data); sbHtml.AppendLine(str.ToString()); } } #endregion }
private static void HtmlDropDownLisByTable(HtmlHelper helper, SoftProjectAreaEntity data, StringBuilder sbHtml, Type type, SoftProjectAreaEntity field, ref PropertyInfo property, ref object value, ref string val, string css = "") { #region 拉列表框 property = type.GetProperty(field.name); value = property.GetValue(data, null); if (value != null) { var strval = value.ToString(); val = strval; } var dict = field.name; if (!string.IsNullOrEmpty(field.Dicts)) { dict = field.Dicts; } if (ProjectCache.IsExistyCategory(dict)) { var str = HtmlHelpers.DropDownList(helper, field.name, ProjectCache.GetByCategory(dict), "DValue", "DText", val, css); sbHtml.AppendLine(str.ToString()); } else { if (ProjectCache.HtmlDropDownLiss.ContainsKey(field.name)) { var str = ProjectCache.HtmlDropDownLiss[field.name](val, field.NameCn, data); sbHtml.AppendLine(str.ToString()); } } //else if (field.name == "Pre_RoleID") //{ // var Pre_Roles = ProjectCache.Pre_Roles; // var str = HtmlHelpers.DropDownList(helper, "Item." + field.name, Pre_Roles, "Pre_RoleID", "RoleName", val, ""); // sbHtml.AppendLine(str.ToString()); //} //else if (field.name == "Comp_RoleID") //{ // var Comp_Roles = ProjectCache.Comp_Roles; // var str = HtmlHelpers.DropDownList(helper, "Item." + field.name, Comp_Roles, "Comp_RoleID", "CompRoleName", val, ""); // sbHtml.AppendLine(str.ToString()); //} #endregion }
//public static MvcHtmlString Menu(this HtmlHelper helper, object obj)// MyResponseBase Model)// string ModularOrFunCode) //{ // var Items = new List<SoftProjectAreaEntity>(); // //var past = new List<SoftProjectAreaEntity>(); // var conts = helper.ViewContext.Controller as BaseController; // var CurrMenu = conts.CurrMenu; // Items = conts.Menu(); // var roots = Items.Where(p => p.ParentPremID == 0).OrderBy(p => p.Sort).ToList(); // if (conts.MenuIdent != "") // roots = Items; // roots = roots.OrderBy(p=>p.Sort).ToList(); // StringBuilder sb = new StringBuilder(); // foreach (var item in roots) // { // //如果有子节点 // var action = ""; // if (item.ActionPath == CurrMenu) // action = "active"; // var childs = Items.Where(p => item.Design_ModularOrFunID == p.ParentPremID).OrderBy(p => p.PremSort).ToList(); // if (childs.Count > 0) // { // sb.AppendLine("<li class=''>"); // sb.AppendLine(" <a href='#'>"); // sb.AppendLine(" <i class='glyphicon glyphicon-th-large'></i>"); // sb.AppendLine(string.Format(" <span>{0}</span>",item.ModularName)); // sb.AppendLine(" <b class='icon-angle-down'></b></a>"); // sb.AppendLine(" <ul style='display: none;' class='submenu'>"); // foreach (var item1 in childs) // { // action = ""; // if (item1.ActionPath == CurrMenu) // action = "active"; // #region 参数 // var strParam = ""; // if (item1.ParamName != null && item1.ParamName.Length > 0 && obj != null) // { // #region 对象数据类型 // Type type = obj.GetType(); // #endregion // var paramNames = item1.ParamName.Split(','); // foreach (var param in paramNames) // { // PropertyInfo property = type.GetProperty(param); // var value = property.GetValue(obj, null); // strParam += "item1." + param + "=" + value; // //var val=item1. // } // } // if (strParam.Length > 0) // strParam = "?" + strParam; // #endregion // var ActionPath = item1.ActionPath + strParam; // //sb.AppendLine(" <li>"); // //sb.AppendLine(" <a class='' href='/PurchaseOrderAreas/Pu_PurchaseOrder/WaitExamineIndex'>"); // //sb.AppendLine(" <span>待审核采购订单管理</span>"); // //sb.AppendLine(" </a>"); // //sb.AppendLine(" </li>"); // if (item1.BUrlNva == 1) // sb.AppendLine(string.Format("<li class='" + action + "'><a href='{0}'><span>{1}</span></a></li>", ActionPath, item1.ModularName)); // else // sb.AppendLine(string.Format("<li class='" + action + "'><a href='{0}'><span>{1}</span></a></li>", ActionPath, item1.MenuName)); // } // sb.AppendLine(" </ul>"); // sb.AppendLine(" </a>"); // sb.AppendLine("</li>"); // } // else // { // #region 参数 // var strParam = ""; // if (item.ParamName != null && item.ParamName.Length > 0 && obj != null) // { // #region 对象数据类型 // Type type = obj.GetType(); // #endregion // var paramNames = item.ParamName.Split(','); // foreach (var param in paramNames) // { // PropertyInfo property = type.GetProperty(param); // var value = property.GetValue(obj, null); // strParam += "Item." + param + "=" + value; // //var val=item. // } // } // if (strParam.Length > 0) // strParam = "?" + strParam; // #endregion // var ActionPath = item.ActionPath + strParam; // if (item.BUrlNva == 1) // sb.AppendLine(string.Format("<li class='" + action + "'><a href='{0}'><i class='glyphicon glyphicon-th-large'></i><span>{1}</span></a></li>", ActionPath, item.ModularName)); // else // sb.AppendLine(string.Format("<li class='" + action + "'><a href='{0}'><i class='glyphicon glyphicon-th-large'></i><span>{1}</span></a></li>", ActionPath, item.MenuName)); // } // } // // <li> // // <a href="/P_ProductAreas/P_Product/IndexTechnology"> // // <i class="glyphicon glyphicon-th-large"></i> // // <span>待完善商品描述</span> // // </a> // //</li> // MvcHtmlString mstr = new MvcHtmlString(sb.ToString()); // return mstr; //} #region 界面控件的辅助方法 /// <summary> /// 查询的下拉列表框:1015-7-5 /// </summary> /// <param name="helper"></param> /// <param name="Querys"></param> /// <param name="item"></param> /// <param name="strDrop"></param> /// <returns></returns> private static string QueryHtmlDropDownList(HtmlHelper helper, Querys Querys, SoftProjectAreaEntity data, SoftProjectAreaEntity item, string strDrop) { #region 拉列表框 var val = Querys.GetValue(item.name + "___equal"); var Dicts = item.name; if (!string.IsNullOrEmpty(item.Dicts)) { Dicts = item.Dicts; } if (ProjectCache.IsExistyCategory(Dicts)) { var str = HtmlHelpers.DropDownList(helper, item.name + "___equal", ProjectCache.GetByCategory(Dicts), "DValue", "DText", val, "", "==" + item.NameCn + "=="); strDrop = str.ToString(); } else { if (ProjectCache.QueryHtmlDropDownLists.ContainsKey(item.name)) { strDrop = ProjectCache.QueryHtmlDropDownLists[item.name](val, item.NameCn, data); } } //else if (item.name == "Pre_RoleID") //{ // var Pre_Roles = ProjectCache.Pre_Roles; // var str = HtmlHelpers.DropDownList(helper, item.name + "___equal", Pre_Roles, "Pre_RoleID", "RoleName", val, "", "==" + item.NameCn + "=="); // //var str = HtmlHelpers.DropDownList(helper, "Item." + Item.name, Pre_Roles, "Pre_RoleID", "RoleName", val, ""); // //sbHtml.AppendLine(str.ToString()); // strDrop = str.ToString(); //} //else if (item.name == "Comp_RoleID") //{ // var Pre_Roles = ProjectCache.Comp_Roles; // var str = HtmlHelpers.DropDownList(helper, item.name + "___equal", Pre_Roles, "Comp_RoleID", "CompRoleName", val, "", "==" + item.NameCn + "=="); // //var str = HtmlHelpers.DropDownList(helper, "Item." + Item.name, Pre_Roles, "Pre_RoleID", "RoleName", val, ""); // //sbHtml.AppendLine(str.ToString()); // strDrop = str.ToString(); //} #endregion return(strDrop); }