Exemple #1
0
        private void InitValidationRules()
        {
            if (Opt == Util.Operateion.Add)
            {
                var decoderNameValidationRule = new DecoderNameValidationRule();
                decoderNameValidationRule.ErrorText = "名称必须长度大于4且还未被使用!";
                dxValidationProvider1.SetValidationRule(textEditname, decoderNameValidationRule);
                dxValidationProvider1.SetIconAlignment(textEditname, ErrorIconAlignment.MiddleRight);
            }
            else if (Opt == Util.Operateion.Update)
            {
                var decoderNameValidationRule = new DecoderUpdateNameValidationRule();
                decoderNameValidationRule.ErrorText = "名称必须长度大于4且还未被使用!";
                dxValidationProvider1.SetValidationRule(textEditname, decoderNameValidationRule);
                dxValidationProvider1.SetIconAlignment(textEditname, ErrorIconAlignment.MiddleRight);
            }



            //IP地址验证
            var ipValidationRule = new IpValidationRule();

            ipValidationRule.ErrorText = "必须是合法的IP地址";

            dxValidationProvider1.SetValidationRule(textEditIp, ipValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditIp, ErrorIconAlignment.MiddleRight);

            //端口验证
            var portValidationRule = new PortValidationRule();

            portValidationRule.ErrorText = "必须是合法的端口0-65535";

            dxValidationProvider1.SetValidationRule(textEditport, portValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditport, ErrorIconAlignment.MiddleRight);

            //最大解码通道数验证
            var maxDecodeChannelValidationRule = new MaxDecodeChannelValidationRule();

            maxDecodeChannelValidationRule.ErrorText = "合法的解码通道1-20";

            dxValidationProvider1.SetValidationRule(textEditmax, maxDecodeChannelValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditmax, ErrorIconAlignment.MiddleRight);
        }
        private void InitValidationRules()
        {
            if (Opt == Util.Operateion.Add)
            {
                var decoderNameValidationRule = new DecoderNameValidationRule();
                decoderNameValidationRule.ErrorText = "名称必须长度大于4且还未被使用!";
                dxValidationProvider1.SetValidationRule(textEditname, decoderNameValidationRule);
                dxValidationProvider1.SetIconAlignment(textEditname, ErrorIconAlignment.MiddleRight);
            }
            else if (Opt == Util.Operateion.Update)
            {
                var decoderNameValidationRule = new DecoderUpdateNameValidationRule();
                decoderNameValidationRule.ErrorText = "名称必须长度大于4且还未被使用!";
                dxValidationProvider1.SetValidationRule(textEditname, decoderNameValidationRule);
                dxValidationProvider1.SetIconAlignment(textEditname, ErrorIconAlignment.MiddleRight);
            }

            //IP地址验证
            var ipValidationRule = new IpValidationRule();
            ipValidationRule.ErrorText = "必须是合法的IP地址";

            dxValidationProvider1.SetValidationRule(textEditIp, ipValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditIp, ErrorIconAlignment.MiddleRight);

            //端口验证
            var portValidationRule = new PortValidationRule();
            portValidationRule.ErrorText = "必须是合法的端口0-65535";

            dxValidationProvider1.SetValidationRule(textEditport, portValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditport, ErrorIconAlignment.MiddleRight);

            //最大解码通道数验证
            var maxDecodeChannelValidationRule = new MaxDecodeChannelValidationRule();
            maxDecodeChannelValidationRule.ErrorText = "合法的解码通道1-20";

            dxValidationProvider1.SetValidationRule(textEditmax, maxDecodeChannelValidationRule);
            dxValidationProvider1.SetIconAlignment(textEditmax, ErrorIconAlignment.MiddleRight);
        }