← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 182: validate due date of lost to follow up events

 

------------------------------------------------------------
revno: 182
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Tue 2013-11-05 15:37:00 +0700
message:
  validate due date of lost to follow up events
modified:
  src/org/hisp/dhis/mobile/view/LostToFollowUpDetailView.java


--
lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking
https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking

Your team DHIS mobile developers is subscribed to branch lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking/+edit-subscription
=== modified file 'src/org/hisp/dhis/mobile/view/LostToFollowUpDetailView.java'
--- src/org/hisp/dhis/mobile/view/LostToFollowUpDetailView.java	2013-10-10 04:37:14 +0000
+++ src/org/hisp/dhis/mobile/view/LostToFollowUpDetailView.java	2013-11-05 08:37:00 +0000
@@ -66,6 +66,8 @@
     
     private Label lblWrongDOB;
     
+    private boolean isValid;
+    
     public LostToFollowUpDetailView( DHISMIDlet dhisMIDlet )
     {
         super( dhisMIDlet );
@@ -76,24 +78,19 @@
     {
         if( ae.getCommand().getCommandName().equals( Text.SEND() ) )
         {
-            String dateOfBirth = txtDueDate.getText();
-
-            boolean isViolatedDOB = false;
-
-            if ( !PeriodUtil.isDateValid( dateOfBirth ) )
-            {
-                isViolatedDOB = true;
-            }
-            if ( dateOfBirth.equals( "" ) || isViolatedDOB == true )
-            {
-                getLblWrongDOB().setText( "Required Fields" );
+            String dueDate = txtDueDate.getText();
+
+            validateDueDate( dueDate );
+            
+            if ( isValid == false )
+            {
                 mainForm.show();
             }
             else
             {
-                lostEvent.setDueDate( dateOfBirth );
+                lostEvent.setDueDate( dueDate );
                 
-                // why +4? Check class ProgramStageInstance for more clearer explanation
+                // why +4? Check class ProgramStageInstance for clearer explanation
                 lostEvent.setStatus( cbxStatus.getSelectedIndex()+4 );
                 lostEvent.setRiskCase( false );
                 lostEvent.setComment( txtComment.getText() );
@@ -117,6 +114,15 @@
         else
         {
             nameBasedMIDlet.getLostToFollowUpView().getMainForm().show();
+            backCommand = null;
+            sendCommand = null;
+            lostEvent = null;
+            txtDueDate = null; 
+            txtComment = null;
+            txtSMS = null;
+            cbxStatus = null;
+            lblWrongDOB = null;
+            mainForm = null;
         }
     }
 
@@ -155,6 +161,25 @@
         prepareView();
         mainForm.show();
     }
+    
+    public void validateDueDate( String dueDate )
+    {
+        if ( dueDate.trim().equals( "" ) )
+        {
+            getLblWrongDOB().setText( "(*):Required Field" );
+            isValid = false;
+        }
+        else if ( !PeriodUtil.isDateValid( dueDate ) )
+        {
+            getLblWrongDOB().setText( "YYYY-MM-dd" );
+            isValid = false;
+        }
+        else
+        {
+            isValid = true;
+            getLblWrongDOB().setText( "" );
+        }
+    }
 
     public Form getMainForm()
     {