예제 #1
0
        private Boolean ValidateUserInput()
        {
            bool bool_Test = true;

            if (txt_CustomerDescription.Text.Trim().Length == 0)
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_CustomerDescription, "Enter Customer Description");
                string str_error = ErrorProvider.GetError(txt_CustomerDescription);
                MessageBox.Show(str_error);
            }
            else if (cbx_Catagory.Text.Trim().Length == 0 || cbx_Catagory.SelectedValue == null)
            {
                bool_Test = false;
                ErrorProvider.SetError(cbx_Catagory, "Please Select Customer Catagory");
                string str_error = ErrorProvider.GetError(cbx_Catagory);
                MessageBox.Show(str_error);
            }

            ErrorProvider.Clear();
            return(bool_Test);
        }
예제 #2
0
        protected override void OnValidating(System.ComponentModel.CancelEventArgs e)
        {
            base.OnValidating(e);
            if (this.Text != "")
            {
                DateTime        dateOut;
                IFormatProvider iFP       = new CultureInfo("en-GB", true);
                DateTimeStyles  style     = DateTimeStyles.None;
                string          givendate = this.Text;

                if (!DateTime.TryParse(givendate, iFP, style, out dateOut))
                {
                    errDate.SetError(this, String.Format("Silahkan masukkan tanggal yang valid dalam format ({0})", _format.ToUpper()));
                    e.Cancel = true;
                }
                else
                {
                    this.DateValue = dateOut;
                    errDate.Clear();
                }
            }
        }
예제 #3
0
        private bool Validar()
        {
            bool rtn = true;

            errorProvider.Clear();
            string errorMensaje = string.Empty;
            string correos      = _txtPara.Text.Replace(',', ';');

            string[] emails = correos.Split(';');

            if (correos.Trim().Length == 0)
            {
                errorMensaje = MessageMgr.Instance.GetMessage("EMAILS_OBLIGATORIO");
            }
            else
            {
                EmailValidator validador        = new EmailValidator();
                string         detalleNoValidos = string.Empty;
                foreach (string email in emails)
                {
                    if (!validador.IsValidEmail(email.Trim()))
                    {
                        detalleNoValidos += email + ";";
                    }
                }
                if (detalleNoValidos.Length > 0)
                {
                    string emailsNoValidosMsg = MessageMgr.Instance.GetMessage("EMAIL_NO_VALIDO");
                    errorMensaje += emailsNoValidosMsg + detalleNoValidos;
                }
            }

            if (errorMensaje.Length > 0)
            {
                rtn = false;
                errorProvider.SetError(_txtPara, errorMensaje);
            }
            return(rtn);
        }
예제 #4
0
        public static bool ObaveznoPolje(Control control, ErrorProvider err, string poruka)
        {
            bool validno = true;

            if (control is TextBox && string.IsNullOrEmpty((control as TextBox).Text))
            {
                validno = false;
            }

            else if (control is ComboBox && (control as ComboBox).SelectedIndex == -1)
            {
                validno = false;
            }

            if (!validno)
            {
                err.SetError(control, poruka);
                return(false);
            }
            err.Clear();
            return(true);
        }
예제 #5
0
        /// <summary>
        /// Валидация формы
        /// </summary>
        /// <param name="el">Элемент-отправитель события</param>
        /// <param name="errorProvider">Обработчик ошибок</param>
        public ushort DoValidate(Control el, ErrorProvider errorProvider)
        {
            ushort val = 0;

            if (string.IsNullOrEmpty(el.Text.Trim()))
            {
                errorProvider.SetError(el, "Обязательное поле!");
            }
            else if (!ushort.TryParse(el.Text.Trim(), out val))
            {
                errorProvider.SetError(el, "Значение некорректно!");
            }
            else if (val == 0)
            {
                errorProvider.SetError(el, "Значение не 0!");
            }
            else
            {
                errorProvider.Clear();
            }
            return(val);
        }
예제 #6
0
파일: FrmVentas.cs 프로젝트: jordaly/SGF
        public bool ComprobarCamposFactura()
        {
            ErrorProvider.Clear();
            bool ok = true;

            if (gridarticulo.Rows.Count < 1)
            {
                ok = false;

                ErrorProvider.SetError(gridarticulo, "Debe haber al menos un articulo para poder facturar.");
            }
            if (txtcliente.Text == "")
            {
                ok = false;

                ErrorProvider.SetError(txtcliente, "Este campo no puede estar vacio.");
            }



            return(ok);
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            int error = 0;

            errorProvider.Clear();

            if (textBoxName.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxName, "Required");
            }

            if (textBoxOrigin.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxOrigin, "Required");
            }

            if (error > 0)
            {
                return;
            }

            DAL.Brand brand = new Brand();
            brand.Name   = textBoxName.Text;
            brand.Origin = textBoxOrigin.Text;

            if (brand.Insert())
            {
                MessageBox.Show("Save Brand");
                textBoxName.Text   = "";
                textBoxOrigin.Text = "";
                textBoxName.Focus();
            }
            else
            {
                MessageBox.Show(brand.Error);
            }
        }
예제 #8
0
        public void MethodClear()
        {
            Form myForm = new Form();

            myForm.ShowInTaskbar = false;
            Label         label1          = new Label();
            Label         label2          = new Label();
            ErrorProvider myErrorProvider = new ErrorProvider();

            myErrorProvider.SetError(label1, "ErrorMsg1");
            myErrorProvider.SetError(label2, "ErrorMsg2");

            Assert.AreEqual("ErrorMsg1", myErrorProvider.GetError(label1), "#1");
            Assert.AreEqual("ErrorMsg2", myErrorProvider.GetError(label2), "#2");

            myErrorProvider.Clear();

            Assert.AreEqual(string.Empty, myErrorProvider.GetError(label1), "#3");
            Assert.AreEqual(string.Empty, myErrorProvider.GetError(label2), "#4");

            myForm.Dispose();
        }
예제 #9
0
        public static bool CheckInputAddUser(TextBox txbUserName, TextBox txbphone, TextBox txbfullname, TextBox txbEmail, ErrorProvider errorProvider)
        {
            errorProvider.Clear();
            bool k = true;

            if (txbfullname.Text == "")
            {
                k = false;
                errorProvider.SetError(txbfullname, "Khong duoc bo trong fullname");
            }
            if (txbUserName.Text == "")
            {
                k = false;
                errorProvider.SetError(txbUserName, "Khong duoc bo trong username");
            }
            else
            if (ChuaSpace(txbUserName.Text))
            {
                k = false;
                errorProvider.SetError(txbUserName, "user khong duoc chua khoan cach");
            }
            else
            if (UserController.GetUser(txbUserName.Text.Trim()) != null)
            {
                k = false;
                errorProvider.SetError(txbUserName, "user da ton tai");
            }
            if (!IsPhone(txbphone.Text))
            {
                k = false;
                errorProvider.SetError(txbphone, "Phone khong hop le");
            }
            if (!IsEmail(txbEmail.Text))
            {
                k = false;
                errorProvider.SetError(txbEmail, "Email khong hop le");
            }
            return(k);
        }
        private Boolean ValidataUserInput()
        {
            string str_Password        = txt_Password.Text;
            string str_ConfirmPassword = txt_ConfirmPassword.Text;

            bool bool_Test = true;

            if (txt_Name.Text.Length == 0)
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_Name, "Enter UserName");
                string str_error = ErrorProvider.GetError(txt_Name);
                MessageBox.Show(str_error);
            }
            else if (txt_LoginName.Text.Length == 0)
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_LoginName, "Enter LoginName");
                string str_error = ErrorProvider.GetError(txt_LoginName);
                MessageBox.Show(str_error);
            }
            else if (user.UserId == Guid.Empty && checkUserExistedOrNot(txt_LoginName.Text))
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_LoginName, "LoginName already Existed. Please Choose Another");
                string str_error = ErrorProvider.GetError(txt_LoginName);
                MessageBox.Show(str_error);
            }
            else if (str_Password != str_ConfirmPassword)
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_ConfirmPassword, "Password And ConfirmPassword does not Match");
                string str_error = ErrorProvider.GetError(txt_ConfirmPassword);
                MessageBox.Show(str_error);
            }

            ErrorProvider.Clear();
            return(bool_Test);
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            int error = 0;

            aErrorProvider.Clear();
            if (cityNameTextBox.Text == "")
            {
                error++;
                aErrorProvider.SetError(cityNameTextBox, "Requred");
            }
            if (countryNameComboBox.SelectedValue == null || countryNameComboBox.SelectedValue.ToString() == "")
            {
                error++;
                aErrorProvider.SetError(countryNameComboBox, "Requred");
            }
            if (error > 0)
            {
                return;
            }


            DAL.City aCity = new DAL.City();
            aCity.Name      = cityNameTextBox.Text;
            aCity.CountryId = Convert.ToInt32(countryNameComboBox.SelectedValue);

            if (aCity.Insert())
            {
                MessageBox.Show("Data Saved");
                cityNameTextBox.Text = "";
                countryNameComboBox.SelectedValue = -1;

                cityNameTextBox.Focus();
            }
            else
            {
                MessageBox.Show(aCity.Error);
            }
        }
