Link to home
Start Free TrialLog in
Avatar of jdr0606
jdr0606Flag for United States of America

asked on

Explain what this section of code does

Hello,
     I am looking at one of the functions inside of an integration application that we use to remove shipcomplete holds since some orders have not been automatically released like they should.  I'm new to C++ Builder and I don't understand what the  function is doing.  The entire function is below.  

The main part that I don't understand is the record count and how it relates with removing the hold and how the values of the Add() function are calculated (the part with the formula atyalloc + qtyprinv != quantity - qtycance).  Please explain this in as much detail as possible.

Thanks for your help!

void __fastcall TKeleForm::ShipCompleteUpdate()
{
ShipCompleteQuery();
TDateTime wow = Now();
DM->GPXOPQuery->First();
while(!DM->GPXOPQuery->Eof)
    {
    salesordernmbr = DM->GPXOPQuery->FieldByName("SOPNUMBE")->AsString;
    DM->GPModifyQuery->Close();
    DM->GPModifyQuery->SQL->Clear();
    DM->GPModifyQuery->SQL->Add("Select Count(*) As Recordcount From SOP10200 ");
    DM->GPModifyQuery->SQL->Add("Where SOPNUMBE = '" + salesordernmbr + "'");
    //December 17, 2002 Added the "+ QTYPRINV" to following line
    //DM->GPModifyQuery->SQL->Add("And ATYALLOC + QTYPRINV != QUANTITY ");
    DM->GPModifyQuery->SQL->Add("And ATYALLOC + QTYPRINV != QUANTITY - QTYCANCE ");
    //January 7, 2005 Added the following And statements
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'FREIGHT' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'REPAIRS' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'LABOR' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'RESTOCKING FEE' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'EXPEDITE FEE' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'MISCELLANEOUS' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'UL FEES' ");
    DM->GPModifyQuery->SQL->Add("And ITEMNMBR != 'ENGINEERING FEE' ");
    DM->GPModifyQuery->Open();
    recordcount = DM->GPModifyQuery->FieldByName("RECORDCOUNT")->AsInteger;

    if(recordcount == 0)
       {
       DM->GPModifyQuery->Close();
       DM->GPModifyQuery->SQL->Clear();
       DM->GPModifyQuery->SQL->Add("Update SOP10104 ");
       DM->GPModifyQuery->SQL->Add("Set DELETE1 = '1', ");
       DM->GPModifyQuery->SQL->Add("USERID = 'Int', ");
       DM->GPModifyQuery->SQL->Add("HOLDDATE = '" + DateToStr(wow) + "', ");
       DM->GPModifyQuery->SQL->Add("TIME1 = '" + TimeToStr(wow) + "' ");
       DM->GPModifyQuery->SQL->Add("Where SOPNUMBE = '" + salesordernmbr + "' ");
       DM->GPModifyQuery->SQL->Add("And PRCHLDID = 'SHIPCOMPLETE'");
       DM->GPModifyQuery->ExecSQL();

       GPFascorInsert();

       }
    DM->GPXOPQuery->Next();
    }
}
ASKER CERTIFIED SOLUTION
Avatar of kode99
kode99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial