diff --git a/app/src/main/java/com/example/firstintent/DatabaseHelper.java b/app/src/main/java/com/example/firstintent/DatabaseHelper.java index b63f1418c72ee4783f62d6abaa9bf7c846743e84..58c86be63068edbd7b8c4e839296386bb2689d11 100644 --- a/app/src/main/java/com/example/firstintent/DatabaseHelper.java +++ b/app/src/main/java/com/example/firstintent/DatabaseHelper.java @@ -182,6 +182,22 @@ public class DatabaseHelper extends SQLiteOpenHelper { } + public boolean updateData(Akte akte){ + + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues cv = new ContentValues(); + + cv.put(COLUMN_ID,akte.getId()); + cv.put(COLUMN_PATIENT_NAME, akte.get_Patientname()); + cv.put(COLUMN_VERSICHERUNGS_NUMMER, akte.get_VersicherungsNummer()); + cv.put(COLUMN_ZIMMER_NUMMER, akte.get_ZimmerNummer()); + cv.put(COLUMN_ACTIVE_PATIENT, akte.isActive()); + + db.update(PATIENT_TABLE,cv,"ID = ?", new String[]{String.valueOf(akte.getId())}); + + return true; + } + diff --git a/app/src/main/java/com/example/firstintent/PatientenVerlegen.java b/app/src/main/java/com/example/firstintent/PatientenVerlegen.java index 311ea273e3f069d5f6b3ecce325295e53521a762..8036170af58fce085aa1eb5c976ff6765bb0c098 100644 --- a/app/src/main/java/com/example/firstintent/PatientenVerlegen.java +++ b/app/src/main/java/com/example/firstintent/PatientenVerlegen.java @@ -4,22 +4,87 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; +import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; +import android.widget.Switch; +import android.widget.Toast; public class PatientenVerlegen extends AppCompatActivity { + + EditText ppname,vvname,rrname,id; + Button vvbutton,ubutton; + Switch swPatient1; + ListView listings4; + + + + ArrayAdapter patientArrayAdapter; + DatabaseHelper databaseHelper; + Akte akte; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_patienten_verlegen); - Button twentiethButton= (Button) findViewById(R.id.button20); + ppname=findViewById(R.id.editTextTextPersonName13); + vvname=findViewById(R.id.editTextTextPersonName14); + rrname=findViewById(R.id.editTextTextPersonName15); + id=findViewById(R.id.editTextTextPersonName16); - twentiethButton.setOnClickListener(new View.OnClickListener() { + swPatient1=findViewById(R.id.switch2); + listings4=findViewById(R.id.list4); + vvbutton=findViewById(R.id.button2); + ubutton=findViewById(R.id.button15); + + + + ubutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - finish(); + try { + databaseHelper= new DatabaseHelper(PatientenVerlegen.this); + akte = new Akte( Integer.parseInt(id.getText().toString()), Integer.parseInt(vvname.getText().toString()), ppname.getText().toString(), Integer.parseInt(rrname.getText().toString()), swPatient1.isChecked()); + boolean isUpdate= databaseHelper.updateData(akte); + if(isUpdate==true){ + + Toast.makeText(PatientenVerlegen.this,"succesfully updated information", Toast.LENGTH_SHORT).show(); + } + else{ + Toast.makeText(PatientenVerlegen.this,"data not updated", Toast.LENGTH_SHORT).show(); + + } + + + } + catch (Exception e){ + + Toast.makeText(PatientenVerlegen.this,"Error updating data ", Toast.LENGTH_SHORT).show(); + } + } }); + + + vvbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + try { + databaseHelper= new DatabaseHelper(PatientenVerlegen.this); + patientArrayAdapter= new ArrayAdapter<Akte>(PatientenVerlegen.this, android.R.layout.simple_list_item_1,databaseHelper.getEveryone()); + listings4.setAdapter(patientArrayAdapter); + } + catch(Exception e ){ + + Toast.makeText(PatientenVerlegen.this,"This is the message from the patient verlegen", Toast.LENGTH_SHORT).show(); + } + } + }); + + } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/activity_patienten_verlegen.xml b/app/src/main/res/layout/activity_patienten_verlegen.xml index 79bbb0bec4607a6fa2df34544c5c2a8c54850bf3..391240e1f0013b24881b55031f7294a9e205c858 100644 --- a/app/src/main/res/layout/activity_patienten_verlegen.xml +++ b/app/src/main/res/layout/activity_patienten_verlegen.xml @@ -6,13 +6,108 @@ android:layout_height="match_parent" tools:context=".PatientenVerlegen"> + <EditText + android:id="@+id/editTextTextPersonName13" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:ems="10" + android:hint="PatientName" + android:inputType="textPersonName" + android:minHeight="48dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <EditText + android:id="@+id/editTextTextPersonName14" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:ems="10" + android:hint="VersicherungsNummer" + android:inputType="textPersonName" + android:minHeight="48dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName13" /> + + <EditText + android:id="@+id/editTextTextPersonName15" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:ems="10" + android:hint="ZimmerNummer" + android:inputType="textPersonName" + android:minHeight="48dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName14" /> + + <EditText + android:id="@+id/editTextTextPersonName16" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:ems="10" + android:hint="ID" + android:inputType="textPersonName" + android:minHeight="48dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName15" /> + + <Switch + android:id="@+id/switch2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:minHeight="48dp" + android:text="Switch" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName16" /> + <Button - android:id="@+id/button20" + android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="142dp" - android:layout_marginTop="304dp" - android:text="close" + android:layout_marginTop="16dp" + android:text="viewall" + app:layout_constraintEnd_toStartOf="@+id/button15" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/switch2" /> + + <Button + android:id="@+id/button15" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + android:text="update " + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@+id/switch2" + app:layout_constraintStart_toEndOf="@id/button2"/> + + <ListView + android:id="@+id/list4" + android:layout_width="409dp" + android:layout_height="418dp" + android:layout_marginStart="8dp" + android:layout_marginTop="128dp" + android:layout_marginEnd="8dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/button2" + app:layout_constraintVertical_bias="0.536" /> + </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file