Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- przycisk 2 :
- C:
- float suma, srednia;
- int ile;
- suma = 0;
- ile = 0;
- DataModule2->IBTable1->First();
- if (Edit1->Text == "") {
- ShowMessage("Nie podano wartosci");
- }
- else
- {
- while(!DataModule2->IBTable1->Eof)
- {
- if (DataModule2->IBTable1->Fields->Fields[2]->AsInteger > StrToInt(Edit1->Text)) {
- suma+=DataModule2->IBTable1->Fields->Fields[3]->AsFloat;
- ile+=1;
- }
- DataModule2->IBTable1->Next();
- }
- srednia = suma/ile;
- Form4->Label2->Caption=srednia;
- Form4->ShowModal();
- }
- PRZYCISK 3 :
- B:
- Form5->ShowModal();
- float dlugosc;
- float nota;
- String s;
- TLocateOptions Opts;
- Opts.Clear();
- Form5->Memo1->Clear();
- DataModule2->IBTable1->First();
- while (! DataModule2->IBTable1->Eof){
- if (DataModule2->IBTable1->Fields->Fields[3]->AsFloat < StrToFloat(Edit1->Text)){
- s = DataModule2->IBTable1->Fields->Fields[0]->AsString + " " + DataModule2->IBTable1->Fields->Fields[1]->AsString + " " + DataModule2->IBTable1->Fields->Fields[2]->AsString + " ";
- dlugosc = DataModule2->IBTable1->Fields->Fields[3]->AsFloat;
- nota = DataModule2->IBTable1->Fields->Fields[4]->AsFloat;
- Form5->Memo1->Lines->Add(s + FloatToStr(DataModule2->IBTable1->Fields->Fields[3]->AsFloat) + " " + dlugosc + nota );
- }
- DataModule2->IBTable1->Next();
- }
- C:
- int i;
- String s;
- float wartosc;
- Form5->Memo1->Clear();
- DataModule2->IBTable1->First();
- if (Edit2->Text == "") {
- ShowMessage("Nie podano wartosci");
- }
- else
- {
- while(!DataModule2->IBTable1->Eof)
- {
- if (DataModule2->IBTable1->Fields->Fields[3]->AsFloat < StrToFloat(Edit2->Text)) {
- wartosc = DataModule2->IBTable1->Fields->Fields[3]->AsFloat * DataModule2->IBTable1->Fields->Fields[2]->AsFloat;
- s = DataModule2->IBTable1->Fields->Fields[0]->AsString + " " + DataModule2->IBTable1->Fields->Fields[3]->AsString + " " + DataModule2->IBTable1->Fields->Fields[2]->AsString;
- Form5->Memo1->Lines->Add(s + " " + FloatToStr(wartosc));
- }
- DataModule2->IBTable1->Next();
- }
- Form5->ShowModal();
- }
- A: !!!!!!!!!!!!!!!!!!!!!!!!!!!!
- DRUGI:
- int pom1, pom2, srch, srdz, lchlopcy=0, ldziewczynki=0, sumawagchl=0, sumawagdzw=0 ;
- IBTable1->First();
- while (!IBTable1->Eof)
- {
- if (IBTable1->Fields->Fields[4]->AsInteger > StrToInt(Edit1->Text))
- {
- if (IBTable1->Fields->Fields[3]->AsString=="K")
- {
- pom1=IBTable1->Fields->Fields[5]->AsInteger;
- sumawagdzw = sumawagdzw+pom1;
- ldziewczynki++;
- }
- else if
- (IBTable1->Fields->Fields[3]->AsString=="M")
- {
- lchlopcy++;
- pom2=IBTable1->Fields->Fields[5]->AsInteger;
- sumawagchl = sumawagchl+pom2;
- }
- }
- IBTable1->Next();
- }
- if (ldziewczynki == 0) {
- Form3->Label4->Caption=0;
- }
- else Form3->Label4->Caption=IntToStr(sumawagdzw/ldziewczynki);
- if (lchlopcy == 0) {
- Form3->Label5->Caption=0;
- }
- else Form3->Label5->Caption=IntToStr(sumawagchl/lchlopcy);
- chlopcy = StrToInt(Form3->Label5->Caption);
- dziewczynki = StrToInt(Form3->Label4->Caption);
- Form3->Show();
- PRZYCISK 3 :
- IBTable1->First();
- while (!IBTable1->Eof)
- {
- if(IBTable1->Fields->Fields[3]->AsString=="K" && IBTable1->Fields->Fields[5]->AsInteger >= dziewczynki)
- {
- String s;
- s = (IBTable1->Fields->Fields[0]->AsString + " " + IBTable1->Fields->Fields[1]->AsString +
- " " + IBTable1->Fields->Fields[2]->AsString + " " + IBTable1->Fields->Fields[4]->AsString +
- " " + IBTable1->Fields->Fields[5]->AsString);
- Form4->Memo1->Lines->Add(s);
- }
- if(IBTable1->Fields->Fields[3]->AsString=="M" && IBTable1->Fields->Fields[5]->AsInteger >= chlopcy)
- {
- String s;
- s = (IBTable1->Fields->Fields[0]->AsString + " " + IBTable1->Fields->Fields[1]->AsString +
- " " + IBTable1->Fields->Fields[2]->AsString + " " + IBTable1->Fields->Fields[4]->AsString +
- " " + IBTable1->Fields->Fields[5]->AsString);
- Form4->Memo1->Lines->Add(s);
- }
- IBTable1->Next();
- }
- Form4->Show();
- WARUNKI: !!!!!!!!!!!!!!!!!!!!!!!!
- if(DBEdit1->Field->AsString == "")
- {
- ShowMessage("Pole Nazwa musi byc wypelnione");
- DBEdit1->SetFocus();
- return;
- }
- if(DBEdit2->Field->AsString == "")
- {
- ShowMessage("Pole Jednostka musi byc wypelnione");
- DBEdit2->SetFocus();
- return;
- }
- if((DBEdit3->Field->AsString == "") || (DBEdit3->Field->AsInteger < 0))
- {
- ShowMessage("Pole Ilosc musi byc wypelnione i nieujemne");
- DBEdit3->SetFocus();
- return;
- }
- if((DBEdit4->Field->AsString == "") || (DBEdit4->Field->AsFloat < 0))
- {
- ShowMessage("Pole Cena musi byc wypelnione i nieujemne");
- DBEdit4->SetFocus();
- return;
- }
- DataModule2->IBTable1->Post();
- Close();
- ---Łączenie z bazą---
- IBDatabase1:
- DatabaseName: nazwa i ścieżka pliku bazy
- DefaultTransaction: wybrać IBTransaction1
- Connected: True
- IBTable1:
- DataBase: wybrać IBDatabase1
- TableName: wybrać DRUZYNY
- Active: True
- IBTable2:
- DataBase: wybrać IBDatabase1
- TableName: wybrać ZAWODNICY
- Active: True
- DataSource1:
- DataSet: wybrać IBTable1
- DataSource2:
- DataSet: wybrać IBTable2
- DBGrid1:
- DataSource: wybrać DataSource1
- DBGrid2:
- DataSource: wybrać DataSource2
- Label1:
- Caption: ‘Tabela DRUZYNY’
- Label2:
- Caption: ‘Tabela ZAWODNICY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement