Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.17 KB | None | 0 0
  1. przycisk 2 :
  2. C:
  3.  
  4.  
  5.  
  6.         float suma, srednia;
  7.     int ile;
  8.     suma = 0;
  9.     ile = 0;
  10.     DataModule2->IBTable1->First();
  11.     if (Edit1->Text == "") {
  12.         ShowMessage("Nie podano wartosci");
  13.     }
  14.     else
  15.     {
  16.     while(!DataModule2->IBTable1->Eof)
  17.     {
  18.         if (DataModule2->IBTable1->Fields->Fields[2]->AsInteger > StrToInt(Edit1->Text)) {
  19.             suma+=DataModule2->IBTable1->Fields->Fields[3]->AsFloat;
  20.             ile+=1;
  21.         }
  22.         DataModule2->IBTable1->Next();
  23.     }
  24.     srednia = suma/ile;
  25.     Form4->Label2->Caption=srednia;
  26.  
  27.  
  28.  
  29. Form4->ShowModal();
  30. }
  31.  
  32. PRZYCISK 3 :
  33.  
  34. B:
  35.    
  36. Form5->ShowModal();
  37. float dlugosc;
  38.  float nota;
  39.  
  40.  String s;
  41.  
  42.  TLocateOptions Opts;
  43.  
  44.  Opts.Clear();
  45.  
  46.  Form5->Memo1->Clear();
  47.  
  48.  DataModule2->IBTable1->First();
  49.  
  50.  while (! DataModule2->IBTable1->Eof){
  51.  
  52.  if (DataModule2->IBTable1->Fields->Fields[3]->AsFloat < StrToFloat(Edit1->Text)){
  53.  
  54.  s = DataModule2->IBTable1->Fields->Fields[0]->AsString + " " + DataModule2->IBTable1->Fields->Fields[1]->AsString + " " + DataModule2->IBTable1->Fields->Fields[2]->AsString + " ";
  55.  
  56.  dlugosc = DataModule2->IBTable1->Fields->Fields[3]->AsFloat;
  57.  nota = DataModule2->IBTable1->Fields->Fields[4]->AsFloat;
  58.  
  59.  Form5->Memo1->Lines->Add(s + FloatToStr(DataModule2->IBTable1->Fields->Fields[3]->AsFloat) + " " + dlugosc + nota );
  60.  
  61.  }
  62.  
  63.  DataModule2->IBTable1->Next();
  64.  
  65.  }   
  66.      
  67. C:
  68.     int i;
  69.     String s;
  70.     float wartosc;
  71.  
  72.     Form5->Memo1->Clear();
  73.     DataModule2->IBTable1->First();
  74.     if (Edit2->Text == "") {
  75.         ShowMessage("Nie podano wartosci");
  76.     }
  77.     else
  78.     {
  79.     while(!DataModule2->IBTable1->Eof)
  80.     {
  81.         if (DataModule2->IBTable1->Fields->Fields[3]->AsFloat < StrToFloat(Edit2->Text)) {
  82.             wartosc = DataModule2->IBTable1->Fields->Fields[3]->AsFloat * DataModule2->IBTable1->Fields->Fields[2]->AsFloat;
  83.             s = DataModule2->IBTable1->Fields->Fields[0]->AsString + " " + DataModule2->IBTable1->Fields->Fields[3]->AsString + " " + DataModule2->IBTable1->Fields->Fields[2]->AsString;
  84.             Form5->Memo1->Lines->Add(s + " " + FloatToStr(wartosc));
  85.         }
  86.         DataModule2->IBTable1->Next();
  87.     }
  88.     Form5->ShowModal();
  89.     }
  90.  
  91.  
  92.  
  93. A: !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  94. DRUGI:
  95.  
  96. int pom1, pom2, srch, srdz, lchlopcy=0, ldziewczynki=0, sumawagchl=0, sumawagdzw=0 ;
  97.  
  98.     IBTable1->First();
  99.     while (!IBTable1->Eof)
  100.     {
  101.         if (IBTable1->Fields->Fields[4]->AsInteger > StrToInt(Edit1->Text))
  102.         {
  103.             if (IBTable1->Fields->Fields[3]->AsString=="K")
  104.              {
  105.                 pom1=IBTable1->Fields->Fields[5]->AsInteger;
  106.                 sumawagdzw = sumawagdzw+pom1;
  107.                 ldziewczynki++;
  108.              }
  109.             else if
  110.             (IBTable1->Fields->Fields[3]->AsString=="M")
  111.             {
  112.                 lchlopcy++;
  113.                 pom2=IBTable1->Fields->Fields[5]->AsInteger;
  114.                 sumawagchl = sumawagchl+pom2;
  115.             }
  116.         }
  117.  
  118.     IBTable1->Next();
  119.     }
  120.     if (ldziewczynki == 0) {
  121.          Form3->Label4->Caption=0;
  122.     }
  123.     else Form3->Label4->Caption=IntToStr(sumawagdzw/ldziewczynki);
  124.     if (lchlopcy == 0) {
  125.          Form3->Label5->Caption=0;
  126.     }
  127.     else Form3->Label5->Caption=IntToStr(sumawagchl/lchlopcy);
  128.  
  129.     chlopcy = StrToInt(Form3->Label5->Caption);
  130.     dziewczynki = StrToInt(Form3->Label4->Caption);
  131.  
  132.     Form3->Show();
  133.  
  134. PRZYCISK 3 :
  135.  
  136. IBTable1->First();
  137.      while (!IBTable1->Eof)
  138.      {
  139.         if(IBTable1->Fields->Fields[3]->AsString=="K" && IBTable1->Fields->Fields[5]->AsInteger >= dziewczynki)
  140.         {
  141.             String s;
  142.             s = (IBTable1->Fields->Fields[0]->AsString + " " + IBTable1->Fields->Fields[1]->AsString +
  143.             " " + IBTable1->Fields->Fields[2]->AsString + " " + IBTable1->Fields->Fields[4]->AsString +
  144.             " " + IBTable1->Fields->Fields[5]->AsString);
  145.             Form4->Memo1->Lines->Add(s);
  146.         }
  147.         if(IBTable1->Fields->Fields[3]->AsString=="M" && IBTable1->Fields->Fields[5]->AsInteger >= chlopcy)
  148.         {
  149.             String s;
  150.             s = (IBTable1->Fields->Fields[0]->AsString + " " + IBTable1->Fields->Fields[1]->AsString +
  151.             " " + IBTable1->Fields->Fields[2]->AsString + " " + IBTable1->Fields->Fields[4]->AsString +
  152.             " " + IBTable1->Fields->Fields[5]->AsString);
  153.             Form4->Memo1->Lines->Add(s);
  154.         }
  155.         IBTable1->Next();
  156.      }
  157.  
  158.      Form4->Show();
  159.      
  160.      WARUNKI: !!!!!!!!!!!!!!!!!!!!!!!!
  161.      
  162.         if(DBEdit1->Field->AsString == "")
  163.     {
  164.         ShowMessage("Pole Nazwa musi byc wypelnione");
  165.         DBEdit1->SetFocus();
  166.         return;
  167.     }
  168.     if(DBEdit2->Field->AsString == "")
  169.     {
  170.         ShowMessage("Pole Jednostka musi byc wypelnione");
  171.         DBEdit2->SetFocus();
  172.         return;
  173.     }
  174.     if((DBEdit3->Field->AsString == "") || (DBEdit3->Field->AsInteger < 0))
  175.     {
  176.         ShowMessage("Pole Ilosc musi byc wypelnione i nieujemne");
  177.         DBEdit3->SetFocus();
  178.         return;
  179.     }
  180.     if((DBEdit4->Field->AsString == "") || (DBEdit4->Field->AsFloat < 0))
  181.     {
  182.         ShowMessage("Pole Cena musi byc wypelnione i nieujemne");
  183.         DBEdit4->SetFocus();
  184.         return;
  185.     }
  186.     DataModule2->IBTable1->Post();
  187.     Close();
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197. ---Łączenie z bazą---
  198. IBDatabase1:
  199. DatabaseName: nazwa i ścieżka pliku bazy
  200. DefaultTransaction: wybrać IBTransaction1
  201. Connected: True
  202. IBTable1:
  203. DataBase: wybrać IBDatabase1
  204. TableName: wybrać DRUZYNY
  205. Active: True
  206. IBTable2:
  207. DataBase: wybrać IBDatabase1
  208. TableName: wybrać ZAWODNICY
  209. Active: True
  210. DataSource1:
  211. DataSet: wybrać IBTable1
  212. DataSource2:
  213. DataSet: wybrać IBTable2
  214. DBGrid1:
  215. DataSource: wybrać DataSource1
  216. DBGrid2:
  217. DataSource: wybrać DataSource2
  218. Label1:
  219. Caption: ‘Tabela DRUZYNY’
  220. Label2:
  221. Caption: ‘Tabela ZAWODNICY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement