private void OnTextChange(object sender, System.EventArgs e) { if (!Validate()) { if (ErrorProvider.GetError(_control) == "") { if (Mask != MaskTypes.None) { ErrorProvider.SetError(_control, "Please enter a valid value for " + Text); } else { ErrorProvider.SetError(_control, Text + " is a required field."); } } } else { if (ErrorProvider.GetError(_control) != "") { ErrorProvider.SetError(_control, ""); } } base.OnChanged(); }
private void check_input(TextBox a, TextBox a_, Button b, ErrorProvider e, ErrorProvider e_) { bool f; int t; if ((f = a.Text == "") || Int32.TryParse(a.Text, out t) && t > 0) { e.Clear(); if (restart != 2) { if (!f) { b.Enabled = true; } else { b.Enabled = false; } } else { b.Enabled = e_.GetError(a_) == ""; } } else { e.SetError(a, "Неверный формат ввода"); b.Enabled = false; } }
public static void validarPassword_Validating(object sender, CancelEventArgs e) { Control control = (Control)sender; ErrorProvider nameErrorProvider = obtenerErrorProvider(control); Boolean isValid = true; TextBox tb = (TextBox)sender; isValid = (tb.Text.Length >= 6 & tb.Text.Length <= 10); if (isValid == false) { nameErrorProvider.SetError(control, "La contraseña debe ser de 6 a 10 caracteres"); e.Cancel = true; } else { if (nameErrorProvider.GetError(control).Equals(("La contraseña debe ser de 6 a 10 caracteres"))) { nameErrorProvider.SetError(control, ""); } } }
public void ErrorProvider_Dispose_InvokeWithItems_Clears() { var provider = new ErrorProvider(); var control = new Control(); provider.SetError(control, "error"); Assert.Equal("error", provider.GetError(control)); provider.Dispose(); Assert.NotNull(provider.Icon); Assert.Empty(provider.GetError(control)); provider.Dispose(); Assert.NotNull(provider.Icon); Assert.Empty(provider.GetError(control)); }
public static void validarUnicidadCuit_Validating(object sender, CancelEventArgs e) { SqlConnection conn = new SqlConnection(); conn = Procedimientos.abrirConexion(); Control control = (Control)sender; ErrorProvider nameErrorProvider = obtenerErrorProvider(control); Boolean isValid = true; if (sender is TextBox) { TextBox tb = (TextBox)sender; isValid = Procedimientos.esUnico("LOS_OPTIMISTAS.Empresa", "Cuit", tb.Text); } if (isValid == false) { nameErrorProvider.SetError(control, "El CUIT ingresado ya existe"); e.Cancel = true; } else { if (nameErrorProvider.GetError(control).Equals(("El CUIT ingresado ya existe"))) { nameErrorProvider.SetError(control, ""); } } Procedimientos.cerrarConexion(conn); }
private void BtnOk_Click(object sender, EventArgs e) { for (int i = 0; i < parameters.Length; ++i) { Control[] ctrl = Controls.Find(parameters[i].Name, true); ErrorProvider.SetError(ctrl[0].Parent, string.Empty); if (ctrl[0] is CheckBox) { objets[i] = ((CheckBox)ctrl[0]).Checked; } else if (ctrl[0] is DateTimePicker) { objets[i] = ((DateTimePicker)ctrl[0]).Value.Date; } else if (ctrl[0] is TextBox) { objets[i] = ConvertTo((TextBox)ctrl[0], parameters[i]); } if (!string.IsNullOrEmpty(ErrorProvider.GetError(ctrl[0].Parent))) { return; } } DialogResult = DialogResult.OK; }
//********************************************************** //* VALIDACION DE DATOS OBLIGATORIOS COMPLETADOS //********************************************************** public static void validarCampoObligatorio_Validating(object sender, CancelEventArgs e) { Control control = (Control)sender; ErrorProvider nameErrorProvider = obtenerErrorProvider(control); Boolean isValid = true; if (sender is TextBox) { TextBox tb = (TextBox)sender; if (tb.Text.Equals(string.Empty)) { isValid = false; } else { isValid = true; } } else if (sender is ComboBox) { ComboBox cb = (ComboBox)sender; if (cb.Text.Equals(string.Empty)) { isValid = false; } else { isValid = true; } } else if (sender is DataGridView) { DataGridView dgv = (DataGridView)sender; if (dgv.Rows.Count.Equals(0)) { isValid = false; } } if (isValid == false) { nameErrorProvider.SetError(control, "Es un campo obligatorio, por favor completar"); e.Cancel = true; } else { if (nameErrorProvider.GetError(control).Equals(("Es un campo obligatorio, por favor completar"))) { nameErrorProvider.SetError(control, ""); } } }
public static void ErrorLog(Form oForm, EventHandler eEventHandler, Boolean oBoolean) { ErrorProvider eError = new ErrorProvider(); eError.GetError(oForm); System.Diagnostics.EventLog oEventLog = new System.Diagnostics.EventLog(); string str = oEventLog.Entries.ToString(); }
/// <summary> /// Returns the Error Provider's Error message. /// </summary> /// <returns></returns> public virtual string GetErrorMessage() { if (ErrorProvider == null) { return(""); } return(ErrorProvider.GetError(Control)); }
public static void SetErrorWithCount(this ErrorProvider ep, Control c, string message) { if (message == "") { if (ep.GetError(c) != "") { _count--; } } else if (ep.GetError(c) == "") { _count++; } ep.SetError(c, message); }
public override string ToString() { if (!mErrors.Any()) { return(null); } return(mErrors.Select(x => mProvider.GetError(x)).JoinValuesToString(Environment.NewLine)); }
private void btnOK_Click(object sender, EventArgs e) { bool statues = false; valTextBox(textBox1); if (checkBox1.Checked && err.GetError(textBox1).Length == 0) { statues = true; updateClass.UpdateProductsStatues(textBox1.Text.Trim(), statues, int.Parse(textBox2.Text)); textBox1.Clear(); this.Close(); } else { MessageBox.Show("Please tick 'freeze item' to perform item freezing" + Environment.NewLine + "Also Assign a reason for freezing the product", "SAVED - King Bar Beque Restaurant", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
public void SetError_WithErrorMessage_SetsErrorMessageOnControl(string errorMessage) { // Setup using (var resultControl = new AssessmentSectionAssemblyResultControl()) { // Call resultControl.SetError(errorMessage); // Assert ErrorProvider errorProvider = GetErrorProvider(resultControl); BorderedLabel groupLabel = GetGroupLabel(resultControl); Assert.AreEqual(errorMessage, errorProvider.GetError(groupLabel)); BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl); Assert.AreEqual(errorMessage, errorProvider.GetError(probabilityLabel)); } }
public void ErrorProvider_CorrectErrorValue() { // Check string for _control1 string actual = _errorProvider.GetError(_control1); string expected = _errorText1; Assert.Equal(expected, actual); actual = _controlItem1.Error; Assert.Equal(expected, actual); // Check string for _control2 actual = _errorProvider.GetError(_control2); expected = _errorText2; Assert.Equal(expected, actual); actual = _controlItem2.Error; Assert.Equal(expected, actual); }
public void ErrorProvider_SetError_Invoke_GetErrorReturnsExpected(ErrorBlinkStyle blinkStyle, string value, string expected) { var provider = new ErrorProvider { BlinkStyle = blinkStyle }; var control = new Control(); provider.SetError(control, value); Assert.Equal(expected, provider.GetError(control)); // Call again. provider.SetError(control, value); Assert.Equal(expected, provider.GetError(control)); // Set empty. provider.SetError(control, string.Empty); Assert.Empty(provider.GetError(control)); }
private bool IsValid() { dgvScoreConfig.EndEdit(); errorProvider1.Clear(); foreach (DataGridViewRow row in dgvScoreConfig.Rows) { if (row.IsNewRow) { continue; } row.Cells[0].ErrorText = ""; row.Cells[1].ErrorText = ""; row.Cells[2].ErrorText = ""; row.Cells[3].ErrorText = ""; if (string.IsNullOrEmpty((row.Cells[0].Value + "").Trim())) { row.Cells[0].ErrorText = "必填"; } decimal score; if (bool.Parse(row.Cells[1].Value + "") && !decimal.TryParse((row.Cells[2].Value + "").Trim(), out score)) { row.Cells[2].ErrorText = "僅允許數字"; } if (bool.Parse(row.Cells[1].Value + "") && string.IsNullOrEmpty((row.Cells[2].Value + "").Trim())) { row.Cells[2].ErrorText = "勾選「是否計算成績」時,此欄必填"; } } if ((!string.IsNullOrEmpty((dgvScoreConfig.Rows[0].Cells[0].Value + "").Trim())) && ((!string.IsNullOrEmpty((dgvScoreConfig.Rows[1].Cells[0].Value + "").Trim())) && (dgvScoreConfig.Rows[0].Cells[0].Value + "").Trim() == (dgvScoreConfig.Rows[1].Cells[0].Value + "").Trim())) { dgvScoreConfig.Rows[0].Cells[0].ErrorText = "項目不可重複"; dgvScoreConfig.Rows[1].Cells[0].ErrorText = "項目不可重複"; } if (!string.IsNullOrEmpty(errorProvider1.GetError(dgvScoreConfig))) { return(false); } foreach (DataGridViewRow row in dgvScoreConfig.Rows) { if (row.IsNewRow) { continue; } if (!string.IsNullOrEmpty(row.Cells[0].ErrorText) || !string.IsNullOrEmpty(row.Cells[1].ErrorText) || !string.IsNullOrEmpty(row.Cells[2].ErrorText) || !string.IsNullOrEmpty(row.Cells[3].ErrorText)) { return(false); } } return(true); }
public void SetErrorWithCount(Control c, string message) { if (message == "") { if (ep.GetError(c) != "") { count--; } } else { if (ep.GetError(c) == "") { count++; } } ep.SetError(c, message); }
public static bool errorProviderConError(ErrorProvider errorProvider, Control.ControlCollection controlCollection) { foreach (Control c in controlCollection) { if (errorProvider.GetError(c) != "" || Validaciones.errorProviderConError(errorProvider, c.Controls)) { return(true); } } return(false); }
public bool IsAllInputsValidate() { foreach (var tb in ruleMap.Keys) { if (errorProvider.GetError(tb) != "") { return(false); } } return(true); }
// Check if exist any errors public bool CheckErrorProvider(ref ErrorProvider errorProvider) { foreach (Control c in errorProvider.ContainerControl.Controls) { if (errorProvider.GetError(c) != "") { return(false); } } return(true); }
//Kontrollo nese te gjithe ErrorProviderat jane te barabarte me asgje. public static bool IsValid(ErrorProvider ep) { foreach (Control c in ep.ContainerControl.Controls) { if (ep.GetError(c) != "") { return(false); } } return(true); }
private void button1_Click(object sender, EventArgs e) { ValidateUserID(txtUserID); ValidateUserName(txtUserName); ValidateCurrentPass(txtCurrent); ValidateNewPass(txtNewPassword); ValidateRepeattPass(txtrepeatPassword); if (err.GetError(txtUserID).Length != 0) { err.SetError(txtUserID, "Please enter a value"); } else if (err.GetError(txtUserName).Length != 0) { err.SetError(txtUserID, "Please enter a value"); } else if (err.GetError(txtCurrent).Length != 0) { err.SetError(txtUserID, "Please enter a value"); } else if (err.GetError(txtNewPassword).Length != 0) { err.SetError(txtUserID, "Please enter a value"); } else if (err.GetError(txtrepeatPassword).Length != 0) { err.SetError(txtUserID, "Please enter a value"); } else { if (txtNewPassword.Text.Trim() == txtrepeatPassword.Text.Trim()) { selectUsers(); ClearErrorProviderIcons(); } else { MessageBox.Show("Password mismatch", "Error Data - Onana HMS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private static bool PossuiErros(this ErrorProvider provedorDeErro, Form formulario) { foreach (Control controle in formulario.Controls) { if (provedorDeErro.GetError(controle) != string.Empty) { return(false); } } return(true); }
//=================== // SAVE BUTTON //================== private void btnSaveResult_Click(object sender, EventArgs e) { validateDiagnosis(txtDiagnose); validateTreatment(txtTreatment); validateMedication(txtMedications); if (err.GetError(txtDiagnose).Length != 0) { err.SetError(txtDiagnose, "Please field can not be empty"); } else if (err.GetError(txtTreatment).Length != 0) { err.SetError(txtTreatment, "Please field can not be empty"); } else if (err.GetError(txtMedications).Length != 0) { err.SetError(txtMedications, "Please field can not be empty"); } else { try { UpdateBalance(); varInsert.insertIntoConsultation(cboPatcode, txtDocName.Text.ToString(), sysdate, sysdate, txtDiagnose.Text, txtTreatment.Text, txtMedications.Text + ", " + cboFor.SelectedItem.ToString(), pictureBox1); varInsert.ItemsBills(cboPatcode.SelectedItem.ToString(), txtPatName.Text, sysdate, sysdate, "Consultation", consultBills, txtDocName.Text); cboPatcode.SelectedIndex = 0; selectClass.selectIdForname(cboPatcode); cboFor.SelectedIndex = 0; txtDiagnose.ResetText(); txtTreatment.ResetText(); txtMedications.ResetText(); pictureBox1.Image = Properties.Resources.labs; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void SetButtonEnabled() { foreach (Control control in Controls) // обязательное для ввода поле { if (string.IsNullOrEmpty(errorProvider.GetError(control))) { continue; } buttonAdd.Enabled = false; return; } buttonAdd.Enabled = true; }
private void mtb_TextChanged(object sender, EventArgs e) { Validate(true); if (maskedTextBox2.Visible == true) { if ((epA.GetError(maskedTextBox1) == "") & (epB.GetError(maskedTextBox2) == "") & (epC.GetError(maskedTextBox3) == "") & (epX.GetError(maskedTextBox5) == "") & (maskedTextBox1.TextLength != 0) & (maskedTextBox2.TextLength != 0) & (maskedTextBox3.TextLength != 0)) { btnCompute.Enabled = true; } } else { if ((epA.GetError(maskedTextBox1) == "") & (epC.GetError(maskedTextBox3) == "") & (epX.GetError(maskedTextBox5) == "") & (maskedTextBox1.TextLength != 0) & (maskedTextBox3.TextLength != 0)) { btnCompute.Enabled = true; } } }
private void SetButtonEnabled() { foreach (Control control in Controls) { if (string.IsNullOrEmpty(errorProvider.GetError(control))) { continue; //указывает на пустые строки } buttonSum.Enabled = false; return; } buttonSum.Enabled = true; }
public static void GetErrorMessages(Control parentControl, ICollection <string> errorList, ErrorProvider errorProvider) { string error = errorProvider.GetError(parentControl); if (!string.IsNullOrWhiteSpace(error) && !errorList.Contains(error)) { errorList.Add(error); } foreach (Control control in parentControl.Controls) { GetErrorMessages(control, errorList, errorProvider); } }
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(); }
public void GivenFormWithAssemblyResultTotalView_WhenAssessmentSectionNotifiesObservers_ThenRefreshButtonEnabledAndWarningSet() { // Given AssessmentSection assessmentSection = CreateAssessmentSection(); using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) { // Precondition ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); Button button = buttonTester.Properties; Assert.IsFalse(button.Enabled); ErrorProvider warningProvider = GetWarningProvider(view); Assert.IsEmpty(warningProvider.GetError(button)); // When assessmentSection.NotifyObservers(); // Then Assert.IsTrue(buttonTester.Properties.Enabled); Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); } }