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