feat: add intervention details
This commit is contained in:
parent
37e4d063d7
commit
e6484ef53c
@ -1,10 +1,18 @@
|
||||
package com.example.depanntout
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Button
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.depanntout.bdd.CreateBdDepannTout
|
||||
import com.example.depanntout.bdd.DAO
|
||||
import com.example.depanntout.bdd.Intervention
|
||||
import com.example.depanntout.bdd.InterventionDAO
|
||||
|
||||
class ClientDetails : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -18,5 +26,21 @@ class ClientDetails : AppCompatActivity() {
|
||||
}
|
||||
|
||||
val client: Client = Client(intent.getIntExtra("ID", 0), intent.getStringExtra("FIRSTNAME")!!, intent.getStringExtra("LASTNAME")!!, intent.getStringExtra("MAIL")!!, intent.getStringExtra("TEL")!!, intent.getStringExtra("ADRESSE")!!)
|
||||
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.recyclerViewDetails)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
|
||||
val createBdDepannTout: CreateBdDepannTout = CreateBdDepannTout(this)
|
||||
val dao: DAO = DAO(this, createBdDepannTout)
|
||||
val interventionDAO : InterventionDAO = InterventionDAO(dao)
|
||||
val interventions: List<Intervention> = interventionDAO.getInterventionsOfClient(client)
|
||||
|
||||
val adapter = interventionAdapter(interventions, this)
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
val buttonExit = findViewById<Button>(R.id.btnQuitt)
|
||||
buttonExit.setOnClickListener() {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,25 @@ class InterventionDAO(private val dao: DAO) {
|
||||
)
|
||||
}
|
||||
|
||||
fun getInterventionsOfClient(client: Client): List<Intervention> {
|
||||
val interventions: MutableList<Intervention> = arrayListOf<Intervention>()
|
||||
val cursor = dao.db.rawQuery("SELECT * FROM 'interventions' where idClient = " + client.idClient, null)
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
Log.d("DatabaseRow", "Column1: ${cursor.getString(0)}, Column2: ${cursor.getString(1)}")
|
||||
val idIntervention = cursor.getInt(cursor.getColumnIndexOrThrow("idIntervention"))
|
||||
val datetime = cursor.getString(cursor.getColumnIndexOrThrow("datetime"))
|
||||
val observation = cursor.getString(cursor.getColumnIndexOrThrow("observation"))
|
||||
val idClient = cursor.getInt(cursor.getColumnIndexOrThrow("idClient"))
|
||||
|
||||
val client = Intervention(idIntervention, datetime, observation, idClient)
|
||||
interventions.add(client)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
cursor.close()
|
||||
return interventions
|
||||
}
|
||||
|
||||
fun getInterventions(): List<Intervention> {
|
||||
val interventions: MutableList<Intervention> = arrayListOf<Intervention>()
|
||||
val cursor = dao.db.rawQuery("SELECT * FROM 'interventions'", null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user