Guest User

Untitled

a guest
Jun 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. int TPump::AddComponent(int code, AnsiString name)
  2. {
  3. int ResultId;
  4.  
  5.  
  6. entry:
  7.  
  8. // Sprawdzenie, czy komponent jest wpisany
  9.  
  10. CheckComponentQuery->Params->ParamByName("kod")->AsString = AnsiString("SK") + code;
  11. CheckComponentQuery->Open();
  12.  
  13. if (CheckComponentQuery->RecordCount > 0)
  14. {
  15. ResultId = CheckComponentQuery->FieldByName("")->AsInteger;
  16. goto finally;
  17. }
  18.  
  19. // Ewentualne dopisanie nowego
  20.  
  21. AddComponentQuery->Params->ParamByName("kod")->AsString = AnsiString("SK") + code;
  22. AddComponentQuery->Params->ParamByName("nazwa")->AsString = name;
  23. AddComponentQuery->ExecSQL();
  24.  
  25. Logger->Add("Dodano nowy komponent", LoggerMsgType::information);
  26.  
  27. /* niezgrabne rozwiązanie, pobranie id z bazy bez rekurencyjnego zapychania
  28. stosu wydaje się bardziej na miejscu */
  29.  
  30. goto entry; // ResultId = AddComponent(code, name);
  31.  
  32. finally:
  33. CheckComponentQuery->Close();
  34. return ResultId;
  35. }
Add Comment
Please, Sign In to add comment