Автор работы: Пользователь скрыл имя, 12 Марта 2012 в 19:19, курсовая работа
В настоящее время уровень компьютеризации во всех сферах человеческой жизни достиг небывалых высот. Уже трудно представить какое либо крупное промышленное предприятие без компьютерного управления производством, наука шагает семимильными шагами опять же благодаря компьютерным технологиям, медицина стала более эффективна благодаря «умным машинам».
Введение 3
1. Основные понятия
1.1 Описание среды разработки. 4
1.2 Организация баз данных 5
1.3 Поддержка языков БД 7
1.4 BDE………………………………………………………………….8
1.5 Архитектура СУБД 9
2. Постановка задачи 11
3. Использованные инструменты Delphi 12
4. Описание базы данных 12
4.1 Связь таблиц……………………………………………………….. 13
5. Структура программного продукта 14
5.1 Межмодульные связи………………………………………………15
6. Разработанные алгоритмы по теме работы…….....…………16
6.1 Сортировка………………………………………………………….16
6.2 Поиск………………………………………………………………...16
6.3 Фильтрация………………………………………………………….16
6.4 Формирование запросов……………………………………………16
6.5 Формирование отчетов 16
7. Описание пользовательского интерфейса 17
8. Заключение 23
9. Список использованной литературы 24
Приложение А. Текст программы. 18
Приложение Б. Экранные формы. 35
else Zap[i]:='('+Pole[i]+'>='+
4: Zap[i]:='('+Pole[i]+'='+''''+
5: if (Edit5.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit6.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
6: if (Edit7.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit8.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
7: if (Edit9.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit10.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
8: Zap[i]:='('+Pole[i]+'='+''''+
9: if (Edit12.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit13.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
10: if (Edit14.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit15.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
11: if (Edit16.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit17.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
12: if (Edit18.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit19.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
13: if (Edit20.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit21.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
14: if (Edit22.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit23.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
15: if (Edit24.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit25.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
16: if (Edit26.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit27.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
17: if (Edit28.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit29.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
18: if (Edit11.Text='') then Zap[i]:='('+Pole[i]+'<='+
else if (Edit30.Text='') then Zap[i]:='('+Pole[i]+'>='+
else Zap[i]:='('+Pole[i]+'>='+
end;
if sm='' then sm:=zap[i];
end;
Zapros:='';
Flag:=false;
for i:=1 to 18 do begin
if (Zap[i]<>'') then
for j:=i+1 to 18 do
if (Zap[j]<>'') then flag:=true;
if flag then
Zapros:=Zapros+Zap[i]+' AND '
else Zapros:=Zapros+Zap[i];
Flag:=false;
end;
if (k1>0) and ((k2>0) or (k3>0) or (k4>0)) then ZaTab:=ZaTab+'Limit,'
else if (k1>0) then ZaTab:=ZaTab+'Limit';
if (k2>0) and ((k3>0) or (k4>0)) then ZaTab:=ZaTab+'Pokazateli,'
else if (k2>0) then ZaTab:=ZaTab+'Pokazateli';
if (k3>0) and (k4>0) then ZaTab:=ZaTab+'Veshestva,'
else if (k3>0) then Zatab:=ZaTab+'Veshestva';
if (k4>0) then ZaTab:=ZaTab+'Normative';
svz:='';
if (k4>0) then svz:=svz+'';
if (k3>0) and (k4>0) then svz:=svz+' AND (NormID=VeshNID) ';
if (k2>0) and (k3>0) then svz:=svz+' AND (ClassPokaz=ClassVesh) ';
if (k1>0) and (k2>0) then svz:=svz+' AND (TipL=TipP) ';
if ((k1>0) and (k2=0) and (k3=0) and (k4=0)) or ((k1=0) and (k2>0) and (k3=0) and (k4=0)) or ((k1=0) and (k2=0) and (k3>0) and (k4=0)) or ((k1=0) and (k2=0) and (k3=0) and (k4>0)) then
svz:='';
if (not CheckBox18.Checked) then begin
st.pass:='SELECT DISTINCT Limit,God,Kvartal,AllPlata,
AssignFile(F,'Log.txt');
Rewrite(F);
Write(F,st);
CloseFile(F);
if (k1>0) then begin
dm.q1.SQL.Clear;
dm.q1.SQL.Text:='SELECT DISTINCT Limit,God,Kvartal,AllPlata,
dm.q1.Open;
end;
if (k2>0) then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT DISTINCT Pokazatel,PlataPoPlanu,
dm.q2.Open;
end;
if (k3>0) then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT DISTINCT Veshestvo,NormPlatZaTonn,
dm.q3.Open;
end;
if (k4>0) then begin
dm.q4.SQL.Clear;
dm.q4.SQL.Text:='SELECT DISTINCT NormGod,Norm1,Norm2,Norm3,
dm.q4.Open;
end;
end;
s:='';
if Checkbox18.Checked then begin
if (ComboBox4.ItemIndex=2) or (ComboBox4.ItemIndex=3) or (ComboBox4.ItemIndex=4) then begin
for i:=1 to 2 do
if Sravn[i]<>0 then
if (i=1) then s:=s+Pole[Sravn[i]]+ComboBox4.
else s:=s+Pole[Sravn[i]];
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli WHERE '+s;
dm.q2.Open;
nz2:=true;
CheckBox18.Checked:=false;
end;
if (ComboBox4.ItemIndex=0) or (ComboBox4.ItemIndex=1) then begin
if (not CheckBox20.Checked) then begin
Zapros:='';
i:=1;
while (not che[i].Checked) do inc(i);
Zapros:=Zapros+Pole[i];
dm.Query3.SQL.Clear;
dm.Query3.SQL.Text:='SELECT '+ComboBox4.Text+'('+Zapros+') FROM '+ZaTab;
dm.Query3.Open;
if (i>=1) and (i<=3) or (i=18) then begin
dm.q1.SQL.Clear;
dm.q1.SQL.Text:='SELECT DISTINCT * FROM '+ZaTab+' WHERE '+Zapros+'='+DBGrid5.Fields[0]
dm.q1.Open;
end else
if (i>=4) and (i<=7) then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT DISTINCT * FROM '+ZaTab+' WHERE '+Zapros+'='+DBGrid5.Fields[0]
dm.q2.Open;
vp1:=false;
nz3:=false; vp3:=true;
nz2:=true; vp2:=true;
end else
if (i>=8) and (i<=12) then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT DISTINCT * FROM '+ZaTab+' WHERE '+Zapros+'='+DBGrid5.Fields[0]
dm.q3.Open;
vp1:=false;
nz3:=true; vp3:=true;
nz2:=true; vp2:=false;
end else
if (i>=13) and (i<=17) then begin
dm.q4.SQL.Clear;
dm.q4.SQL.Text:='SELECT DISTINCT * FROM '+ZaTab+' WHERE '+Zapros+'='+DBGrid5.Fields[0]
dm.q4.Open;
vp1:=false;
nz4:=true;
nz3:=true; vp3:=false;
nz2:=true; vp2:=false;
end;
end;
end;
if (CheckBox20.Checked) then begin
Case ComboBox2.ItemIndex of
0: s:='A%';
1: s:='B%';
2: s:='C%';
3: s:='D%';
4: s:='E%';
5: s:='F%';
6: s:='G%';
7: s:='H%';
8: s:='I%';
9: s:='J%';
end;
s:=''''+s+'''';
dm.Query3.SQL.Clear;
dm.Query3.SQL.Text:='SELECT '+ComboBox5.Text+'('+Pole[
dm.Query3.Open;
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT DISTINCT Veshestvo,ClassVesh,ObemZagr,
dm.q3.Open;
nz3:=true;
nz2:=true; vp2:=false;
vp1:=false;
end;
st.pass:='SELECT '+ComboBox4.Text+'('+Zapros+') FROM '+ZaTab;
AssignFile(F,'Log.txt');
Rewrite(F);
Write(F,st);
CloseFile(F);
ok:=false;
CheckBox18.Checked:=false;
CheckBox20.Checked:=false;
ComboBox4.ItemIndex:=0;
ComboBox4.Visible:=false;
end;
end else MessageDlg('Выберите критерии запроса!', mtWarning, [mbOk], 0);
end;
procedure TZaprosForm.FormCreate(Sender: TObject);
begin
//nk:=1;
ok:=false;
vp1:=true;
vp2:=true;
vp3:=true;
nz2:=false;
nz3:=false;
nz4:=false;
che[1]:=CheckBox1;
che[2]:=CheckBox2;
che[3]:=CheckBox3;
che[4]:=CheckBox4;
che[5]:=CheckBox5;
che[6]:=CheckBox6;
che[7]:=CheckBox7;
che[8]:=CheckBox8;
che[9]:=CheckBox9;
che[10]:=CheckBox10;
che[11]:=CheckBox11;
che[12]:=CheckBox12;
che[13]:=CheckBox13;
che[14]:=CheckBox14;
che[15]:=CheckBox15;
che[16]:=CheckBox16;
che[17]:=CheckBox17;
che[18]:=CheckBox19;
end;
procedure TZaprosForm.Button2Click(
begin
vp1:=true;
vp2:=true;
vp3:=true;
nz2:=false;
nz3:=false;
nz4:=false;
dm.q1.SQL.Clear;
dm.q1.SQL.Text:='SELECT * FROM Limit';
dm.q1.Open;
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli';
dm.q2.Open;
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT * FROM Veshestva';
dm.q3.Open;
end;
procedure TZaprosForm.DBGrid3CellClick(
begin
if vp3 then begin
dm.q4.SQL.Clear;
dm.q4.SQL.Text:='SELECT * FROM Normative WHERE VeshNID='+IntToStr(DBGrid3.
dm.q4.Open;
end;
if nz3 then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli WHERE ClassPokaz='+''''+(DBGrid3.
dm.q2.Open;
end;
end;
procedure TZaprosForm.DBGrid2CellClick(
begin
if vp2 then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT * FROM Veshestva WHERE ClassVesh='+''''+(DBGrid2.
dm.q3.Open;
end;
if nz2 then begin
dm.q1.SQL.Clear;
dm.q1.SQL.Text:='SELECT * FROM Limit WHERE TipL='+''''+(DBGrid2.Fields[4]
dm.q1.Open;
end;
end;
procedure TZaprosForm.DBGrid1CellClick(
begin
if vp1 then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli WHERE TipP='+''''+(DBGrid1.Fields[3]
dm.q2.Open;
end;
end;
procedure TZaprosForm.FormActivate(
begin
// ViewTab;
end;
procedure TZaprosForm.DBGrid2ColEnter(
begin
if vp2 then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT * FROM Veshestva WHERE ClassVesh='+''''+(DBGrid2.
dm.q3.Open;
end;
if nz2 then begin
dm.q1.SQL.Clear;
dm.q1.SQL.Text:='SELECT * FROM Limit WHERE TipL='+''''+(DBGrid2.Fields[4]
dm.q1.Open;
end;
end;
procedure TZaprosForm.DBGrid1ColEnter(
begin
if vp1 then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli WHERE TipP='+''''+(DBGrid1.Fields[3]
dm.q2.Open;
end;
end;
procedure TZaprosForm.DBGrid3ColEnter(
begin
if vp3 then begin
dm.q4.SQL.Clear;
dm.q4.SQL.Text:='SELECT * FROM Normative WHERE VeshNID='+IntToStr(DBGrid3.
dm.q4.Open;
end;
if nz3 then begin
dm.q2.SQL.Clear;
dm.q2.SQL.Text:='SELECT * FROM Pokazateli WHERE ClassPokaz='+''''+(DBGrid3.
dm.q2.Open;
end;
end;
procedure TZaprosForm.Button5Click(
var
s:string;
begin
end;
procedure TZaprosForm.CheckBox18Click(
begin
if CheckBox18.Checked then begin
for i:=1 to 17 do
che[i].Checked:=false;
nk:=1;
ComboBox4.Visible:=true;
CheckBox20.Visible:=true;
end else begin
ComboBox4.Visible:=false;
CheckBox20.Visible:=false;
end;
end;
procedure TZaprosForm.ComboBox4Change(
begin
if (ComboBox4.ItemIndex =3) or (ComboBox4.ItemIndex =4) then
//ok:=true
else ok:=false;
for i:=1 to 17 do
if (not ok) then che[i].Checked:=false;
end;
procedure TZaprosForm.CheckBox19Click(
begin
if ((CheckBox19.Checked) and (not CheckBox18.Checked)) or ((CheckBox19.Checked) and ok) then GroupBox27.Visible:=true
else GroupBox27.Visible:=false;
if CheckBox18.Checked then
if CheckBox19.Checked then begin
Sravn[nk]:=18;
inc(nk);
end else dec(nk);
end;
procedure TZaprosForm.CheckBox20Click(
begin
if CheckBox20.Checked then begin
ComboBox5.Visible:=true;
ComboBox4.Visible:=false;
ok:=true;
end else begin
ComboBox5.Visible:=false;
ComboBox4.Visible:=true;
ok:=false;
end;
end;
procedure TZaprosForm.DBGrid4ColEnter(
begin
if nz4 then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT DISTINCT Veshestvo,NormPlatZaTonn,
dm.q3.Open;
end;
end;
procedure TZaprosForm.DBGrid4CellClick(
begin
if nz4 then begin
dm.q3.SQL.Clear;
dm.q3.SQL.Text:='SELECT DISTINCT Veshestvo,NormPlatZaTonn,
dm.q3.Open;
end;
end;
end.
Текст модуля fmDiag.
unit fmDiag;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, DbChart, Series, StdCtrls,
DBCtrls;
type
TDiag = class(TForm)
DBChart1: TDBChart;
Series1: TPieSeries;
RadioGroup1: TRadioGroup;
Series2: TPieSeries;
Series3: TPieSeries;
Button1: TButton;
DBNavigator1: TDBNavigator;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure RadioGroup1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Diag: TDiag;
implementation
uses dmRashet, fmRashet;
{$R *.dfm}
procedure TDiag.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0:begin
DBChart1.Series[0].Active:=
DBChart1.Title.Text.Text:=#13#
DBChart1.Series[1].Active:=
DBChart1.Series[2].Active:=
DBChart1.AxisVisible:=false;
DBChart1.View3DWalls:=false;
end;
1:begin
DBChart1.Series[1].Active:=
DBChart1.Title.Text.Text:=#13#
DBChart1.Series[0].Active:=
DBChart1.Series[2].Active:=
DBChart1.AxisVisible:=false;
DBChart1.View3DWalls:=false;
end;
2:begin
DBChart1.Series[2].Active:=
DBChart1.Title.Text.Text:=#13#
DBChart1.Series[1].Active:=
DBChart1.Series[0].Active:=
DBChart1.AxisVisible:=false;
DBChart1.View3DWalls:=false;
end;
end;
end;
procedure TDiag.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TDiag.FormActivate(Sender: TObject);
begin
DBChart1.AxisVisible:=false;
DBChart1.View3DWalls:=false;
Label1.Caption:='Тип платежей: '+GlavForm.DBGrid1.Fields[0].
Label2.Caption:='Год: '+GlavForm.DBGrid1.Fields[1].
Label3.Caption:='Квартал: '+GlavForm.DBGrid1.Fields[2].
end;
procedure TDiag.DBNavigator1Click(
begin
GlavForm.Button2.Click;
Label1.Caption:='Тип платежей: '+GlavForm.DBGrid1.Fields[0].
Label2.Caption:='Год: '+GlavForm.DBGrid1.Fields[1].
Label3.Caption:='Квартал: '+GlavForm.DBGrid1.Fields[2].
end;
end.
Текст модуля fmAvtorForm.
unit fmAvtorForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type