Разработка информационно-справочной системы по учету вагонов на подъездном пути предприятия

Детальная разработка информационно-справочной системы по учету железнодорожных вагонов на подъездном пути предприятия с целью автоматизации обработки информации по вагонам и расчета затрат на обслуживание подвижного состава. Проект модели базы данных.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 20.10.2008
Размер файла 1,4 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

end;

end.

unit Unit4;

interface

Uses ADODB;

var QueryString, TBL, pole1, pole2, Pole3, pole4, Pole5, pole6 : string;

pole7, pole8, pole9, pole10, pole11, pole12, pole13 : string;

ToIns, ToIns2, ToIns3, ToIns4, ToIns5, ToIns6, ToIns7, ToIns8 : string;

ToIns9, ToIns10, ToIns11, ToIns12, ToIns13, ForDel, ForEdit, ForOrder, Diap, TmpFiltr : string;

InsEdit,InsEdit2,InsEdit3,InsEdit4,InsEdit5 : boolean;

SelectQ : TADOQuery;

EditMode, ForSort, ForFiltr, EditMode2, EditMode3, EditMode4, EditIns, EditIns2 : boolean;

Procedure ShowZapros();

Procedure InsertZapros();

Procedure DelZapros();

Procedure SelTab();

Procedure ForReport();

implementation

Uses Dialogs, Unit2, Unit5, Unit6, Unit3, Unit7, Unit8, Unit1, Unit9, Unit10, DB;

Procedure ShowZapros();

var Polya, Tabli, Svyaz, MyKey : String;

begin

if ((Tbl='Operation')or(Tbl='Station')or(Tbl='Ceha')or

(Tbl='Front')or(Tbl='Gruz')or(Tbl='Rod_vagona')or

(Tbl='Raion_dvizheniya')or(Tbl='Ves')or(Tbl='Vid_uslug')) then

begin

QueryString := 'select * from ' + TBL + ' order by ' + pole2;

SelectQ := DataModule2.Query1;

end;

if (Tbl='Vagon') then

begin

QueryString := 'select * from Vagon V, Rod_vagona RV, Raion_dvizheniya RD where V.key_rod_vagona=RV.id and V.key_raion_dvizh=RD.id order by invent_nomer desc';

SelectQ := DataModule2.QShow;

end;

if (Tbl='Operations_s_vagonom') then

begin

MyKey := DataModule2.Qshow['v.id'];

SelectQ := DataModule2.QOSV;

Polya := 'OSV.*, SNACH.*, SKON.*, FNACH.*, FKON.*, O.*, G.*';

Tabli := 'vagon V, station SNACH, station SKON, front FNACH, front FKON, operation O, gruz G, Operations_s_vagonom OSV';

Svyaz:= 'OSV.key_station_otpr=SNACH.id and OSV.key_front_otpr=FNACH.id and OSV.key_station_naznach=SKON.id and OSV.key_front_naznach=FKON.id and OSV.key_operation=O.id and OSV.key_gruz=G.id and OSV.key_vagon=V.id and OSV.key_vagon=' + MyKey;

QueryString := 'select '+Polya+' from '+Tabli+' where '+Svyaz;

end;

if (Tbl='Uslugi_sv') then

begin

MyKey := DataModule2.QOSV['OSV.id'];

SelectQ := DataModule2.Quslugi;

Polya := 'USV.*, CNA.*, CS.*, ST.*, VU.*, V.*';

Tabli := 'Ceha CNA, Ceha CS, Uslugi_sv USV, Operations_s_vagonom OSV, Stoimost ST, Vid_uslug VU, Ves V';

Svyaz:= 'USV.key_uslugi=ST.id and USV.key_na=CNA.id and USV.key_s=CS.id and USV.key_vagon=OSV.id and ST.key_vid_uslug=VU.id and ST.key_ves=V.id and USV.key_vagon=' + MyKey;

QueryString := 'select '+Polya+' from '+Tabli+' where '+Svyaz;

end;

if (Tbl='Stoimost') then

begin

SelectQ := DataModule2.QSelUs;

Polya := ' VU.*, V.*, ST.*';

Tabli := 'Vid_uslug VU, Ves V, Stoimost ST';

Svyaz:= 'ST.key_vid_uslug=VU.id and ST.key_ves=V.id';

QueryString := 'select '+Polya+' from '+Tabli+' where '+Svyaz;

end;

with SelectQ do

begin

Close;

SQL.Clear;

SQL.Add(QueryString);

Open;

end;

if (Tbl='Vagon') then

begin

SelectQ.Fields[0].Visible := false;

SelectQ.Fields[7].Visible := false;

SelectQ.Fields[9].Visible := false;

SelectQ.Fields[10].Visible := false;

SelectQ.Fields[12].Visible := false;

Form1.DBGrid1.Columns[0].Title.Caption :='Месяц';

Form1.DBGrid1.Columns[1].Title.Caption :='Год';

Form1.DBGrid1.Columns[2].Title.Caption :='№ вагона';

Form1.DBGrid1.Columns[3].Title.Caption :='Инв. №';

Form1.DBGrid1.Columns[4].Title.Caption :='Изгот.';

Form1.DBGrid1.Columns[5].Title.Caption :='Грузопод. т.';

Form1.DBGrid1.Columns[6].Title.Caption :='Износ %';

Form1.DBGrid1.Columns[7].Title.Caption :='Род вагона';

Form1.DBGrid1.Columns[8].Title.Caption :='Район движения';

end;

if (Tbl='Operations_s_vagonom') then

begin

SelectQ.Fields[0].Visible := false;

SelectQ.Fields[1].Visible := false;

SelectQ.Fields[2].Visible := false;

SelectQ.Fields[3].Visible := false;

SelectQ.Fields[4].Visible := false;

SelectQ.Fields[7].Visible := false;

SelectQ.Fields[8].Visible := false;

SelectQ.Fields[12].Visible := false;

SelectQ.Fields[13].Visible := false;

SelectQ.Fields[15].Visible := false;

SelectQ.Fields[17].Visible := false;

SelectQ.Fields[19].Visible := false;

SelectQ.Fields[21].Visible := false;

SelectQ.Fields[23].Visible := false;

Form6.DBGrid1.Columns[0].Title.Caption :='Дата';

Form6.DBGrid1.Columns[1].Title.Caption :='Время';

Form6.DBGrid1.Columns[2].Title.Caption :='Вес';

Form6.DBGrid1.Columns[3].Title.Caption :='№ дор. вед.';

Form6.DBGrid1.Columns[4].Title.Caption :='№ вед.';

Form6.DBGrid1.Columns[5].Title.Caption :='Станция отпр.';

Form6.DBGrid1.Columns[6].Title.Caption :='Станция пол.';

Form6.DBGrid1.Columns[7].Title.Caption :='Фронт отпр.';

Form6.DBGrid1.Columns[8].Title.Caption :='Фронт пол.';

Form6.DBGrid1.Columns[9].Title.Caption :='Операция';

Form6.DBGrid1.Columns[10].Title.Caption :='Груз';

end;

if (Tbl='Uslugi_sv') then

