예제 #1
0
        private void rdoANS_SelectedIndexChanged(object sender, EventArgs e)
        {
            DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider ep = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider();
            if (txtANS1.Text == "")
            {
                ep.SetError(txtANS1, "Please enter answer #1");
                return;
            }
            else if (txtANS2.Text == "")
            {
                ep.SetError(txtANS2, "Please enter answer #2");
                return;
            }
            else if (txtANS2.Text == "")
            {
                ep.SetError(txtANS3, "Please enter answer #3");
                return;
            }
            else if (txtANS2.Text == "")
            {
                ep.SetError(txtANS4, "Please enter answer #4");
                return;
            }
            else
            {
                ep.ClearErrors();
            }
            switch (rdoANS.SelectedIndex)
            {
            case 0:
                txtANS.Text = txtANS1.Text;
                break;

            case 1:
                txtANS.Text = txtANS2.Text;
                break;

            case 2:
                txtANS.Text = txtANS3.Text;
                break;

            case 3:
                txtANS.Text = txtANS4.Text;
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// 验证界面通用方法
        /// </summary>
        /// <param name="listPara"></param>
        /// <param name="erro"></param>
        /// <returns></returns>
        public bool CheckPara(List <IParameterAble> listPara, DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider erro)
        {
            bool result = true;

            erro.ClearErrors();
            foreach (IParameterAble para in listPara)
            {
                if (para.IsRequired)
                {
                    if (!para.CheckRequired())
                    {
                        erro.SetError(para as Control, "必填项");
                        result = false;
                    }
                }
                if (string.IsNullOrEmpty(para.RegexString))
                {
                    continue;
                }
                if (Regex.IsMatch(para.ObjectValue.ToString(), RegexHelper.RegexDIC[para.RegexString]))
                {
                    continue;
                }
                else
                {
                    string erroInfo = "";
                    if (para.RegexErro == "")
                    {
                        erroInfo = RegexHelper.RegexDIC[para.RegexString + "_ERRO"];
                    }
                    else
                    {
                        erroInfo = RegexHelper.RegexDIC[para.RegexErro];
                    }
                    erro.SetError(para as Control, erroInfo);
                    result = false;
                }
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Provedor de validações de objeto input.
        /// </summary>
        /// <returns>Retorna um tipo VERDADEIRO caso erros sejam detectados, caso contrário FALSO.</returns>
        private bool ValidaCampos()
        {
            dxErrorProvider.ClearErrors();

            if (municipioDTO.Codigoibge == 0)
            {
                dxErrorProvider.SetError(codigoibgeTextEdit, "Cód. IBGE inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (municipioDTO.Codigosrfb == 0)
            {
                dxErrorProvider.SetError(codigosrfbTextEdit, "Cód. Rec. Federal inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (municipioDTO.Nome.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(nomeTextEdit, "Nome inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            return(dxErrorProvider.HasErrors);
        }
 public static bool checkDataInput(Control _control, String _erroContent, ref DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider _dxErroControl)
 {
     if (String.IsNullOrEmpty(_control.Text) || String.IsNullOrWhiteSpace(_control.Text) || _control.Text == "0")
     {
         _dxErroControl.SetError(_control, _erroContent);
         return(false);
     }
     else
     {
         _dxErroControl.ClearErrors();
         return(true);
     }
 }
예제 #5
0
 public void TextBoslukKontrol_DevExpress(DevExpress.XtraBars.Ribbon.RibbonForm winForm, DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider, string warningMessage)
 {
     foreach (DevExpress.XtraBars.Ribbon.RibbonForm formControl in winForm.Controls)
     {
         if (formControl is DevExpress.XtraEditors.TextEdit)
         {
             if (formControl.Text == string.Empty)
             {
                 dxErrorProvider.SetError(formControl, warningMessage);
             }
             else
             {
                 dxErrorProvider.ClearErrors();
             }
         }
     }
 }
예제 #6
0
        private void BuidConnection()
        {
            string conn1 = "Data Source={0};Integrated Security=True;";
            string conn2 = "Data Source={0};User ID={1};Password={2}";

            if (string.IsNullOrEmpty(fServer.Text))
            {
                err.SetError(fServer, "IsNullOrEmpty");
            }
            if (string.IsNullOrEmpty(fUser.Text))
            {
                SqlHelper.connectionString = string.Format(conn1, fServer.Text);
            }
            else
            {
                SqlHelper.connectionString = string.Format(conn2, fServer.Text, fUser.Text, fPass.Text);
            }
        }
예제 #7
0
 internal static bool IsNullOrEmpty(DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dx, System.Windows.Forms.Control.ControlCollection p)
 {
     try
     {
         foreach (System.Windows.Forms.Control item in p)
         {
             if (item.Tag != null & string.IsNullOrWhiteSpace(item.Text))
             {
                 dx.SetError(item, L.BosGecilemez);
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         Commons.Status(Commons.GetErrorCode("CMN", 23) + ex.Message);
         return(true);
     }
 }