Ajuste na validadão de dados do cidadão antes de salvar no banco de dados
This commit is contained in:
@@ -115,6 +115,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
String idBairro='';
|
||||
String idTipo='';
|
||||
bool showCheckError = false;
|
||||
bool showTab = false;
|
||||
|
||||
escolherprazoInicio(BuildContext context,String type) async {
|
||||
var pickDate = await showDatePicker(
|
||||
@@ -155,11 +156,12 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
unitController.text = listControl[0]['NOME_UNIDADE'];
|
||||
});
|
||||
}
|
||||
|
||||
changedCity()async{
|
||||
Database db = await DbSqliteLoad().intialDB();
|
||||
var queryCity = "SELECT * FROM ARGS";
|
||||
List listCity = await db.rawQuery(queryCity);
|
||||
print(listCity);
|
||||
// print(listCity);
|
||||
setState(() {
|
||||
cityController.text = '${listCity[0]['NAME_CITY_FRONT']} - ${listCity[0]['COD_STATE']}'.toUpperCase();
|
||||
codIBGEController.text = listCity[0]['COD_IBGE'].toString();
|
||||
@@ -197,7 +199,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
for(int i=0; list.length > i;i++){
|
||||
streetDB.add('${list[i]['DESC_LOGR_ENDERECO']}');
|
||||
}
|
||||
print(streetDB);
|
||||
// print(streetDB);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -208,16 +210,18 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
for(int i=0; list.length > i;i++){
|
||||
subdivisionDB.add('${list[i]['DESC_LOGR_LOTEAMENTO']}');
|
||||
}
|
||||
print(list);
|
||||
// print(list);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_searchCity(){
|
||||
searchCity('city');
|
||||
}
|
||||
|
||||
_searchCityBirth(){
|
||||
searchCity('birth');
|
||||
}
|
||||
|
||||
getCity()async{
|
||||
Database db = await DbSqliteLoad().intialDB();
|
||||
var query = "SELECT * FROM MUNICIPIOS ORDER BY NO_MUNICIPIO";
|
||||
@@ -260,7 +264,47 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
}
|
||||
|
||||
checkSave(){
|
||||
if(nameController.text.isEmpty){
|
||||
bool checkMother = false;
|
||||
bool checkFather = false;
|
||||
bool checkClassification = false;
|
||||
if(!enableMother && nameMotherController.text.isEmpty){
|
||||
checkMother = true;
|
||||
print('colocar nome mãe');
|
||||
}
|
||||
if(!enableFather && nameFatherController.text.isEmpty){
|
||||
checkFather = true;
|
||||
print('colocar nome pai');
|
||||
}
|
||||
if((selectClassification!='OUTRO MUNICIPIO' && selectCountry == 'BRASIL' && selectStreet == null) ||
|
||||
(selectStreet!=null && (cepController.text.isEmpty || cepController.text.length!=8)) ||
|
||||
(selectStreet!=null && numberController.text.isEmpty) ||
|
||||
(selectTypeStreet == null && selectClassification!='OUTRO MUNICIPIO') ||
|
||||
(selectVillage == null && (selectCountry == 'BRASIL' && selectClassification!='OUTRO MUNICIPIO')) ||
|
||||
(cityController.text.isEmpty && selectCountry!='OUTRO') ||
|
||||
selectCountry == null
|
||||
){
|
||||
checkClassification = true;
|
||||
print('erro no end');
|
||||
}
|
||||
|
||||
//ok
|
||||
if(nameController.text.isEmpty ||
|
||||
selectGender==null ||
|
||||
selectNaturality==null ||
|
||||
selectBreed==null ||
|
||||
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
|
||||
){
|
||||
setState(() {
|
||||
showCheckError = true;
|
||||
});
|
||||
@@ -352,8 +396,11 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
'SINCRONIZADO' : '',
|
||||
};
|
||||
await DbSqliteSync().insertCidadaos(row,'update').then((value){
|
||||
print('sucesso');
|
||||
print(value);
|
||||
print('novo usuário foi salvo');
|
||||
setState(() {
|
||||
showTab = true;
|
||||
});
|
||||
// print(value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -388,7 +435,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
decoration: ConstVariable().backgroundGradient,
|
||||
child: ListView(
|
||||
children: [
|
||||
SubtitleAppbarCitizen(title: 1,edit: true),
|
||||
SubtitleAppbarCitizen(title: 1,edit: showTab),
|
||||
showCheckError?Card(
|
||||
margin: EdgeInsets.all(10),
|
||||
child: Container(
|
||||
@@ -462,6 +509,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
widthInput: width*0.7,
|
||||
widthSubtitle: width*0.7,
|
||||
hintInput: 'Escreva aqui',
|
||||
mandatory: false,
|
||||
onChanged: (v)=>setState((){}),
|
||||
),
|
||||
DropdownWithSubtitle(
|
||||
@@ -954,7 +1002,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
setState(() {
|
||||
cityController.text = showResultSearchCity[index];
|
||||
codIBGEController.text = showResultSearchIbge[index];
|
||||
print("IBGE ${showResultSearchIbge[index]}");
|
||||
// print("IBGE ${showResultSearchIbge[index]}");
|
||||
Navigator.pop(context);
|
||||
});
|
||||
},
|
||||
@@ -1040,7 +1088,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
},
|
||||
list: typeStreetDB
|
||||
),
|
||||
selectTypeStreet!='OUTRO MUNICIPIO' && selectTypeStreet == null?ErrorDefault():Container(),
|
||||
selectTypeStreet!='OUTRO MUNICIPIO' && selectTypeStreet == null && selectCountry == null?ErrorDefault():Container(),
|
||||
DropdownWithSubtitle(
|
||||
subtitle: 'Nome do Logradouro',
|
||||
select: selectStreet,
|
||||
@@ -1056,9 +1104,10 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
list: streetDB
|
||||
),
|
||||
InputWithSubtitle(
|
||||
typeInput: 'cep',
|
||||
controller: cepController,
|
||||
subtitle: 'CEP(só números)',
|
||||
errorInput: 'Campo Obrigatório',
|
||||
errorInput: selectClassification!='OUTRO MUNICIPIO'&& cepController.text.isEmpty?'Campo Obrigatório':cepController.text.length!=8?'CEP incorreto':'',
|
||||
labelInput: 'CEP(só números)',
|
||||
widthInput: width*0.7,
|
||||
widthSubtitle: width*0.2,
|
||||
@@ -1079,7 +1128,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
|
||||
widthSubtitle: width*0.2,
|
||||
widthError: 0.4,
|
||||
hintInput: 'Escreva aqui',
|
||||
enable: selectClassification!='OUTRO MUNICIPIO'?true:false,
|
||||
enable: selectClassification!='OUTRO MUNICIPIO' && !checkBoxNumber?true:false,
|
||||
onChanged: (v)=>setState((){}),
|
||||
),
|
||||
Checkbox(
|
||||
|
||||
@@ -19,6 +19,7 @@ class InputWithSubtitle extends StatelessWidget {
|
||||
TextInputType textInputType;
|
||||
int maxLines;
|
||||
Color colorBorder;
|
||||
String typeInput;
|
||||
|
||||
InputWithSubtitle({
|
||||
required this.subtitle,
|
||||
@@ -28,6 +29,7 @@ class InputWithSubtitle extends StatelessWidget {
|
||||
required this.widthSubtitle,
|
||||
required this.widthInput,
|
||||
required this.controller,
|
||||
this.typeInput = 'normal',
|
||||
this.enable = true,
|
||||
this.mandatory = true,
|
||||
this.textInputType = TextInputType.text,
|
||||
@@ -63,7 +65,8 @@ class InputWithSubtitle extends StatelessWidget {
|
||||
colorBorder: colorBorder,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
controller.text=='' &&(enable&&mandatory)?ErrorDefault(widthDefault: widthError,):Container(),
|
||||
typeInput=='normal'&& controller.text=='' &&(enable&&mandatory)?ErrorDefault(widthDefault: widthError,error: errorInput,):Container(),
|
||||
typeInput!='normal'&&(enable&&mandatory)&& errorInput!=''?ErrorDefault(widthDefault: widthError,error: errorInput,):Container(),
|
||||
Divider(color: ColorPalette.black54,height: 5,endIndent: 10,)
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user