public static bool CheckLotValue(this BaseEdit baseEdit, double?maxQuantity, DXErrorProvider errorProvider, string error) { var text = baseEdit.Text.Trim(); if (string.IsNullOrEmpty(text)) { errorProvider.SetError(baseEdit, error, ErrorType.Critical); return(false); } else { if (double.TryParse(text, out double quantity)) { if (quantity > 0 && maxQuantity != null && quantity <= maxQuantity) { errorProvider.SetError(baseEdit, string.Empty, ErrorType.None); return(true); } errorProvider.SetError(baseEdit, error, ErrorType.Critical); return(false); } errorProvider.SetError(baseEdit, error, ErrorType.Critical); return(false); } }
public static bool Validate_ValueOverAndSTDMaching(BaseEdit control, int compareValue, int stdValue, ref DXErrorProvider ctlErrorProvider) { if (control.Text == null || control.Text.Trim().Length == 0) { ctlErrorProvider.SetError(control, "This field is Invalid", ErrorType.Critical); return(false); } else { int controlValue = Convert.ToInt32(control.EditValue); if (controlValue <= 0) { ctlErrorProvider.SetError(control, "Qty can't be zero", ErrorType.Critical); return(false); } if (controlValue >= compareValue) { ctlErrorProvider.SetError(control, "Qty must be less than Label Qty", ErrorType.Critical); return(false); } //Modified by pravin on 12-10-2010 //if ((controlValue % stdValue) != 0) //{ // ctlErrorProvider.SetError(control, "Qty must be multiple of " + stdValue.ToString(), ErrorType.Critical); // return false; //} //no error ctlErrorProvider.SetError(control, ""); return(true); } }
public static void Validate_EmptyStringRule(BaseEdit control, ref DXErrorProvider ctlErrorProvider) { if (control.Text == null || control.Text.Trim().Length == 0) { ctlErrorProvider.SetError(control, "This field can't be empty", ErrorType.Critical); } else { ctlErrorProvider.SetError(control, ""); } }
public static void Validate_EmptyOrNotEqual(BaseEdit control, string compareValue, ref DXErrorProvider ctlErrorProvider) { if (control.Text == null || control.Text.Trim().Length == 0 || !control.Text.Equals(compareValue)) { ctlErrorProvider.SetError(control, "This field is Invalid", ErrorType.Critical); } else { ctlErrorProvider.SetError(control, ""); } }
public static bool CheckTextValue(this BaseEdit baseEdit, DXErrorProvider errorProvider, string error) { if (string.IsNullOrEmpty(baseEdit.Text.Trim())) { errorProvider.SetError(baseEdit, error, ErrorType.Critical); return(false); } errorProvider.SetError(baseEdit, string.Empty, ErrorType.None); return(true); }
public static void Validate_EmptyOrNotMorethan(BaseEdit control, int compareValue, ref DXErrorProvider ctlErrorProvider) { if (control.Text == null || control.Text.Trim().Length == 0 || Convert.ToInt32(control.EditValue, NumberFormatInfo.InvariantInfo) <= compareValue) { ctlErrorProvider.SetError(control, "This field is Invalid", ErrorType.Critical); } else { ctlErrorProvider.SetError(control, ""); } }
public void SetParserError(string parserError) { if (string.IsNullOrEmpty(parserError)) { _warningProvider.SetError(txtFormulaString, null); } else { _warningProvider.SetError(txtFormulaString, parserError, ErrorType.Critical); } _presenter.ViewChanged(); }
public static bool Validate_EmptyOrNotMorethan(BaseEdit control, int compareValue, ref DXErrorProvider ctlErrorProvider, string msg, ErrorType type) { if (control.Text == null || control.Text.Trim().Length == 0 || Convert.ToInt32(control.EditValue, NumberFormatInfo.InvariantInfo) <= compareValue) { ctlErrorProvider.SetError(control, msg, ErrorType.Critical); return(false); } else { ctlErrorProvider.SetError(control, ""); return(true); } }
public static bool Validate_Empty(BaseEdit control, ref DXErrorProvider ctlErrorProvider, string msg, ErrorType type) { if (control.Text == null || control.Text.Trim().Length == 0) { ctlErrorProvider.SetError(control, msg, ErrorType.Critical); return(false); } else { ctlErrorProvider.SetError(control, ""); return(true); } }
private void btnLuu_Click(object sender, EventArgs e) { if (txtTen.Text == "") { error.SetError(txtTen, "Vui lòng điền thông tin !"); } else { error.SetError(txtTen, string.Empty); } if (lePhanLoai.Text == "") { error.SetError(lePhanLoai, "Vui lòng điền thông tin !"); } else { error.SetError(lePhanLoai, string.Empty); } if (leDonVi.Text == "") { error.SetError(leDonVi, "Vui lòng điền thông tin !"); } else { error.SetError(leDonVi, string.Empty); } if (txtMa.Text == "") { error.SetError(txtMa, "Vui lòng điền thông tin !"); } else if (add == true && BUS_HangHoa.KiemTraHH(txtMa.Text)) { error.SetError(txtMa, "Mã đã tồn tại, vui lòng chọn mã khác !"); } else { error.SetError(txtMa, string.Empty); } if (error.GetError(txtMa) == "" && error.GetError(txtTen) == "" && error.GetError(leDonVi) == "" && error.GetError(lePhanLoai) == "") { if (add == true) { xlThem(); } else { xlSua(); } } }
private static bool TryGetValue(Control control, DXErrorProvider provider, out double value) { provider.SetError(control, null); try { value = Convert.ToDouble(control.Text); return(true); } catch { provider.SetError(control, "Должно быть числом"); } value = default(double); return(false); }
protected bool Validate_EmptyStringRule(BaseEdit control) { if (control.Text == null || control.Text.Trim().Length == 0) { dxErrorProviderModel.SetError(control, "Trường này không được để trống!", ErrorType.Critical); this.isValidModel = false; return(false); } else { this.isValidModel = this.isValidModel ? true : this.isValidModel; dxErrorProviderModel.SetError(control, ""); return(true); } }
internal static bool ValidarMascara(TextEdit textEdit, DXErrorProvider dXErrorProvider) { dXErrorProvider.ClearErrors(); eMascara mascara = textEdit.RetornarValorPropriedade <eMascara>("Mascara"); if (mascara != eMascara.Default && !textEdit.Text.NuloOuVazio()) { switch (mascara) { case eMascara.Email: { if (textEdit.Text.IndexOf("@").Equals(-1)) { dXErrorProvider.SetError(textEdit, "Entre com um e-mail válido.", ErrorType.Critical); } break; } } if (dXErrorProvider.HasErrors) { textEdit.Focus(); } } dXErrorProvider.GetError(textEdit); return(!dXErrorProvider.HasErrors); }
public static bool ValidateForm(this XtraForm frm) { dXErrorProvider.ClearErrors(); var ctrls = frm.Controls.Cast <Control>().OrderBy(x => x.TabIndex).ToList(); foreach (Control c in ctrls) { foreach (var ctrl in GetControls(c)) { if (ctrl is BaseEdit control) { if (!string.IsNullOrEmpty(control.Tag?.ToString())) { if (control.EditValue == null) { dXErrorProvider.SetError(control, control.Tag?.ToString()); dXErrorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); control.Focus(); return(false); } } } } } return(true); }
private void txbRolename_Validating(object sender, CancelEventArgs e) { var edit = sender as TextEdit; var rxPattern = @"^\w[a-z0-9\.]{3,11}"; var match = Regex.Match(txbUsername.Text, rxPattern, RegexOptions.IgnoreCase); if (match.Success) { errorProvider.SetError(edit, ""); } else { errorProvider.SetError(edit, "A good role is:\n> 4-12 characters.\n> Lower case alphabet character\n> Numberic character\n> No space or others", ErrorType.Critical); e.Cancel = true; } }
/// <summary> /// 校验控件是否为空,如果全部非空,则返回True /// </summary> /// <param name="dxErrorProvider"></param> /// <param name="baseEdits">输入控件集合</param> /// <returns></returns> public static bool ValidateEditNull(this DXErrorProvider dxErrorProvider, BaseEdit[] baseEdits, string errorText = "不能为空", ErrorType errorType = ErrorType.Critical) { bool passed = true; for (int i = 0; i < baseEdits.Length; i++) { BaseEdit edit = baseEdits[i]; string editValue = string.Concat(edit.EditValue).Trim(); if (string.IsNullOrEmpty(editValue)) { //多语言支持 errorText = JsonLanguage.Default.GetString(errorText); dxErrorProvider.SetError(edit, errorText, errorType); if (i == 0) { edit.Focus(); edit.SelectAll(); } passed = false; } } return(passed); }
public static string ValidateFolderComboBox(ComboBoxEdit comboBox, DXErrorProvider errorProvider) { string folderPath = comboBox.Text; if (string.IsNullOrEmpty(folderPath)) { errorProvider.SetError(comboBox, "Please enter a valid folder"); return(null); } if (!Directory.Exists(folderPath)) { errorProvider.SetError(comboBox, "The specified folder does not exist"); return(null); } return(folderPath); }
private void RemoveError(object sender) { if ((m_ErrorProvider != null) && Enabled) { BaseEdit control = sender as BaseEdit; if (control != null) { m_ErrorProvider.SetError(control, string.Empty); if ((m_AssociatedControls != null) && m_AssociatedControls.ContainsKey(control)) { foreach (BaseEdit associatedControl in m_AssociatedControls[control]) { m_ErrorProvider.SetError(associatedControl, string.Empty); } } } } }
/// <summary> /// 设定控件的警告信息 /// </summary> /// <param name="ErrorInfo">异常信息对象提供者</param> /// <param name="ctl">控件对象</param> /// <param name="messageId">出错信息,可以用ID,可以用字符串</param> public static void ShowErrorInfo(DXErrorProvider ErrorInfo, Control ctl, string messageId) { ErrorInfo.SetError (ctl,messageId); ErrorInfo.SetIconAlignment(ctl, ErrorIconAlignment.MiddleRight); //设定窗体控件的焦点 Common.SetContorlFocus(ctl); }
public static bool ValidateControl(this Control control, object value, string regex, DXErrorProvider dxErrorProvider, string messageError = "Vui lòng nhập giá trị") { if (value == null || string.IsNullOrEmpty(value.ToString()) || new Regex(regex).Match(value.ToString()).Success == false) { dxErrorProvider.SetError(control, messageError); return(false); } return(true); }
public static void Validate_DateNotEqual(BaseEdit control, DateTime controlDate, DateTime compareDate, ref DXErrorProvider ctlErrorProvider) { if (control.Text == null || control.Text.Trim().Length == 0) { ctlErrorProvider.SetError(control, "This field is Invalid", ErrorType.Critical); } else { if (DateTime.Compare(controlDate.Date, compareDate.Date) != 0) { ctlErrorProvider.SetError(control, "This field is Invalid", ErrorType.Critical); } else { ctlErrorProvider.SetError(control, ""); } } }
private void txbQuantity_Validating(object sender, CancelEventArgs e) { var edit = sender as TextEdit; try { int quatity = int.Parse(txbQuantity.Text); if (quatity <= 0) { throw new Exception(""); } errorProvider.SetError(edit, ""); } catch (Exception ex) { errorProvider.SetError(edit, "Please type the correct quantity (number only)", ErrorType.Critical); e.Cancel = true; } }
private void txbPassword_Validating(object sender, CancelEventArgs e) { var edit = sender as TextEdit; var hasNumber = new Regex(@"[0-9]+"); var hasUpperChar = new Regex(@"[A-Z]+"); var hasMinimum8Chars = new Regex(@".{8,}"); var input = textEdit2.Text; if (hasNumber.IsMatch(input) && hasUpperChar.IsMatch(input) && hasMinimum8Chars.IsMatch(input)) { errorProvider.SetError(edit, ""); } else { errorProvider.SetError(edit, "A good password is:\n> >=8 characters.\n> At least one upper case alphabet character\n> At least one numberic character", ErrorType.Critical); e.Cancel = true; } }
public static void Event_ErrorProvider(DXErrorProvider dxErrorProvider, Control x, bool isCheck, string errorText, bool CheckTrung = false, string errorTrung = "") { if (!isCheck || string.IsNullOrEmpty(x.Text) || CheckTrung) { x.Focus(); dxErrorProvider.SetIconAlignment(x, ErrorIconAlignment.BottomRight); if (CheckTrung) { dxErrorProvider.SetError(x, errorTrung); } else { dxErrorProvider.SetError(x, errorText); } } else { dxErrorProvider.SetError(x, null); } }
private void TxtMail_OnValueChanged(object sender, EventArgs e) { BunifuMaterialTextbox mail = (BunifuMaterialTextbox)sender; if (isEmail(mail.Text.ToString().Trim())) { dxErrorProvider1.ClearErrors(); } else { dxErrorProvider1.SetError(mail, "Email không hợp lệ!"); } }
public static bool ValidationTextEditNullValueWidthErrorProvider(DXErrorProvider errorProvider, TextEdit textEdit, string errorMessage) { if (string.IsNullOrEmpty(textEdit.Text)) { textEdit.Properties.Appearance.BorderColor = Color.DarkRed; textEdit.Focus(); errorProvider.SetError(textEdit, errorMessage); return(false); } return(true); }
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 BtnLuu_Click(object sender, EventArgs e) { if (txtTen.Text == "") { error.SetError(txtTen, "Vui lòng điền thông tin !"); } else { error.SetError(txtTen, string.Empty); } if (txtMa.Text == "") { error.SetError(txtMa, "Vui lòng điền thông tin !"); } else if (add == true && BUS_TienTe.KiemTraTienTe(txtMa.Text)) { error.SetError(txtMa, "Mã đã tồn tại, vui lòng chọn mã khác !"); } else { error.SetError(txtMa, string.Empty); } if (error.GetError(txtMa) == "" && error.GetError(txtTen) == "") { if (add == true) { xlThem(); } else { xlSua(); } } }
/// <summary> /// Not good reset default /// </summary> /// <param name="textEdit"></param> /// <param name="errorMessage"></param> /// <returns></returns> public static bool ValidationTextEditNullValueWidthErrorProvider(TextEdit textEdit, string errorMessage) { if (string.IsNullOrEmpty(textEdit.Text)) { DXErrorProvider dxErrorProvider = new DXErrorProvider(); textEdit.Properties.Appearance.BorderColor = Color.Red; textEdit.Focus(); dxErrorProvider.SetError(textEdit, errorMessage); return false; } return true; }
/// <summary> /// 检验输入控件是否没有输入,为空则显示错误图标 /// </summary> /// <param name="baseEdit">输入控件</param> /// <param name="dxErrorProvider"></param> /// <returns></returns> public static string ValidateEditNullError(this BaseEdit baseEdit, DXErrorProvider dxErrorProvider) { string editValue = string.Concat(baseEdit.EditValue).Trim(); if (string.IsNullOrEmpty(editValue)) { //多语言支持 string errorText = "请输入值"; errorText = JsonLanguage.Default.GetString(errorText); dxErrorProvider.SetError(baseEdit, errorText); baseEdit.Focus(); baseEdit.SelectAll(); } return(editValue); }
private void SetValidControls(Control control, DXErrorProvider errCtl) { if (control is TextEdit || control is ButtonEdit || control is ImageComboBoxEdit || control is LookUpEdit) { errCtl.SetError(control, string.Empty); } foreach (Control c in control.Controls) { // get any nested controls SetValidControls(c, errCtl); } }
/// <summary> /// Hàm xử lý việc sửa thông tin /// </summary> private void xlSua() { if (txtTen.Text == "") { error.SetError(txtTen, "Vui lòng điền thông tin !"); } else { error.SetError(txtTen, string.Empty); } if (error.GetError(txtTen) == string.Empty) { switch (flag) { case 0: { SuaKV(); break; } case 1: { SuaDV(); break; } case 2: { SuaNH(); break; } case 3: { SuaBP(); break; } } ; } }
public void SetError(DXErrorProvider errorProvider, string errorMsg) { errorProvider.SetError(this.Ngay, errorMsg); }
/// <summary> Hiển thị thông tin lỗi trên các control /// True: nếu không có bất cứ lỗi nào /// False: nếu có bất cứ lỗi nào /// Chú ý: Sẽ gặp vấn đè khi nâng cấp DEVEXPRESS HAS NEW CONTROL /// </summary> public static bool ShowRequiredError(DXErrorProvider Error, object[] DataNErrorMsg) { bool flag = true; if (DataNErrorMsg == null) return true; for (int i = 0; i < DataNErrorMsg.Length; i = i + 2) { string ErrorMsg = ErrorMsgLib.errorRequired(DataNErrorMsg[i + 1].ToString()); string CtrlName = DataNErrorMsg[i].GetType().FullName; if (CtrlName == typeof(PLCombobox).FullName || CtrlName == typeof(PLComboboxAdd).FullName || CtrlName == typeof(PLDMTreeGroup).FullName || CtrlName == typeof(PLDMTreeGroupElement).FullName) #region Kiểu ID { IIDValidation ctrl = (IIDValidation)DataNErrorMsg[i]; if (HelpIsCheck.isBlankID("" + ctrl._getSelectedID())) { ctrl.SetError(Error, ErrorMsg); flag = false; } } #endregion #region Kiểu DataSet else if (CtrlName == typeof(DataSet).FullName) //PHUOCNC : Thông báo lỗi trên Grid ở góc như Refresh của Hùng { DataSet temp = DataNErrorMsg[i] as DataSet; if (HelpIsCheck.IsBlankDataSet(temp)) { PLMessageBox.ShowErrorMessage(ErrorMsg); flag = false; } } #endregion #region GridControl else if (CtrlName == typeof(GridControl).FullName) { GridControl temp = DataNErrorMsg[i] as GridControl; DataSet tmpDS = ((DataTable)temp.DataSource).DataSet; if (HelpIsCheck.IsBlankDataSet(tmpDS)) { try { GridValidation.ShowGridError(temp, ErrorMsg); } catch { PLMessageBox.ShowErrorMessage(ErrorMsg); } flag = false; } else { try { GridValidation.ClearGridError(temp); } catch { } } } #endregion #region Kiểu CalcEdit else if (CtrlName == typeof(CalcEdit).FullName || CtrlName == typeof(PLCalcEdit).FullName) //Kiểu số { CalcEdit temp = DataNErrorMsg[i] as CalcEdit; if (HelpIsCheck.isBlankString(temp.Text)) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion #region Kiểu SpinEdit else if (CtrlName == typeof(SpinEdit).FullName || CtrlName == typeof(PLSpinEdit).FullName) //Kiểu số { SpinEdit temp = DataNErrorMsg[i] as SpinEdit; if (HelpIsCheck.isBlankString(temp.Text)) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion #region Kiểu DateEdit else if (CtrlName == typeof(DateEdit).FullName) //Kiểu ngày { DateEdit temp = (DateEdit)DataNErrorMsg[i]; if (HelpIsCheck.isBlankDate(temp.DateTime)) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion #region PLDateTime else if (CtrlName == typeof(PLDateTime).FullName) { PLDateTime temp = (PLDateTime)DataNErrorMsg[i]; if (temp._getDate() == null || temp._getTime() == null) { temp.SetError(Error, ErrorMsg); flag = false; } } #endregion #region PLLookupEdit else if (CtrlName == typeof(PLLookupEdit).FullName) { PLLookupEdit temp = (PLLookupEdit)DataNErrorMsg[i]; if (temp._getSelectedID() == -1) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion #region Kiểu Text & Memo else if (CtrlName == typeof(TextEdit).FullName || CtrlName == typeof(MemoEdit).FullName) //Kiểu chuỗi { TextEdit temp = (TextEdit)DataNErrorMsg[i]; if (HelpIsCheck.isBlankString(temp.Text)) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion #region PLDMGrid else if (CtrlName == typeof(PLDMGrid).FullName) { PLDMGrid temp = (PLDMGrid)DataNErrorMsg[i]; if (temp._getSelectedID() == -1) { temp.SetError(Error, ErrorMsg); flag = false; } } #endregion #region PLMoneyType else if (CtrlName == typeof(PLMoneyType).FullName) { PLMoneyType temp = (PLMoneyType)DataNErrorMsg[i]; if (temp._getSelectedTienTeID() == -1) { temp.SetError(Error, ErrorMsg); flag = false; } } #endregion #region PLEditor else if (CtrlName == typeof(PLEditor).FullName) { PLEditor temp = (PLEditor)DataNErrorMsg[i]; if (HelpIsCheck.isBlankString(temp._getHTMLText())) { Error.SetError(temp, ErrorMsg); flag = false; } } #endregion else { PLMessageBoxDev.ShowMessage("Chưa hỗ trợ kiểm tra Required trên control " + CtrlName); } } return flag; }
public void SetError(DXErrorProvider errorProvider, string errorMsg) { errorProvider.SetError(comboBoxEdit1, errorMsg); }
/// <summary> /// Gán validation cho control /// </summary> /// <param name="error"></param> /// <param name="errorText"></param> public void SetError(DXErrorProvider error, string errorText) { error.SetError(this._buttonEdit, errorText); }