Hi,
i have a defined function, but when i run my program jumps the function without reading it. Here is how my code look like:
when i run my application it doesn't go through the calling it skips that part.
can anyone help?
i have a defined function, but when i run my program jumps the function without reading it. Here is how my code look like:
Code:
void processComboItem(); declaring the function
void TPosGetPaymentMethodForm::processComboItem()//details of the function
{
int key = PosMainForm->PosTrnObj->PayKey;
long double FITotal = PosMainForm->PosTrnObj->FinalInvoiceTotal;
long double FIDue = PosMainForm->PosTrnObj->FinalInvoiceDue ;
long double FIVat = PosMainForm->PosTrnObj->FinalInvoiceVat;
long double FIDiscount = PosMainForm->PosTrnObj->FinalInvoiceDiscount ;
double total = 0;
AnsiString StockCode = "";
AnsiString Slipnumber = PosMainForm->PosTrnObj->SlipNumber;
double value = 0;
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT StockCode,Value,Quantity FROM POS_Transactions WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and Type = '02'";
PosDataForm->SelectQuery->Open();
if (PosDataForm->SelectQuery->RecordCount > 0)
{
StockCode = AnsiString(PosDataForm->SelectQuery->FieldValues["StockCode"]);
value = double(PosDataForm->SelectQuery->FieldValues["Value"]);
PosDataForm->SelectQuery->Close();
PosDataForm->SelectQuery->CommandText = "SELECT IngredientID, Quantity FROM RECIPES WHERE KitchenItemID = '" + AnsiReplaceStr( StockCode.Trim(), "'", "`" ) + "'";
PosDataForm->SelectQuery->Open();
if (PosDataForm->SelectQuery->RecordCount > 0)
{
while(!PosDataForm->SelectQuery->Eof)
{
PosMainForm->PosTrnObj->Search(AnsiString(PosDataForm->SelectQuery->FieldValues["IngredientID"]),"POSTerminal" );
PosDataForm->SelectQueryCents->Close();
PosDataForm->SelectQueryCents->CommandText = "SELECT Value FROM POS_Transactions WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and StockCode = '"+AnsiString(PosDataForm->SelectQuery->FieldValues["IngredientID"])+"'";
PosDataForm->SelectQueryCents->Open();
if (PosDataForm->SelectQueryCents->RecordCount > 0)
{
total += double(PosDataForm->SelectQueryCents->FieldValues["Value"]);
}
PosDataForm->SelectQuery->Next();
}
}
total = value - total;
PosDataForm->UpdateCommand->CommandText = "UPDATE POS_Transactions SET Value = "+AnsiString(total)+", Total = "+AnsiString(total)+" WHERE Slip = '" + AnsiReplaceStr( Slipnumber, "'", "`" ) + "' and StockCode = '"+ StockCode +"'";
PosDataForm->UpdateCommand->Execute();
}
//restore values
PosMainForm->PosTrnObj->FinalInvoiceTotal = FITotal;
PosMainForm->PosTrnObj->FinalInvoiceDue = FIDue;
PosMainForm->PosTrnObj->FinalInvoiceVat=FIVat;
PosMainForm->PosTrnObj->FinalInvoiceDiscount=FIDiscount;
PosMainForm->PosTrnObj->PayKey = key;
}
//calling the function
void __fastcall TPosGetPaymentMethodForm::Button19Click(TObject *Sender)
{
processComboItem();
PosPaymentReceivedKeyPress(this, 'n');
}
can anyone help?
Comment