//Validaciones PARA EL DNI void numText_Validating(Control Objeto, ErrorProvider ErrorProvider) { NumericTextBox miTxt = (NumericTextBox)Objeto; if (string.IsNullOrEmpty(miTxt.Text)) { miTxt.Select(0, miTxt.Text.Length); ErrorProvider.SetError(Objeto, "Formato no valido para dni"); } }
//VALIDACION PARA CAMPO NUMERIC public static Boolean ValidarNumericTxt(Control Objeto, ErrorProvider ErrorProvider) { Boolean sinError = true; NumericTextBox Obj = (NumericTextBox)Objeto; if (Obj.Validar == true) { if (string.IsNullOrEmpty(Obj.Text.Trim())) { ErrorProvider.SetError(Obj, "Este campo es obligatorio"); sinError = false; } else { ErrorProvider.SetError(Obj, ""); } } return(sinError); }
//VALIDACION DEL FORMULARIO EN EL PROCESO DE CARGA DE CREDITO public static Boolean ValidarCargaCredito(Control Objeto, ErrorProvider ErrorProvider) { Boolean SinErrores = true; Boolean tarjVenc = true; Boolean tarjNum = true; foreach (Control element in Objeto.Controls) { if (element is GroupBox) { foreach (Control Item in element.Controls) { if (Item is ErrorTxtBox) { ErrorTxtBox Obj = (ErrorTxtBox)Item; if (Obj.Validar == true) { if (string.IsNullOrEmpty(Obj.Text.Trim())) { ErrorProvider.SetError(Obj, "Este campo es obligatorio"); SinErrores = false; } else { ErrorProvider.SetError(Obj, ""); } if (Obj.Name == "dateVenc") { tarjVenc = ValidarTarjetaVencimiento(Obj, ErrorProvider); } } } if (Item is NumericTextBox) { NumericTextBox Obj = (NumericTextBox)Item; SinErrores = ValidarNumericTxt(Obj, ErrorProvider); } if (Item is NumericTextBox && Item.Name == "numTarjeta") { NumericTextBox Obj = (NumericTextBox)Item; tarjNum = ValidarTarjeta(Obj, ErrorProvider); } if (Item is ComboBox) { ComboBox Obj = (ComboBox)Item; if (Obj.SelectedIndex == -1) { ErrorProvider.SetError(Obj, "Este campo es obligatorio"); } else { ErrorProvider.SetError(Obj, ""); } } } } } return(SinErrores && tarjVenc && tarjNum); }
//Validaciones para que se llenen los campos obligatorios. public static Boolean ValidarTextBox(Control Objeto, ErrorProvider ErrorProvider) { Boolean SinErrores = true; Boolean MailValidado = true; Boolean CuitValidado = true; foreach (Control element in Objeto.Controls) { if (element is GroupBox) { foreach (Control Item in element.Controls) { if (Item is ErrorTxtBox) { ErrorTxtBox Obj = (ErrorTxtBox)Item; if (Obj.Validar == true) { if (string.IsNullOrEmpty(Obj.Text.Trim())) { ErrorProvider.SetError(Obj, "Este campo es obligatorio"); SinErrores = false; } else { ErrorProvider.SetError(Obj, ""); } if (Obj.Name == "txtCuit") { CuitValidado = ValidarCuit(Obj, ErrorProvider); } } } if (Item is TxtBoxMail) { TxtBoxMail ObjMail = (TxtBoxMail)Item; MailValidado = ValidarEmail(ObjMail, ErrorProvider); } if (Item is NumericTextBox) { NumericTextBox Obj = (NumericTextBox)Item; if (Obj.Validar == true) { if (string.IsNullOrEmpty(Obj.Text.Trim())) { ErrorProvider.SetError(Obj, "Este campo es obligatorio"); SinErrores = false; } else { ErrorProvider.SetError(Obj, ""); } } } if (Item is ComboBox) { ComboBox cb = (ComboBox)Item; if (cb.SelectedIndex == -1) { ErrorProvider.SetError(Item, "Este campo es obligatorio"); SinErrores = false; } else { ErrorProvider.SetError(cb, ""); } } } } } return(SinErrores && MailValidado && CuitValidado && CuitValidado); }