Приложение а. текст программы

Аннотация

Текст программы – это последовательность инструкций, определяющих процедуру решения конкретной задачи компьютером.

Таблица 1 - Модули программы

Наименование Размер строк Назначение
AdminUnit Данный модуль является формой администратора, в нём можно измерять данные о пользователях, удалять учётные записи, а так же добавлять новые.
AuthorizationUnit Данный модуль является формой авторизацией в системе.
MainUnit Данный модуль является связывающим.
PolzovatelUnit Данный модуль хранит в себе записи пользователей.
PosechaemostUnit Данный модуль является основным и отвечает за работоспособность приложения.
DMUnit Данный модуль отвечает за привязку базы данных к приложению.

Текст модуля AdminUnit

unit AdminUnit;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, ComCtrls, ExtCtrls, DBCtrls, StdCtrls;

type

TForm3 = class(TForm)

Panel1: TPanel;

PageControl1: TPageControl;

TabSheet1: TTabSheet;

TabSheet2: TTabSheet;

TabSheet3: TTabSheet;

TabSheet4: TTabSheet;

TabSheet5: TTabSheet;

TabSheet6: TTabSheet;

DBGrid1: TDBGrid;

DBGrid2: TDBGrid;

DBNavigator1: TDBNavigator;

DBGrid3: TDBGrid;

DBNavigator2: TDBNavigator;

DBGrid4: TDBGrid;

ComboBox1: TComboBox;

DBNavigator3: TDBNavigator;

DBGrid5: TDBGrid;

DBGrid6: TDBGrid;

DBNavigator4: TDBNavigator;

DBNavigator5: TDBNavigator;

DBGrid7: TDBGrid;

DBNavigator6: TDBNavigator;

Label1: TLabel;

DBNavigator7: TDBNavigator;

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure TabSheet3Show(Sender: TObject);

procedure ComboBox1Change(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

implementation

uses DMUnit, MainUnit;

{$R *.dfm}

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);

begin

form1.show;

end;

procedure TForm3.TabSheet3Show(Sender: TObject);

begin

ComboBox1.Clear;

DM.GRUPP.First;

while not DM.GRUPP.Eof do

begin

ComboBox1.Items.Add(DM.GRUPP.FieldValues['NAZVANIE_GRUPP']);

DM.GRUPP.Next;

end;

end;

procedure TForm3.ComboBox1Change(Sender: TObject);

var

res : variant;

begin

res:= DM.GRUPP.Lookup('NAZVANIE_GRUPP',ComboBox1.Text,'ID_GRUPP') ;

DM.STUDENT.Filter:='ID_GRUPP = '+ IntToStr(res);

DM.STUDENT.Filtered:=true;

end;

end.

Текст модуля AuthorizationUnit

unit AuthorezationUnit;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm2 = class(TForm)

Panel1: TPanel;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Button1: TButton;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form2: TForm2;

implementation

uses MainUnit, DMUnit;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);

begin

DM.POLZOVATEL.Insert;

DM.POLZOVATEL.FieldByName('LOGIN').asstring:= Edit2.Text;

DM.POLZOVATEL.FieldByName('PASSWORD').asstring:= Edit3.Text;

DM.POLZOVATEL.FieldByName('FIO').asstring:= Edit1.Text;

DM.POLZOVATEL.FieldByName('ROL').asinteger:= 2;

DM.POLZOVATEL.Post;

Form2.Hide;

Form1.Show;

end;

end.

Текст модуля MainUnit

unit MainUnit;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

Panel1: TPanel;

Edit1: TEdit;

Edit2: TEdit;

Label1: TLabel;

Label2: TLabel;

Button1: TButton;

Button2: TButton;

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses DMUnit, AuthorezationUnit, AdminUnit, PolzovatelUnit;

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);

begin

form1.Hide;

form2.Show;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

res: variant;

begin

res:=DM.POLZOVATEL.Lookup('LOGIN;PASSWORD',VarArrayOf([Edit1.Text, Edit2.Text]),'ROL');

