Verifica Rut C# Programacion .net
Bueno aka dejo la funcion de verificar el rut en sichar jajajajja, se que eres una mierda y no lo programarías ni cagando asi que aki un regalo....
private bool verificaRut(int rut, string dv)
{
int Digito;
int Contador;
int Multiplo;
int Acumulador;
string RutDigito;
Contador = 2;
Acumulador = 0;
while (rut != 0)
{
Multiplo = (rut % 10) * Contador;
Acumulador = Acumulador + Multiplo;
rut = rut/10;
Contador = Contador + 1;
if (Contador == 8)
{
Contador = 2;
}
}
Verifica Rut C# Programacion .net
Digito = 11 - (Acumulador % 11);
RutDigito = Digito.ToString().Trim();
if (Digito == 10)
{
RutDigito = "K";
}
if (Digito == 11)
{
RutDigito = "0";
}
Verifica Rut C# Programacion .net
if(RutDigito.ToString() == dv.ToString())
{
return true;
}else{
return false;
}
}
Verifica Rut C# Programacion .net
se agradece esta rutina de mierda, mierda porque es un pajazo programarla, asi que gracias al que se la dió saludos.
ResponderEliminarYo uso esta
ResponderEliminarpublic bool validarRut(string rut)
{
bool validacion = false;
try
{
rut = rut.ToUpper();
rut = rut.Replace(".", "");
rut = rut.Replace("-", "");
int rutAux = int.Parse(rut.Substring(0, rut.Length - 1));
char dv = char.Parse(rut.Substring(rut.Length - 1, 1));
int m = 0, s = 1;
for (; rutAux != 0; rutAux /= 10)
{
s = (s + rutAux % 10 * (9 - m++ % 6)) % 11;
}
if (dv == (char)(s != 0 ? s + 47 : 75))
{
validacion = true;
}
}
catch (Exception)
{
}
return validacion;
}
gracias puto
ResponderEliminarEsta función va dentro del onclick del botón o afuera y después se llama ?
ResponderEliminaryo la ocupo al momento de grabar los datos si esta ok grabo, tambien puedes activarla cuando quieras en un onblur o onchange ahi tu decides.
EliminarEste comentario ha sido eliminado por el autor.
ResponderEliminarUna mierda de post jaja
ResponderEliminarEste comentario ha sido eliminado por el autor.
ResponderEliminarsaco wea
ResponderEliminar166371180-2 no valida este rut siendo que no es valido
ResponderEliminar