Ejemplo n.º 1
0
void workerHandlingProductsMenu(Product *products, int *productCount) {
    int op;
    do {
        workerHandlingProductsMenuPrint();
        readInt(&op, MENU_OPT_MIN, MENU_OPT_MAX, MENU_MSG_OPT);
        switch (op) {
            case 0: //exit
                break;
            case 1: 
                cleanScreen();
                addProduct(products, productCount);
                break;
            case 2: 
                cleanScreen();
                editProduct(products, productCount);
                break;
            case 3: 
                cleanScreen();
                removeProduct(products, productCount);
                break;
            case 4: 
                cleanScreen();
                listProducts(products, productCount);
                break;
            default:
                printf(MENU_MSG_OPT_INVALID);
        }
    } while (op != 0);
}
Ejemplo n.º 2
0
int main(){

	inputData();
	inputData();
	inputData();

	outputData();

	removeProduct("Tomato");

	outputData();

	return 0;
}
Ejemplo n.º 3
0
int main() {

	inputData();
	inputData();
	inputData();

	outputData();

	printf("Searching for product ... \n");
	searchForProduct("Tomato");

	printf("Removing a product ...\n");
	removeProduct("Tomato");

	printf("The remaining products are: \n");
	outputData();

	return 0;
}
void ShoppingList::removeProduct(Product* product)
{
    removeProduct(product,1);
}
Ejemplo n.º 5
0
/**
 * Methode permettant de creer l'interface d'ajout
 * de produit au documents
 * @return l'interface
 */
QGroupBox* NewDocumentWindow::createAddProductInterface(){

    QGroupBox *groupAddProduct = new QGroupBox(trUtf8("Ajout de produit"), this);
    QFormLayout *layoutFormAddProduct=new QFormLayout;

    productName=new QComboBox(this);
    productName->setToolTip(trUtf8("Nom du produit, description, prix"));
    QList<Product> listProduct= Product::getAllProduct();

    if(listProduct.size()==0){
        this->setDisabled(true);
    }

    for(int i=0;i<listProduct.size();i++)
        productName->addItem(listProduct.at(i).name+", "+listProduct.at(i).description+", "+QVariant(listProduct.at(i).price).toString()+QString(8364));

    layoutFormAddProduct->addRow(trUtf8("Produit: "),productName);


    productQuantity=new QSpinBox(this);
    productQuantity->setMinimum(1);
    productQuantity->setMaximum(99999);
    layoutFormAddProduct->addRow(trUtf8("Quantité: "),productQuantity);

    productReduction=new QDoubleSpinBox(this);
    productQuantity->setMinimum(0);
    productQuantity->setMaximum(99999);
    layoutFormAddProduct->addRow(trUtf8("Remise: "),productReduction);

    QGroupBox *groupTypeReduction = new QGroupBox(this);

    fixedValue=new QRadioButton(trUtf8("Valeur fixe"),this);
    fixedValue->setChecked(true);
    percentage=new QRadioButton(trUtf8("Pourcentage"),this);

    QHBoxLayout *layoutRadioButton = new QHBoxLayout;
    layoutRadioButton->addWidget(fixedValue);
    layoutRadioButton->addWidget(percentage);
    layoutRadioButton->addStretch();

    groupTypeReduction->setLayout(layoutRadioButton);

    layoutFormAddProduct->addRow(trUtf8("Type de reduction"),groupTypeReduction);


    QHBoxLayout *layoutButtonProduct=new QHBoxLayout;

    buttonAddProduct=new QPushButton(trUtf8("Ajouter le produit"),this);
    layoutButtonProduct->addWidget(buttonAddProduct);

    buttonRemoveProduct=new QPushButton(trUtf8("Supprimer le produit sélectionné"),this);
    layoutButtonProduct->addWidget(buttonRemoveProduct);

    layoutButtonProduct->addStretch();
    layoutFormAddProduct->addRow(trUtf8("Actions: "),layoutButtonProduct);

    groupAddProduct->setLayout(layoutFormAddProduct);

    /** ******************************** **/
    /**               Slots              **/
    /** ******************************** **/
    connect(buttonAddProduct, SIGNAL(clicked()), this, SLOT(addProduct()));
    connect(buttonRemoveProduct, SIGNAL(clicked()), this, SLOT(removeProduct()));


    return groupAddProduct;

}