Exemplo n.º 1
0
        public static Boolean validNullTxt(System.Windows.Forms.Control txtCtl,
                                           System.Windows.Forms.ErrorProvider errorProvider,
                                           int minLength = 0, string type = null, string msg = "This field is required")
        {
            switch (type)
            {
            case "Number": {
                break;
            }

            case "strEnglishOnly": {
                break;
            }

            default: {
                if ((!String.IsNullOrWhiteSpace(txtCtl.Text)))
                {
                    errorProvider.SetError(txtCtl, "");
                    return(false);
                }
                else
                {
                    if (txtCtl.Text.Length < minLength)
                    {
                        msg += " and Length must be greater than " + minLength;
                    }
                    errorProvider.SetError(txtCtl, msg);
                    return(true);
                }
            }
            }
            return(false);
        }
Exemplo n.º 2
0
 public static Boolean validNotSelectCB(Syncfusion.Windows.Forms.Tools.ComboBoxAdv cbCtl,
                                        System.Windows.Forms.ErrorProvider errorProvider, string msg = "This field is required")
 {
     if (cbCtl.SelectedIndex == -1)
     {
         errorProvider.SetError(cbCtl, msg);
         return(true);
     }
     else
     {
         errorProvider.SetError(cbCtl, "");
         return(false);
     }
 }
Exemplo n.º 3
0
        private void BindBrokenMessages2WinformErrorProvider(System.Windows.Forms.ErrorProvider errorProvider, System.Windows.Forms.Control.ControlCollection controls, bool clearMessages)
        {
            if (clearMessages)
            {
                errorProvider.Clear();
            }

            foreach (BrokenRuleMessage rule in this.BrokenRuleMessages)
            {
                for (int i = 0; i < controls.Count; i++)
                {
                    if (controls[i] is System.Windows.Forms.Control)
                    {
                        System.Windows.Forms.Control cv = (System.Windows.Forms.Control)controls[i];
                        if (cv.Tag == null)
                        {
                            continue;
                        }
                        if (Convert.ToString(cv.Tag) != rule.Key)
                        {
                            continue;
                        }

                        errorProvider.SetError(cv, rule.Message);
                    }
                    else if (controls[i].Controls.Count > 0)
                    {
                        BindBrokenMessages2WinformErrorProvider(errorProvider, controls[i].Controls, false);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static bool ValidarForm2(System.Windows.Forms.Control objForm, System.Windows.Forms.ErrorProvider error)
        {
            bool valor = true;

            foreach (System.Windows.Forms.Control obj in objForm.Controls)
            {
                if (obj.Controls.Count > 0)
                {
                    valor = ValidarForm2(obj, error);
                    continue;
                }

                if (obj is textbox)
                {
                    textbox obj2 = (textbox)obj;
                    if (obj2.Validar)
                    {
                        if (string.IsNullOrEmpty(obj2.Text.Trim()))
                        {
                            valor = false;

                            error.SetError(obj, (string.IsNullOrEmpty(obj2.Text.Trim())) ? "Campo obligatorio" : "");
                        }
                    }
                }
            }
            return(valor);
        }
        void BtStartMaintenanceClick(object sender, System.EventArgs e)
        {
            bool allPropertiesSet = false;

            if (cbDuration.SelectedIndex >= 0)
            {
                allPropertiesSet = true;
            }
            else
            {
                epDuration.SetError(cbDuration, "Must select duration!");
                allPropertiesSet = false;
            }
            if (cbReason.SelectedIndex >= 0)
            {
                allPropertiesSet = true;
            }
            else
            {
                epReason.SetError(cbReason, "Must select reason!");
                allPropertiesSet = false;
            }
            if (epIllegalComment.GetError(tbComment) != "" ||
                epReason.GetError(cbReason) != "" ||
                epDuration.GetError(cbDuration) != "")
            {
                allPropertiesSet = false;
            }

            // All inputs looks OK, write start command to event log.
            if (allPropertiesSet)
            {
                OpsMMEventLog opsEventlog = new OpsMMEventLog();
                KeyValuePair  kvpDuration = (KeyValuePair)cbDuration.SelectedItem;
                KeyValuePair  kvpReason   = (KeyValuePair)cbReason.SelectedItem;
                string        comment     = tbComment.Text;
                string        userName    = tbCurrentUser.Text;
                if (opsEventlog.writeStartEvent(kvpDuration.m_objectKey.ToString(), kvpReason.m_objectKey.ToString(), "", "", comment, userName))
                {
                    setStatusMessage("", STATUS_INFO);
                    updateProgressBar(0, MM_TIMEOUT, Color.Green);
                    tmCheckForACK.Start();
                    btStartMaintenance.Enabled = false;
                    btStopMaintenance.Enabled  = false;
                    btnCancel.Text             = "&Close";
                }
                else
                {
                    setStatusMessage("Failed to write event! Are you running as administrator?", STATUS_ERROR);
                }
            }
        }
Exemplo n.º 6
0
        private bool ControlErrores()
        {
            bool Retorno = true;

            if (txtDominio.Text == "")
            {
                epControlCampos.SetError(txtDominio, "Debe ingresar un Dominio");
                Retorno = false;
            }
            else
            {
                epControlCampos.Clear();
            }
            return(Retorno);
        }
Exemplo n.º 7
0
        private void OnExportClick(object sender, EventArgs e)
        {
            var hasError = false;

            if (!this.chkCs.Checked && !this.chkJs.Enabled)
            {
                errorProvider.SetError(this.chkCs, "At least one should be checked!");
                errorProvider.SetError(this.chkJs, "At least one should be checked!");
                hasError = true;
            }
            else
            {
                if (this.chkCs.Checked)
                {
                    if (string.IsNullOrWhiteSpace(this.txtCsNamespace.Text))
                    {
                        errorProvider.SetError(this.txtCsNamespace, "Please insert the namespace");
                        hasError = true;
                    }
                    if (string.IsNullOrWhiteSpace(this.txtCsFolder.Text))
                    {
                        errorProvider.SetError(this.txtCsFolder, "Please select the folder that will contain C# files");
                        hasError = true;
                    }
                    else if (!Directory.Exists(this.txtCsFolder.Text))
                    {
                        errorProvider.SetError(this.txtCsFolder, "Please select a folder that exists!");
                        hasError = true;
                    }
                }
                if (this.chkJs.Checked)
                {
                    if (string.IsNullOrWhiteSpace(this.txtJsNamespace.Text))
                    {
                        errorProvider.SetError(this.txtJsNamespace, "Please insert the namespace");
                        hasError = true;
                    }
                    if (string.IsNullOrWhiteSpace(this.txtJsFolder.Text))
                    {
                        errorProvider.SetError(this.txtJsFolder, "Please select the folder that will contain JS files");
                        hasError = true;
                    }
                    else if (!Directory.Exists(this.txtJsFolder.Text))
                    {
                        errorProvider.SetError(this.txtJsFolder, "Please select a folder that exists!");
                        hasError = true;
                    }
                }
            }


            if (this.cmbSolutionList.SelectedItem == null)
            {
                errorProvider.SetError(this.cmbSolutionList, "Please select a solution");
                hasError = true;
            }

            if (hasError)
            {
                return;
            }

            this.Settings.GetCsConstants      = this.chkCs.Checked;
            this.Settings.GetJsConstants      = this.chkJs.Checked;
            this.Settings.CsFolder            = this.txtCsFolder.Text;
            this.Settings.JsFolder            = this.txtJsFolder.Text;
            this.Settings.NamespaceCs         = this.txtCsNamespace.Text;
            this.Settings.NamespaceJs         = this.txtJsNamespace.Text;
            this.Settings.JsHeaderLines       = this.txtJsHeaders.Text;
            this.Settings.ExtractTypes        = this.chkExtractTypes.Checked;
            this.Settings.ExtractDescriptions = this.chkExtractDescriptions.Checked;
            this.Settings.SolutionName        = ((Solution)this.cmbSolutionList.SelectedItem).uniquename;

            SettingsManager.Instance.Save(typeof(MainView), this.Settings);

            this.messenger.Send(new Export(this.Settings));
            this.Enabled = false;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Reset the ErrorProvider
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void textBoxText_TextChanged(object sender, System.EventArgs e)
 {
     errorProviderText.SetError(textBoxText, "");
 }