if VarIsNull(res) then

begin

showmessage ('не правильный логин или пароль');

exit;

end;

if res = 1 then

begin

Edit1.Clear;

Edit2.Clear;

Form1.Hide;

Form3.Show;

end

else

begin

Edit1.Clear;

Edit2.Clear;

Form1.Hide;

Form4.Show;

end;

end;

end.

Текст модуля PolzovatelUnit

unit PolzovatelUnit;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ComCtrls, Grids, DBGrids;

type

TForm4 = class(TForm)

PageControl1: TPageControl;

TabSheet1: TTabSheet;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

DateTimePicker1: TDateTimePicker;

ComboBox1: TComboBox;

ComboBox2: TComboBox;

ComboBox3: TComboBox;

ComboBox4: TComboBox;

ComboBox5: TComboBox;

Edit1: TEdit;

Button1: TButton;

DBGrid1: TDBGrid;

procedure FormShow(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure ComboBox2Change(Sender: TObject);

procedure ComboBox4Change(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form4: TForm4;

implementation

uses DMUnit, MainUnit;

{$R *.dfm}

procedure TForm4.FormShow(Sender: TObject);

begin

ComboBox4.Clear;

DM.GRUPP.First;

while not DM.GRUPP.Eof do

begin

ComboBox4.Items.Add(DM.GRUPP.FieldValues['NAZVANIE_GRUPP']);

DM.GRUPP.Next;

end;

ComboBox2.Clear;

DM.PREPODAVATEL.First;

while not DM.PREPODAVATEL.Eof do

begin

ComboBox2.Items.Add(DM.PREPODAVATEL.FieldValues['FIO']);

DM.PREPODAVATEL.Next;

end;

ComboBox3.Clear;

end;

procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Form1.Show;

end;

procedure TForm4.ComboBox2Change(Sender: TObject);

var

res : variant;

begin

ComboBox3.Clear;

res:= DM.PREPODAVATEL.Lookup('FIO',ComboBox2.Text,'ID_PREPODAVATEL') ;

DM.PP.Filter:='PREPODAVATEL_ID = ' + inttostr(res);

DM.PP.Filtered:=true;

Dm.PP.First;

while not DM.PP.Eof do

begin

ComboBox3.Items.Add(DM.PREDMET.Lookup('ID_PREDMET',DM.PP.FieldValues['PREDMET_ID'],'NAZVANIE'));

DM.PP.Next;

end;

end;

procedure TForm4.ComboBox4Change(Sender: TObject);

var

res : variant;

begin

ComboBox5.Clear;

res:= DM.GRUPP.Lookup('NAZVANIE_GRUPP',ComboBox4.Text,'ID_GRUPP') ;

DM.STUDENT.Filter:='ID_GRUPP = ' + inttostr(res);

DM.STUDENT.Filtered:=true;

Dm.STUDENT.First;

while not DM.STUDENT.Eof do

begin

ComboBox5.Items.Add(DM.STUDENT.FieldValues['FIO']);

DM.STUDENT.Next;

end;

end;

procedure TForm4.Button1Click(Sender: TObject);

var

prep, stud, pred : variant;

begin

prep:= DM.PREPODAVATEL.Lookup('FIO',ComboBox2.Text,'ID_PREPODAVATEL') ;

stud:= DM.STUDENT.Lookup('FIO',ComboBox5.Text,'ID_STUDENT') ;

pred:= DM.PREDMET.Lookup('NAZVANIE',ComboBox3.Text,'ID_PREDMET') ;

DM.POSECAEMOST.Insert;

DM.POSECAEMOST.FieldByName('DATA').AsDateTime:=DateTimePicker1.DateTime;

DM.POSECAEMOST.FieldByName('PARA').Asstring:=ComboBox1.Text;

DM.POSECAEMOST.FieldByName('PREDMET_ID').AsInteger:=pred;

DM.POSECAEMOST.FieldByName('STUDENT_ID').AsInteger:=stud;

DM.POSECAEMOST.FieldByName('PREPODAVATEL_ID').AsInteger:=prep;

DM.POSECAEMOST.FieldByName('PRICHINA').AsString:=Edit1.Text;

DM.POSECAEMOST.Post;

DBGrid1.Refresh;

end;

end.

Текст модуля PosechaemostUnit

program Posechaemost;

uses

Forms,

MainUnit in 'MainUnit.pas' {Form1},

DMUnit in 'DMUnit.pas' {DM: TDataModule},

AuthorezationUnit in 'AuthorezationUnit.pas' {Form2},

AdminUnit in 'AdminUnit.pas' {Form3},

PolzovatelUnit in 'PolzovatelUnit.pas' {Form4};

{$R *.res}

begin

Application.Initialize;

Application.CreateForm(TForm1, Form1);

Application.CreateForm(TDM, DM);

Application.CreateForm(TForm2, Form2);

Application.CreateForm(TForm3, Form3);

Application.CreateForm(TForm4, Form4);

Application.Run;

end.

Текст модуля DMUnit

unit DMUnit;

interface

uses

SysUtils, Classes, DB, IBCustomDataSet, IBTable, IBDatabase;

type

TDM = class(TDataModule)

IBDatabase1: TIBDatabase;

IBTransaction1: TIBTransaction;

POLZOVATEL: TIBTable;

GRUPP: TIBTable;

OTDELENIE: TIBTable;

POSECAEMOST: TIBTable;

PREDMET: TIBTable;

STUDENT: TIBTable;

dsPolzovatel: TDataSource;

dsGrupp: TDataSource;

dsOtdelenie: TDataSource;

dsPosecaemost: TDataSource;

dsPredmet: TDataSource;

dsStudent: TDataSource;

POLZOVATELID_POLZOVATEL: TIntegerField;

POLZOVATELLOGIN: TIBStringField;

POLZOVATELPASSWORD: TIBStringField;

POLZOVATELFIO: TIBStringField;

POLZOVATELROL: TSmallintField;

GRUPPID_GRUPP: TIntegerField;

GRUPPID_OTDELENIE: TIntegerField;

GRUPPNAZVANIE_GRUPP: TIBStringField;

PREPODAVATEL: TIBTable;

PREPODAVATELID_PREPODAVATEL: TIntegerField;

PREPODAVATELFIO: TIBStringField;

dsPrepodavatel: TDataSource;

PP: TIBTable;

dsPp: TDataSource;

PPID_PP: TIntegerField;

PPPREPODAVATEL_ID: TIntegerField;

PPPREDMET_ID: TIntegerField;

PREDMETID_PREDMET: TIntegerField;

PREDMETNAZVANIE: TIBStringField;

POSECAEMOSTID_POSECHAEMOST: TIntegerField;

POSECAEMOSTDATA: TDateField;

POSECAEMOSTPARA: TIntegerField;

POSECAEMOSTPREDMET_ID: TIntegerField;

POSECAEMOSTSTUDENT_ID: TIntegerField;

POSECAEMOSTPREPODAVATEL_ID: TIntegerField;

POSECAEMOSTPRICHINA: TIBStringField;

POSECAEMOSTFIO_STUDENTA: TStringField;

STUDENTID_STUDENT: TIntegerField;

STUDENTFIO: TIBStringField;

STUDENTID_GRUPP: TIntegerField;

OTDELENIEID_OTDELENIE: TIntegerField;

OTDELENIENAZVANIE: TIBStringField;

GRUPPNAZVANIE_OTDELENIYA: TStringField;

STUDENTNAZVANIE_GRUPP: TStringField;

PPFIO_PREPODAVATEL: TStringField;

PPNAZVANIE_PREDMETA: TStringField;

private

{ Private declarations }

public

{ Public declarations }

end;

var

DM: TDM;

implementation

{$R *.dfm}

end.

Наши рекомендации