begin

SelectQ.Fields[0].Visible := false;

SelectQ.Fields[2].Visible := false;

SelectQ.Fields[3].Visible := false;

SelectQ.Fields[4].Visible := false;

SelectQ.Fields[5].Visible := false;

SelectQ.Fields[7].Visible := false;

SelectQ.Fields[10].Visible := false;

SelectQ.Fields[13].Visible := false;

SelectQ.Fields[14].Visible := false;

SelectQ.Fields[15].Visible := false;

SelectQ.Fields[17].Visible := false;

SelectQ.Fields[19].Visible := false;

Form7.DBGrid1.Columns[0].Title.Caption :='Заказ';

Form7.DBGrid1.Columns[1].Title.Caption :='Стоимость заказа';

Form7.DBGrid1.Columns[2].Title.Caption :='№ цеха исп.';

Form7.DBGrid1.Columns[3].Title.Caption :='БС ц.и.';

Form7.DBGrid1.Columns[4].Title.Caption :='№ цеха заказ.';

Form7.DBGrid1.Columns[5].Title.Caption :='БС ц.з.';

Form7.DBGrid1.Columns[6].Title.Caption :='Стоим. усл.';

Form7.DBGrid1.Columns[7].Title.Caption :='Вид услуги';

Form7.DBGrid1.Columns[8].Title.Caption :='Единица измерения';

end;

if (Tbl='Stoimost') then

begin

SelectQ.Fields[0].Visible := false;

SelectQ.Fields[2].Visible := false;

SelectQ.Fields[4].Visible := false;

SelectQ.Fields[5].Visible := false;

SelectQ.Fields[6].Visible := false;

Form8.DBGrid1.Columns[0].Title.Caption :='Вид услуги';

Form8.DBGrid1.Columns[1].Title.Caption :='Единица измерения';

Form8.DBGrid1.Columns[2].Title.Caption :='Стоимость';

end;

if ((Tbl='Operation')or(Tbl='Station')or(Tbl='Ceha')or

(Tbl='Front')or(Tbl='Gruz')or(Tbl='Rod_vagona')or

(Tbl='Raion_dvizheniya')or(Tbl='Ves')or(Tbl='Vid_uslug')) then

begin

SelectQ.Fields[0].Visible := false;

Form3.DBGrid1.Columns[0].Title.Caption := Form3.Label1.Caption;

If (tbl='Ceha') then

begin

Form3.DBGrid1.Columns[1].Title.Caption := Form3.Label2.Caption;

end;

end;

end;

Procedure InsertZapros();

var

QueryString, Polya: string;

YN : Boolean;

begin

YN := false;

if ((Tbl='Operation')or(Tbl='Station')or(Tbl='Ceha')or

(Tbl='Front')or(Tbl='Gruz')or(Tbl='Rod_vagona')or

(Tbl='Raion_dvizheniya')or(Tbl='Ves')or(Tbl='Vid_uslug')) then

begin

SelectQ := DataModule2.Query1;

with DataModule2.Query1 do

begin

First;

while (not Eof) do

begin

if (ForEdit <> SelectQ['id']) then

begin

if DataModule2.Query1[pole2] = ToIns then

begin

YN:=true;

Break;

end;

end;

Next;

end;

end;

if InsEdit then

begin

If (tbl='Ceha') then

begin

QueryString := 'UPDATE '+TBL+' SET '+pole2+'='+#39+ToIns+#39+','+pole3+'='+#39+ToIns2+#39+ ' where '+pole1+'='+ForEdit;

end

else

begin

QueryString := 'UPDATE '+TBL+' SET '+pole2+'='+#39+ToIns+#39+' where '+pole1+'='+ForEdit;

end;

InsEdit := false;

end

else

begin

If (tbl='Ceha') then

begin

QueryString := 'insert into '+ TBL +' ('+pole2+','+pole3+') values ('+#39+ToIns+#39+','+#39+ToIns2+#39+')';

end

else

begin

QueryString := 'insert into '+ TBL +' ('+pole2+') values ('+#39+ToIns+#39+')';

end;

end;

end;

if (Tbl='Stoimost') then

begin

SelectQ := DataModule2.QSelUs;

pole1 := 'id';

pole2 := 'key_vid_uslug';

pole3 := 'key_ves';

pole4 := 'stoimost';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

with SelectQ do

begin

First;

while (not Eof) do

begin

if (ForEdit <> SelectQ['ST.id']) then

begin

if ((SelectQ[pole2] = ToIns)and(SelectQ[pole3] = ToIns2)) then

begin

YN:=true;

Break;

end;

end;

Next;

end;

end;

if InsEdit2 then

begin

QueryString := 'UPDATE '+TBL+' SET '+pole2+'='+#39+ToIns+#39+','+pole3+'='+#39+ToIns2+#39+','+pole4+'='+#39+ToIns3+#39+' where '+pole1+'='+ForEdit;

InsEdit2 := false;

end

else

QueryString := 'insert into '+ TBL +' ('+pole2+','+pole3+','+pole4+') values ('+#39+ToIns+#39+','+#39+ToIns2+#39+','+#39+ToIns3+#39+')';

end;

if (Tbl='Vagon') then

begin

pole1 := 'id';

pole2 := 'mymonth';

pole3 := 'myyear';

pole4 := 'nomer_vagona';

pole5 := 'invent_nomer';

pole6 := 'year_izgot';

pole7 := 'gruzopodemnost';

pole8 := 'key_rod_vagona';

pole9 := 'iznos';

pole10 := 'key_raion_dvizh';

pole11 := '';

pole12 := '';

pole13 := '';

SelectQ := DataModule2.QShow;

with SelectQ do

begin

First;

while (not Eof) do

begin

if (ForEdit <> SelectQ['v.id']) then

begin

if (SelectQ[pole5] = ToIns4) then

begin

YN:=true;

Break;

end;

end;

Next;

end;

end;

if InsEdit3 then

begin

QueryString := 'UPDATE '+TBL+' SET '+pole2+'='+#39+ToIns+#39+','+pole3+'='+#39+ToIns2+#39+','+pole4+'='+#39+ToIns3+#39+','+pole5+'='+#39+ToIns4+#39+','+pole6+'='+#39+ToIns5+#39+','+pole7+'='+#39+ToIns6+#39+','+pole8+'='+#39+ToIns7+#39+','+pole9+'='+#39+ToIns8+#39+','+pole10+'='+#39+ToIns9+#39+' where '+pole1+'='+ForEdit;

InsEdit3 := false;

end

else

QueryString := 'insert into '+ TBL +' ('+pole2+', '+pole3+', '+pole4+', '+pole5+', '+pole6+', '+pole7+', '+pole8+', '+pole9+', '+pole10+') values ('+#39+ToIns+#39+', '+#39+ToIns2+#39+', '+#39+ToIns3+#39+', '+#39+ToIns4+#39+', '+#39+ToIns5+#39+', '+#39+ToIns6+#39+', '+#39+ToIns7+#39+', '+#39+ToIns8+#39+', '+#39+ToIns9+#39+')';

