示例#1
0
        private static MvcHtmlString GetDatePickerHtml(HtmlHelper html, string name, DateEnum dateEnum, string value, ValidateOptions validateOptions)
        {
            DatePicketModel model = new DatePicketModel {
                Name     = name,
                DateType = dateEnum
            };

            html.RenderPartial("~/Views/ControlScripts/_DatePicketScripts.cshtml", model);
            List <string> keyList  = new List <string>();
            StringBuilder builder  = new StringBuilder();
            TagBuilder    builder2 = new TagBuilder("input");

            builder2.GenerateId(name);
            builder2.MergeAttribute("type", "text");
            builder2.MergeAttribute("name", name);
            builder2.MergeAttribute("readonly", "readonly");
            if (!string.IsNullOrEmpty(value))
            {
                builder2.MergeAttribute("value", value);
            }
            bool flag = false;

            if (validateOptions != null)
            {
                builder2.MergeAttribute("data-bvalidator", ValidateCommon.GetValidateAttr(validateOptions));
                if (validateOptions.Required)
                {
                    flag = true;
                }
                if (!string.IsNullOrEmpty(validateOptions.ErrorMsg))
                {
                    builder2.MergeAttribute("data-bvalidator-msg", validateOptions.ErrorMsg);
                }
            }
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(CtrlScripts.RenderScript(html, keyList));
            return(MvcHtmlString.Create((flag ? "<span class='star'>*</span>" : "<span class='star'>&nbsp</span>") + builder.ToString()));
        }
示例#2
0
        public static MvcHtmlString KingUploader(this HtmlHelper helper, string name, string fileType = null, string fileSize = null, int fileCount = 1, bool readOnly = false, string jsCallBack = null)
        {
            UploaderModel model = new UploaderModel {
                Name = name
            };

            helper.RenderPartial("~/Views/ControlScripts/_UploaderScripts.cshtml", model);
            List <string> keyList = new List <string>();
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("<div class=\"divUpload\">");
            if (!readOnly)
            {
                builder.AppendLine("<input type=\"file\" name=\"uploadify_" + name + "\" id=\"uploadify_" + name + "\" />");
            }
            builder.AppendLine("<input type=\"hidden\" class=\"currentFlag\" value=\"" + name + "\" />");
            builder.AppendLine("<input type=\"hidden\" id=\"" + name + "\" name=\"" + name + "\" />");
            builder.AppendLine("<input type=\"hidden\" id=\"hidCallBack_" + name + "\" name=\"hidCallBack_" + name + "\"  value=\"" + jsCallBack + "\" />");
            fileSize = string.IsNullOrEmpty(fileSize) ? string.Empty : fileSize;
            builder.AppendLine("<input type=\"hidden\" id=\"hidFileSize_" + name + "\" name=\"hidFileSize_" + name + "\" value=\"" + fileSize + "\" />");
            fileCount = (fileCount < 1) ? 1 : fileCount;
            builder.AppendLine(string.Concat(new object[] { "<input type=\"hidden\" id=\"hidFileCount_", name, "\" name=\"hidFileCount_", name, "\" value=\"", fileCount, "\" />" }));
            if (!string.IsNullOrEmpty(fileType))
            {
                StringBuilder builder2 = new StringBuilder();
                string[]      strArray = fileType.Split(new char[] { ',', Convert.ToChar(0xff0c) }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string str in strArray)
                {
                    builder2.AppendFormat("*.{0};", str);
                }
                builder.AppendLine("<input type=\"hidden\" id=\"hidFileType_" + name + "\" name=\"hidFileType_" + name + "\" value=\"" + builder2.ToString() + "\" />");
            }
            builder.AppendLine("<div id=\"divAttachmentList_" + name + "\"></div>");
            builder.AppendLine("</div>");
            builder.AppendLine(CtrlScripts.RenderScript(helper, keyList));
            return(MvcHtmlString.Create(builder.ToString()));
        }
