#include "ajouter_parking2.h"
#include "ui_ajouter_parking2.h"
#include"smtp.h"
#include"parking.h"
ajouter_parking2::ajouter_parking2(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ajouter_parking2)
{
    ui->setupUi(this);
}

ajouter_parking2::~ajouter_parking2()
{
    delete ui;
}

void ajouter_parking2::on_pushButton_clicked()
{
    int id = ui->LineEdit_id->text().toInt();
    int  numero= ui->LineEdit_numero->text().toInt();
    QString etat= ui->LineEdit_etat->text();

  parking p (id,numero,etat);
  bool test=p.ajouter();
  if(test)

{
      Smtp* s = new Smtp( "hajmoussa2368@gmail.com", "Hm123456", "smtp.gmail.com", 465 );
      s->sendMail("hajmoussa2368@gmail.com","youssef.ghedas@esprit.tn","un parking  a été ajouter avec succés","Mr skander");
      notifier = new QSystemTrayIcon(this);
      notifier->setIcon(QIcon("notification.png"));
      notifier->show();
      notifier->showMessage("Succés","un parking  a été ajouter avec succés",QSystemTrayIcon::Warning,10000);
      hide();
}
  else
  {
      notifier = new QSystemTrayIcon(this);
      notifier->setIcon(QIcon("notification.png"));
      notifier->show();
      notifier->showMessage("Erreur","Le parking n'a pas été ajouté",QSystemTrayIcon::Warning,10000);

}
}
