package fr.iut_fbleau.apl41.couleurs;

import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class Detect implements View.OnClickListener {
    private Activity act;
    private Button annuler, supprimer;
    private long id_base;
    public Detect(Activity a, Button an, Button sup, long id){
        this.act=a;
        this.annuler = an;
        this.supprimer = sup;
        this.id_base=id;
    }
    @Override
    public void onClick(View v){
        if (v==this.annuler) {
            this.act.finish();
        } else if (v==this.supprimer){
            AccesBaseDeDonnees acces = new AccesBaseDeDonnees(this.act);
            SQLiteDatabase baseDeDonnees = acces.getWritableDatabase();
            baseDeDonnees.execSQL("DELETE FROM " + AccesBaseDeDonnees.NOM_TABLE + " WHERE " + BaseColumns._ID+" = "+this.id_base);

            this.act.finish();
        }
    }
}
