Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fcf615279 | |||
98dedab992 | |||
a8b1c28dd1 | |||
baf79378ee |
@ -1,4 +0,0 @@
|
|||||||
package com.example.depanntout;
|
|
||||||
|
|
||||||
public class ModifClient {
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.example.depanntout;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
public class ModifInter extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_modif_inter);
|
|
||||||
|
|
||||||
initialisation();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialisation() {
|
|
||||||
|
|
||||||
// Get data from Intent
|
|
||||||
String date = getIntent().getStringExtra("date");
|
|
||||||
String heure = getIntent().getStringExtra("heure");
|
|
||||||
String observation = getIntent().getStringExtra("observation");
|
|
||||||
int idCli = getIntent().getIntExtra("idCli", -1);
|
|
||||||
|
|
||||||
// Reference TextViews
|
|
||||||
TextView tvDate = findViewById(R.id.ptModifDate);
|
|
||||||
TextView tvHeure = findViewById(R.id.ptModifHeure);
|
|
||||||
TextView tvObservation = findViewById(R.id.ptModifObserv);
|
|
||||||
TextView tvIdCli = findViewById(R.id.ptModifIdClient);
|
|
||||||
|
|
||||||
// Set data in TextViews
|
|
||||||
tvDate.setText(date);
|
|
||||||
tvHeure.setText(heure);
|
|
||||||
tvObservation.setText(observation);
|
|
||||||
tvIdCli.setText(String.valueOf(idCli));
|
|
||||||
|
|
||||||
// gestion du boutton Quitter
|
|
||||||
Button btQuitterInter = (Button) findViewById(R.id.btQuitterInter);
|
|
||||||
// Association d'un écouteur d'événement au clic de btQuitter
|
|
||||||
btQuitterInter.setOnClickListener(new View.OnClickListener() {
|
|
||||||
public void onClick(View arg0) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Button btnDelete = findViewById(R.id.btnDeleteInter);
|
|
||||||
btnDelete.setOnClickListener(v -> supprimer());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void supprimer() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvTitre"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvTitre"
|
|
||||||
android:textColor="#C10101"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btGestClient"
|
|
||||||
android:layout_width="374dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/libBtGestClient"
|
|
||||||
android:textColor="#FFFFFF" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btGestInter"
|
|
||||||
android:layout_width="366dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/libBtGestInter"
|
|
||||||
android:textColor="#FFFFFF" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btQuitter"
|
|
||||||
android:layout_width="356dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/libBtQuitter"
|
|
||||||
android:textColor="#FFFFFF" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,62 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvIdClient"
|
|
||||||
android:layout_width="2dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvIdClient" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvNomClient"
|
|
||||||
android:layout_width="15dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvNomClient" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvDateInter"
|
|
||||||
android:layout_width="25dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvPrenomClient" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvHeureInter"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvNumTelClient" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvObervInter"
|
|
||||||
android:layout_width="95dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvMailClient" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvIdClientInter"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/libTvAdrClient" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
0
Android_DepannTout/.idea/.gitignore → DepannRien/.idea/.gitignore
generated
vendored
@ -6,7 +6,7 @@
|
|||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="jbr-21" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
@ -1,9 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -27,6 +27,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".GestionClient"
|
android:name=".GestionClient"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ModifClient"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
@ -48,4 +48,28 @@ public class ClientDAO {
|
|||||||
Log.d("bdd", "insert, :" + c);
|
Log.d("bdd", "insert, :" + c);
|
||||||
return db.insert(CreateBdDepannTout.TABLE_CLIENT, null, values);
|
return db.insert(CreateBdDepannTout.TABLE_CLIENT, null, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean delete(int id) {
|
||||||
|
int result = db.delete(CreateBdDepannTout.TABLE_CLIENT,
|
||||||
|
"id = ?",
|
||||||
|
new String[]{String.valueOf(id)});
|
||||||
|
db.close();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(int id, String nom, String prenom, int numTel, String adrMail, String adrPostale) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("nom", nom);
|
||||||
|
values.put("prenom", prenom);
|
||||||
|
values.put("numTel", numTel);
|
||||||
|
values.put("adrMail", adrMail);
|
||||||
|
values.put("adrPostale", adrPostale);
|
||||||
|
int result = db.update(CreateBdDepannTout.TABLE_CLIENT,
|
||||||
|
values,
|
||||||
|
"id = ?",
|
||||||
|
new String[]{String.valueOf(id)});
|
||||||
|
db.close();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -48,5 +48,26 @@ public class InterventionDAO {
|
|||||||
return db.insert(CreateBdDepannTout.TABLE_INTER, null, values);
|
return db.insert(CreateBdDepannTout.TABLE_INTER, null, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean delete(int id) {
|
||||||
|
int result = db.delete(CreateBdDepannTout.TABLE_INTER,
|
||||||
|
"id = ?",
|
||||||
|
new String[]{String.valueOf(id)});
|
||||||
|
db.close();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(int id, String date, String heure, String observation, int idCli) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("date", date);
|
||||||
|
values.put("heure", heure);
|
||||||
|
values.put("observation", observation);
|
||||||
|
values.put("idCli", idCli);
|
||||||
|
int result = db.update(CreateBdDepannTout.TABLE_INTER,
|
||||||
|
values,
|
||||||
|
"id = ?",
|
||||||
|
new String[]{String.valueOf(id)});
|
||||||
|
db.close();
|
||||||
|
return result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -59,7 +59,7 @@ public class CreateClient extends AppCompatActivity {
|
|||||||
etAdrMail = (EditText) findViewById(R.id.ptSaisirMailClient);
|
etAdrMail = (EditText) findViewById(R.id.ptSaisirMailClient);
|
||||||
etAdrPostale = (EditText) findViewById(R.id.ptSaisirAdrClient);
|
etAdrPostale = (EditText) findViewById(R.id.ptSaisirAdrClient);
|
||||||
btCreateClient = (Button) findViewById(R.id.btCreateClient);
|
btCreateClient = (Button) findViewById(R.id.btCreateClient);
|
||||||
// Accès à la table article
|
// Accès à la table client
|
||||||
clientDAO = new ClientDAO(this);
|
clientDAO = new ClientDAO(this);
|
||||||
// Gestion de l'événement onClick sur le boutn Ajouter
|
// Gestion de l'événement onClick sur le boutn Ajouter
|
||||||
btCreateClient.setOnClickListener(new View.OnClickListener() {
|
btCreateClient.setOnClickListener(new View.OnClickListener() {
|
@ -56,8 +56,8 @@ public class GestionClient extends AppCompatActivity {
|
|||||||
Toast.makeText(getApplicationContext(), "Il y a +" +
|
Toast.makeText(getApplicationContext(), "Il y a +" +
|
||||||
c.getCount() + "articles", Toast.LENGTH_SHORT).show();
|
c.getCount() + "articles", Toast.LENGTH_SHORT).show();
|
||||||
String[] from = new String[]{"_id", "nom", "prenom", "numTel", "adrMail", "adrPostale"};
|
String[] from = new String[]{"_id", "nom", "prenom", "numTel", "adrMail", "adrPostale"};
|
||||||
int[] to = new int[] {R.id.tvIdClient, R.id.tvNomClient, R.id.tvDateInter, R.id.tvHeureInter, R.id.tvObervInter, R.id.tvIdClientInter};
|
int[] to = new int[] {R.id.tvIdClient, R.id.tvNomClient, R.id.tvPrenomClient, R.id.tvNumTelClient, R.id.tvAdrMailClient, R.id.tvAdrPostClient};
|
||||||
SimpleCursorAdapter dataAdapter = new SimpleCursorAdapter(this, R.layout.ligne_client3, c, from, to, 0);
|
SimpleCursorAdapter dataAdapter = new SimpleCursorAdapter(this, R.layout.ligne_client, c, from, to, 0);
|
||||||
ListView lvClients = (ListView) findViewById(R.id.lvClients);
|
ListView lvClients = (ListView) findViewById(R.id.lvClients);
|
||||||
lvClients.setAdapter(dataAdapter);
|
lvClients.setAdapter(dataAdapter);
|
||||||
|
|
||||||
@ -67,17 +67,22 @@ public class GestionClient extends AppCompatActivity {
|
|||||||
c.moveToPosition(position);
|
c.moveToPosition(position);
|
||||||
|
|
||||||
// Extract details from the cursor
|
// Extract details from the cursor
|
||||||
String date = c.getString(c.getColumnIndexOrThrow("date"));
|
int idCli = c.getInt(c.getColumnIndexOrThrow("_id"));
|
||||||
String heure = c.getString(c.getColumnIndexOrThrow("heure"));
|
String prenom = c.getString(c.getColumnIndexOrThrow("prenom"));
|
||||||
String observation = c.getString(c.getColumnIndexOrThrow("observation"));
|
String nom = c.getString(c.getColumnIndexOrThrow("nom"));
|
||||||
int idCli = c.getInt(c.getColumnIndexOrThrow("idCli"));
|
int numTel = c.getInt(c.getColumnIndexOrThrow("numTel"));
|
||||||
|
String adrMail = c.getString(c.getColumnIndexOrThrow("adrMail"));
|
||||||
|
String adrPostale = c.getString(c.getColumnIndexOrThrow("adrPostale"));
|
||||||
|
|
||||||
|
|
||||||
// Pass the details to the new activity using Intent
|
// Pass the details to the new activity using Intent
|
||||||
Intent intent = new Intent(this, ModifInter.class);
|
Intent intent = new Intent(this, ModifClient.class);
|
||||||
intent.putExtra("idCli", idCli);
|
intent.putExtra("_id", idCli);
|
||||||
intent.putExtra("date", date);
|
intent.putExtra("prenom", prenom);
|
||||||
intent.putExtra("heure", heure);
|
intent.putExtra("nom", nom);
|
||||||
intent.putExtra("observation", observation);
|
intent.putExtra("numTel", numTel);
|
||||||
|
intent.putExtra("adrMail", adrMail);
|
||||||
|
intent.putExtra("adrPostale", adrPostale);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -67,6 +67,7 @@ public class GestionInter extends AppCompatActivity {
|
|||||||
c.moveToPosition(position);
|
c.moveToPosition(position);
|
||||||
|
|
||||||
// Extract details from the cursor
|
// Extract details from the cursor
|
||||||
|
int idInter = c.getInt(c.getColumnIndexOrThrow("_id"));
|
||||||
String date = c.getString(c.getColumnIndexOrThrow("date"));
|
String date = c.getString(c.getColumnIndexOrThrow("date"));
|
||||||
String heure = c.getString(c.getColumnIndexOrThrow("heure"));
|
String heure = c.getString(c.getColumnIndexOrThrow("heure"));
|
||||||
String observation = c.getString(c.getColumnIndexOrThrow("observation"));
|
String observation = c.getString(c.getColumnIndexOrThrow("observation"));
|
||||||
@ -74,10 +75,11 @@ public class GestionInter extends AppCompatActivity {
|
|||||||
|
|
||||||
// Pass the details to the new activity using Intent
|
// Pass the details to the new activity using Intent
|
||||||
Intent intent = new Intent(this, ModifInter.class);
|
Intent intent = new Intent(this, ModifInter.class);
|
||||||
intent.putExtra("idCli", idCli);
|
intent.putExtra("_id", idInter);
|
||||||
intent.putExtra("date", date);
|
intent.putExtra("date", date);
|
||||||
intent.putExtra("heure", heure);
|
intent.putExtra("heure", heure);
|
||||||
intent.putExtra("observation", observation);
|
intent.putExtra("observation", observation);
|
||||||
|
intent.putExtra("idCli", idCli);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
package com.example.depanntout;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import bdd.ClientDAO;
|
||||||
|
import metier.Client;
|
||||||
|
|
||||||
|
public class ModifClient extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_modif_client);
|
||||||
|
initialisation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialisation() {
|
||||||
|
|
||||||
|
String prenom = getIntent().getStringExtra("prenom");
|
||||||
|
String nom = getIntent().getStringExtra("nom");
|
||||||
|
int numTel = getIntent().getIntExtra("numTel", -1);
|
||||||
|
String adrMail = getIntent().getStringExtra("adrMail");
|
||||||
|
String adrPostale = getIntent().getStringExtra("adrPostale");
|
||||||
|
idCli = getIntent().getIntExtra("_id", -1);
|
||||||
|
|
||||||
|
EditText etPrenom = findViewById(R.id.ptModifPrenom);
|
||||||
|
EditText etNom = findViewById(R.id.ptModifNom);
|
||||||
|
EditText etNumTel = findViewById(R.id.ptModifNumTel);
|
||||||
|
EditText etAdrMail = findViewById(R.id.ptModifAdrMail);
|
||||||
|
EditText etAdrPostale = findViewById(R.id.ptModifAdrPostale);
|
||||||
|
|
||||||
|
etPrenom.setText(prenom);
|
||||||
|
etNom.setText(nom);
|
||||||
|
etNumTel.setText(numTel != -1 ? String.valueOf(numTel) : "");
|
||||||
|
etAdrMail.setText(adrMail);
|
||||||
|
etAdrPostale.setText(adrPostale);
|
||||||
|
|
||||||
|
Button btnDeleteClient = findViewById(R.id.btnDeleteClient);
|
||||||
|
Button btnModifClient = findViewById(R.id.btnModifClient);
|
||||||
|
|
||||||
|
// Accès à la table client
|
||||||
|
clientDAO = new ClientDAO(this);
|
||||||
|
|
||||||
|
// Gestion de l'événement onClick sur le boutn Ajouter
|
||||||
|
btnDeleteClient.setOnClickListener(v -> {
|
||||||
|
boolean isDeleted = clientDAO.delete(idCli);
|
||||||
|
if (isDeleted) {
|
||||||
|
Toast.makeText(this, "Client deleted successfully", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Delete failed", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnModifClient.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
String prenomModif = etPrenom.getText().toString();
|
||||||
|
String nomModif = etNom.getText().toString();
|
||||||
|
int numTelModif = Integer.parseInt(etNumTel.getText().toString());
|
||||||
|
String adrMailModif = etAdrMail.getText().toString();
|
||||||
|
String adrPostaleModif = etAdrPostale.getText().toString();
|
||||||
|
|
||||||
|
Log.d("UpdateDebug", idCli + nomModif + prenomModif + numTelModif + adrMailModif + adrPostaleModif);
|
||||||
|
boolean isUpdated = clientDAO.update(idCli, nomModif, prenomModif, numTelModif, adrMailModif, adrPostaleModif);
|
||||||
|
if (isUpdated) {
|
||||||
|
Toast.makeText(this, "Client updated successfully", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Update failed", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// gestion du boutton Quitter
|
||||||
|
Button btQuitterInter = (Button) findViewById(R.id.btQuitterClient);
|
||||||
|
// Association d'un écouteur d'événement au clic de btQuitter
|
||||||
|
btQuitterInter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View arg0) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientDAO clientDAO = null;
|
||||||
|
Client cli = null;
|
||||||
|
|
||||||
|
// Contrôle graphiques
|
||||||
|
private EditText etNom;
|
||||||
|
private EditText etPrenom;
|
||||||
|
private EditText etNumTel;
|
||||||
|
private EditText etAdrMail;
|
||||||
|
private EditText etAdrPostale;
|
||||||
|
private Button btnDeleteClient;
|
||||||
|
|
||||||
|
//Valeur saisies
|
||||||
|
Integer idCli;
|
||||||
|
String nom;
|
||||||
|
String prenom;
|
||||||
|
Integer numTel;
|
||||||
|
String adrMail;
|
||||||
|
String adrPostale;
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package com.example.depanntout;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import bdd.InterventionDAO;
|
||||||
|
import metier.Intervention;
|
||||||
|
|
||||||
|
public class ModifInter extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_modif_inter);
|
||||||
|
|
||||||
|
initialisation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialisation() {
|
||||||
|
|
||||||
|
// Get data from Intent
|
||||||
|
String date = getIntent().getStringExtra("date");
|
||||||
|
String heure = getIntent().getStringExtra("heure");
|
||||||
|
String observation = getIntent().getStringExtra("observation");
|
||||||
|
int idCli = getIntent().getIntExtra("idCli", -1);
|
||||||
|
int idInter = getIntent().getIntExtra("_id", -1);
|
||||||
|
|
||||||
|
// Reference TextViews
|
||||||
|
TextView etDate = findViewById(R.id.ptModifDate);
|
||||||
|
TextView etHeure = findViewById(R.id.ptModifHeure);
|
||||||
|
TextView etObservation = findViewById(R.id.ptModifObserv);
|
||||||
|
TextView etIdCli = findViewById(R.id.ptModifIdClient);
|
||||||
|
|
||||||
|
// Set data in TextViews
|
||||||
|
etDate.setText(date);
|
||||||
|
etHeure.setText(heure);
|
||||||
|
etObservation.setText(observation);
|
||||||
|
etIdCli.setText(String.valueOf(idCli));
|
||||||
|
|
||||||
|
// gestion du boutton Quitter
|
||||||
|
Button btQuitterInter = (Button) findViewById(R.id.btQuitterInter);
|
||||||
|
// Association d'un écouteur d'événement au clic de btQuitter
|
||||||
|
btQuitterInter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View arg0) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button btnDeleteInter = findViewById(R.id.btnDeleteInter);
|
||||||
|
Button btnModifInter = findViewById(R.id.btnModifInter);
|
||||||
|
|
||||||
|
// Accès à la table intervention
|
||||||
|
InterventionDAO interventionDAO = new InterventionDAO(this);
|
||||||
|
|
||||||
|
// Gestion de l'événement onClick sur le boutn Ajouter
|
||||||
|
btnDeleteInter.setOnClickListener(v -> {
|
||||||
|
boolean isDeleted = interventionDAO.delete(idCli);
|
||||||
|
if (isDeleted) {
|
||||||
|
Toast.makeText(this, "Client deleted successfully", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Delete failed", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnModifInter.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
String dateModif = etDate.getText().toString();
|
||||||
|
String heureModif = etHeure.getText().toString();
|
||||||
|
String obsModif = etObservation.getText().toString();
|
||||||
|
int idCliModif = Integer.parseInt(etIdCli.getText().toString());
|
||||||
|
|
||||||
|
boolean isUpdated = interventionDAO.update(idInter, dateModif, heureModif, obsModif, idCliModif);
|
||||||
|
if (isUpdated) {
|
||||||
|
Toast.makeText(this, "Client updated successfully", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Update failed", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Before Width: | Height: | Size: 488 KiB After Width: | Height: | Size: 488 KiB |
@ -16,6 +16,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15sp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
@ -16,6 +16,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15sp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
115
DepannRien/app/src/main/res/layout/activity_modif_client.xml
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/header_layout" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15sp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvModifNomClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libTvNomClient"
|
||||||
|
android:textColor="#1976D2"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/ptModifNom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textPersonName" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvModifPrenomClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libTvPrenomClient"
|
||||||
|
android:textColor="#1976D2"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/ptModifPrenom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textPersonName" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvModifNumTel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libTvNumTelClient"
|
||||||
|
android:textColor="#1976D2"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/ptModifNumTel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="number" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvModifAdrMail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libTvMailClient"
|
||||||
|
android:textColor="#1976D2"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/ptModifAdrMail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvModifAdrPostale"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libTvAdrClient"
|
||||||
|
android:textColor="#1976D2"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/ptModifAdrPostale"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnModifClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Modifier" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnDeleteClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Supprimer" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btQuitterClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/libBtQuitter" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -10,13 +10,14 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/header_layout" />
|
<include layout="@layout/header_layout" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15sp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
@ -19,30 +19,51 @@
|
|||||||
android:id="@+id/tvIdClient"
|
android:id="@+id/tvIdClient"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="10sp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:text="@string/libTvIdClient"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:text="@string/libTvIdClient"/>
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvDateInter"
|
android:id="@+id/tvPrenomClient"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="10sp"
|
android:layout_marginEnd="10sp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:text="@string/libTvPrenomClient"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
android:text="@string/libTvPrenomClient" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvNomClient"
|
android:id="@+id/tvNomClient"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="10sp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:text="TextView"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
android:text="@string/libTvNomClient"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNumTelClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="TextView" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAdrMailClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="TextView" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAdrPostClient"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="TextView" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |