コード例 #1
0
        void GridViewOnCustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            BaseEditViewInfo info = ((GridCellInfo)e.Cell).ViewInfo;
            var   enumDescriptor  = new EnumDescriptor(typeof(ErrorType));
            var   row             = ((GridView)sender).GetRow(e.RowHandle);
            var   resultItem      = row as DisplayableValidationResultItem;
            Image errorIcon       = null;

            if (resultItem != null)
            {
                errorIcon = ErrorIcon(resultItem, enumDescriptor);
            }
            else if (Columns.Any())
            {
                var keyValuePairs = Columns.SelectMany(types => types);
                var propertyName  = e.Column.PropertyName();
                Func <KeyValuePair <ColumnWrapper, Validation.RuleType.RuleType>, bool> predicate = pair => propertyName == pair.Key.PropertyName;
                if (keyValuePairs.Any(predicate))
                {
                    var caption = keyValuePairs.Last(predicate).Value.ToString();
                    errorIcon = DXErrorProvider.GetErrorIconInternal((ErrorType)enumDescriptor.ParseCaption(caption));
                }
            }
            if (errorIcon != null)
            {
                info.ErrorIcon = errorIcon;
                info.CalcViewInfo(e.Graphics);
            }
        }
コード例 #2
0
ファイル: TransferForm.cs プロジェクト: thachgiasoft/RPOS
 void SetError(BaseEditViewInfo cellInfo, string errorIconText)
 {
     if (errorIconText == string.Empty)
     {
         return;
     }
     cellInfo.ErrorIconText  = errorIconText;
     cellInfo.ShowErrorIcon  = true;
     cellInfo.FillBackground = true;
     cellInfo.ErrorIcon      = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
 }
コード例 #3
0
        public static void ShowError(DXErrorProvider errorProvider, BaseEdit control, ToolTipController tipController, string errorMessage)
        {
            control.Properties.Appearance.BorderColor = Color.Red;
            control.Focus();
            control.SelectAll();
            errorProvider.SetError(control, errorMessage);
            ToolTipControllerShowEventArgs args = new ToolTipControllerShowEventArgs();

            args.ToolTipImage    = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
            args.ToolTip         = control.ErrorText;
            args.SelectedControl = control;
            args.SuperTip        = null; // here

            tipController.ShowHint(args, control.Parent.PointToScreen(control.Location));
        }
        private void propertyGridControl1_CustomDrawRowValueCell(object sender, CustomDrawRowValueCellEventArgs e)
        {
            if (e.CellValue != null)
            {
                return;
            }
            BaseRowViewInfo  rowInfo      = GetRowInfo(e);
            BaseEditViewInfo editViewInfo = GetEditorViewInfo(rowInfo, e);

            editViewInfo.ErrorIconText  = "IsNull";
            editViewInfo.ShowErrorIcon  = true;
            editViewInfo.FillBackground = true;
            editViewInfo.ErrorIcon      = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
            editViewInfo.CalcViewInfo(e.Graphics);
        }
コード例 #5
0
 Image ErrorIcon(DisplayableValidationResultItem resultItem, EnumDescriptor enumDescriptor)
 {
     if (resultItem.Rule != null)
     {
         var ruleType =
             ((IModelRuleBaseRuleType)
              ((IModelApplicationValidation)Application.Model).Validation.Rules[resultItem.Rule.Id]);
         if (ruleType != null)
         {
             var errorType = (ErrorType)enumDescriptor.ParseCaption(ruleType.RuleType.ToString());
             return(DXErrorProvider.GetErrorIconInternal(errorType));
         }
     }
     return(null);
 }
