ajustes no cadastro cidadão

This commit is contained in:
Reginaldo
2023-04-14 12:32:22 -03:00
parent 4a135901d4
commit 3b83349259

View File

@@ -103,6 +103,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
bool enableBlocked = false; bool enableBlocked = false;
bool checkBoxNumber = false; bool checkBoxNumber = false;
String date = 'Data de Nascimento'; String date = 'Data de Nascimento';
String dateDB = '';
List cityDB = []; List cityDB = [];
List ibgeDB = []; List ibgeDB = [];
List<String> streetDB = []; List<String> streetDB = [];
@@ -116,6 +117,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
String idTipo=''; String idTipo='';
bool showCheckError = false; bool showCheckError = false;
bool showTab = false; bool showTab = false;
String errorTopo = 'Existem campos obrigatórios não preenchidos.';
escolherprazoInicio(BuildContext context,String type) async { escolherprazoInicio(BuildContext context,String type) async {
var pickDate = await showDatePicker( var pickDate = await showDatePicker(
@@ -126,6 +128,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
if (pickDate != null) { if (pickDate != null) {
setState(() { setState(() {
if(type == 'birth'){ if(type == 'birth'){
dateDB = '${pickDate.year}-${pickDate.month<10?'0':''}${pickDate.month}-${pickDate.day<10?'0':''}${pickDate.day}';
date = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day); date = formatData(year: pickDate.year, month: pickDate.month, day: pickDate.day);
} }
if(type == 'rg'){ if(type == 'rg'){
@@ -295,32 +298,33 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
selectDeficiency==null || selectDeficiency==null ||
selectClassification==null || selectClassification==null ||
selectCountry==null || selectCountry==null ||
selectVillage==null ||
selectStreet==null ||
date == 'Data de Nascimento'|| date == 'Data de Nascimento'||
cityBirthController.text.isEmpty || cityBirthController.text.isEmpty ||
messageDDDController.text.isEmpty || messageDDDController.text.isEmpty ||
messageController.text.isEmpty || messageController.text.isEmpty ||
checkMother || checkMother ||
checkFather || checkFather ||
checkClassification checkClassification||
(selectMaritalStatus == 'CASADO(A)' && spouseController.text.isEmpty)
){ ){
print('erro');
setState(() { setState(() {
showCheckError = true; showCheckError = true;
}); });
}else{ }else{
showCheckError = false; print('passou');
saveCitizen(); saveCitizen();
} }
} }
saveCitizen()async{ saveCitizen()async{
Map<String, dynamic> row = { Map<String, dynamic> row = {
'CD_USUARIO_SUS' : '0', 'CD_USUARIO_SUS' : '0',
'NOME_CIDADAO' : nameController.text, 'NOME_CIDADAO' : nameController.text,
'NOME_SOCIAL' : nameSocialController.text, 'NOME_SOCIAL' : nameSocialController.text,
'SEXO' : selectGender, 'SEXO' : selectGender,
'DT_NASCIMENTO' : date, 'DT_NASCIMENTO' : dateDB,
'ID_ESTADO_CIVIL' : '', 'ID_ESTADO_CIVIL' : '',
'ID_ESTADO_CIVIL' : '', 'ID_ESTADO_CIVIL' : '',
'NOME_CONJUGE' : spouseController.text, 'NOME_CONJUGE' : spouseController.text,
@@ -362,7 +366,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
'EMAIL' : emailController.text, 'EMAIL' : emailController.text,
'OBSERVACOES' : observationController.text, 'OBSERVACOES' : observationController.text,
'CPF' : CPFController.text, 'CPF' : CPFController.text,
'CNS' : CNSController.text, 'CNS' : checkCNS == 'ok'&& CNSController.text.isNotEmpty?CNSController.text:'999999999999999',
'TITULO_ELEITOR' : voterController.text, 'TITULO_ELEITOR' : voterController.text,
'RG_NUMERO' : RGController.text, 'RG_NUMERO' : RGController.text,
'RG_COMPLEMENTO' : RGComplementController.text, 'RG_COMPLEMENTO' : RGComplementController.text,
@@ -396,7 +400,27 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
'SINCRONIZADO' : '', 'SINCRONIZADO' : '',
}; };
await DbSqliteSync().insertCidadaos(row,'update').then((value){ await DbSqliteSync().insertCidadaos(row,'update').then((value){
print('novo usuário foi salvo'); if(checkCNS != 'ok' || CNSController.text.isEmpty){
AlertDialogDefault().alert(
context,
'Aviso',
'CNS Inválido!',
'OK'
);
setState(() {
errorTopo = 'O usuário foi cadastrado sem um CNS válido!';
});
}else{
setState(() {
showCheckError = false;
});
}
AlertDialogDefault().alert(
context,
'Aviso',
'Cidadão cadastrado com sucesso!',
'OK'
);
setState(() { setState(() {
showTab = true; showTab = true;
}); });
@@ -443,7 +467,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
child: Row( child: Row(
children: [ children: [
Icon(Icons.warning,color: Colors.red,), Icon(Icons.warning,color: Colors.red,),
TextDefault(text: 'Existem campos obrigatórios não preenchidos.',color: ColorPalette.red,fontSize: 15,) TextDefault(text: errorTopo,color: ColorPalette.red,fontSize: 15,)
], ],
), ),
), ),