예제 #12
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();

            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Name Required");
            }

            if (txtDescription.Text == "")
            {
                er++;
                ep.SetError(txtDescription, "Description Required");
            }


            if (er == 0)
            {
                DAL.Department department = new DAL.Department();

                department.Name        = txtName.Text;
                department.Description = txtDescription.Text;

                if (department.Insert())
                {
                    MessageBox.Show("Data Saved");
                    txtName.Text        = "";
                    txtDescription.Text = "";
                }
                else
                {
                    MessageBox.Show(department.Error);
                }
            }
        }
예제 #13
0
        private void Save()
        {
            ErrorProvider.Clear();
            var isFormValid = true;

            if (intInCount.Value <= 0)
            {
                ErrorProvider.SetError(intInCount, Resources.RequiredValidation);
                isFormValid = false;
            }
            if (dblInPrice.Value <= 0)
            {
                ErrorProvider.SetError(dblInPrice, Resources.RequiredValidation);
                isFormValid = false;
            }
            if (!isFormValid)
            {
                return;
            }
            var selectedItemId = int.Parse(cmbItems.SelectedValue.ToString());
            var count          = intInCount.Value;

            if (!SaleManager.IsItemAvailableToSale(selectedItemId, count))
            {
                ShowErrorMsg(Resources.SaleCountNotAvailable);
                return;
            }
            SaleManager.AddNewSale(new Sale
            {
                Date   = dtSaleDate.Value,
                ItemId = selectedItemId,
                Count  = count,
                Price  = (decimal)dblInPrice.Value
            });
            ItemManager.DecreaseItemCount(selectedItemId, count);
            ShowInfoMsg(Resources.SaleAddedSuccessfully);
            Close();
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            int error = 0;

            errorProvider.Clear();

            if (textBoxName.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxName, "Required");
            }

            if (comboBoxCountry.SelectedValue == null || comboBoxCountry.SelectedValue.ToString() == "")
            {
                error++;
                errorProvider.SetError(comboBoxCountry, "Required");
            }

            if (error > 0)
            {
                return;
            }

            cityEdit.Name      = textBoxName.Text;
            cityEdit.CountryId = Convert.ToInt32(comboBoxCountry.SelectedValue);

            if (cityEdit.Update())
            {
                MessageBox.Show("City is Update.");
                textBoxName.Text     = "";
                comboBoxCountry.Text = "";
                textBoxName.Focus();
            }
            else
            {
                MessageBox.Show(cityEdit.Error);
            }
        }
예제 #15
0
        private Boolean validateSignUp()
        {
            bool result = false;



            if (String.IsNullOrEmpty(txtFullNameSignUp.Text))
            {
                ErrorProvider.Clear();
                ErrorProvider.SetError(txtFullNameSignUp, "Name can not be empty");
            }
            else if (!Validations.isValidEmail(txtEmailSignUp.Text))
            {
                ErrorProvider.Clear();
                ErrorProvider.SetError(txtEmailSignUp, "Invalid Email Address");
            }
            else if (!Validations.isValidMobile(txtMobileNoSignUp.Text))
            {
                ErrorProvider.Clear();
                ErrorProvider.SetError(txtMobileNoSignUp, "Invalid Mobile No");
            }
            else if (!Validations.isLengthValid(txtPasswordSignUp.Text, 4))
            {
                ErrorProvider.Clear();
                ErrorProvider.SetError(txtPasswordSignUp, "Password length should be more than 4");
            }
            else if (!txtPasswordSignUp.Text.Equals(txtConfirmPassSignUp.Text))
            {
                ErrorProvider.Clear();
                ErrorProvider.SetError(txtConfirmPassSignUp, "Passwords do not match");
            }
            else
            {
                ErrorProvider.Clear();
                result = true;
            }
            return(result);
        }
예제 #16
0
        void PassTextBox_TextChanged2(object sender, EventArgs e)
        {
            Regex regex = new Regex(@"[^a-zA-Z0-9\s]");

            string text = Text;

            if (text.Length < 6)
            {
                errP.SetError(this, "Not valid!");
            }
            else
            {
                foreach (char c in text)
                {
                    if (regex.IsMatch(c.ToString()))
                    {
                        errP.Clear();
                        return;
                    }
                    errP.SetError(this, "Not valid!");
                }
            }
        }
 private void limparCampos()
 {
     errorProvider.Clear();
     dataAvaliacaoObjetivo.Value = DateTime.Today;
     dataUltimaMenstruacao.Value = DateTime.Today;
     UpDownPeso.Value            = 0;
     UpDownAltura.Value          = 0;
     UpDownPressaoArterial.Value = 0;
     UpDownFC.Value          = 0;
     UpDownTemperatura.Value = 0;
     UpDownSPO2.Value        = 0;
     upDownMenarca.Value     = 0;
     UpDownBTM.Value         = 0;
     UpDownAC.Value          = 0;
     UpDownAP.Value          = 0;
     upDownINR.Value         = 0;
     upDownMenarca.Value     = 0;
     upDownGravidezes.Value  = 0;
     upDownFilhosVivos.Value = 0;
     upDownAbortos.Value     = 0;
     txtObservacoes.Text     = "";
     reiniciar();
 }
