Hi
i am new to c++ and i am working on Point Of Sales programs.I have been asked to write and functionality in the current software so that it handles buying items in specials. I have items that i enter into the SPECIALS table and link them to the normal STOCK table so when someone buys items it should be able to check if they exist into the SPECIALS table and form a complete combo before it can give him the discount. I am encountering a problem of linking all found items to a specific combo as one item can be part of many specials. here is my code
//SELECT THE CODE ,QUANTINTY AND PRICE SCANNED AT THE POS
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT StockCode,Sum(Value) as Value,sum(Quantity) AS Quantity FROM POS_Transactions WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and Type = '02' group by StockCode";
PosDataForm->SelectQuery->Open();
//ONCE A RECORD IS FOUND UPDATE THE POS_SCAN COLUMN IN THE SPECIALS TABLE BY //SETTING THE QUANTITY OF THE SCANNED CODE EQUAL TO THE QUANTITY SCANNED
if (PosDataForm->SelectQuery->RecordCount > 0)
{
while(!PosDataForm->SelectQuery->Eof)
{
StockCode = AnsiString(PosDataForm->SelectQuery->FieldValues["StockCode"]);
Value = double(PosDataForm->SelectQuery->FieldValues["Value"]);
qty= double(PosDataForm->SelectQuery->FieldValues["Quantity"]);
InsertQuery = "UPDATE RECIPES SET POS_Scan =' " ;
InsertQuery += qty+ "' WHERE IngredientId = '"+ StockCode + "' ";
try
{
PosDataForm->UpdateCommand->CommandText = InsertQuery ;
PosDataForm->UpdateCommand->Execute();
}
catch(Exception &e){}
PosDataForm->SelectQuery->Next();
}
//NOW SELECT ALL THAT HAVE BEEN SCANNED
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT * FROM RECIPES WHERE POS_SCAN>=Quantity AND INGREDIENTID IN(SELECT STOCKCODE FROM POS_TRANSACTIONS WHERE SLIP= '" + AnsiReplaceStr( Slipnumber, "'", "`" )+"')";
PosDataForm->SelectQuery->Open();
//WHEN RECORD FOUND THEN START READING
if (PosDataForm->SelectQuery->RecordCount > 0) //if a record is found then start reading all the record that were found
{
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT KITCHENITEMID,COUNT(*) AS TotalCount FROM RECIPES WHERE INGREDIENTID IN(SELECT STOCKCODE FROM POS_TRANSACTIONS WHERE SLIP= '" + AnsiReplaceStr( Slipnumber, "'", "`" )+"') GROUP BY KITCHENITEMID HAVING COUNT(*) > 1";
PosDataForm->SelectQuery->Open();
if (PosDataForm->SelectQuery->RecordCount > 0)
{
while(!PosDataForm->SelectQuery->Eof)
{
AnsiString Kitchen="";
double Count=0;
Kitchen = AnsiString(PosDataForm->SelectQuery->FieldValues["KitchenItemID"]);
Count= double(PosDataForm->SelectQuery->FieldValues["TotalCount"]);
for(int i =0; i<=Count; i++)
{
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT DISTINCT(STOCKCODE) FROM POS_TRANSACTIONS WHERE SLIP='" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and Type = '02' "'";
PosDataForm->SelectQuery->Open();
if ( PosDataForm->SelectQuery->RecordCount > 0)
{
while(!PosDataForm->SelectQuery->Eof)
{
AnsiString STCode="";
STCode = AnsiString(PosDataForm->SelectQuery->FieldValues["STOCKCODE"]);
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT INGREDIENTID FROM RECIPES WHERE ";
PosDataForm->SelectQuery->Open();
if( Ingredient==StockCode)
{
MessageDlg( "\nError MATCH found !", mtInformation, TMsgDlgButtons() << mbOK, 0 );
}
}
PLEASE HELP ME AS THIS PART STUCKS AND I CAN SEE THE RESULT