ajustes no cadastro cidadão
This commit is contained in:
@@ -103,6 +103,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
bool enableBlocked = false;
|
||||
bool checkBoxNumber = false;
|
||||
String date = 'Data de Nascimento';
|
||||
String dateDB = '';
|
||||
List cityDB = [];
|
||||
List ibgeDB = [];
|
||||
List<String> streetDB = [];
|
||||
@@ -116,6 +117,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
String idTipo='';
|
||||
bool showCheckError = false;
|
||||
bool showTab = false;
|
||||
String errorTopo = 'Existem campos obrigatórios não preenchidos.';
|
||||
|
||||
escolherprazoInicio(BuildContext context,String type) async {
|
||||
var pickDate = await showDatePicker(
|
||||
@@ -126,6 +128,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
if (pickDate != null) {
|
||||
setState(() {
|
||||
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);
|
||||
}
|
||||
if(type == 'rg'){
|
||||
@@ -295,32 +298,33 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
selectDeficiency==null ||
|
||||
selectClassification==null ||
|
||||
selectCountry==null ||
|
||||
selectVillage==null ||
|
||||
selectStreet==null ||
|
||||
date == 'Data de Nascimento'||
|
||||
cityBirthController.text.isEmpty ||
|
||||
messageDDDController.text.isEmpty ||
|
||||
messageController.text.isEmpty ||
|
||||
checkMother ||
|
||||
checkFather ||
|
||||
checkClassification
|
||||
checkClassification||
|
||||
(selectMaritalStatus == 'CASADO(A)' && spouseController.text.isEmpty)
|
||||
){
|
||||
print('erro');
|
||||
setState(() {
|
||||
showCheckError = true;
|
||||
});
|
||||
}else{
|
||||
showCheckError = false;
|
||||
print('passou');
|
||||
saveCitizen();
|
||||
}
|
||||
}
|
||||
|
||||
saveCitizen()async{
|
||||
|
||||
Map<String, dynamic> row = {
|
||||
'CD_USUARIO_SUS' : '0',
|
||||
'NOME_CIDADAO' : nameController.text,
|
||||
'NOME_SOCIAL' : nameSocialController.text,
|
||||
'SEXO' : selectGender,
|
||||
'DT_NASCIMENTO' : date,
|
||||
'DT_NASCIMENTO' : dateDB,
|
||||
'ID_ESTADO_CIVIL' : '',
|
||||
'ID_ESTADO_CIVIL' : '',
|
||||
'NOME_CONJUGE' : spouseController.text,
|
||||
@@ -362,7 +366,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
'EMAIL' : emailController.text,
|
||||
'OBSERVACOES' : observationController.text,
|
||||
'CPF' : CPFController.text,
|
||||
'CNS' : CNSController.text,
|
||||
'CNS' : checkCNS == 'ok'&& CNSController.text.isNotEmpty?CNSController.text:'999999999999999',
|
||||
'TITULO_ELEITOR' : voterController.text,
|
||||
'RG_NUMERO' : RGController.text,
|
||||
'RG_COMPLEMENTO' : RGComplementController.text,
|
||||
@@ -396,7 +400,27 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
'SINCRONIZADO' : '',
|
||||
};
|
||||
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(() {
|
||||
showTab = true;
|
||||
});
|
||||
@@ -443,7 +467,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
child: Row(
|
||||
children: [
|
||||
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,)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user