コード例 #1
0
 private void btnConfirmar_Click(object sender, EventArgs e)
 {
     cidade.Nome = textBoxNome.Text;
     cidade.Uf   = comboBoxUf.Text;
     if (controlActions.Status != ControlActions.STAND_BY)
     {
         if (Validator.validaCampos(new Object[] { textBoxNome, comboBoxUf }))
         {
             bool sucess = false;
             if (controlActions.Status == ControlActions.INSERIR)
             {
                 sucess = dao.inserir(cidade);
                 if (sucess)
                 {
                     setFieldsEnable(false);
                     getDadosTable();
                     controlActions.setButtonsEnable(true);
                     reset();
                     controlActions.Status = ControlActions.STAND_BY;
                 }
             }
             else if (controlActions.Status == ControlActions.EDITAR)
             {
                 sucess = dao.editar(cidade);
                 if (sucess)
                 {
                     setFieldsEnable(false);
                     getDadosTable();
                     controlActions.setButtonsEnable(true);
                     reset();
                     controlActions.Status = ControlActions.STAND_BY;
                 }
             }
             else
             {
                 controlActions.Status = ControlActions.STAND_BY;
             }
             if (isSubCadastro && sucess)
             {
                 this.Close();
             }
         }
     }
 }