unit DMU interface uses System SysUtils IdGlobal System Classes EhLibM

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
unit DMU;
interface
uses
System.SysUtils, IdGlobal,System.Classes, EhLibMTE, MemTableDataEh, Data.DB,
windows, messages, MemTableEh, DataDriverEh, Data.Win.ADODB, MemDS,
VirtualTable, Vcl.ImgList, Vcl.Controls, acAlphaImageList, Vcl.Menus,
Vcl.Dialogs, sDialogs, ToolCtrlsEh, DBGridEhToolCtrls, ADODataDriverEh,
DynVarsEh, sSkinManager, PrnDbgeh, frxClass, frxDBSet, frxExportPDF,
Forms, RzCommon, IniFiles, frxExportXLS, frxExportRTF, frxExportHTML, System.Types;
type
TDM = class(TDataModule)
VPT: TVirtualTable;
VPS: TDataSource;
AOSS: TDataSource;
CabS: TDataSource;
OSS: TDataSource;
SotrS: TDataSource;
DevS: TDataSource;
CON: TADOConnection;
ITT: TADOTable;
CabT: TADOTable;
OST: TADOTable;
SotrT: TADOTable;
DevT: TADOTable;
DSD: TDataSetDriverEh;
AOST: TMemTableEh;
AOSTКод: TAutoIncField;
AOSTCOD: TIntegerField;
AOSTИНВ: TIntegerField;
AOSTУстройство: TIntegerField;
AOSTКабинет: TIntegerField;
AOSTОС: TIntegerField;
AOSTСотрудник: TIntegerField;
AOSTДатаучета: TDateTimeField;
AOSTUpgrade: TDateTimeField;
AOSTSN: TWideStringField;
AOSTКонфигурация: TWideMemoField;
AOSTDev: TStringField;
AOSTCab: TStringField;
AOSTOS: TStringField;
AOSTSotr: TStringField;
VPTКод: TAutoIncField;
VPTKabinet: TWideStringField;
VPTINB: TWideStringField;
VPTName: TWideStringField;
VPTQRCOD: TBlobField;
MImage: TsAlphaImageList;
ITTКод: TAutoIncField;
ITTCOD: TIntegerField;
ITTИНВ: TIntegerField;
ITTУстройство: TIntegerField;
ITTКабинет: TIntegerField;
ITTОС: TIntegerField;
ITTСотрудник: TIntegerField;
ITTДатаучета: TDateTimeField;
ITTUpgrade: TDateTimeField;
ITTSN: TWideStringField;
ITTКонфигурация: TWideMemoField;
CabTКод: TAutoIncField;
CabTКабинет: TWideStringField;
OSTКод: TAutoIncField;
OSTОС: TWideStringField;
SotrTКод: TAutoIncField;
SotrTСотрудник: TWideStringField;
DevTКод: TAutoIncField;
DevTУстройство: TWideStringField;
OpenDB: TsOpenDialog;
sSkinManager1: TsSkinManager;
SFile: TsSaveDialog;
AImage: TsAlphaImageList;
PGrid: TPrintDBGridEh;
QRDS: TfrxDBDataset;
QRPrint: TfrxReport;
PDF: TfrxPDFExport;
XLS: TfrxXLSExport;
Export: TfrxDBDataset;
Export1: TfrxReport;
EPT: TVirtualTable;
EPTКод: TAutoIncField;
EPTCOD: TIntegerField;
EPTИНВ: TIntegerField;
EPTУстройство: TStringField;
EPTКабинет: TStringField;
EPTОС: TStringField;
EPTСотрудник: TWideStringField;
EPTДатаучета: TDateTimeField;
EPTUpgrade: TDateTimeField;
EPTSN: TWideStringField;
EPTКонфигурация: TWideMemoField;
RTF: TfrxRTFExport;
HTML: TfrxHTMLExport;
procedure DataModuleCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DM: TDM;
SetIni: Tinifile;
Source: string;
procedure Connect;
procedure LoadIni;
procedure SaveIni;
implementation
uses AOSU, SetU;
{ %CLASSGROUP 'Vcl.Controls.TControl' }
{$R *.dfm}
//Открытие, создание БД...
procedure Connect;
var
FilePath: String;
begin
AOS.GRID.StartLoadingStatus('Загрузка БД...', -1);
if FileExists(Source) then
FilePath := Source
else if DM.OpenDB.Execute then
FilePath := DM.OpenDB.FileName
else
if Application.MessageBox
(PChar('База Данных не найдена, хотите создать новую БД?'), 'Внимание!!!',
MB_OKCANCEL + MB_ICONWARNING) = id_OK then
begin
DM.SFile.Filter := 'MDB|*.mdb';
DM.SFile.DefaultExt := 'MDB';
AOS.GRID.StartLoadingStatus('Создание БД...', -1);
if DM.SFile.Execute then
With DM.CON do
begin
CopyFile(PChar(ExtractFilePath(ParamStr(0)) + '\new.aos'),
(PChar(DM.SFile.FileName)), true);
FilePath := DM.SFile.FileName;
AOS.GRID.FinishLoadingStatus;
end;
end
else
Application.Terminate;
DM.CON.ConnectionString := ('Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;'
+ 'Data Source=' + FilePath + ';' +
'Mode=Share Deny None;Jet OLEDB:System database="";');
Source := FilePath;
AOS.Caption := 'Инвентаризация оборудования';
DM.AOST.Active := true;
DM.ITT.Active := true;
DM.CabT.Active := true;
DM.OST.Active := true;
DM.SotrT.Active := true;
DM.DevT.Active := true;
DM.DSD.KeyFields := 'Код';
DM.AOST.Refresh;
AOS.Show;
AOS.GRID.Refresh;
AOS.GRID.FinishLoadingStatus;
end;
//Действие при создание формы...
procedure TDM.DataModuleCreate(Sender: TObject);
begin
LoadIni;
CON.Connected := False;
Connect;
CON.Connected := true;
end;
// Сохранение параметров конфигурации...
procedure SaveIni;
begin
SetIni := Tinifile.Create(ExtractFilePath(Application.ExeName) + '\aosit.aos');
SetIni.WriteBool('Grid', 'Find', AOS.GRID.STFilter.Visible);
SetIni.WriteInteger('Grid', 'FindIco', AOS.Find.ImageIndex);
SetIni.WriteString('Grid', 'FindHint', AOS.Find.Hint);
SetIni.WriteString('Source', 'Source', Source);
end;
// Загрузкка параметров конфигурации...
procedure LoadIni;
begin
SetIni := Tinifile.Create(ExtractFilePath(Application.ExeName) + '\aosit.aos');
AOS.GRID.STFilter.Visible := SetIni.ReadBool('Grid', 'Find', False);
AOS.Find.ImageIndex := SetIni.ReadInteger('Grid', 'FindIco', 4);
AOS.Find.Hint:= SetIni.ReadString('Grid', 'FindHint','Поиск Включить');
Source := SetIni.ReadString('Source', 'Source', '');
end;end;
end.