/// <summary> /// 获取字段列表 /// </summary> /// <param name="modeid"></param> /// <returns></returns> public static IList <ModelFiled> GetModelList(int modeid) { List <ModelFiled> modellist = new List <ModelFiled>(); string sql = "select * from ModelFiled where ModelID=" + modeid + " order by OrderId Asc"; using (DataTable dt = DBHelper.GetDataSet(sql)) { if (dt != null && dt.Rows.Count >= 1) { for (int i = 0; i < dt.Rows.Count; i++) { ModelFiled model = new ModelFiled(); model.FiledId = Convert.ToInt32(dt.Rows[i]["FiledId"]); model.Alias = dt.Rows[i]["Alias"].ToString(); model.FiledName = dt.Rows[i]["FiledName"].ToString(); model.Description = dt.Rows[i]["Description"].ToString(); model.ModelId = Convert.ToInt32(dt.Rows[i]["ModelID"]); model.Content = dt.Rows[i]["Content"].ToString(); model.OrderId = Convert.ToInt32(dt.Rows[i]["OrderId"]); model.Type = dt.Rows[i]["Type"].ToString(); model.Validation = dt.Rows[i]["Validation"].ToString(); model.AddTime = Convert.ToDateTime(dt.Rows[i]["AddTime"]); modellist.Add(model); } } } return(modellist); }
/// <summary> /// 获取普通单行文本框显示样式 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetTextTypeShowStyle(ModelFiled model) { string inputshowstyle = string.Empty; string size = WebUtility.GetFieldContent(model.Content, 0, 1); string defaultvalue = WebUtility.GetFieldContent(model.Content, 1, 1); string textLength = WebUtility.GetFieldContent(model.Content, 2, 1); string request = WebUtility.GetFieldContent(model.Validation, 0, 1); string other = WebUtility.GetFieldContent(model.Validation, 1, 1); string validate = string.Empty; size = (size == "") ? "style=\"width:320px\"" : "style=\"width:" + size + "px\""; textLength = (textLength == "") ? "maxlength=\"100\"" : "maxlength=\"" + textLength + "\""; if (request == "" && other == "") { validate = string.Empty; } else { if (request != "" && other == "") { validate = "validate[required]"; } else if (request == "" && other != "") { validate = "validate[custom[" + other + "]]"; } else { validate = "validate[required,custom[" + other + "]]"; } } inputshowstyle = string.Format("<input id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\" {0} type=\"text\" class=\"{1} input-txt\" {2} value=\"" + defaultvalue + "\" /> <span class=\"prompttext\">" + model.Description + "</span>", size, validate, textLength); return(inputshowstyle); }
/// <summary> /// 多行文本 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetMutiTxtShowStyle(ModelFiled model) { string width = WebUtility.GetFieldContent(model.Content, 0, 1) + "px"; string height = WebUtility.GetFieldContent(model.Content, 1, 1) + "px"; return("<textarea id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\" cols=\"20\" rows=\"2\" style=\"width:" + width + ";height:" + height + " \"></textarea> <span class=\"prompttext\">" + model.Description + "</span>"); }
/// <summary> /// 数据字典01 PID=101,type=2,name=电脑 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetDictionary1LinkageStyle(ModelFiled model) { string types = WebUtility.GetFieldContent(model.Content, 1, 1); string values = WebUtility.GetFieldContent(model.Content, 0, 1); string selectstr = null; selectstr += "<span id=\"customtxt_" + model.FiledName + "_span\">{$" + model.FiledName + "$}</span> <span class=\"prompttext\">" + model.Description + "</span> <a attrs=\"func" + model.FiledName + "\" rel=\"adddictionaryManage\" href=\"diaologdictionaryManage.aspx?Type=" + values + "&action=1\">管理类别</a><script type=\"text/javascript\"> function func" + model.FiledName + "(){ GetDictionary1(\"customtxt_" + model.FiledName + "\",\"" + values + "\",\"" + types + "\");}</script>"; return(selectstr); }
/// <summary> /// 转换数据类型(数据库数据类型) /// </summary> /// <param name="type"></param> /// <returns></returns> public static string ConvertDataType(ModelFiled modey) { string returntype = string.Empty; switch (modey.Type) { case "TextType": string other = WebUtility.GetFieldContent(modey.Validation, 1, 1); returntype = other == "integer" ? "int" : other == "currency" ? "decimal(18,2)" : "nvarchar(255)"; break; case "MultipleTextType": returntype = "ntext"; break; case "Editor": returntype = "ntext"; break; case "eWebEditor": returntype = "ntext"; break; case "ListBoxType": returntype = "nvarchar(255)"; break; case "PicType": returntype = "nvarchar(255)"; break; case "FileType": returntype = "nvarchar(255)"; break; case "FileUpload": returntype = "nvarchar(255)"; break; case "ColorPicker": returntype = "nvarchar(255)"; break; case "MutiImgSelect": returntype = "ntext"; break; case "TimerPicker": returntype = "datetime"; break; case "ProvincialLinkage": returntype = "nvarchar(255)"; break; case "Dictionary-1": returntype = "nvarchar(50)"; break; case "Dictionary-2": returntype = "nvarchar(50)"; break; case "Relevance": returntype = "nvarchar(255)"; break; } return(returntype); }
/// <summary> /// eWebEditor编辑器 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GeteWebEditorTxtShowStyle(ModelFiled model) { string width = WebUtility.GetFieldContent(model.Content, 0, 1); string height = WebUtility.GetFieldContent(model.Content, 1, 1); StringBuilder builder = new StringBuilder(); string str = null; if (!string.IsNullOrEmpty(model.Description)) { str = "display:inline"; } builder.Append("<input style=\"display:inline\" type=\"button\" value=\"插入图片\" onclick=\"OpenewebEditorDialog('customtxt_" + model.FiledName + "')\" class=\"btn2\" /> <span class=\"prompttext\" style=\"" + str + "\">" + model.Description + "</span><input id=\"customtxt_" + model.FiledName + "Content\" name=\"customtxt_" + model.FiledName + "Content\" type=\"hidden\" /><iframe style=\"display:block\" id=\"customtxt_" + model.FiledName + "\" src=\"htmlEditor/ewebeditor/ewebeditor.htm?id=customtxt_" + model.FiledName + "Content&style=mini500&skin=light1\" frameborder=\"0\" scrolling=\"no\" width=\"" + width + "\" height=\"" + height + "\"></iframe><br/><br/>"); return(builder.ToString()); }
/// <summary> /// 编辑器 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetEditorTxtShowStyle(ModelFiled model) { string width = WebUtility.GetFieldContent(model.Content, 0, 1); string height = WebUtility.GetFieldContent(model.Content, 1, 1); StringBuilder builder = new StringBuilder(); string str = null; if (!string.IsNullOrEmpty(model.Description)) { str = " padding-top:10px; padding-bottom:12px;line-height:200%;"; } builder.Append(" <span class=\"prompttext\" style=\"" + str + "\">" + model.Description + "</span><textarea id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\"></textarea><script type=\"text/javascript\"> var editorOption = {initialFrameWidth:" + width + ",initialFrameHeight:" + height + " };var ue = new UE.ui.Editor(editorOption);ue.render(\"customtxt_" + model.FiledName + "\");</script><br/><br/>"); return(builder.ToString()); }
/// <summary> /// 下拉框 三种情况 1 2 3 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetSelectListShowStyle(ModelFiled model) { string types = WebUtility.GetFieldContent(model.Content, 0); string values = WebUtility.GetFieldContent(model.Content, 1); if (types == "1") { string selectstr = "<select id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\">"; string[] option = values.Split('|'); for (int i = 0; i < option.Length; i++) { selectstr += "<option value=\"" + option[i] + "\">" + option[i] + "</option>"; } selectstr += "</select> <span class=\"prompttext\">" + model.Description + "</span>"; return(selectstr); } else if (types == "2") { string selectstr = null; string[] option = values.Split('|'); for (int i = 0; i < option.Length; i++) { selectstr += "<input id=\"customtxt_" + model.FiledName + "_" + i + "\" type=\"radio\" name=\"customtxt_" + model.FiledName + "\" value=\"" + option[i] + "\"/><label for=\"customtxt_" + model.FiledName + "_" + i + "\">" + option[i] + "</label>"; } selectstr += " <span class=\"prompttext\">" + model.Description + "</span>"; return(selectstr); } else { string selectstr = null; string[] option = values.Split('|'); for (int i = 0; i < option.Length; i++) { selectstr += "<input id=\"customtxt_" + model.FiledName + "_" + i + "\" type=\"checkbox\" name=\"customtxt_" + model.FiledName + "\" value=\"" + option[i] + "\"/><label for=\"customtxt_" + model.FiledName + "_" + i + "\">" + option[i] + "</label>"; } selectstr += " <span class=\"prompttext\">" + model.Description + "</span>"; return(selectstr); } }
/// <summary> /// 添加模型字段 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Add(ModelFiled model) { try { string tablename = GetModelIdByExpression("ModelId=" + model.ModelId, "TableName")["TableName"].ToString(); string sqlf = "ALTER TABLE [" + WebUtility.CheckStr(tablename) + "] ADD [" + WebUtility.CheckStr(model.FiledName) + "] " + ConvertDataType(model) + ""; DBHelper.ExecuteCommand(sqlf); string sql = "insert into ModelFiled ( " + "[FiledName]," + "[Alias]," + "[Description]," + "[Type]," + "[Content]," + "[OrderId]," + "[Validation]," + "[ModelID]" + " ) " + "values( " + "'" + WebUtility.CheckStr(model.FiledName) + "', " + "'" + WebUtility.CheckStr(model.Alias) + "', " + "'" + WebUtility.CheckStr(model.Description) + "', " + "'" + WebUtility.CheckStr(model.Type) + "', " + "'" + WebUtility.CheckStr(model.Content) + "', " + "" + model.OrderId + "," + "'" + WebUtility.CheckStr(model.Validation) + "', " + "" + model.ModelId + "" + " )"; DBHelper.ExecuteCommand(sql); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 省级联动 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetProvincialLinkageStyle(ModelFiled model) { return("<select id=\"customtxt_" + model.FiledName + "_provice\" name=\"customtxt_" + model.FiledName + "_provice\"></select><select id=\"customtxt_" + model.FiledName + "_city\" name=\"customtxt_" + model.FiledName + "_city\"></select><select id=\"customtxt_" + model.FiledName + "_eara\" name=\"customtxt_" + model.FiledName + "_eara\"></select> <span class=\"prompttext\">" + model.Description + "</span><script type=\"text/javascript\">new PCAS(\"customtxt_" + model.FiledName + "_provice\",\"customtxt_" + model.FiledName + "_city\",\"customtxt_" + model.FiledName + "_eara\")</script>"); }
/// <summary> /// 颜色选择 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetColorPickerStyle(ModelFiled model) { return("<input id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\" type=\"text\" class=\"input-txt\" style=\"width:50px\" maxlength=\"6\" /> <span class=\"prompttext\">" + model.Description + "</span><script type=\"text/javascript\">$(\"#customtxt_" + model.FiledName + "\").ColorPicker({ onSubmit: function(hsb, hex, rgb, el) { $(el).val(hex); $(el).ColorPickerHide(); jQuery(\"#customtxt_" + model.FiledName + "\").css(\"background\",\"#\"+hex);},onBeforeShow: function () { $(this).ColorPickerSetColor(this.value);}}).bind(\"keyup\", function(){$(this).ColorPickerSetColor(this.value);jQuery(\"#customtxt_" + model.FiledName + "\").css(\"background\", \"#\" + this.value);});</script>"); }
/// <summary> /// 文件上传器 /// </summary> /// <param name="model"></param> public static string GetFileUploadStyle(ModelFiled model) { return("<div style=\"width:545px;padding:5px 0 0 0; overflow:hidden; position:relative;\"><input id=\"customtxt_" + model.FiledName + "\" type=\"text\" name=\"customtxt_" + model.FiledName + "\" class=\"input-txt\" style=\"float:left;\"/><a href=\"javascript:void(0)\" onclick=\"$('#uploadify_" + model.FiledName + "').uploadifyUpload()\" style=\"position:absolute;left:405px;top:10px;\"><img src=\"swfupload/jquery.uploadify2.1.4/uploadloding.gif\" /></a> <span class=\"prompttext\" style=\"position:absolute;left:480px;top:0px;\">" + model.Description + "</span><input type=\"file\" name=\"uploadify_" + model.FiledName + "\" id=\"uploadify_" + model.FiledName + "\" style=\"display:none;\" /></div>{$" + model.FiledName + "$}"); }
/// <summary> /// 附加选择 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetFileShowStyle(ModelFiled model) { return("<input id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\" type=\"text\" class=\"input-txt\" maxlength=\"250\" /> <input id=\"selectimg\" type=\"button\" value=\"选择文件\" class=\"btn2\" onclick=\"OpenFileDialog('customtxt_" + model.FiledName + "')\" /> <span class=\"prompttext\">" + model.Description + "</span>"); }
/// <summary> /// 图片显示 /// </summary> /// <param name="model"></param> /// <returns></returns> public static string GetPicShowStyle(ModelFiled model) { return("<input id=\"customtxt_" + model.FiledName + "\" name=\"customtxt_" + model.FiledName + "\" type=\"text\" class=\"input-txt\" maxlength=\"250\" /> <input id=\"selectimg\" type=\"button\" value=\"选择图片\" class=\"btn2\" onclick=\"OpenPictureDialog('customtxt_" + model.FiledName + "','previw_" + model.FiledName + "')\" /> <a id=\"previw_" + model.FiledName + "\" href=\"#\" rel=\"lightbox\">预览图片</a> <span class=\"prompttext\">" + model.Description + "</span>"); }