lundi 23 mars 2015

Programming with C++ using phpMyAdmin + sale function


I am struggling with the continuation of my project.


I am programming a store console application which lets me put products into phpMyAdmin, but also functions as a cash register. Where I am able to retrieve all the products from the stock and show them in a list, whereafter the cashier can enter the product ID's and ammounts of the products and make 'ticket'.


Now I am able to print out all the products succesfull by retrieving them from the table 'stock' and print them with their id's and names.


But how do I continue now?


Do I make a loop where i ask the cashier to enter the product id + amount ? Do i need to need a new vector? Do i need to use an array? What's the best thing to do in order to continue with this sale function?


Thank you


This is my code: which prints out all the products from the table (works flawless)



void menuKassa::newSale()
{
bool continue = true;
while (continue)
{
cout << "* * * * * * N E W S A L E * * * * ** * \n";
cout << "What articles did the client pick?" << endl;
string products = productlist();
}
}

string menuKassa::productlist()
{

int choice;
vector<Product*> products= ProductDAO::getAll();

vector<string>productnames;
bool validChoice;

validChoice = false;
int k = 0;
cout << "What did the client pick?" << endl;


for (int i = 1; i<products.size(); i++)
{

bool a = true;
for (int j = 0; j<productnames.size(); j++)
{
string x = products.at(i)->getProd_Name();
string y = productnames.at(j);
if (x == y)
a = false;
}
if (a == true){
k++;
cout << " " << products.at(i)->getProd_ID() << " - " << products.at(i)->getProd_Name() << endl;
productnames.push_back(products.at(i)->getProd_Naam());
}



}
/*
cout << "Product ID: ";
cin >> choice;
*/

}



Aucun commentaire:

Enregistrer un commentaire