/// <summary> /// 获取属性控件字符串 /// </summary> /// <param name="CatID">产品分类ID</param> /// <returns></returns> public string GetControlList(int CatID) { var prtvbl = new DS_PropertyValue_Br(); var prtlist = Query("SysCatID=@0", "px", CatID); var sb = new System.Text.StringBuilder(); int i = 0; foreach (var item in prtlist.Where(a => a.Request == true).OrderBy(a => a.Px)) { GetControl(sb, item, prtvbl); } foreach (var item in prtlist.Where(a => a.Request == false).OrderBy(a => a.Px)) { GetControl(sb, item, prtvbl); } return(sb.ToString()); }
private void GetControl(System.Text.StringBuilder sb, DS_Property item, DS_PropertyValue_Br prtvbl) { string temstr = ""; string itemstr = "<div class=\"prtctn overflowAuto\"><div class=\"prtn floatL\">{0}:</div><div class=\"floatL\">{1}</div></div>"; switch (item.ControlType) { case (byte)ControlType.文本框: sb.Append(string.Format(itemstr, (item.Request ? "<span class='red'>*</span>" : "") + item.ProName, "<input name=\"txt_" + item.ID + "\" class=\"txtbox" + (item.Request ? " required" : "") + " Property" + item.MapID + "\" type=\"text\" />" + item.Unit)); break; case (byte)ControlType.拉框: var prtvlist = prtvbl.Query("PropertyID=@0", "px", item.ID); temstr = "<select name=\"sl_" + item.ID + "\" " + "class='Property" + item.MapID + (item.Request ? " required" : "") + "'" + ">"; foreach (var vitem in prtvlist) { temstr += "<option value=\"" + vitem.PropertyValue + "\">" + vitem.PropertyValue + "</option>"; } temstr += "</select>" + item.Unit; sb.Append(string.Format(itemstr, (item.Request ? "<span class='red'>*</span>" : "") + item.ProName, temstr)); break; case (byte)ControlType.多选框: var prtvlist2 = prtvbl.Query("PropertyID=@0", "px", item.ID); foreach (var vitem in prtvlist2) { temstr += "<input type=\"checkbox\" " + "class=\"Property" + item.MapID + (item.Request ? " required" : "") + "\" value=\"" + vitem.PropertyValue + "\" name=\"cb_" + item.ID + "\" id=\"cb_" + vitem.ID + "\" /><label for=\"cb_" + vitem.ID + "\">" + vitem.PropertyValue + "</label> "; } sb.Append(string.Format(itemstr, (item.Request ? "<span class='red'>*</span>" : "") + item.ProName, temstr + item.Unit)); break; case (byte)ControlType.单选框: var prtvlist3 = prtvbl.Query("PropertyID=@0", "px", item.ID); foreach (var vitem in prtvlist3) { temstr += "<input type=\"radio\" " + "class=\"Property" + item.MapID + (item.Request ? " required" : "") + "\" value=\"" + vitem.PropertyValue + "\" name=\"rd_" + item.ID + "\" id=\"rd_" + vitem.ID + "\" /><label for=\"rd_" + vitem.ID + "\">" + vitem.PropertyValue + "</label> "; } sb.Append(string.Format(itemstr, (item.Request ? "<span class='red'>*</span>" : "") + item.ProName, temstr + item.Unit)); break; } }