#include "editboxinfodialog.h"
#include "ui_editboxinfodialog.h"
#include "QDebug"

EditBoxInfoDialog::EditBoxInfoDialog(QSharedPointer<BoxInfo> &box, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EditBoxInfoDialog),_box(box)
{
    ui->setupUi(this);

    ui->ts->setValue(_box->tube_number);
    ui->tz->setValue(_box->bucket_weight / 1000.00);
    ui->pz->setValue(_box->box_weight / 1000.00);
    ui->netW->setValue(_box->net_weight / 1000.00);
    ui->grossW->setValue(_box->gross_weight / 1000.0);
}

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



void EditBoxInfoDialog::on_pushClose_clicked()
{
    this->close();
}

void EditBoxInfoDialog::on_pushSave_clicked()
{
    _box->tube_number = ui->ts->value();
    _box->bucket_weight = ui->tz->value() * 1000;
    _box->box_weight = ui->pz->value() * 1000;
    _box->net_weight = ui->netW->value() * 1000;
    _box->gross_weight = ui->grossW->value() * 1000;

    this->close();
}
