ajustes de edição e envio dos dados para o post

This commit is contained in:
Reginaldo
2023-04-20 19:37:26 -03:00
parent a2869661b6
commit b2ba044039
7 changed files with 166 additions and 101 deletions

View File

@@ -43,19 +43,19 @@ class MainControllers{
// Retorna a senha criptografada
return senhaCriptogradafa;
}
validaCNS(String cns)async{
validaCNS(String cns,bool editing)async{
//valido provisório 783107557570002
//cns valido def 187455333020009
String response = 'CNS inválido';
String type = cns.substring(0,1);
if(type == '7'|| type =='8' || type == '9'){
response = await validaCNSProv(cns);
response = await validaCNSProv(cns,editing);
}else{
response = validaCNSDef(cns);
response = validaCNSDef(cns,editing);
}
return response;
}
validaCNSProv(String vlrCNS)async{
validaCNSProv(String vlrCNS,bool editing)async{
int resto;
int soma;
if(vlrCNS.length == 15){
@@ -85,7 +85,7 @@ class MainControllers{
if (resto == 0)
{
// CNS provisório válido
List result = await DBQuerys().duplicidadeCNS(vlrCNS);
List result = editing?[]:await DBQuerys().duplicidadeCNS(vlrCNS);
if(result.length==0){
return 'ok';
}else{
@@ -105,7 +105,7 @@ class MainControllers{
}
}
}
validaCNSDef(String vlrCNS){
validaCNSDef(String vlrCNS,bool editing){
int soma = 0;
int resto = 0;
int dv = 0;
@@ -153,7 +153,7 @@ class MainControllers{
return 'CNS definitivo inválido';
} else {
// CNS válido
String result = DBQuerys().duplicidadeCNS(vlrCNS);
String result = editing?[]: DBQuerys().duplicidadeCNS(vlrCNS);
if(result==''){
return 'ok';
}else{
@@ -168,15 +168,19 @@ class MainControllers{
}
}
}
validaCPF(String cpf)async{
validaCPF(String cpf,bool editing)async{
// 60352523620 CPF VÁLIDO
if(GetUtils.isCpf(cpf)){
List result = await DBQuerys().duplicidadeCPF(cpf);
print(cpf);
if(result.length==0){
if(editing){
return 'ok';
}else{
return 'CPF duplicado';
List result = await DBQuerys().duplicidadeCPF(cpf);
// print(cpf);
if(result.length==0){
return 'ok';
}else{
return 'CPF duplicado';
}
}
}else{
return 'CPF inválido';