end;

if (Tbl='Operations_s_vagonom') then

begin

SelectQ := DataModule2.QOSV;

pole1 := 'id';

pole2 := 'key_station_otpr';

pole3 := 'key_front_otpr';

pole4 := 'key_station_naznach';

pole5 := 'key_front_naznach';

pole6 := 'mydate';

pole7 := 'mytime';

pole8 := 'key_operation';

pole9 := 'key_gruz';

pole10 := 'weight';

pole11 := 'n_dor_ved';

pole12 := 'n_ved';

pole13 := 'key_vagon';

with SelectQ do

begin

First;

while (not Eof) do

begin

if (ForEdit <> SelectQ['OSV.id']) then

begin

if ((SelectQ[pole11] = ToIns10)and(SelectQ[pole12] = ToIns11)) then

begin

YN:=true;

Break;

end;

end;

Next;

end;

end;

if InsEdit4 then

begin

QueryString := 'UPDATE '+TBL+' SET '+pole2+'='+#39+ToIns+#39+','+pole3+'='+#39+ToIns2+#39+','+pole4+'='+#39+ToIns3+#39+','+pole5+'='+#39+ToIns4+#39+','+pole6+'='+#39+ToIns5+#39+','+pole7+'='+#39+ToIns6+#39+','+pole8+'='+#39+ToIns7+#39+','+pole9+'='+#39+ToIns8+#39+','+pole10+'='+#39+ToIns9+#39+','+pole11+'='+#39+ToIns10+#39+','+pole12+'='+#39+ToIns11+#39+','+pole13+'='+#39+ToIns12+#39+' where '+pole1+'='+ForEdit;

InsEdit4 := false;

end

else

QueryString := 'insert into '+ TBL +' ('+pole2+', '+pole3+', '+pole4+', '+pole5+', '+pole6+', '+pole7+', '+pole8+', '+pole9+', '+pole10+', '+pole11+', '+pole12+', '+pole13+') values ('+#39+ToIns+#39+', '+#39+ToIns2+#39+', '+#39+ToIns3+#39+', '+#39+ToIns4+#39+', '+#39+ToIns5+#39+', '+#39+ToIns6+#39+', '+#39+ToIns7+#39+', '+#39+ToIns8+#39+', '+#39+ToIns9+#39+', '+#39+ToIns10+#39+', '+#39+ToIns11+#39+', '+#39+ToIns12+#39+')';

end;

if (Tbl='Uslugi_sv') then

begin

SelectQ := DataModule2.Quslugi;

pole1 := 'id';

pole2 := 'zakaz';

pole3 := 'key_vagon';

pole4 := 'key_uslugi';

pole5 := 'key_na';

pole6 := 'key_s';

pole7 := 'cena';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

with SelectQ do

begin

First;

while (not Eof) do

begin

if (ForEdit <> SelectQ['USV.id']) then

begin

if (SelectQ[pole2] = ToIns) then

begin

YN:=true;

Break;

end;

end;

Next;

end;

end;

if InsEdit5 then

begin

Polya := pole2+'='+#39+ToIns+#39+','+pole3+'='+#39+ToIns2+#39+','+pole4+'='+#39+ToIns3+#39+','+pole5+'='+#39+ToIns4+#39+','+pole6+'='+#39+ToIns5+#39+','+pole7+'='+#39+ToIns6+#39;

QueryString := 'UPDATE '+TBL+' SET '+Polya+' where '+pole1+'='+ForEdit;

InsEdit5 := false;

end

else

QueryString := 'insert into '+ TBL +' ('+pole2+', '+pole3+', '+pole4+', '+pole5+', '+pole6+', '+pole7+') values ('+#39+ToIns+#39+', '+#39+ToIns2+#39+', '+#39+ToIns3+#39+', '+#39+ToIns4+#39+', '+#39+ToIns5+#39+', '+#39+ToIns6+#39+')';

end;

if (YN = false) then

begin

ShowMessage(QueryString);

with SelectQ do

begin

Close;

SQL.Clear;

SQL.Add(QueryString);

ExecSQL;

end;

end

else

ShowMessage('Либо такая запись есть, либо запись введена не корректно');

end;

Procedure DelZapros();

var

TmpString: string;

begin

TmpString := 'delete from '+ TBL +' where ' + pole1 +'=' + ForDel;

// ShowMessage(TmpString);

with DataModule2.Query1 do

begin

Close;

SQL.Clear;

SQL.Add(TmpString);

ExecSQL;

end;

end;

Procedure SelTab();

begin

if (Tbl = 'Rod_vagona') then

begin

Form6.Edit9.Text := SelectQ[pole2];

Form6.Edit9.Tag := SelectQ[pole1];

end;

if (Tbl = 'Raion_dvizheniya') then

begin

Form6.Edit10.Text := SelectQ[pole2];

Form6.Edit10.Tag := SelectQ[pole1];

end;

if (Tbl = 'Station')and(Form3.Caption = 'Станция отправитель') then

begin

Form7.Edit1.Text := SelectQ[pole2];

Form7.Edit1.Tag := SelectQ[pole1];

end;

if (Tbl = 'Station')and(Form3.Caption = 'Станция получатель') then

begin

Form7.Edit7.Text := SelectQ[pole2];

Form7.Edit7.Tag := SelectQ[pole1];

end;

if (Tbl = 'Front')and(Form3.Caption = 'Фронт отправитель') then

begin

Form7.Edit2.Text := SelectQ[pole2];

Form7.Edit2.Tag := SelectQ[pole1];

end;

if (Tbl = 'Front')and(Form3.Caption = 'Фронт получатель') then

begin

Form7.Edit8.Text := SelectQ[pole2];

Form7.Edit8.Tag := SelectQ[pole1];

end;

if (Tbl = 'Operation') then

begin

Form7.Edit9.Text := SelectQ[pole2];

Form7.Edit9.Tag := SelectQ[pole1];

end;

if (Tbl = 'Gruz') then

begin

Form7.Edit10.Text := SelectQ[pole2];

Form7.Edit10.Tag := SelectQ[pole1];

end;

if (Tbl = 'Ceha')and(Form3.Caption = 'Цех заказчик') then

begin

Form8.Edit2.Text := SelectQ[pole2];

Form8.Edit2.Tag := SelectQ[pole1];

end;

if (Tbl = 'Ceha')and(Form3.Caption = 'Цех исполнитель') then

begin

Form8.Edit3.Text := SelectQ[pole2];

Form8.Edit3.Tag := SelectQ[pole1];

end;

if (Tbl = 'Vid_uslug') then

begin

Form5.Edit1.Text := SelectQ[pole2];

Form5.Edit1.Tag := SelectQ[pole1];

end;

if (Tbl = 'Ves') then

begin

Form5.Edit2.Text := SelectQ[pole2];

Form5.Edit2.Tag := SelectQ[pole1];

end;

end;

Procedure ForReport();

var

Polya, Tabli, Tabli2, Svyaz, Svyaz2, QueryString : string;

begin

