tTable1Ostatok.AsFloat:=tTable1Prihod.AsFloat-tTable1Rashod.AsFloat;
end;
//Кнопка "Выход из программы"
procedure TForm1.N5Click(Sender: TObject);
begin
CloseQuery;
end;
//Кнопка "Новаязапись"
procedure TForm1.cmdNewClick(Sender: TObject);
begin
Form2.ShowModal;
end;
//Кнопка "Удалениезаписи"
procedure TForm1.cmdDelClick(Sender: TObject);
begin
if MessageDlg('Удалитьзапись?',
mtConfirmation,[mbYes,mbNo],0) = mrYes then tTable1.Delete;
end;
procedure TForm1.tTable1AfterPost(DataSet: TDataSet);
begin
tTable1.Active:=False;
tTable1.Active:=True;
tTable1.Last;
end;
//Кнопка "Типтовара"
procedure TForm1.cmdTypeClick(Sender: TObject);
begin
Form3.ShowModal;
end;
procedure TForm1.tTable2AfterPost(DataSet: TDataSet);
begin
tTable2.Active:=False;
tTable2.Active:=True;
tTable2.Last;
end;
//Включение режимов сортировки
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
tTable1.Active:=False;
case RadioGroup1.ItemIndex of
0: tTable1.IndexName:='indNazvanie';
1: tTable1.IndexName:='indKod';
2: tTable1.IndexName:='';
end;
tTable1.Active:=True;
end;
//Управлениефильтром
procedure FilterOn();
var v:Variant;
begin
with Form1 do
begin
if CheckBox1.Checked=False then
begin
DBLookupComboBox1.Enabled:=True;
v:=DBLookupComboBox1.KeyValue;
if VarIsNumeric(v) then tTable1.Filter:='Kod='+IntToStr(v)
else tTable1.Filter:='';
tTable1.Filtered:=True;
end
else
begin
DBLookupComboBox1.Enabled:=False;
tTable1.Filtered:=False;
end;
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
FilterOn;
end;
procedure TForm1.DBLookupComboBox1Click(Sender: TObject);
begin
FilterOn;
end;
//Кнопка "Диаграмма"
procedure TForm1.cmdChartClick(Sender: TObject);
begin
Form4.ShowModal;
end;
//Кнопка "Поисктовара"
procedure TForm1.cmdFindClick(Sender: TObject);
var s:String;
f:Boolean;
begin
if InputQuery('Найти','', s) then
begin
f:=tTable1.Locate('Nazvanie',s,[loPartialKey,loCaseInsensitive]);
if f=False then Application.MessageBox('Значениененайдено',
'Результат поиска',MB_ICONWARNING+MB_OK);
end
else tTable1.Cancel;
end;
//Кнопка "Отчет"
procedure TForm1.cmdReportClick(Sender: TObject);
var bm: TBookmark;
begin
bm:=tTable1.GetBookmark;
Form5.QuickRep1.Preview;
tTable1.GotoBookmark(bm);
end;
//Работасменю
procedure TForm1.N6Click(Sender: TObject);
begin
cmdNew.Click;
end;
procedure TForm1.N7Click(Sender: TObject);
begin
cmdDel.Click;
end;
procedure TForm1.N8Click(Sender: TObject);
begin
cmdChart.Click;
end;
procedure TForm1.N9Click(Sender: TObject);
begin
cmdReport.Click;
end;
procedure TForm1.N12Click(Sender: TObject);
begin
cmdFind.Click;
end;
procedure TForm1.N10Click(Sender: TObject);
begin
Application.HelpFile := 'kp.hlp';
Application.HelpCommand(HELP_CONTENTS, 0);
end;
//Выводподсказкивстрокусостояния
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnHint := DisplayHint;
end;
//Выходизпрограммы
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Application.MessageBox('Выуверены?',
'Подтверждениевыхода',mb_yesno+mb_iconquestion)=idyes then CanClose:=True
else CanClose:=False;
end;
//Выводзаставки
procedure TForm1.FormShow(Sender: TObject);
begin
Intro.ShowModal;
end;
procedure TForm1.N11Click(Sender: TObject);
begin
AboutBox.ShowModal;
end;
end.
Листинг П. 4.2 Файл unit2.pas
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, DBTables, Grids, DBGrids, Mask;
type
TForm2 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
cmdOK: TButton;
cmdCancel: TButton;
Label4: TLabel;
DBEdit1: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBLookupComboBox1: TDBLookupComboBox;
procedure cmdOKClick(Sender: TObject);
procedure cmdCancelClick(Sender: TObject);
procedure DBLookupComboBox1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure DBEdit1Change(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.cmdOKClick(Sender: TObject);
begin
Form1.tTable1.Post;
Form2.Close;
end;
procedure TForm2.cmdCancelClick(Sender: TObject);
begin
Form1.tTable1.Cancel;
Form2.Close;
end;
procedure TForm2.DBLookupComboBox1Click(Sender: TObject);
begin
if DBLookupComboBox1.Text<>'' then
if DBEdit1.Text<>'' then cmdOK.Enabled:=True;
end;
procedure TForm2.FormActivate(Sender: TObject);
begin
cmdOK.Enabled:=False;
Form1.tTable1.Append;
end;
procedure TForm2.DBEdit1Change(Sender: TObject);
begin
if DBLookupComboBox1.Text<>'' then
if DBEdit1.Text<>'' then cmdOK.Enabled:=True;
end;
procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Form1.tTable1.Cancel;
Form2.Close;
end;
end.
база данные ведомость приложение
Файл unit3.pas
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, DB;
type
TForm3 = class(TForm)
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit1;
{$R *.dfm}
end.
Файл unit4.pas
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, DbChart, TeeFunci,
DB, DBTables, Grids, DBGrids;
type
TForm4 = class(TForm)
Query1: TQuery;
DBChart1: TDBChart;
Series1: TPieSeries;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm4.FormActivate(Sender: TObject);
begin
Query1.Active:=False;
Query1.Active:=True;
end;
end.
Файл unit5.pas
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, ExtCtrls, DB, DBTables, QRCtrls;
type
TForm5 = class(TForm)
QuickRep1: TQuickRep;
QRGroup1: TQRGroup;
QRBand1: TQRBand;
Table1: TTable;
Table1KodZapisi: TAutoIncField;
Table1Nazvanie: TStringField;
Table1Kod: TIntegerField;
Table1Prihod: TFloatField;
Table1Rashod: TFloatField;
Table1Zena: TFloatField;
Table2: TTable;
Table2Kod: TAutoIncField;
Table2Tip: TStringField;
QRDBText1: TQRDBText;
DataSource1: TDataSource;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel2: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
QRShape1: TQRShape;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
QRDBText5: TQRDBText;
QRDBText6: TQRDBText;
QRExpr1: TQRExpr;
QRExpr2: TQRExpr;
QRBand3: TQRBand;
QRBand4: TQRBand;
QRLabel1: TQRLabel;
QRExpr3: TQRExpr;
QRExpr4: TQRExpr;
QRExpr5: TQRExpr;
QRExpr6: TQRExpr;
QRShape2: TQRShape;
QRLabel9: TQRLabel;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.FormActivate(Sender: TObject);
begin
Table1.Active:=True;
end;
end.
Файл unit6.pas
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls;
type
TIntro = class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Intro: TIntro;
implementation
uses Unit1;
{$R *.dfm}
procedure TIntro.Timer1Timer(Sender: TObject);
begin
Close;
end;
end.
Файл unit7.pas
unit Unit7;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls;
type
TAboutBox = class(TForm)
Panel1: TPanel;
ProductName: TLabel;
Version: TLabel;
OKButton: TButton;
procedure OKButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutBox: TAboutBox;
implementation
{$R *.dfm}
procedure TAboutBox.OKButtonClick(Sender: TObject);
begin
AboutBox.Close;
end;
end.