Esempio n. 1
0
        public void BtnValidate_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var fieldId   = Convert.ToInt32(Request.QueryString["fieldId"]);
            var fieldInfo = Main.FieldDao.GetFieldInfo(fieldId, false);
            var settings  = new FieldSettings(fieldInfo.FieldSettings)
            {
                IsValidate   = Convert.ToBoolean(DdlIsValidate.SelectedValue),
                IsRequired   = Convert.ToBoolean(DdlIsRequired.SelectedValue),
                MinNum       = Convert.ToInt32(TbMinNum.Text),
                MaxNum       = Convert.ToInt32(TbMaxNum.Text),
                ValidateType = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue),
                ErrorMessage = TbErrorMessage.Text
            };

            fieldInfo.FieldSettings = settings.ToString();

            try
            {
                Main.FieldDao.Update(fieldInfo);
                isChanged = true;
            }
            catch (Exception ex)
            {
                LtlModalValidateMessage.Text = Utils.GetMessageHtml($"设置表单验证失败:{ex.Message}", false);
            }

            if (isChanged)
            {
                Response.Redirect(PageUrl);
            }
        }
        public void DdlValidate_SelectedIndexChanged(object sender, EventArgs e)
        {
            PhValidate.Visible = !EBooleanUtils.Equals(EBoolean.False, DdlIsValidate.SelectedValue);
            var type = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue);

            PhRegExp.Visible = type == ValidateType.RegExp;
        }
Esempio n. 3
0
        public void BtnValidate_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var fieldId   = Utils.ToInt(Request.QueryString["fieldId"]);
            var fieldInfo = Main.Instance.FieldDao.GetFieldInfo(fieldId, false);
            var settings  = new FieldSettings(fieldInfo.Settings)
            {
                IsRequired   = Convert.ToBoolean(DdlIsRequired.SelectedValue),
                MinNum       = Utils.ToInt(TbMinNum.Text),
                MaxNum       = Utils.ToInt(TbMaxNum.Text),
                ValidateType = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue)
            };

            fieldInfo.Settings = settings.ToString();

            try
            {
                Main.Instance.FieldDao.Update(fieldInfo);
                isChanged = true;
            }
            catch (Exception ex)
            {
                LtlMessage.Text = Utils.GetMessageHtml($"设置表单验证失败:{ex.Message}", false);
            }

            if (isChanged)
            {
                LayerUtils.Close(Page);
            }
        }
        private bool InsertOrUpdateTableStyleInfo()
        {
            var isChanged = false;

            _styleInfo.Additional.IsValidate   = TranslateUtils.ToBool(DdlIsValidate.SelectedValue);
            _styleInfo.Additional.IsRequired   = TranslateUtils.ToBool(DdlIsRequired.SelectedValue);
            _styleInfo.Additional.MinNum       = TranslateUtils.ToInt(TbMinNum.Text);
            _styleInfo.Additional.MaxNum       = TranslateUtils.ToInt(TbMaxNum.Text);
            _styleInfo.Additional.ValidateType = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue);
            _styleInfo.Additional.RegExp       = TbRegExp.Text.Trim('/');
            _styleInfo.Additional.ErrorMessage = TbErrorMessage.Text;

            try
            {
                if (_tableStyleId == 0)//数据库中没有此项的表样式,但是有父项的表样式
                {
                    var relatedIdentity = _relatedIdentities[0];
                    _styleInfo.RelatedIdentity = relatedIdentity;
                    _styleInfo.Id = DataProvider.TableStyleDao.Insert(_styleInfo);
                }

                if (_styleInfo.Id > 0)
                {
                    DataProvider.TableStyleDao.Update(_styleInfo);
                    AuthRequest.AddSiteLog(SiteId, "修改表单验证", $"字段:{_styleInfo.AttributeName}");
                }
                else
                {
                    DataProvider.TableStyleDao.Insert(_styleInfo);
                    AuthRequest.AddSiteLog(SiteId, "新增表单验证", $"字段:{_styleInfo.AttributeName}");
                }
                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "设置表单验证失败:" + ex.Message);
            }
            return(isChanged);
        }