Polya := 'n_dor_ved,invent_nomer,OSV.mydate, OSV.mytime,STN.station as STN,FN.front as FN,CNA.n_ceha as NA,CNA.bal_schet as BSO,STK.station as STK,FK.front as FK,CS.n_ceha as CS,CS.bal_schet as CBS,G.gruz,VU.vid_uslug,VE.ves,weight,cena';

Tabli := 'Vagon V, Rod_vagona RV, Raion_dvizheniya RD, Operations_s_vagonom OSV, Uslugi_sv USV, Stoimost ST, Vid_uslug VU, Ves VE, Ceha CNA, Ceha CS, Station STN, Station STK';

Tabli2 := 'Front FN, Front FK, Operation OP, Gruz G';

Svyaz := 'V.key_rod_vagona=RV.id and V.key_raion_dvizh=RD.id and V.id=OSV.key_vagon and OSV.id=USV.key_vagon and ST.id=USV.key_uslugi and VU.id=ST.key_vid_uslug and VE.id=ST.key_ves and USV.key_na=CNA.id and USV.key_s=CS.id';

Svyaz2 := 'STN.id=OSV.key_station_otpr and STK.id=key_Station_naznach and FN.id=OSV.key_front_otpr and FK.id=OSV.key_front_naznach and OSV.key_operation=OP.id and OSV.key_gruz=G.id';

if ForSort then

begin

QueryString := 'select '+Polya+' from '+Tabli+ ', '+ Tabli2 +' where '+Svyaz + ' and ' + Svyaz2 + ' order by '+ ForOrder;

end;

if ForFiltr then

begin

QueryString := 'select '+Polya+' from '+Tabli+ ', '+ Tabli2 +' where '+Svyaz + ' and ' + Svyaz2 + ' and '+ TmpFiltr;

end;

if ((ForSort=false)and(ForFiltr=False)) then

begin

QueryString := 'select '+Polya+' from '+Tabli+ ', '+ Tabli2 +' where '+Svyaz + ' and ' + Svyaz2 + ' order by invent_nomer desc';

end;

with DataModule2.QueryRep do

begin

Close;

SQL.Clear;

SQL.Add(QueryString);

if ForFiltr then

begin

Parameters.ParamByName('Par1').Value := Form10.Edit1.Text;

Parameters.ParamByName('Par2').Value := Form10.Edit2.Text;

end;

Open;

end;

Form9.DBGrid1.Columns[0].Title.Caption :='№ дор. вед.';

Form9.DBGrid1.Columns[1].Title.Caption :='Инвент. №';

Form9.DBGrid1.Columns[2].Title.Caption :='Дата';

Form9.DBGrid1.Columns[3].Title.Caption :='Время';

Form9.DBGrid1.Columns[4].Title.Caption :='Станция отпр.';

Form9.DBGrid1.Columns[5].Title.Caption :='Фронт отпр.';

Form9.DBGrid1.Columns[6].Title.Caption :='№ цеха отпр.';

Form9.DBGrid1.Columns[7].Title.Caption :='БС цеха отпр.';

Form9.DBGrid1.Columns[8].Title.Caption :='Станция заказ.';

Form9.DBGrid1.Columns[9].Title.Caption :='Фронт заказ.';

Form9.DBGrid1.Columns[10].Title.Caption :='№ цеха заказ.';

Form9.DBGrid1.Columns[11].Title.Caption :='БС цеха заказ.';

Form9.DBGrid1.Columns[12].Title.Caption :='Груз';

Form9.DBGrid1.Columns[13].Title.Caption :='Операция';

Form9.DBGrid1.Columns[14].Title.Caption :='Ед. изм.';

Form9.DBGrid1.Columns[15].Title.Caption :='Вес';

Form9.DBGrid1.Columns[16].Title.Caption :='Цена';

end;

end.

unit Unit5;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids;

type

TForm5 = class(TForm)

GroupBox1: TGroupBox;

Edit1: TEdit;

Button1: TButton;

Edit2: TEdit;

