#include "modifier_article2.h"
#include "ui_modifier_article2.h"
#include"smtp.h"
#include"QSystemTrayIcon"

modifier_article2::modifier_article2(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::modifier_article2)
{
    ui->setupUi(this);
}

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

void modifier_article2::on_pushButton_clicked()
{
    QString nom= ui->lineEdit_2->text();
    int    prix=ui->lineEdit_3->text().toInt();
    int    codeabarre=ui->lineEdit->text().toInt();
      bool test=tmparticle.modifier(nom,prix);
      if(test)
      {
          Smtp* s = new Smtp( "hajmoussa2368@gmail.com", "Hm123456", "smtp.gmail.com", 465 );
          s->sendMail("hajmoussa2368@gmail.com","kais.kasmi@esprit.tn","un article a été modifier avec succés","Mr kais");
          notifier = new QSystemTrayIcon(this);
          notifier->setIcon(QIcon("notification.png"));
          notifier->show();
          notifier->showMessage("Succés","l'article a été modifier avec succés",QSystemTrayIcon::Warning,10000);
          hide();
      }
      else
      {
          notifier = new QSystemTrayIcon(this);
          notifier->setIcon(QIcon("notification.png"));
          notifier->show();
          notifier->showMessage("Echec!","L'article n'a pas pu etre modifié",QSystemTrayIcon::Warning,10000);
      }

}