예제 #18
0
        public void NextTab()
        {
            if (IsNextAvailable)
            {
                _errorProvider.Clear();
                var res = ((MyTabPage)this.SelectedTab).OnPageLeaving(new Components.PageLeavingEventArgs());

                if (!res.Cancel)
                {
                    this.SelectedIndex = getNextShowablePageIndex();
                    ((MyTabPage)this.SelectedTab).OnPageEntering(new Components.PageEnteringEventArgs());
                }
                else
                {
                    foreach (PageError pe in res.PageErrors)
                    {
                        _errorProvider.SetIconAlignment(pe.Control, ErrorIconAlignment.MiddleLeft);
                        _errorProvider.SetError(pe.Control, !string.IsNullOrEmpty(pe.ErrorMessage) ? pe.ErrorMessage : "Error");
                    }
                }
                //MessageBox.Show(res.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #19
0
        private int Validar()
        {
            int retorno = 0;

            if (!Regex.Match(CodigoPostalTextBox.Text, @"^\d{5}$").Success)
            {
                miError.SetError(CodigoPostalTextBox, "Codigo postal invalido");
                retorno = 0;
            }
            if (!Regex.Match(NombreTextBox.Text, "^\\w{1,50}$").Success)
            {
                miError.SetError(NombreTextBox, "Sobrepasa el tamaño de 50");
                retorno = 0;
            }
            else
            {
                retorno = 1;
                miError.Clear();
            }


            return(retorno);
        }
예제 #20
0
        private int Validar()
        {
            int retorno = 0;

            if (!Regex.Match(NombreTextBox.Text, "^\\w{1,50}$").Success)
            {
                miError.SetError(NombreTextBox, "Sobrepasa tamaño permitido de 50");
                retorno = 0;
            }

            /*if (!Regex.Match(PrecioTextBox.Text, "/^([0-9])*$/").Success)
             * {
             *  miError.SetError(PrecioTextBox, "Sobrepasa tamaño permitido de 50");
             *  retorno = 0;
             * }*/
            else
            {
                retorno += 1;
                miError.Clear();
            }

            return(retorno);
        }
예제 #21
0
        private void Buscarbutton_Click(object sender, EventArgs e)
        {
            RepositorioBase <Inscripciones> repositorio = new RepositorioBase <Inscripciones>();
            Inscripciones inscripcion = new Inscripciones();
            Estudiantes   estudiante  = new Estudiantes();
            Asignaturas   asignatura  = new Asignaturas();

            int.TryParse(IdnumericUpDown.Text, out int id);

            inscripcion = repositorio.Buscar(id);

            if (inscripcion != null)
            {
                ErrorProvider.Clear();
                LlenaCampo(inscripcion);                                      //todo: llenar datos de la inscripcion
                LLenarEstudiante(BuscarEstudiante(inscripcion.EstudianteId)); //todo: llena id & nombre del estudiante
                LlenarAsignatura(BuscarAsignatura(inscripcion.AsignaturaId)); // todo: llenar id & descripcion de la asignatura
            }
            else
            {
                ErrorProvider.SetError(IdnumericUpDown, "Inscripcion  no encontrada");
            }
        }
        private Boolean ValidateUserInput()
        {
            bool bool_Test = true;

            if (cbx_Product.Text.Length == 0 || cbx_Product.SelectedValue == null)
            {
                bool_Test = false;
                ErrorProvider.SetError(cbx_Product, "Please Select Product");
                string str_error = ErrorProvider.GetError(cbx_Product);
                MessageBox.Show(str_error);
            }
            else if (txt_Quantity.Text.Trim().Length == 0)
            {
                bool_Test = false;
                ErrorProvider.SetError(txt_Quantity, "Enter Quantity");
                string str_error = ErrorProvider.GetError(txt_Quantity);
                MessageBox.Show(str_error);
            }


            ErrorProvider.Clear();
            return(bool_Test);
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();
            if (txtEmail.Text == "")
            {
                er++;
                ep.SetError(txtEmail, "Email / Contact Required");
            }
            if (txtPassword.Text == "")
            {
                er++;
                ep.SetError(txtPassword, "Required");
            }

            if (er > 0)
            {
                return;
            }

            DAL.Login lgn = new DAL.Login();

            lgn.Email    = txtEmail.Text;
            lgn.Password = txtPassword.Text;
            if (lgn.LoginCheck())
            {
                ACL.Login = lgn;

                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid Login, Try Again");
                txtEmail.Focus();
            }
        }
예제 #24
0
        public void OnDirtyChange(int attributeID, bool Dirty)
        {
            switch (attributeID)
            {
            case 2:
                errorProvider1.SetError(CAValueTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 3:
                errorProvider1.SetError(LAValueTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 5:
                errorProvider1.SetError(StatusTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 6:
                errorProvider1.SetError(CaptureTimeTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 7:
                errorProvider1.SetError(CurrentStartTimeTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 8:
                errorProvider1.SetError(PeriodTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            case 9:
                errorProvider1.SetError(NOPeriodTB, GXDLMSDirector.Properties.Resources.ValueChangedTxt);
                break;

            default:
                errorProvider1.Clear();
                break;
            }
        }
예제 #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            String Name, Email, Mobile;

            Name   = textBox1.Text;
            Email  = textBox2.Text;
            Mobile = textBox3.Text;
            if (Name.Length == 0 || Name.Length > 30)
            {
                errorProvider1.SetError(textBox1, " Please Enter Valid Name ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else if (Email.Length == 0 || Email.Length > 30)
            {
                errorProvider1.SetError(textBox2, " Please Enter Valid Email ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else if (Mobile.Length == 0 || Mobile.Length > 30)
            {
                errorProvider1.SetError(textBox3, " Please Enter Valid Mobile ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else
            {
                con.Open();
                errorProvider1.Clear();
                cmd.Connection = con;
                SqlCommand myCommand = new SqlCommand("Update Suppliers set Name = '" +
                                                      Name.ToString() + "',Mobile = '" + Mobile.ToString() + "' Where Email = '" + Email + "'", con);
                int success = myCommand.ExecuteNonQuery();
                if (success == 1)
                {
                    MessageBox.Show(success + " row has been inserted ");
                }
                con.Close();
            }
        }
예제 #26
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();

            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Requred");
            }

            if (txtOrigin.Text == "")
            {
                er++;
                ep.SetError(txtOrigin, "Required");
            }

            if (er > 0)
            {
                return;
            }
            //br.Id = 1;

            br.Name   = txtName.Text;
            br.Origin = txtOrigin.Text;

            if (br.Update())
            {
                MessageBox.Show("Updated");
                txtName.Focus();
            }
            else
            {
                MessageBox.Show(br.Error);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String Name, Address, Mobile;

            Name    = textBox1.Text;
            Address = textBox2.Text;
            Mobile  = textBox3.Text;
            if (Name.Length == 0 || Name.Length > 30)
            {
                errorProvider1.SetError(textBox1, " Please Enter Valid Name ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else if (Address.Length == 0 || Address.Length > 30)
            {
                errorProvider1.SetError(textBox2, " Please Enter Valid Address ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else if (Mobile.Length == 0 || Mobile.Length > 30)
            {
                errorProvider1.SetError(textBox3, " Please Enter Valid Mobile ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else
            {
                con.Open();
                errorProvider1.Clear();
                cmd.Connection = con;
                SqlCommand myCommand = new SqlCommand("insert into Owner values ('" +
                                                      Name.ToString() + "','" + Address.ToString() + "','" + Mobile.ToString() + "')", con);
                int success = myCommand.ExecuteNonQuery();
                if (success == 1)
                {
                    MessageBox.Show(success + " row has been inserted ");
                }
                con.Close();
            }
        }
예제 #28
0
        private int Validar()
        {
            int retorno = 0;

            if (!Regex.Match(NombresTextBox.Text, "^\\w{1,50}$").Success)
            {
                miError.SetError(NombresTextBox, "Sobrepasa tamaño permitido de 50");
                retorno = 0;
            }
            if (!Regex.Match(ApellidostextBox.Text, "^\\w{1,50}$").Success)
            {
                miError.SetError(ApellidostextBox, "Sobrepasa tamaño permitido de 50");
                retorno = 0;
            }
            if (!Regex.Match(DirecciontextBox.Text, "^\\w{1,150}$").Success)
            {
                miError.SetError(DirecciontextBox, "Sobrepasa tamaño permitido de 150");
                retorno = 0;
            }
            if (!Regex.Match(EmailtextBox.Text, "^\\w{1,100}$").Success)
            {
                miError.SetError(EmailtextBox, "Sobrepasa tamaño permitido de 100");
                retorno = 0;
            }
            if (!Regex.Match(EmailtextBox.Text, @"\A(\w+\.?\w*\@\w+.)(com)\Z").Success)
            {
                miError.SetError(EmailtextBox, "Correo Invalido");
                retorno = 0;
            }
            else
            {
                retorno += 1;
                miError.Clear();
            }

            return(retorno);
        }
예제 #29
0
        public static bool ValidateControl <T>(this Control container,
                                               T instance,
                                               ErrorProvider errorProvider,
                                               out ICollection <ValidationResult> validationResults)
            where T : class, new()
        {
            var innerControls = new Dictionary <string, Control>();

            container.GetAllInnerControls <T>(ref innerControls);

            errorProvider.Clear();
            var validationContext = new ValidationContext(instance, null, null);

            validationResults = new List <ValidationResult>();
            var isValid = Validator.TryValidateObject(instance, validationContext, validationResults, true);

            if (isValid)
            {
                return(isValid);
            }

            foreach (var validationResult in validationResults)
            {
                foreach (var member in validationResult.MemberNames)
                {
                    if (!innerControls.ContainsKey(member))
                    {
                        continue;
                    }

                    var control = innerControls[member];
                    errorProvider.SetError(control, validationResult.ErrorMessage);
                }
            }

            return(isValid);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String ProductName = textBox1.Text;

            if (ProductName.Length == 0 || ProductName.Length > 30)
            {
                errorProvider1.SetError(textBox1, " Please Enter Valid ProductName ");
                errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
            }
            else
            {
                con.Open();
                errorProvider1.Clear();
                cmd.Connection = con;
                SqlCommand myCommand = new SqlCommand("Delete From Supply Where ProductName ='" +
                                                      ProductName.ToString() + "'", con);
                int success = myCommand.ExecuteNonQuery();
                if (success == 1)
                {
                    MessageBox.Show(success + " row has been Deleted ");
                }
                con.Close();
            }
        }