コード例 #6
0
        private void SimplePropertiesGrid_CustomDrawRowValueCell(object sender, CustomDrawRowValueCellEventArgs e)
        {
            var propertyName      = e.Row.Name;
            var validationMessage = string.Empty;

            var rule =
                _validationRules.Where(
                    v =>
                    v.Key == propertyName ||
                    (ParentProperty != null && ParentProperty + "." + propertyName == v.Key))
                .Select(r => r.Value)
                .FirstOrDefault();

            if (rule != null)
            {
                try
                {
                    var validationResult = rule(GetItemProperty);
                    if (!validationResult.IsValid)
                    {
                        validationMessage = string.Join(";", validationResult.Items.Select(i => i.ToString()));
                    }

                    else
                    {
                        return;
                    }
                }
                catch
                {
                    return;
                }
            }
            else
            {
                return;
            }

            var rowInfo      = GetRowInfo(e.Row);
            var editViewInfo = GetEditorViewInfo(rowInfo, e);

            editViewInfo.ErrorIconText  = validationMessage;
            editViewInfo.ShowErrorIcon  = true;
            editViewInfo.FillBackground = true;
            editViewInfo.ErrorIcon      = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
            editViewInfo.CalcViewInfo(e.Graphics);
        }
コード例 #7
0
        private void DoLogin()
        {
            //******************
            //* Força validação
            //******************
            if (!this.vprLogin.Validate())
            {
                this.popLogin.Show();
                return;
            }

            //****************
            //* Realiza login
            //****************
            string LoginResult = UserLogin.Login(this.txtEmpresa.Text, this.txtUsuario.Text, this.txtSenha.Text, CommonDesktop.GetMasterConnectionString());

            //****************************
            //* O login foi bem sucedido?
            //****************************
            if (LoginResult == string.Empty)
            {
                //************************
                //* Salva ou apaga dados?
                //************************
                if (this.chkManterConectado.Checked)
                {
                    SaveLoginData();
                }
                else
                {
                    ClearLoginData();
                }

                //***************************************
                //* Atualiza dados do usuário e finaliza
                //***************************************
                LoginInfoUpdate();
                popLogin.Hide();
                return;
            }

            //*************************************************
            //* Exibe falha de acordo com a mensagem - SISTEMA
            //*************************************************
            if (LoginResult.StartsWith("sistema:"))
            {
                this.txtEmpresa.ErrorText          = LoginResult.Substring(8).Trim();
                this.txtEmpresa.ErrorIconAlignment = ErrorIconAlignment.MiddleLeft;
                this.txtEmpresa.ErrorIcon          = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
                this.popLogin.Show();
                return;
            }

            //*************************************************
            //* Exibe falha de acordo com a mensagem - EMPRESA
            //*************************************************
            if (LoginResult.StartsWith("empresa:"))
            {
                this.txtEmpresa.ErrorText          = LoginResult.Substring(9).Trim();
                this.txtEmpresa.ErrorIconAlignment = ErrorIconAlignment.MiddleLeft;
                this.txtEmpresa.ErrorIcon          = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
                this.popLogin.Show();
                return;
            }

            //*************************************************
            //* Exibe falha de acordo com a mensagem - USUARIO
            //*************************************************
            if (LoginResult.StartsWith("usuario:"))
            {
                this.txtUsuario.ErrorText          = LoginResult.Substring(8).Trim();
                this.txtUsuario.ErrorIconAlignment = ErrorIconAlignment.MiddleLeft;
                this.txtUsuario.ErrorIcon          = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
                this.popLogin.Show();
                return;
            }

            //***********************************************
            //* Exibe falha de acordo com a mensagem - SENHA
            //***********************************************
            if (LoginResult.StartsWith("senha:"))
            {
                this.txtSenha.ErrorText          = LoginResult.Substring(6).Trim();
                this.txtSenha.ErrorIconAlignment = ErrorIconAlignment.MiddleLeft;
                this.txtSenha.ErrorIcon          = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical);
                this.popLogin.Show();
                return;
            }

            //*******************************************
            //* Houve falha de conexão ao banco de dados
            //*******************************************
            if (UserLogin.Error)
            {
                //**************************
                //* Exibe mensagem de falha
                //**************************
                string Message = "Ocorreu falha ao conectar ao banco de dados.\r\n\r\n";
                Message += "A mensagem retornar pelo sistema foi:\r\n";
                Message += UserLogin.ErrorText + "\r\n\r\n";
                Message += "O sessão será encerrada.";
                MessageBox.Show(Message, "Falha na inicialização", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmdSair.PerformClick();
            }
        }