Example #1
0
        public static HtmlString RenderControl(WF_FlowPropertys prop, HtmlHelper helper, int index, string value = "")
        {
            IDictionary <string, object> attrs = GetHtmlAttributes(prop);

            if (!String.IsNullOrWhiteSpace(prop.DataSource))
            {
                if (prop.PropertyType == (int)PropertyTypes.RadioGroup)
                {
                    return(helper.RadioButtonList("Properties[" + index + "].Value",
                                                  XElement.Parse(prop.DataSource)
                                                  .Elements("item")
                                                  .Select(
                                                      p =>
                                                      new RadioButtonListItem
                    {
                        Text = p.Value,
                        Checked = p.Value.EqualsIgnoreCaseAndBlank(value)
                    }), RepeatDirection.Horizontal, attrs));
                }
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           XElement.Parse(prop.DataSource)
                                           .Elements("item")
                                           .Select(
                                               p =>
                                               new SelectListItem
                {
                    Text = p.Value,
                    Value = p.Value,
                    Selected = p.Value.EqualsIgnoreCaseAndBlank(value)
                }), "", attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Userno)
            {
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           WebCacheHelper.GetUsernames()
                                           .Select(
                                               p =>
                                               new SelectListItem
                {
                    Text = p.Value,
                    Value = p.Key,
                    Selected = p.Key.EqualsIgnoreCaseAndBlank(value)
                }), "",
                                           attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Text)
            {
                return(helper.TextArea("Properties[" + index + "].Value", value, attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Country)
            {
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           Consts.Countries.Select(
                                               p => new SelectListItem {
                    Text = p, Value = p, Selected = p.EqualsIgnoreCaseAndBlank(value)
                }), "",
                                           attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Role)
            {
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           WebCacheHelper.GetRoles().Select(p => new SelectListItem {
                    Text = p.Value, Value = p.Key, Selected = p.Key.EqualsIgnoreCaseAndBlank(value)
                }), "",
                                           attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Department)
            {
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           WebCacheHelper.GetDepartments().Select(p => new SelectListItem {
                    Text = p.Value, Value = p.Key, Selected = p.Key.EqualsIgnoreCaseAndBlank(value)
                }), "",
                                           attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.DeptType)
            {
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           WebCacheHelper.GetDeptTypes().Select(p => new SelectListItem {
                    Text = p.Value, Value = p.Key, Selected = p.Key.EqualsIgnoreCaseAndBlank(value)
                }), "",
                                           attrs));
            }
            if (prop.PropertyType == (int)PropertyTypes.Brand)
            {
                var country = Codehelper.DefaultCountry ?? "";
                return(helper.DropDownList("Properties[" + index + "].Value",
                                           Consts.BrandsOfContries[country]
                                           .Select
                                           (
                                               b => new SelectListItem
                {
                    Text = Consts.GetBrandFullName(b),
                    Value = b,
                    Selected = b.EqualsIgnoreCaseAndBlank(value)
                }
                                           ), "", attrs));
            }
            {
                return(helper.TextBox("Properties[" + index + "].Value", value, attrs));
            }
        }