Edit3: TEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure Button1Click(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure Edit1Enter(Sender: TObject);

procedure Edit2Enter(Sender: TObject);

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

procedure Edit3Exit(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form5: TForm5;

implementation

Uses Unit2, Unit4, Unit3;

{$R *.dfm}

procedure TForm5.Button1Click(Sender: TObject);

begin

ToIns := IntToStr(Edit1.Tag);

ToIns2 := IntToStr(Edit2.Tag);

ToIns3 := Edit3.Text;

If ((Edit1.Text<>'')and(Edit2.Text<>'')and(Edit3.Text<>'')) then

begin

if EditMode4 then

begin

ForEdit := DataModule2.QSelUs['ST.id'];

InsEdit2 := true;

InsertZapros();

ShowZapros();

end

else

begin

InsertZapros();

ShowZapros();

ForEdit := '-1';

end;

Form5.Close;

end

else

ShowMessage('Все поля обязательны к заполнению!');

end;

procedure TForm5.FormShow(Sender: TObject);

begin

TBL:='Stoimost';

if EditMode4 then

begin

Edit1.Text := DataModule2.QSelUs['vid_uslug'];

Edit1.Tag := StrToInt(DataModule2.QSelUs['key_vid_uslug']);

Edit2.Text := DataModule2.QSelUs['ves'];

Edit2.Tag := StrToInt(DataModule2.QSelUs['key_ves']);

Edit3.Text := DataModule2.QSelUs['stoimost'];

Form5.Edit3.SetFocus;

end

else

begin

Edit1.Text := '';

Edit2.Text := '';

Edit2.Tag := 0;

Edit3.Text := '';

Edit3.Tag := 0;

Button1.SetFocus;

end

end;

procedure TForm5.Edit1Enter(Sender: TObject);

begin

Form3.Caption := 'Вид услуг';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Vid_uslug';

pole1 := 'id';

pole2 := 'vid_uslug';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Stoimost';

Form5.Edit2.SetFocus;

end;

procedure TForm5.Edit2Enter(Sender: TObject);

begin

Form3.Caption := 'Единица измерения';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Ves';

pole1 := 'id';

pole2 := 'ves';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Stoimost';

Form5.Edit3.SetFocus;

end;

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

begin

if EditMode4 then

begin

EditMode4:=false;

end;

TBL:='Uslugi_sv';

end;

procedure TForm5.Edit3Exit(Sender: TObject);

var ResVar : real;

E : integer;

begin

try

strtofloat(Edit3.Text);

except

ShowMessage('Здесь должно быть число!!... ну или поменяйте точку на запятую;)');

Edit3.SetFocus;

end;

end;

end.

unit Unit6;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids, ActnList, Menus, ComCtrls;

type

TForm6 = class(TForm)

GroupBox1: TGroupBox;

ComboBox1: TComboBox;

Edit2: TEdit;

Edit3: TEdit;

Edit5: TEdit;

Button1: TButton;

GroupBox2: TGroupBox;

DBGrid1: TDBGrid;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label8: TLabel;

Label10: TLabel;

Edit8: TEdit;

Label12: TLabel;

Edit9: TEdit;

Edit10: TEdit;

PopupMenu1: TPopupMenu;

ActionList1: TActionList;

add: TAction;

edit: TAction;

del: TAction;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

DateTimePicker1: TDateTimePicker;

DateTimePicker2: TDateTimePicker;

procedure Button1Click(Sender: TObject);

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

procedure FormShow(Sender: TObject);

procedure Edit9Enter(Sender: TObject);

procedure Edit10Enter(Sender: TObject);

procedure addExecute(Sender: TObject);

procedure editExecute(Sender: TObject);

procedure delExecute(Sender: TObject);

procedure Edit2Exit(Sender: TObject);

procedure Edit3Exit(Sender: TObject);

procedure Edit5Exit(Sender: TObject);

procedure Edit8Exit(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form6: TForm6;

implementation

Uses Unit2, Unit4, Unit3, Unit7, DateUtils;

{$R *.dfm}

procedure TForm6.Button1Click(Sender: TObject);

var qtmp: string;

begin

ToIns := ComboBox1.Items[ComboBox1.ItemIndex];

ToIns2 := IntToStr(YearOf(DateTimePicker1.Date));

ToIns3 := Edit2.Text;

ToIns4 := Edit3.Text;

ToIns5 := IntToStr(YearOf(DateTimePicker2.Date));

ToIns6 := Edit5.Text;

ToIns7 := IntToStr(Edit9.Tag);

ToIns8 := Edit8.Text;

ToIns9 := IntToStr(Edit10.Tag);

If ((ComboBox1.Text<>'')and(Edit2.Text<>'')and(Edit3.Text<>'')

and(Edit5.Text<>'')and(Edit8.Text<>'')and(Edit9.Text<>'')and(Edit10.Text<>'')) then

begin

if EditMode then

begin

ForEdit := DataModule2.QShow['V.id'];

InsEdit3 := true;

InsertZapros();

ShowZapros();

end

else

begin

EditIns := true;

InsertZapros();

QueryString:='SELECT top 1 id from '+ TBL+' order by id desc';

with DataModule2.Qtmp do

begin

Close;

SQL.Clear;

SQL.Add(QueryString);

Open;

end;

qtmp := DataModule2.Qtmp['id'];

Form6.Close;

ShowZapros();

DataModule2.QShow.Locate('v.id',qtmp,[]);

ForEdit := '-1';

end;

Form6.Close;

end

else

ShowMessage('Все поля обязательны к заполнению!');

end;

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

begin

if EditMode then

begin

EditMode:=false;

end;

end;

procedure TForm6.FormShow(Sender: TObject);

var i, k: integer;

begin

EditIns := False;

if EditMode then

begin

DBGrid1.Visible := true;

DateTimePicker1.Date := StrToDate('01.01.'+ DataModule2.QShow['myyear']);

Edit2.Text := DataModule2.QShow['nomer_vagona'];

Edit3.Text := DataModule2.QShow['invent_nomer'];

DateTimePicker2.Date := StrToDate('01.01.'+ DataModule2.QShow['year_izgot']);

Edit5.Text := DataModule2.QShow['gruzopodemnost'];

Edit8.Text := DataModule2.QShow['iznos'];

Edit9.Text := DataModule2.QShow['rod_vagona'];

Edit9.Tag := DataModule2.QShow['rv.id'];

Edit10.Text := DataModule2.QShow['raion_dvizh'];

Edit10.Tag := DataModule2.QShow['rd.id'];

For i:=0 to ComboBox1.Items.Count do

begin

ComboBox1.ItemIndex := i;

if ComboBox1.Items[ComboBox1.ItemIndex] = DataModule2.QShow['mymonth'] then

k := ComboBox1.ItemIndex;

end;

ComboBox1.ItemIndex := k;

Tbl:='Operations_s_vagonom';

ShowZapros();

end

else

begin

DateTimePicker1.Date := Date;

DateTimePicker2.Date := StrToDate('01.01.1950');

Edit2.Text := '';

Edit3.Text := '';

Edit5.Text := '';

Edit8.Text := '';

Edit9.Text := '';

Edit9.Tag := 0;

Edit10.Text := '';

Edit10.Tag := 0;

DBGrid1.Visible := false;

end;

TBL:='Vagon';

end;

procedure TForm6.Edit9Enter(Sender: TObject);

begin

Form3.Caption := 'Род вагона';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Rod_vagona';

pole1 := 'id';

pole2 := 'Rod_vagona';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Vagon';

Edit10.SetFocus;

end;

procedure TForm6.Edit10Enter(Sender: TObject);

begin

Form3.Caption := 'Район движения';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Raion_dvizheniya';

pole1 := 'id';

pole2 := 'Raion_dvizh';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Vagon';

Button1.SetFocus;

end;

procedure TForm6.addExecute(Sender: TObject);

begin

Form7.Caption := 'Информация по вагону';

Tbl := 'Operations_s_vagonom';

pole1 := 'id';

pole2 := 'key_station_otpr';

pole3 := 'key_front_otpr';

pole4 := 'key_sttion_naznach';

pole5 := 'key_front_naznach';

pole6 := 'date';

pole7 := 'time';

pole8 := 'key_operation';

pole9 := 'key_gruz';

pole10 := 'weight';

pole11 := 'n_dor_ved';

pole12 := 'n_ved';

pole13 := 'key_vagon';

Form7.ShowModal;

if ((EditMode2=false)and(EditIns2)) then

begin

EditMode2:=true;

Form7.ShowModal;

end;

end;

procedure TForm6.editExecute(Sender: TObject);

begin

if (DataModule2.QOSV['OSV.id']=Null) then

begin

ShowMessage('Нечего редактировать');

EditMode2 := false;

end

else

begin

EditMode2 := True;

Form7.ShowModal;

end;

end;

procedure TForm6.delExecute(Sender: TObject);

begin

if (DataModule2.QOSV['OSV.id']=Null) then

begin

ShowMessage('Нечего удалять');

EditMode2 := false;

end

else

begin

Tbl := 'Operations_s_vagonom';

pole1 := 'id';

pole2 := 'key_station_otpr';

pole3 := 'key_front_otpr';

pole4 := 'key_station_naznach';

pole5 := 'key_front_naznach';

pole6 := 'mydate';

pole7 := 'mytime';

pole8 := 'key_operation';

pole9 := 'key_gruz';

pole10 := 'weight';

pole11 := 'n_dor_ved';

pole12 := 'n_ved';

pole13 := 'key_vagon';

ForDel := DataModule2.QOSV['OSV.id'];

DelZapros;

ShowZapros();

TBL:='Vagon';

end;

end;

procedure TForm6.Edit2Exit(Sender: TObject);

begin

try

strtoint(Edit2.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit2.SetFocus;

end;

end;

procedure TForm6.Edit3Exit(Sender: TObject);

begin

try

strtoint(Edit3.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit3.SetFocus;

end;

end;

procedure TForm6.Edit5Exit(Sender: TObject);

begin

try

strtoint(Edit5.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit5.SetFocus;

end;

end;

procedure TForm6.Edit8Exit(Sender: TObject);

begin

try

strtoint(Edit8.Text);

//----далее команды если введённая вещь - число

except

ShowMessage('Здесь должно быть число!!');

Edit8.SetFocus;

end;

end;

end.

unit Unit7;

interface

uses

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

Dialogs, StdCtrls, ComCtrls, TabNotBk, Grids, DBGrids, Menus, ActnList;

type

TForm7 = class(TForm)

GroupBox1: TGroupBox;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Edit6: TEdit;

Edit4: TEdit;

Edit3: TEdit;

Button1: TButton;

GroupBox2: TGroupBox;

DBGrid1: TDBGrid;

DateTimePicker1: TDateTimePicker;

DateTimePicker2: TDateTimePicker;

Edit1: TEdit;

Edit2: TEdit;

Edit7: TEdit;

Edit8: TEdit;

Edit9: TEdit;

Edit10: TEdit;

ActionList1: TActionList;

PopupMenu1: TPopupMenu;

add: TAction;

edit: TAction;

del: TAction;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

procedure FormShow(Sender: TObject);

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

procedure Button1Click(Sender: TObject);

procedure Edit1Enter(Sender: TObject);

procedure Edit2Enter(Sender: TObject);

procedure Edit9Enter(Sender: TObject);

procedure Edit10Enter(Sender: TObject);

procedure Edit7Enter(Sender: TObject);

procedure Edit8Enter(Sender: TObject);

procedure addExecute(Sender: TObject);

procedure editExecute(Sender: TObject);

procedure delExecute(Sender: TObject);

procedure Edit6Exit(Sender: TObject);

procedure Edit4Exit(Sender: TObject);

procedure Edit3Exit(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form7: TForm7;

implementation

Uses Unit2, Unit4, Unit3, Unit8, DateUtils;

{$R *.dfm}

procedure TForm7.FormShow(Sender: TObject);

begin

if EditMode2 then

begin

DBGrid1.Visible := true;

Edit6.Text := DataModule2.QOSV['n_ved'];

Edit4.Text := DataModule2.QOSV['n_dor_ved'];

DateTimePicker1.Date := StrToDate(DataModule2.QOSV['mydate']);

DateTimePicker2.DateTime := StrToTime(DataModule2.QOSV['mytime']);

Edit1.Text := DataModule2.QOSV['SNACH.station'];

Edit1.Tag := StrToInt(DataModule2.QOSV['key_station_otpr']);

Edit2.Text := DataModule2.QOSV['FNACH.front'];

Edit2.Tag := StrToInt(DataModule2.QOSV['key_front_otpr']);

Edit7.Text := DataModule2.QOSV['SKON.station'];

Edit7.Tag := StrToInt(DataModule2.QOSV['key_station_naznach']);

Edit8.Text := DataModule2.QOSV['FKON.front'];

Edit8.Tag := StrToInt(DataModule2.QOSV['key_front_naznach']);

Edit9.Text := DataModule2.QOSV['operation'];

Edit9.Tag := StrToInt(DataModule2.QOSV['key_operation']);

Edit10.Text := DataModule2.QOSV['gruz'];

Edit10.Tag := StrToInt(DataModule2.QOSV['key_gruz']);

Edit3.Text := DataModule2.QOSV['weight'];

Tbl:='Uslugi_sv';

ShowZapros();

end

else

begin

Edit6.Text := '';

Edit4.Text := '';

Edit1.Text := '';

Edit1.Tag := 0;

Edit2.Text := '';

Edit2.Tag := 0;

Edit7.Text := '';

Edit7.Tag := 0;

Edit8.Text := '';

Edit8.Tag := 0;

Edit9.Text := '';

Edit9.Tag := 0;

Edit10.Text := '';

Edit10.Tag := 0;

Edit3.Text := '';

DBGrid1.Visible := false;

DateTimePicker1.Date := Date;

DateTimePicker2.Time := Time;

end;

TBL:='Operations_s_vagonom';

end;

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

begin

if EditMode2 then

begin

EditMode2:=false;

end;

TBL:='Vagon';

end;

procedure TForm7.Button1Click(Sender: TObject);

var qtmp : string;

begin

ToIns := IntToStr(Edit1.Tag);

ToIns2 := IntToStr(Edit2.Tag);

ToIns3 := IntToStr(Edit7.Tag);

ToIns4 := IntToStr(Edit8.Tag);

ToIns5 := DateToStr(DateTimePicker1.Date);

ToIns6 := TimeToStr(DateTimePicker2.Time);

ToIns7 := IntToStr(Edit9.Tag);

ToIns8 := IntToStr(Edit10.Tag);

ToIns9 := Edit3.Text;

ToIns10 := Edit6.Text;

ToIns11 := Edit4.Text;

ToIns12 := DataModule2.QShow['V.id'];

if ((Edit6.Text<>'')and(Edit4.Text<>'')and(Edit3.Text<>'')and

(Edit1.Text<>'')and(Edit2.Text<>'')and(Edit7.Text<>'')and

(Edit8.Text<>'')and(Edit9.Text<>'')and(Edit10.Text<>'')) then

begin

if EditMode2 then

begin

ForEdit := DataModule2.QOSV['OSV.id'];

InsEdit4 := true;

InsertZapros();

ShowZapros();

end

else

begin

EditIns2 := true;

InsertZapros();

QueryString:='SELECT top 1 id from '+ TBL+' order by id desc';

with DataModule2.Qtmp do

begin

Close;

SQL.Clear;

SQL.Add(QueryString);

Open;

end;

qtmp := DataModule2.Qtmp['id'];

Form7.Close;

ShowZapros();

DataModule2.QShow.Locate('v.id',qtmp,[]);

ForEdit := '-1';

end;

Form7.Close;

end

else

ShowMessage('Все поля обязательны к заполнению!');

end;

procedure TForm7.Edit1Enter(Sender: TObject);

begin

Form3.Caption := 'Станция отправитель';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Station';

pole1 := 'id';

pole2 := 'Station';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit2.SetFocus;

end;

procedure TForm7.Edit2Enter(Sender: TObject);

begin

Form3.Caption := 'Фронт отправитель';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Front';

pole1 := 'id';

pole2 := 'Front';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit7.SetFocus;

end;

procedure TForm7.Edit9Enter(Sender: TObject);

begin

Form3.Caption := 'Операции';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Operation';

pole1 := 'id';

pole2 := 'Operation';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit10.SetFocus;

end;

procedure TForm7.Edit10Enter(Sender: TObject);

begin

Form3.Caption := 'Груз';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Gruz';

pole1 := 'id';

pole2 := 'Gruz';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit3.SetFocus;

end;

procedure TForm7.Edit7Enter(Sender: TObject);

begin

Form3.Caption := 'Станция получатель';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Station';

pole1 := 'id';

pole2 := 'Station';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit8.SetFocus;

end;

procedure TForm7.Edit8Enter(Sender: TObject);

begin

Form3.Caption := 'Фронт получатель';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Front';

pole1 := 'id';

pole2 := 'Front';

pole3 := '';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Operations_s_vagonom';

Edit9.SetFocus;

end;

procedure TForm7.addExecute(Sender: TObject);

begin

Form8.ShowModal;

end;

procedure TForm7.editExecute(Sender: TObject);

begin

if (DataModule2.Quslugi['USV.id']=Null) then

begin

ShowMessage('Нечего редактировать');

EditMode3 := false;

end

else

begin

EditMode3 := True;

Form8.ShowModal;

end;

end;

procedure TForm7.delExecute(Sender: TObject);

begin

if (DataModule2.Quslugi['USV.id']=Null) then

begin

ShowMessage('Нечего удалять');

EditMode3 := false;

end

else

begin

Tbl := 'Uslugi_sv';

pole1 := 'id';

pole2 := 'zakaz';

pole3 := 'key_vagon';

pole4 := 'key_uslugi';

pole5 := 'key_na';

pole6 := 'key_s';

pole7 := 'cena';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

ForDel := DataModule2.Quslugi['USV.id'];

DelZapros;

ShowZapros();

TBL:='Operations_s_vagonom';

end;

end;

procedure TForm7.Edit6Exit(Sender: TObject);

begin

try

strtoint(Edit6.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit6.SetFocus;

end;

end;

procedure TForm7.Edit4Exit(Sender: TObject);

begin

try

strtoint(Edit4.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit4.SetFocus;

end;

end;

procedure TForm7.Edit3Exit(Sender: TObject);

begin

try

strtoint(Edit3.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit3.SetFocus;

end;

end;

end.

unit Unit8;

interface

uses

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

Dialogs, StdCtrls, Grids, DBGrids, ActnList, Menus;

type

TForm8 = class(TForm)

GroupBox1: TGroupBox;

Edit1: TEdit;

Label1: TLabel;

Edit2: TEdit;

Edit3: TEdit;

Label2: TLabel;

Label3: TLabel;

DBGrid1: TDBGrid;

Label4: TLabel;

ActionList1: TActionList;

PopupMenu1: TPopupMenu;

add: TAction;

edit: TAction;

del: TAction;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

procedure Edit2Enter(Sender: TObject);

procedure Edit3Enter(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure DBGrid1DblClick(Sender: TObject);

procedure addExecute(Sender: TObject);

procedure editExecute(Sender: TObject);

procedure delExecute(Sender: TObject);

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

procedure Edit1Exit(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form8: TForm8;

implementation

Uses unit2, unit4, Unit3, Unit5, Unit7;

{$R *.dfm}

procedure TForm8.Edit2Enter(Sender: TObject);

begin

Form3.Caption := 'Цех заказчик';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Ceha';

pole1 := 'id';

pole2 := 'n_ceha';

pole3 := 'bal_schet';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Uslugi_sv';

Edit3.SetFocus;

end;

procedure TForm8.Edit3Enter(Sender: TObject);

begin

Form3.Caption := 'Цех исполнитель';

Form3.Label1.Caption:= Form3.Caption;

Tbl := 'Ceha';

pole1 := 'id';

pole2 := 'n_ceha';

pole3 := 'bal_schet';

pole4 := '';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ShowZapros;

Form3.ShowModal;

Tbl := 'Uslugi_sv';

DBGrid1.SetFocus;

end;

procedure TForm8.FormShow(Sender: TObject);

begin

if EditMode3 then

begin

Edit1.Text := DataModule2.Quslugi['zakaz'];

Edit2.Text := DataModule2.Quslugi['CS.n_ceha'];

Edit2.Tag := StrToInt(DataModule2.Quslugi['key_s']);

Edit3.Text := DataModule2.Quslugi['CNA.n_ceha'];

Edit3.Tag := StrToInt(DataModule2.Quslugi['key_na']);

end

else

begin

Edit1.Text := '';

Edit2.Text := '';

Edit2.Tag := 0;

Edit3.Text := '';

Edit3.Tag := 0;

end;

Tbl:='Stoimost';

ShowZapros();

TBL:='Uslugi_sv';

end;

procedure TForm8.DBGrid1DblClick(Sender: TObject);

begin

ToIns := Edit1.Text;

ToIns2 := DataModule2.QOSV['OSV.id'];

ToIns3 := DataModule2.QSelUs['ST.id'];

ToIns4 := IntToStr(Edit2.Tag);

ToIns5 := IntToStr(Edit3.Tag);

if MessageDlg('Перемножить стоимость заказа на вес?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then

begin

// ToIns6 := IntToStr(StrToInt(DataModule2.QSelUs['stoimost']) * StrToInt(Form7.Edit3.Text));

ToIns6 := FloatToStr(StrToFloat(DataModule2.QSelUs['stoimost']) * StrToFloat(Form7.Edit3.Text));

Close;

end

else

ToIns6 := DataModule2.QSelUs['stoimost'];

If ((Edit1.Text<>'')and(Edit2.Text<>'')and(Edit3.Text<>'')) then

begin

if EditMode3 then

begin

ForEdit := DataModule2.Quslugi['USV.id'];

InsEdit5 := true;

InsertZapros();

ShowZapros();

end

else

begin

InsertZapros();

ShowZapros();

ForEdit := '-1';

end;

Form8.Close;

end

else

ShowMessage('Все поля обязательны к заполнению!');

end;

procedure TForm8.addExecute(Sender: TObject);

begin

Form5.Show;

end;

procedure TForm8.editExecute(Sender: TObject);

begin

if (DataModule2.QSelUs['ST.id']=Null) then

begin

ShowMessage('Нечего редактировать');

EditMode4 := false;

end

else

begin

EditMode4:=true;

Form5.Show;

end;

end;

procedure TForm8.delExecute(Sender: TObject);

begin

if (DataModule2.QSelUs['ST.id']=Null) then

begin

ShowMessage('Нечего удалять');

EditMode4 := false;

end

else

begin

Tbl:='Stoimost';

pole1 := 'id';

pole2 := 'key_vid_uslug';

pole3 := 'key_ves';

pole4 := 'stoimost';

pole5 := '';

pole6 := '';

pole7 := '';

pole8 := '';

pole9 := '';

pole10 := '';

pole11 := '';

pole12 := '';

pole13 := '';

ForDel := DataModule2.QSelUs['ST.id'];

DelZapros;

ShowZapros();

TBL:='Uslugi_sv';

end;

end;

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

begin

if EditMode3 then

begin

EditMode3:=false;

end;

Tbl:='Operations_s_vagonom';

end;

procedure TForm8.Edit1Exit(Sender: TObject);

begin

try

strtoint(Edit1.Text);

except

ShowMessage('Здесь должно быть число!!');

Edit1.SetFocus;

end;

end;

end.

unit Unit9;

interface

uses

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

Dialogs, StdCtrls, Grids, Menus, DBGrids;

type

TForm9 = class(TForm)

GroupBox1: TGroupBox;

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

DBGrid1: TDBGrid;

N5: TMenuItem;

N6: TMenuItem;

procedure N1Click(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N6Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form9: TForm9;

implementation

uses Unit2, Unit10, Unit4, Unit1, Unit11;

{$R *.dfm}

procedure TForm9.N1Click(Sender: TObject);

var tmpRadio, MyI : integer;

begin

Form10.Caption := 'Сортировка';

ForSort := true;

ForFiltr := false;

Form10.RadioGroup2.Enabled := true;

Form10.Edit1.Enabled:=False;

Form10.Edit2.Enabled:=False;

Form10.Edit1.Clear;

Form10.Edit2.Clear;

Form10.Button3.Caption := 'Next';

Form10.RadioGroup1.ItemIndex := 0;

Form10.RadioGroup2.ItemIndex := 0;

ForOrder:='';

Form10.RadioGroup1.Items.Clear;

For MyI:=0 to Form9.DBGrid1.Columns.Count-1 do

begin

Form10.RadioGroup1.Items.Add(Form9.DBGrid1.Columns[MyI].Title.Caption);

end;

for tmpRadio:=0 to Form10.RadioGroup1.Items.Count-1 do

begin

TRadioButton(Form10.RadioGroup1.Controls[tmpRadio]).Enabled := true;

end;

Form10.RadioGroup1.ItemIndex := 0;

Form10.ShowModal;

end;

procedure TForm9.N3Click(Sender: TObject);

var tmpRadio, MyI : integer;

begin

Form10.Caption := 'Фильтрация';

Form10.RadioGroup2.ItemIndex := 0;

Form10.RadioGroup2.Enabled := false;

Diap := 'in';

ForSort := false;

ForFiltr := true;

Form10.Edit1.Enabled:=true;

Form10.Edit2.Enabled:=true;

Form10.Edit1.Clear;

Form10.Edit2.Clear;

Form10.Button3.Caption := 'Ok';

Form10.RadioGroup1.ItemIndex := 0;

Form10.RadioGroup1.Items.Clear;

For MyI:=0 to Form9.DBGrid1.Columns.Count-1 do

begin

Form10.RadioGroup1.Items.Add(Form9.DBGrid1.Columns[MyI].Title.Caption);

end;

for tmpRadio:=0 to Form10.RadioGroup1.Items.Count-1 do

begin

TRadioButton(Form10.RadioGroup1.Controls[tmpRadio]).Enabled := true;

end;

Form10.RadioGroup1.ItemIndex := 0;

Form10.ShowModal;

end;

procedure TForm9.N4Click(Sender: TObject);

var tmpRadio, MyI : integer;

begin

Form10.Caption := 'Фильтрация';

Form10.RadioGroup2.ItemIndex := 0;

Form10.RadioGroup2.Enabled := false;

Diap := 'out';

ForSort := false;

ForFiltr := true;

Form10.Edit1.Enabled:=true;

Form10.Edit2.Enabled:=true;

Form10.Edit1.Clear;

Form10.Edit2.Clear;

Form10.Button3.Caption := 'Ok';

Form10.RadioGroup1.ItemIndex := 0;

Form10.RadioGroup1.Items.Clear;

For MyI:=0 to Form9.DBGrid1.Columns.Count-1 do

begin

Form10.RadioGroup1.Items.Add(Form9.DBGrid1.Columns[MyI].Title.Caption);

end;

for tmpRadio:=0 to Form10.RadioGroup1.Items.Count-1 do

begin

TRadioButton(Form10.RadioGroup1.Controls[tmpRadio]).Enabled := true;

end;

Form10.RadioGroup1.ItemIndex := 0;

Form10.ShowModal;

end;

procedure TForm9.N5Click(Sender: TObject);

begin

ForReport();

end;

procedure TForm9.N6Click(Sender: TObject);

begin

Form11.QuickRep1.PreviewModal;

end;

end.

unit Unit10;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls;

type

TForm10 = class(TForm)

RadioGroup2: TRadioGroup;

Edit2: TEdit;

Edit1: TEdit;

Button3: TButton;

Button2: TButton;

RadioGroup3: TRadioGroup;

RadioGroup1: TRadioGroup;

procedure Button3Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Sort();

procedure Filtr();

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form10: TForm10;

implementation

Uses Unit4;

{$R *.dfm}

procedure TForm10.Sort();

var tmpRadio, myNumb: integer;

QueryString: string;

tmp, Napr: String;

begin

if RadioGroup2.ItemIndex = 0 then

Napr := ''

else

Napr := ' Desc ';

TRadioButton(RadioGroup1.Controls[RadioGroup1.ItemIndex]).Enabled := False;

if (ForOrder='') then

ForOrder := RadioGroup3.Items[RadioGroup1.ItemIndex] + Napr

else

ForOrder := ForOrder + ','+ RadioGroup3.Items[RadioGroup1.ItemIndex] + Napr;

for tmpRadio:=0 to RadioGroup1.Items.Count-1 do

begin

myNumb := -1;

if (TRadioButton(RadioGroup1.Controls[tmpRadio]).Enabled) then

begin

MyNumb := tmpRadio;

Break;

end;

end;

if (myNumb<>-1) then

RadioGroup1.ItemIndex := myNumb

else

Button3.Caption := 'Выполнить';

if (myNumb=-1) then

begin

ForReport();

Form10.Close;

ForSort := false;

end;

end;

procedure TForm10.Filtr();

begin

if Diap='in' then

tmpFiltr := RadioGroup3.Items[RadioGroup1.ItemIndex] + ' BETWEEN :Par1 AND :Par2'

else

tmpFiltr := RadioGroup3.Items[RadioGroup1.ItemIndex] + ' NOT BETWEEN :Par1 AND :Par2';

ForReport();

Edit1.Enabled:=False;

Edit2.Enabled:=False;

ForFiltr := False;

Form10.Close;

end;

procedure TForm10.Button3Click(Sender: TObject);

begin

if ForSort = true then Sort();

if ForFiltr = true then Filtr();

end;

procedure TForm10.Button2Click(Sender: TObject);

begin

If ForSort then

begin

if RadioGroup2.ItemIndex = 0 then

ForOrder := RadioGroup3.Items[RadioGroup1.ItemIndex]

else

ForOrder := RadioGroup3.Items[RadioGroup1.ItemIndex] + ' Desc';

ForReport();

end;

ForSort := false;

ForFiltr := False;

Form10.Close;

end;

end.

unit Unit11;

interface

uses

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

Dialogs, ExtCtrls, QuickRpt, QRCtrls;

type

TForm11 = class(TForm)

QuickRep1: TQuickRep;

ColumnHeaderBand1: TQRBand;

DetailBand1: TQRBand;

PageFooterBand1: TQRBand;

QRExpr1: TQRExpr;

QRExpr2: TQRExpr;

QRExpr3: TQRExpr;

QRExpr4: TQRExpr;

QRExpr5: TQRExpr;

QRExpr7: TQRExpr;

QRExpr8: TQRExpr;

QRExpr10: TQRExpr;

QRExpr11: TQRExpr;

QRExpr14: TQRExpr;

QRExpr15: TQRExpr;

QRExpr16: TQRExpr;

QRExpr17: TQRExpr;

QRExpr18: TQRExpr;

QRExpr19: TQRExpr;

QRExpr9: TQRExpr;

QRExpr12: TQRExpr;


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.