
- •Void __fastcall tForm1::FormCreate(tObject *Sender)
- •Void __fastcall tForm1::bCloseClick(tObject *Sender)
- •Void __fastcall tForm1::FormCreate(tObject *Sender)
- •Void __fastcall tForm1::bCloseClick(tObject *Sender)
- •Void __fastcall tForm1::RadioGroup1Click(tObject *Sender)
- •Void __fastcall tForm1::FormCreate(tObject *Sender)
- •Void __fastcall tForm1::bCloseClick(tObject *Sender)
- •Void __fastcall tForm1::RadioGroup1Click(tObject *Sender)
- •Void __fastcall tForm1::FormCreate(tObject *Sender)
Лабораторная работа №1
Внешний вид формы программы:
Листинг кода :
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
tSpisok->Open();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::bCloseClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
Лабораторная работа №2
Внешний вид формы программы:
Листинг кода :
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
Void __fastcall tForm1::FormCreate(tObject *Sender)
{
tSpisok->Open();
}
//---------------------------------------------------------------------------
Void __fastcall tForm1::bCloseClick(tObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioGroup1Click(TObject *Sender)
{ switch (RadioGroup1->ItemIndex)
{ case 0:{tSpisok->IndexName="";break;}
case 1:tSpisok->IndexName="indSpisokFIO";break;
case 2:tSpisok->IndexName="indSpisokGodPost";break;
case 3:tSpisok->IndexName="indSpisokGodRoj";break;
case 4:tSpisok->IndexName="indSpisokSredBall";break;
case 5:tSpisok->IndexName="indSpisokSpec";break;
}//конец switch
}
//---------------------------------------------------------------------------
Лабораторная работа №3
Внешний вид формы программы:
Лабораторная работа №4
Внешний вид формы программы:
Листинг кода лаборат. работ №3,4.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void KolichStud()
{ Form1->Label11->Caption="Всего студентов "+
IntToStr(Form1->tSpisok->RecordCount);
}
//---------------------------------------------------------------------------
boolean Proverka1(AnsiString sp,AnsiString sr)
{int gr,gp; AnsiString s;
s=Trim(sp);
if (s.Length()==0)
{ShowMessage("Не заполнено поле <Год поступления>");
return false;}
gp=StrToInt(s);
if ((gp>2010)||(gp<1990)||(gp==0))
{ShowMessage("Нереальный год поступления"+IntToStr(gp));
return false;}
s=Trim(sr);
if (s.Length()==0)
{ShowMessage("Не заполнено поле <Год рождения>");
return false;}
gp=StrToInt(s);
if ((gp>=1995)||(gp<1950)||(gp==0))
{ShowMessage("Нереальный год рождения"+IntToStr(gp));
return false;}
return true;
}
//---------------------------------------------------------------------------
Void __fastcall tForm1::FormCreate(tObject *Sender)
{
tSpisok->Open();
KolichStud();
}
//---------------------------------------------------------------------------
Void __fastcall tForm1::bCloseClick(tObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
Void __fastcall tForm1::RadioGroup1Click(tObject *Sender)
{ switch (RadioGroup1->ItemIndex)
{ case 0:{tSpisok->IndexName="";break;}
case 1:tSpisok->IndexName="indSpisokFIO";break;
case 2:tSpisok->IndexName="indSpisokGodPost";break;
case 3:tSpisok->IndexName="indSpisokGodRoj";break;
case 4:tSpisok->IndexName="indSpisokSredBall";break;
case 5:tSpisok->IndexName="indSpisokSpec";break;
}//конец switch
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int NewShifr;
Panel1->Show();Panel2->Hide();
tSpisok->IndexName="";//устанавливаем главный индекс, чтобы получить значение наибольшего шифра
tSpisok->Last();//наибольший шифр в последней записи
NewShifr=tSpisok->FieldByName("Shifr")->AsInteger+1;
Edit1->Text=IntToStr(NewShifr);//записали новый уникальный шифр в Edit1
// очищаем остальные окна ввода
Edit2->Text="";Edit3->Text="0";Edit4->Text="0";
tSpisok->Insert();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
{ Panel1->Hide();Panel2->Show();
tSpisok->Edit();
Edit5->Text=tSpisok->FieldByName("Shifr")->AsString;
Edit6->Text=tSpisok->FieldByName("FIO")->AsString;
Edit7->Text=tSpisok->FieldByName("GodPost")->AsString;
Edit8->Text=tSpisok->FieldByName("GodRoj")->AsString;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
tSpisok->Cancel();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
tSpisok->Cancel();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
tSpisok->FieldByName("Shifr")->AsString=Edit1->Text;
tSpisok->FieldByName("FIO")->AsString= Edit2->Text;
tSpisok->FieldByName("GodPost")->AsString= Edit3->Text;
tSpisok->FieldByName("GodRoj")->AsString= Edit4->Text;
tSpisok->Post();
KolichStud();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
tSpisok->FieldByName("Shifr")->AsString=Edit5->Text;
tSpisok->FieldByName("FIO")->AsString= Edit6->Text;
tSpisok->FieldByName("GodPost")->AsString= Edit7->Text;
tSpisok->FieldByName("GodRoj")->AsString= Edit8->Text;
tSpisok->Post();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if ( MessageDlg("Подтвердите удаление записи\n "+tSpisok->FieldByName("FIO")->AsString,
mtConfirmation, TMsgDlgButtons()<< mbYes<< mbNo,0)==mrYes)
{ tSpisok->Delete();Beep();}
KolichStud();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key)
{
if (((Key>='0')&&(Key<='9'))||(Key==8)) return;
else Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit4KeyPress(TObject *Sender, char &Key)
{
if (((Key>='0')&&(Key<='9'))||(Key==8)) return;
else Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit7KeyPress(TObject *Sender, char &Key)
{
if (((Key>='0')&&(Key<='9'))||(Key==8)) return;
else Key=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit8KeyPress(TObject *Sender, char &Key)
{
if (((Key>='0')&&(Key<='9'))||(Key==8)) return;
else Key=0;
}
//---------------------------------------------------------------------------
Лабораторная работа №5
Внешний вид формы программы:
Листинг кода :
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------
Лабораторная работа №6,7
Внешний вид формы программы:
Листинг кода :
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void KolichStud()
{ Form1->Label11->Caption="Всего студентов "+
IntToStr(Form1->tSpisok->RecordCount);
}
//---------------------------------------------------------------------------
boolean Proverka1(AnsiString sp,AnsiString sr)
{int gr,gp; AnsiString s;
s=Trim(sp);
if (s.Length()==0)
{ShowMessage("Не заполнено поле <Год поступления>");
return false;}
gp=StrToInt(s);
if ((gp>2010)||(gp<1990)||(gp==0))
{ShowMessage("Нереальный год поступления"+IntToStr(gp));
return false;}
s=Trim(sr);
if (s.Length()==0)
{ShowMessage("Не заполнено поле <Год рождения>");
return false;}
gp=StrToInt(s);
if ((gp>=1995)||(gp<1950)||(gp==0))
{ShowMessage("Нереальный год рождения"+IntToStr(gp));
return false;}
return true;
}
//---------------------------------------------------------------------------