Пример #1
0
        /// <summary>
        /// 基本输入框
        /// </summary>
        /// <returns></returns>
        public TextBoxHtmlTag AsTextBox()
        {
            TextBoxHtmlTag tag = new TextBoxHtmlTag(modelType, Key);

            if (Attributes.ContainsKey(this.Key))
            {
                Attributes.Remove(this.Key);
            }
            tag.DataType = dataType;
            Attributes.Add(this.Key, tag);
            return(tag);
        }
Пример #2
0
        public void Init()
        {
            Alias      = "T0";
            TargetType = typeof(T);
            foreach (var item in TargetType.GetProperties())
            {
                TypeCode code;
                code = Type.GetTypeCode(item.PropertyType.Name == "Nullable`1" ? item.PropertyType.GetGenericArguments()[0] : item.PropertyType);
                switch (code)
                {
                case TypeCode.Boolean: ViewConfig(item.Name).AsCheckBox(); break;

                case TypeCode.Char: ViewConfig(item.Name).AsTextBox().MaxLength(1).RegularExpression(RegularExpression.Letters); break;

                case TypeCode.DateTime: ViewConfig(item.Name).AsTextBox().FormatAsDate(); break;

                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64: ViewConfig(item.Name).AsTextBox().RegularExpression(RegularExpression.PositiveIntegersAndZero); break;

                case TypeCode.SByte:
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64: ViewConfig(item.Name).AsTextBox().RegularExpression(RegularExpression.Integer); break;

                case TypeCode.Object:
                {
                    ViewConfig(item.Name).AsHidden().Ignore(); break;
                }

                case TypeCode.Single:
                case TypeCode.Double:
                case TypeCode.Decimal:
                {
                    TextBoxHtmlTag tag = ViewConfig(item.Name).AsTextBox().RegularExpression(Easy.Constant.RegularExpression.Float);
                    if (code == TypeCode.Decimal)
                    {
                        tag.Format(FormatStyle.Currency);
                    }
                    break;
                }

                case TypeCode.String: ViewConfig(item.Name).AsTextBox().MaxLength(200);
                    break;

                case TypeCode.DBNull:
                case TypeCode.Byte:
                case TypeCode.Empty:
                default: ViewConfig(item.Name).AsTextBox();
                    break;
                }
                if (code == TypeCode.Object)
                {
                    DataConfig(item.Name).Ignore();
                }
                else
                {
                    DataConfig(item.Name);
                }
            }
            if (typeof(EditorEntity).IsAssignableFrom(TargetType))
            {
                ViewConfig("CreateBy").AsHidden();
                ViewConfig("CreatebyName").AsTextBox().Hide();
                ViewConfig("CreateDate").AsTextBox().Hide().FormatAsDateTime();

                ViewConfig("LastUpdateBy").AsHidden();
                ViewConfig("LastUpdateByName").AsTextBox().Hide();
                ViewConfig("LastUpdateDate").AsTextBox().Hide().FormatAsDateTime();
                ViewConfig("ActionType").AsHidden().AddClass("actionType");
                ViewConfig("Title").AsTextBox().Order(1);
                ViewConfig("Description").AsMutiLineTextBox().Order(101);
                ViewConfig("Status").AsDropDownList().DataSource(Constant.DicKeys.RecordStatus, SourceType.Dictionary);

                DataConfig("CreateBy").Update();
                DataConfig("CreatebyName").Update();
                DataConfig("CreateDate").Update();
                DataConfig("ActionType").Ignore();
            }
            if (typeof(IImage).IsAssignableFrom(TargetType))
            {
                ViewConfig("ImageUrl").AsTextBox().HideInGrid();
                ViewConfig("ImageThumbUrl").AsTextBox().HideInGrid();
            }
            if (IsIgnoreBase())
            {
                IgnoreBase();
            }
            DataConfigure();
            ViewConfigure();
        }