示例#3
0
        public static MvcHtmlString KingUploaderFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, string name, string objectName = null, string fileType = null, string fileSize = null, int fileCount = 1, bool readOnly = false, string jsCallBack = null)
        {
            UploaderModel model = new UploaderModel {
                Name = name
            };

            helper.RenderPartial("~/Views/ControlScripts/_UploaderScripts.cshtml", model);
            List <string> keyList  = new List <string>();
            ModelMetadata metadata = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression, helper.ViewData);
            string        s        = (metadata.Model == null) ? "" : metadata.Model.ToString();
            StringBuilder builder  = new StringBuilder();
            int           objId    = 0;

            using (BizDataContext context = new BizDataContext(true))
            {
                builder.AppendLine("<div class=\"divUpload\">");
                if (!readOnly)
                {
                    builder.AppendLine("<input type=\"file\" name=\"uploadify_" + name + "\" id=\"uploadify_" + name + "\" />");
                    builder.AppendLine("<input type=\"hidden\" class=\"currentFlag\" value=\"" + name + "\" />");
                }
                string        str2     = string.Empty;
                StringBuilder builder2 = new StringBuilder();
                builder2.AppendLine("<div id=\"divAttachmentList_" + name + "\">");
                if (int.TryParse(s, out objId))
                {
                    List <T_Attachment> list2 = context.Where <T_Attachment>(a => ((a.State == 0) && (a.OwnerObjectId == objId)) && (string.IsNullOrWhiteSpace(objectName) || (a.OwnerEntityType == objectName)));
                    if ((list2 != null) && (list2.Count > 0))
                    {
                        foreach (T_Attachment attachment in list2)
                        {
                            str2 = str2 + attachment.Attachment_ID + ",";
                            builder2.AppendLine("<div class='CurrCount_" + name + "'>");
                            if (!readOnly)
                            {
                                builder2.AppendLine(string.Concat(new object[] { "<a href='javascript:void(0)' onclick='DeleteAttachment(this)' extAttachmentName='", name, "' extAttachmentId='", attachment.Attachment_ID, "'>[删除]</a>&nbsp;" }));
                            }
                            builder2.AppendLine(string.Concat(new object[] { "<a href='/Attachment/Download?attachmentId=", attachment.Attachment_ID, "'>", attachment.DisplayName, "</a></div>" }));
                        }
                    }
                }
                builder2.AppendLine("</div>");
                builder.AppendLine("<input type=\"hidden\" id=\"" + name + "\" name=\"" + name + "\" value=\"" + str2 + "\" />");
                builder.AppendLine("<input type=\"hidden\" id=\"hidCallBack_" + name + "\" name=\"hidCallBack_" + name + "\"  value=\"" + jsCallBack + "\" />");
                fileSize = string.IsNullOrEmpty(fileSize) ? string.Empty : fileSize;
                builder.AppendLine("<input type=\"hidden\" id=\"hidFileSize_" + name + "\" name=\"hidFileSize_" + name + "\" value=\"" + fileSize + "\" />");
                fileCount = (fileCount < 1) ? 1 : fileCount;
                builder.AppendLine(string.Concat(new object[] { "<input type=\"hidden\" id=\"hidFileCount_", name, "\" name=\"hidFileCount_", name, "\" value=\"", fileCount, "\" />" }));
                if (!string.IsNullOrEmpty(fileType))
                {
                    StringBuilder builder3 = new StringBuilder();
                    string[]      strArray = fileType.Split(new char[] { ',', Convert.ToChar(0xff0c) }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string str3 in strArray)
                    {
                        builder3.AppendFormat("*.{0};", str3);
                    }
                    builder.AppendLine("<input type=\"hidden\" id=\"hidFileType_" + name + "\" name=\"hidFileType_" + name + "\" value=\"" + builder3.ToString() + "\" />");
                }
                builder.AppendLine(builder2.ToString());
                builder.AppendLine("</div>");
                builder.AppendLine(CtrlScripts.RenderScript(helper, keyList));
            }
            return(MvcHtmlString.Create(builder.ToString()));
        }
 public static string AddJs <TModel, TValue>(HtmlHelper <TModel> html)
 {
     return(CtrlScripts.RenderScript(html, new List <string> {
         CtrlScripts.JqueryUiCss, CtrlScripts.JqueryBvalidatorCss, CtrlScripts.JQueryUI, CtrlScripts.bValidate
     }));
 }
 public static string AddJs(HtmlHelper html)
 {
     return(CtrlScripts.RenderScript(html, new List <string>()));
 }
 public static string RegisteredResources(HtmlHelper html)
 {
     return(CtrlScripts.RenderScript(html, new List <string>()));
 }
        private static MvcHtmlString GetSelectUserHtml(HtmlHelper html, string name, List <ITreeData> data, string GetLeafURL, string CallBackMethod, UserStyle userStyle, OpenNoteEnum openNote, ValidateOptions validateOptions, string value)
        {
            BizDataContext       context;
            List <string>        keyList    = new List <string>();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            StringBuilder        builder    = new StringBuilder();
            TagBuilder           builder2   = new TagBuilder("div");

            builder2.GenerateId(name);
            builder2.AddCssClass("treeDiv");
            TagBuilder builder3 = GetTagBuilder("ul", name, "ztree");

            builder3.MergeAttribute("style", "display : none;");
            builder2.InnerHtml = builder2.InnerHtml + builder3;
            TagBuilder builder4 = GetTagBuilder("div", name, "dataHF");

            builder4.MergeAttribute("style", "display:none;");
            if ((data != null) && (data.Count > 0))
            {
                data = DealWithNoteOpenState(data, openNote);
                builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(data);
            }
            else
            {
                using (context = new BizDataContext(true))
                {
                    ParameterExpression expression;
                    // List<ITreeData> list2 = DealWithNoteOpenState(context.Set<T_Department>().
                    //    Select<T_Department, TreeData>(Expression.Lambda<Func<T_Department, TreeData>>(Expression.MemberInit(Expression.New((ConstructorInfo) methodof(TreeData..ctor), new Expression[0]), new MemberBinding[] { Expression.Bind((MethodInfo) methodof(TreeData.set_id), Expression.Property(expression = Expression.Parameter(typeof(T_Department), "u"), (MethodInfo) methodof(T_Department.get_Department_ID))), Expression.Bind((MethodInfo) methodof(TreeData.set_name), Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Department_Name))), Expression.Bind((MethodInfo) methodof(TreeData.set_open), Expression.Constant(false, typeof(bool))), Expression.Bind((MethodInfo) methodof(TreeData.set_pId), Expression.Coalesce(Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Parent_ID)), Expression.Constant(-1, typeof(int)))) }), new ParameterExpression[] { expression })).ToList<ITreeData>(), openNote);
                    //builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(list2);
                }
            }
            builder2.InnerHtml = builder2.InnerHtml + builder4;
            TagBuilder builder5 = GetTagBuilder("input", name, "resultInput");

            if (userStyle == UserStyle.Normal)
            {
                builder5.MergeAttribute("style", "float: left;");
            }
            else
            {
                builder5.MergeAttribute("style", "float: left;display:none");
            }
            builder5.MergeAttribute("type", "text");
            if (validateOptions != null)
            {
                builder5.MergeAttribute("data-bvalidator", ValidateCommon.GetValidateAttr(validateOptions));
                if (!string.IsNullOrEmpty(validateOptions.ErrorMsg))
                {
                    builder5.MergeAttribute("data-bvalidator-msg", validateOptions.ErrorMsg);
                }
            }
            builder5.MergeAttribute("readonly", "true");
            TagBuilder builder6 = GetTagBuilder("input", name, "resultHf");

            builder6.MergeAttribute("type", "hidden");
            builder2.InnerHtml = builder2.InnerHtml + builder5;
            builder2.InnerHtml = builder2.InnerHtml + builder6;
            TagBuilder builder7 = GetTagBuilder("input", name, "treeButton");

            builder7.MergeAttribute("type", "button");
            builder7.MergeAttribute("value", "选择");
            builder7.MergeAttribute("treeName", name);
            builder2.InnerHtml = builder2.InnerHtml + builder7;
            TagBuilder builder8 = GetTagBuilder("input", name, "selectedIDHf");

            builder8.MergeAttribute("type", "hidden");
            string str = string.Empty;

            if (!string.IsNullOrEmpty(value))
            {
                string[] strArray = value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                using (context = new BizDataContext(true))
                {
                    IEnumerable <string> values = from u in context.FetchAll <T_User>()
                                                  join suid in strArray on u.User_ID.ToString() equals suid
                                                  select u.User_Name;

                    str = string.Join(",", values);
                }
                builder8.MergeAttribute("value", value);
            }
            builder2.InnerHtml = builder2.InnerHtml + builder8;
            TagBuilder builder9 = GetTagBuilder("input", name, "selectedNameHF");

            builder9.MergeAttribute("type", "hidden");
            builder9.MergeAttribute("value", str);
            builder2.InnerHtml = builder2.InnerHtml + builder9;
            TagBuilder builder10 = GetTagBuilder("input", name, "configDataHF");

            builder10.MergeAttribute("type", "hidden");
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("GetLeafURL", GetLeafURL);
            dictionary.Add("CallBackMethod", CallBackMethod);
            builder10.MergeAttribute("value", serializer.Serialize(dictionary));
            builder2.InnerHtml = builder2.InnerHtml + builder10;
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(CtrlScripts.RenderScript(html, keyList));
            return(MvcHtmlString.Create(builder.ToString()));
        }