Hello Goodnight,
I send this email since I need if you can post 2 queries that I need to do about xamarin to see if you can help me.
1: I am doing a validation in one of the texts that I need to do a validation I have the code that performs the validation but it is in c #.
The button does the validations in the methods and I have it like this
if (string.IsNullOrEmpty(this.RutTxt))
{
await Application.Current.MainPage.DisplayAlert(
"Error",
"Ingrese el Rut",
"Aceptar");
return;
}
else if (this.RutTxt.Length != 7)
{
await Application.Current.MainPage.DisplayAlert("Advertencia", "Faltan digitos, favor de ingresar el rut debe tener al menos 7 digitos.", "Aceptar");
return;
}
else
{
if (!this.RutTxt.ToCharArray().All(Char.IsDigit))
{
await Application.Current.MainPage.DisplayAlert("Advertencia", "El formato del rut es incorrecto, solo se aceptan numeros.", "Aceptar");
return;
}
}
I already have 3 different validations that validate the data of the rut that are only numbers but I need it to validate the check digit
this is the check digit button:
if (string.IsNullOrEmpty(this.DvTxt))
{
await Application.Current.MainPage.DisplayAlert(
"Error",
"Ingrese el Rut",
"Aceptar");
return;
}
that this is the code in C #
public static string Digito(int rut)
{
int suma = 0;
int multiplicador = 1;
while (rut != 0)
{
multiplicador++;
if (multiplicador == 8)
multiplicador = 2;
suma += (rut % 10) * multiplicador;
rut = rut / 10;
}
suma = 11 - (suma % 11);
if (suma == 11)
{
return "0";
}
else if (suma == 10)
{
return "K";
}
else
{
return suma.ToString();
}
}
And the truth of the things that I do not know how to do the validation properly so that it really validates the information.
2: On the other hand I have 2 Piker and a texbox that I need to activate when I actually enter some information
For example
If I have in the Piker called user type and I have selected a Supplier, the supplier category texbox must be activated and if in the piker I have a worker selected, the other piker that is from the position must be activated.
I thank you in advance and I hope you have an excellent day.
What I have tried:
I have tried so far to try to call the class but it does not work for me and I really do not know how to solve it, if someone knows how to perform this validation I would appreciate it.