jvcllaz: Add JvTimeFramework components, incl adapted demo which uses sqlite3 instead of BDE.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7097 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-08-07 15:55:11 +00:00
parent c7dda5d7a3
commit 408079c041
42 changed files with 32355 additions and 18 deletions

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<Title Value="JvTimeFrameDemo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="6">
<Item1>
<PackageName Value="Printer4Lazarus"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
</Item2>
<Item3>
<PackageName Value="DateTimeCtrls"/>
</Item3>
<Item4>
<PackageName Value="SQLDBLaz"/>
</Item4>
<Item5>
<PackageName Value="JvTimeFrameworkLazR"/>
</Item5>
<Item6>
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="6">
<Unit0>
<Filename Value="JvTimeFrameDemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="tfmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="PhotoOpMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfMain"/>
</Unit1>
<Unit2>
<Filename Value="tfvisibleresources.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="VisibleResources"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfVisibleResources"/>
</Unit2>
<Unit3>
<Filename Value="tfshare.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
<UnitName Value="tfShare"/>
</Unit3>
<Unit4>
<Filename Value="tfapptedit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ApptEdit"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfApptEdit"/>
</Unit4>
<Unit5>
<Filename Value="tfprintprogress.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="PrintProgress"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfPrintProgress"/>
</Unit5>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="../../bin/$(TargetCPU)-$(TargetOS)/JvTimeFrameDemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,35 @@
program JvTimeFrameDemo;
{%File 'dbUTF'}
uses
InterfaceBase, SysUtils, Dialogs,
Forms, datetimectrls, printer4lazarus, Interfaces,
tfMain in 'PhotoOpUnit.pas' {PhotoOpMain},
tfVisibleResources in 'VisibleResourcesUnit.pas' {VisibleResources},
tfShare in 'ShareUnit.pas' {Share},
tfApptEdit in 'ApptEditUnit.pas' {ApptEdit},
tfPrintProgress in 'PrintProgressUnit.pas' {PrintProgress};
{$R *.res}
var
fn: String;
begin
Application.Scaled:=True;
Application.Initialize;
fn := Application.Location + 'data.sqlite';
if not FileExists(fn) then begin
MessageDlg('Database file "' + fn + '" not found. Copy it from the source directory to here.',
mtError, [mbOK], 0);
Halt;
end;
Application.CreateForm(TPhotoOpMain, PhotoOpMain);
Application.CreateForm(TVisibleResources, VisibleResources);
Application.CreateForm(TShare, Share);
Application.CreateForm(TApptEdit, ApptEdit);
Application.CreateForm(TPrintProgress, PrintProgress);
Application.Run;
end.

View File

@ -0,0 +1,18 @@
The JvTimeFrameDemo of the JVCL Lazarus port uses an SQLite3 database to store
the data. In order to run this demo you must have SQLite3 installed, or you must
copy the sqlite3.dll to the folder with JvTimeFrameDemo.exe.
It is also required to copy the data base file, data.sqlite, from the source
directory (the directory which contains this readme.txt) to the folder with
JvTimeFrameDemo.exe.
--------------------------------------------------------------------------------
Original text:
The PhotoOp demo uses a Paradox database to store the data. In order to run this
demo, you need to have the BDE installed and correctly configured. In addition,
the path to the data is restricted in Paradox. If you get an error about the
path being too long when you start the application, copy the executable and
the \Data subfolder from the source folder to a folder with a shorter path and
run the demo from that location instead.

View File

@ -0,0 +1,389 @@
object ApptEdit: TApptEdit
Left = 218
Height = 210
Top = 152
Width = 350
AutoSize = True
Caption = 'ApptEdit'
ClientHeight = 210
ClientWidth = 350
Color = clBtnFace
Font.Color = clWindowText
OnClose = FormClose
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.1.0.0'
Scaled = False
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Edit1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 10
Top = 29
Width = 338
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Shape = bsBottomLine
end
object Bevel2: TBevel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = EndDatePicker
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 10
Top = 97
Width = 338
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Shape = bsBottomLine
end
object Label1: TLabel
AnchorSideLeft.Control = Image1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = StartDatePicker
AnchorSideTop.Side = asrCenter
Left = 50
Height = 15
Top = 51
Width = 56
BorderSpacing.Left = 12
Caption = 'Start &Time:'
FocusControl = StartDatePicker
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = EndDatePicker
AnchorSideTop.Side = asrCenter
Left = 50
Height = 15
Top = 78
Width = 52
Caption = '&End Time:'
FocusControl = EndDatePicker
ParentColor = False
end
object Label5: TLabel
AnchorSideLeft.Control = UpDown1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = AlarmAdvanceEdit
AnchorSideTop.Side = asrCenter
Left = 192
Height = 15
Top = 119
Width = 80
BorderSpacing.Left = 8
BorderSpacing.Right = 6
Caption = 'minutes before'
ParentColor = False
end
object Label6: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Edit1
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 10
Width = 42
BorderSpacing.Left = 6
Caption = '&Subject:'
FocusControl = Edit1
ParentColor = False
end
object Image1: TImage
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 32
Top = 47
Width = 32
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 8
Picture.Data = {
1754506F727461626C654E6574776F726B477261706869633006000089504E47
0D0A1A0A0000000D4948445200000020000000200806000000737A7AF4000005
F7494441545885D596DD53135718C6BDE81FD10B2FFB2778D90BEFFA310326BB
212ACE74A622524BA58C1843BAC9D92C84AAD4CAA0A2824644B47C683AC340B2
399BC4E84C35241A3F08042480094128109290F02DF0F44241680802ED45FBDC
ED39EFEEEFD9739EF3EEEEDAF57FD2D72AF3A7193F998FC8096D6678C925D759
07E53AEB20C34B2E39A1CD193F998F30A72CBBFF757066B1F94B86977C324E5C
C8A9684F16D5BE82BABE1FDAC610B48D21A8EBFB71E2460F722ADCD3324E5C60
78C997A1B1C8FE399833EF51E86D5D0ABD6D4A5DDF8FB3E62848731805359DC8
AFF222AFD285BC4A17BEBFF414C7AB7DD0350DA2DC1243F1ED016409F604AB97
7A3339F39E1DC1F7973AF3E45A71A6D0D8BD7CA66D023F5EEB44B6C18E43061B
2A4D1DB8F7B00F0E6F180E6F184DCE002E983A70C86047B6C18EC21A1FCEB44D
A0D0E85F9671E2C27E83A3705B7086500D43E8BCAE69105C4310D906074E55BB
F0A26F1C6B35164F62249A5837F6A26F1CEA6A17F697D8A0B93300FEEE101842
E7153CADD8F29B3384CE08A61114DF7A05A59EE2FEF321FC5DCBCBCB68F707F1
B8EB3516979652E63D3DA33850224155DB85B29631B0449A3950E6546F0ACFE4
CC7BE43AEBACAE691045B53D3864B021F46722E5E12B8A4FCD20969C4919AFFF
DD0E00088F25917BEE010A6A7C104CC390EBC4F90CAEF5F3B4061482D45978DD
BFC83504A1D4D34DE1E9D4DCF610576EB7AE5E0F47A6A1D45368EE0CE0E4CD5E
B0BC14DA10CE0A8E0C855E9A3AD336816C8303CE0D96FD63F2F5BC4681BE0A13
B1C975E3DEDE31280509A75B2350963A120AC19E971A3C5EF2A9EBFBA1AAED42
D115D7B6E18B8B4BD0FD7A137F3CF16D38CF193D28BADE01AE2108865883EBE0
5FABCC9FCA3871E1AC398A6C833D25ED5BD16F2DF771ADC19C763E3014074BAC
28B7C4C0123A9559DCF2D9AA817D5A31EFDB73AE08690EE390C1B66DF8F3AE3E
9C28BD8A78626AD3BAC3E54E700D41E454786272420DAB06E4843617D5BE4241
4D272A4D1DDB82CFCD2F40536E84EB99FFA3B5464B37F22F3F87AA2E009648D6
0F01D44BEDEAFA7EFC70D98B7B0FFBB6045E5A5A42FBF36EFC52DD8CEB8DE296
EE11DD21E45FF240DB18024B68CF8700123AA86D0CE1BB4A171CDE30466349B4
FB83884FA59EF1153D7477E0A8A602473515303BDD69EB923373707707313231
094FCF288E9E7F04C13402B9CE1A496B60249AC0E3AED78826A6D33EF841FBCB
5503C6A6F42B30393D8BC75DAF31341E4F6F40C14B6E757D3FF2AB9EAE6EC146
ED75AD16DEBEC5FDC72F70F31EC5514D05BCBEDEB4B54BCBCB0036DB029EDE2D
AA7D85E3D53E5CD8660801C0EBEBFDA809E07D08AB9E4155170043A8F421843A
E9BB6F7F754DE89A0677740CB76A62E5181EA9F4C419BDF4F387153865D92DE3
C485724B6CC78D68AD894432353B2B8DE8AC399ADA88DE07D15F7C7B00AA1B9D
38B98356FC3191DA2728BAF6125C43107242DFA47C0BE444CACA12EC89336D13
D85F6283B777EC5F83FB835164E9294EB74670D0E08CB182949F62E07D43EA2D
34762F6AEE0C40A9A7088F25FF313C129F45B6C186E2FAC0BB0EC8D3F05EBDF3
930D0D6472E63D324E5CE0EF0EA1A0C687DC730F301C49DF0B923373989C9EDD
149E7BEE010AAA3B20988621D38A730A42BFDA10BEA28306472143E86C59CB18
4EDEE884524FD36E87BBFBDD2FD9CA395F2B7F308A6C830D45D77D286B194396
609B3A50E22CDD14BE22054F2B585E9A174CC328BE3D00A52081AF7D8281E1F5
3F1A231393181A8FAF1B0B0CC5517AEB29B2F414AABA0004D330B24AEC732CB1
D66C09BEA203654EB54C2BCE9DBCD98BD3AD111CBFFA122CB122A7DC09A3A51B
A23B044FCF283C3DA310DD21182DDDC829778225561CBFF202A75B2350D50520
D38A735B7EF39495D08B7B595E0A294B1D09AE2188B3E628B88620F2AB9EE1D8
450F72CF3F42EEF9473876D183FCAA67585B73D0E08CB13C0DB3C4F6C58EE06B
B54F67FD8621D62043E8746EE59359555D00DAC61004D30804D308B48D21A8EA
02C8AD7C3ACF103A2D27F44DA6CE72386DDA77AACCE296CFF67116C212C9CA10
EA97EBACE3729D759C21D4CF102AEDE32C24A5C3FDD7F517CAA592C8B12E2C19
0000000049454E44AE426082
}
Transparent = True
end
object Image2: TImage
AnchorSideLeft.Control = Image1
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Bevel2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Image1
AnchorSideRight.Side = asrBottom
Left = 14
Height = 24
Top = 115
Width = 24
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
Picture.Data = {
1754506F727461626C654E6574776F726B477261706869633102000089504E47
0D0A1A0A0000000D4948445200000018000000180806000000E0773DF8000001
F8494441544889ED96CF6B134114C773C821070F3978E8C13FC5C3DCF266AB5E
0A2D7A152A147AE8C1533D2C041A8A1091122179B3597F507A50E8C5B6C9BCD6
A52548A93FA07521C628B4074B1A5B83B4104ADD3C0FBA524835B39A631F7C8F
F3F9CCBC99612616332CCF154952F21539726BC1B5064CC799C16D112FE7C1D6
08AC11983075CFB345BC3FE002DC21257743F86F89239B8490F172E2C23FC117
5C6B80947C494A763697463BFBD5690EBE3CE4CEC1636ED5B3ECEB31266505A4
AC778B282F459BB92B12E4581F968B5782FDEA34F3D72767A655CFF28B47D7BE
6B94BB9156420AD21A810FDEDFFD233CCCB74FF77FB64C41DA6CF6F9AB17B592
C75BA55B3DE1617C3DC65AC963CF15C99E82924A8146E03D7FCA58B0E74FB146
E0924A41EFF614E4B846E0A39D9CB1E06827C71A81CB0539DE53109E77537818
8DC0E53CD8E78273412C56C6D483B5D9A17654C1DAEC509B14E4FE0AF75C9124
4736DF3EBF1979059B8BA34C8E6C9E799B3D5724280F9735CAD72BC5C193563D
1B5970B83DC32BC5C1134278B384203C5724BAFA5E991B6E1F6ECF44869FBED1
95B9E176D77E8482DAEA047FACDCFEAFD45627BA37FCF473D8AF189DA8B09695
AC6DCCDFE0863FC90D7F9237E6AF77345A556340AF22848C4619AC3F1D09D69F
8DFC7AF821D33781678B3829489382CFA464831032A6BF8A1FDBA511CB562822
EB0000000049454E44AE426082
}
Transparent = True
end
object StartDatePicker: TDateTimePicker
AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Image1
Left = 114
Height = 23
Top = 47
Width = 79
CenturyFrom = 1941
MaxDate = 2958465
MinDate = -53780
TabOrder = 1
BorderSpacing.Left = 8
TrailingSeparator = False
LeadingZeros = True
Kind = dtkDate
TimeFormat = tf24
TimeDisplay = tdHMS
DateMode = dmComboBox
Date = 36235
Time = 0.775961111103243
UseDefaultSeparators = True
HideDateTimeParts = []
MonthNames = 'Long'
CalAlignment = dtaLeft
end
object StartTimePicker: TDateTimePicker
AnchorSideLeft.Control = StartDatePicker
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = StartDatePicker
Left = 217
Height = 23
Top = 47
Width = 65
CenturyFrom = 1941
MaxDate = 2958465
MinDate = -53780
TabOrder = 2
BorderSpacing.Left = 24
BorderSpacing.Right = 6
TrailingSeparator = False
LeadingZeros = True
Kind = dtkTime
TimeFormat = tf24
TimeDisplay = tdHMS
DateMode = dmComboBox
Date = 36235
Time = 0.776266203698469
UseDefaultSeparators = True
HideDateTimeParts = []
MonthNames = 'Long'
CalAlignment = dtaLeft
end
object EndDatePicker: TDateTimePicker
AnchorSideLeft.Control = StartDatePicker
AnchorSideTop.Control = StartDatePicker
AnchorSideTop.Side = asrBottom
Left = 114
Height = 23
Top = 74
Width = 79
CenturyFrom = 1941
MaxDate = 2958465
MinDate = -53780
TabOrder = 3
BorderSpacing.Top = 4
TrailingSeparator = False
LeadingZeros = True
Kind = dtkDate
TimeFormat = tf24
TimeDisplay = tdHMS
DateMode = dmComboBox
Date = 36235
Time = 0.776392129599117
UseDefaultSeparators = True
HideDateTimeParts = []
MonthNames = 'Long'
CalAlignment = dtaLeft
end
object EndTimePicker: TDateTimePicker
AnchorSideLeft.Control = StartTimePicker
AnchorSideTop.Control = EndDatePicker
Left = 217
Height = 23
Top = 74
Width = 65
CenturyFrom = 1941
MaxDate = 2958465
MinDate = -53780
TabOrder = 4
BorderSpacing.Right = 6
TrailingSeparator = False
LeadingZeros = True
Kind = dtkTime
TimeFormat = tf24
TimeDisplay = tdHMS
DateMode = dmComboBox
Date = 36235
Time = 0.77642199069669
UseDefaultSeparators = True
HideDateTimeParts = []
MonthNames = 'Long'
CalAlignment = dtaLeft
end
object AlarmEnabledCheck: TCheckBox
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = AlarmAdvanceEdit
AnchorSideTop.Side = asrCenter
Left = 50
Height = 19
Top = 117
Width = 74
Caption = '&Reminder:'
TabOrder = 5
end
object AlarmAdvanceEdit: TEdit
AnchorSideLeft.Control = AlarmEnabledCheck
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Image2
Left = 132
Height = 23
Top = 115
Width = 37
BorderSpacing.Left = 8
BorderSpacing.Bottom = 8
ReadOnly = True
TabOrder = 6
Text = '0'
end
object UpDown1: TUpDown
AnchorSideLeft.Control = AlarmAdvanceEdit
AnchorSideLeft.Side = asrBottom
Left = 169
Height = 23
Top = 115
Width = 15
Associate = AlarmAdvanceEdit
Max = 60
Min = 0
OnClick = UpDown1Click
Position = 0
TabOrder = 7
end
object Edit1: TEdit
AnchorSideLeft.Control = Label6
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 54
Height = 23
Top = 6
Width = 290
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Constraints.MinWidth = 280
TabOrder = 0
end
object ButtonPanel1: TButtonPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Image2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 26
Top = 155
Width = 338
Align = alNone
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 10
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 8
ShowButtons = [pbOK, pbCancel]
ShowBevel = False
end
end

View File

@ -0,0 +1,236 @@
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.delphi-jedi.org
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit tfApptEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, JvTFManager, ExtCtrls, ButtonPanel,
DateTimePicker;
type
{ TApptEdit }
TApptEdit = class(TForm)
ButtonPanel1: TButtonPanel;
Label1: TLabel;
Label3: TLabel;
Label5: TLabel;
StartDatePicker: TDateTimePicker;
StartTimePicker: TDateTimePicker;
EndDatePicker: TDateTimePicker;
EndTimePicker: TDateTimePicker;
AlarmEnabledCheck: TCheckBox;
AlarmAdvanceEdit: TEdit;
UpDown1: TUpDown;
Edit1: TEdit;
Label6: TLabel;
Bevel1: TBevel;
Image1: TImage;
Bevel2: TBevel;
Image2: TImage;
procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
private
{ Private declarations }
// This form will use this var to indicate whether the appt is being
// editing or whether is it being created. (This is important in the
// OnClose event.)
AddingAppt : Boolean;
public
{ Public declarations }
// the main form will set this var to the selected appt if the user
// wants to edit the appt OR the main form will set this var to nil
// if the user wants to add a new appointment.
Appt : TJvTFAppt;
end;
var
ApptEdit: TApptEdit;
implementation
Uses
tfMain, JvTFDays;
{$R *.lfm}
procedure TApptEdit.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
// Handles the Alarm Advance "spin"
AlarmAdvanceEdit.Text := IntToStr(UpDown1.Position);
end;
procedure TApptEdit.FormShow(Sender: TObject);
var
ApptStartDate,
ApptEndDate : TDate;
ApptStartTime,
ApptEndTime : TTime;
DaysGrid : TJvTFDays;
begin
// Just a short cut to save typing :)
DaysGrid := PhotoOpMain.JvTFDays1;
If Assigned(Appt) Then
Begin
// Assume we want to edit the selected appt
// Populate the window fields from the selected appt
StartDatePicker.Date := Appt.StartDate;
StartTimePicker.Time := Appt.StartTime;
EndDatePicker.Date := Appt.EndDate;
EndTimePicker.Time := Appt.EndTime;
AlarmEnabledCheck.Checked := Appt.AlarmEnabled;
AlarmAdvanceEdit.Text := IntToStr(Appt.AlarmAdvance);
UpDown1.Position := Appt.AlarmAdvance;
Edit1.Text := Appt.Description;
// Change the caption of the form to indicate that the appointment
// is being edited.
Caption := 'Edit Appointment';
// Set the AddingAppt var to false so that the form will recognize
// that the appt is being edited and not created.
AddingAppt := False;
End
Else
Begin
// Assume we are adding a new appt
// Request an appt from the server
Appt := PhotoOpMain.JvTFDays1.ScheduleManager.dbNewAppt('');
// Right now this appt object is in a state of flux. It is not
// assigned to any schedules and shouldn't be because we're unsure
// of its data. The caching system is programmed to automatically
// destroy any appt objects that are not assigned to any schedules.
// In this particular situation, this is bad.
// So...
// Make the Appt object persistent so the cache does not attempt to
// flush it while this window is open.
Appt.Persistent := True;
// Now populate the appt object with some default data which is
// retrieved from the JvTFDays grid.
With Appt do
Begin
If DaysGrid.ValidSelection Then
Begin
// Set the start/end dates according to the selection
ApptStartDate := DaysGrid.Cols[DaysGrid.SelStart.X].SchedDate;
ApptEndDate := DaysGrid.Cols[DaysGrid.SelEnd.X].SchedDate;
// Set the start/end times according to the selection
ApptStartTime := DaysGrid.RowToTime(DaysGrid.SelStart.Y);
ApptEndTime := DaysGrid.RowEndTime(DaysGrid.SelEnd.Y);
End
Else
Begin
// Set the start/end dates to today
ApptStartDate := Date;
ApptEndDate := Date;
// Set the start/end times to now and now + granularity
ApptStartTime := Time;
// Subtract one min from granularity, then add the minute back in.
// (Avoids minute overflow when granularity is 60)
ApptEndTime := ApptStartTime +
EncodeTime(0, DaysGrid.Granularity - 1, 0, 0) +
EncodeTime(0, 1, 0, 0);
End;
Appt.BeginUpdate;
// Call BeginUpdate so that the appt will NOT be posted when we
// set the following properties. Don't worry about calling
// EndUpdate here. It will be called if the user chooses 'OK' to
// save the new appt. See FormClose below.
SetStartEnd(ApptStartDate, ApptStartTime, ApptEndDate, ApptEndTime);
AlarmEnabled := True;
AlarmAdvance := 15;
End;
// Now call this proc again to populate the window fields
FormShow(nil); // Appt won't be nil now so this call will fill the
// window fields
// Set the caption of the form to indicate that the appt is being added
Caption := 'Add Appointment';
// Set the AddingAppt var to true so that the form will recognize that
// the appt is being added instead of edited.
AddingAppt := True;
End;
end;
procedure TApptEdit.FormClose(Sender: TObject; var TheAction: TCloseAction);
var
DaysGrid : TJvTFDays;
I : Integer;
begin
If (ModalResult = mrOK) and Assigned(Appt) Then
With Appt do
Begin
Appt.BeginUpdate;
// Call BeginUpdate so that the appt is not posted while we are
// setting its properties.
Try
// Copy the data from the window fields to the appt object
SetStartEnd(StartDatePicker.Date, StartTimePicker.Time,
EndDatePicker.Date, EndTimePicker.Time);
AlarmEnabled := AlarmEnabledCheck.Checked;
AlarmAdvance := StrToInt(AlarmAdvanceEdit.Text);
Description := Edit1.Text;
If AddingAppt Then
Begin
// Just a shortcut to save some typing :-)
DaysGrid := PhotoOpMain.JvTFDays1;
// Add the appt to selected schedule(s)
For I := 0 to DaysGrid.Cols.Count - 1 do
Appt.AddSchedule(DaysGrid.Cols[I].SchedName);
// Now that we're done working with the appointment and it is
// actually assigned to a schedule, we should set the Persistent
// property to false. This will ensure the the caching system
// will properly dispose of the appointment object when it is
// no longer needed.
Appt.Persistent := False;
End;
Finally
Appt.EndUpdate; // this causes the appt to be posted
End;
End
Else If AddingAppt Then
// The user canceled the window, but we have already created the appt
// object. We need to clean up the appt object we requested from the
// server. This can be done either by manually destroying the appt
// object (Appt.Free), or by setting Appt.Persistent to false.
Appt.Free;
// Set Appt to nil to prepare window for next opening
Appt := nil;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,712 @@
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.delphi-jedi.org
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit tfMain;
interface
uses
LCLIntf,
//Windows, Messages,
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, sqldb, sqlite3conn, //DBTables,
ComCtrls, StdCtrls, Buttons, ExtCtrls, ImgList, DateTimePicker, JvTFManager,
JvTFDays, JvTFGlance, JvTFGlanceTextViewer, JvTFMonths, JvTFWeeks,
JvComponent, JvExControls;
type
{ TPhotoOpMain }
TPhotoOpMain = class(TForm)
ImageList: TImageList;
Label1: TLabel;
Label2: TLabel;
Panel2: TPanel;
utfScheduleManager1: TJvTFScheduleManager;
StateImageList: TImageList;
NeedApptsQuery: TSQLQuery;
ApptSchedulesQuery: TSQLQuery;
GetApptQuery: TSQLQuery;
DeleteApptLinkQuery: TSQLQuery;
DeleteApptQuery: TSQLQuery;
SchedulesQuery: TSQLQuery;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
JvTFDays1: TJvTFDays;
JvTFWeeks1: TJvTFWeeks;
JvTFMonths1: TJvTFMonths;
GlanceTextViewer1: TJvTFGlanceTextViewer;
GlanceTextViewer2: TJvTFGlanceTextViewer;
Panel1: TPanel;
ResourceCombo: TComboBox;
PrevDateButton: TBitBtn;
NextDateButton: TBitBtn;
NewApptButton: TBitBtn;
EditApptButton: TBitBtn;
DeleteApptButton: TBitBtn;
ViewSchedsButton: TBitBtn;
HideSchedButton: TBitBtn;
ShareButton: TBitBtn;
TimeIncCombo: TComboBox;
GotoDatePicker: TDateTimePicker;
ModeCombo: TComboBox;
DaysCombo: TComboBox;
PrintButton: TBitBtn;
dbUTF: TSQLite3Connection;
SQLTransaction: TSQLTransaction;
procedure Label2Click(Sender: TObject);
procedure Label2MouseEnter(Sender: TObject);
procedure Label2MouseLeave(Sender: TObject);
procedure utfScheduleManager1PostAppt(Sender: TObject; Appt: TJvTFAppt);
procedure utfScheduleManager1DeleteAppt(Sender: TObject; Appt: TJvTFAppt);
procedure utfScheduleManager1RefreshAppt(Sender: TObject; Appt: TJvTFAppt);
procedure ModeComboChange(Sender: TObject);
procedure ViewSchedsButtonClick(Sender: TObject);
procedure HideSchedButtonClick(Sender: TObject);
procedure ResourceComboChange(Sender: TObject);
procedure DaysComboChange(Sender: TObject);
procedure ShareButtonClick(Sender: TObject);
procedure PrevDateButtonClick(Sender: TObject);
procedure NextDateButtonClick(Sender: TObject);
procedure GotoDatePickerChange(Sender: TObject);
procedure GotoDatePickerUserInput(Sender: TObject;
const UserString: String; var DateAndTime: TDateTime;
var AllowChange: Boolean);
procedure TimeIncComboChange(Sender: TObject);
procedure NewApptButtonClick(Sender: TObject);
procedure EditApptButtonClick(Sender: TObject);
procedure DeleteApptButtonClick(Sender: TObject);
procedure JvTFDays1DateChanging(Sender: TObject; var NewDate: TDate);
procedure JvTFDays1DateChanged(Sender: TObject);
procedure JvTFDays1GranularityChanged(Sender: TObject);
procedure JvTFDays1DblClick(Sender: TObject);
procedure JvTFDaysPrinter1ApptProgress(Sender: TObject; Current,
Total: Integer);
procedure JvTFDaysPrinter1AssembleProgress(Sender: TObject; Current,
Total: Integer);
procedure JvTFDaysPrinter1PrintProgress(Sender: TObject; Current,
Total: Integer);
procedure utfScheduleManager1LoadBatch(Sender: TObject; BatchName: String;
BatchStartDate, BatchEndDate: TDate);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PrintButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PhotoOpMain: TPhotoOpMain;
implementation
uses
tfVisibleResources, tfShare, tfApptEdit, tfPrintProgress;
{$R *.lfm}
procedure TPhotoOpMain.utfScheduleManager1PostAppt(Sender: TObject;
Appt: TJvTFAppt);
var
I : Integer;
begin
With GetApptQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
Open;
If RecordCount > 0 Then // SQL RecordCount not reliable except on local tables
Edit
Else
Begin
Insert;
FieldByName('ApptID').AsString := Appt.ID;
End;
FieldByName('StartDate').AsDateTime := Appt.StartDate;
FieldByName('StartTime').AsDateTime := Appt.StartTime;
FieldByName('EndDate').AsDateTime := Appt.EndDate;
FieldByName('EndTime').AsDateTime := Appt.EndTime;
FieldByName('Description').AsString := Appt.Description;
FieldByName('AlarmEnabled').AsBoolean := Appt.AlarmEnabled;
FieldByName('AlarmAdvance').AsInteger := Appt.AlarmAdvance;
Post;
Close;
End;
// Now update the Appt --> Schedule relationship
// First delete all entries in the Link table
With DeleteApptLinkQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
ExecSQL;
End;
// Now "refresh" the link table by adding a record for each of the names
// in Appt.Schedules. We will use the ApptSchedulesQuery to update the table.
With ApptSchedulesQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
Open;
For I := 0 to Appt.ScheduleCount - 1 do
Begin
Insert;
FieldByName('ApptID').AsString := Appt.ID;
FieldByName('SchedName').AsString := Appt.Schedules[I];
Post;
End;
Close;
End;
end;
procedure TPhotoOpMain.utfScheduleManager1DeleteAppt(Sender: TObject;
Appt: TJvTFAppt);
begin
// First delete the appointment from the appointment table
With DeleteApptQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
ExecSQL;
End;
// Next, delete the related records from the link table
With DeleteApptLinkQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
ExecSQL;
End;
end;
procedure TPhotoOpMain.utfScheduleManager1RefreshAppt(Sender: TObject;
Appt: TJvTFAppt);
begin
With GetApptQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
Open;
If RecordCount = 1 Then
Begin
Appt.SetStartEnd(FieldByName('StartDate').AsDateTime,
FieldByName('StartTime').AsDateTime,
FieldByName('EndDate').AsDateTime,
FieldByName('EndTime').AsDateTime);
Appt.Description := FieldByName('Description').AsString;
Appt.AlarmEnabled := FieldByName('AlarmEnabled').AsBoolean;
Appt.AlarmAdvance := FieldByName('AlarmAdvance').AsInteger;
End;
Close;
End;
// Now update the Appt --> Schedule(s) relationship
Appt.ClearSchedules;
With ApptSchedulesQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
Open;
First;
While not EOF do
Begin
Appt.AddSchedule(FieldByName('SchedName').AsString);
Next;
End;
Close; // ApptSchedulesQuery
End;
end;
procedure TPhotoOpMain.ModeComboChange(Sender: TObject);
begin
If ModeCombo.ItemIndex = 0 Then
// Single mode
Begin
// display the appropriate tool bar controls
ViewSchedsButton.Visible := False;
HideSchedButton.Visible := False;
ShareButton.Visible := False;
ResourceCombo.Visible := True;
DaysCombo.Visible := True;
// synchronize the date
JvTFDays1.Template.LinearStartDate := GotoDatePicker.Date;
// "activate" the Linear template
JvTFDays1.Template.ActiveTemplate := agtLinear;
// set the column grouping
JvTFDays1.Grouping := grResource;
End
Else
// Group mode
Begin
// display the appropriate tool bar controls
ViewSchedsButton.Visible := True;
HideSchedButton.Visible := True;
ShareButton.Visible := True;
ResourceCombo.Visible := False;
DaysCombo.Visible := False;
// synchronize the date
JvTFDays1.Template.CompDate := GotoDatePicker.Date;
// "activate" the Comparative template
JvTFDays1.Template.ActiveTemplate := agtComparative;
// set the column grouping
JvTFDays1.Grouping := grDate;
End;
end;
procedure TPhotoOpMain.ViewSchedsButtonClick(Sender: TObject);
begin
VisibleResources.ShowModal;
end;
procedure TPhotoOpMain.HideSchedButtonClick(Sender: TObject);
var
I,
NameIndex : Integer;
NameList : TStringList;
begin
NameList := TStringList.Create;
Try
With JvTFDays1 do
Begin
If ValidSelection Then
Begin
For I := SelStart.X to SelEnd.X do
NameList.Add(Cols[I].SchedName);
For I := 0 to NameList.Count - 1 do
Begin
NameIndex := Template.CompNames.IndexOf(NameList[I]);
If NameIndex > -1 Then
Template.CompNames.Delete(NameIndex);
End;
End
Else
MessageDlg('Please select a schedule to hide.', mtInformation, [mbOK], 0);
End;
Finally
NameList.Free;
End;
end;
procedure TPhotoOpMain.ResourceComboChange(Sender: TObject);
begin
JvTFDays1.Template.LinearName := ResourceCombo.Text;
JvTFWeeks1.SchedNames.Clear;
JvTFWeeks1.SchedNames.Add(ResourceCombo.Text);
JvTFWeeks1.Refresh;
JvTFMonths1.SchedNames.Clear;
JvTFMonths1.SchedNames.Add(ResourceCombo.Text);
JvTFMonths1.Refresh;
end;
procedure TPhotoOpMain.DaysComboChange(Sender: TObject);
begin
Case DaysCombo.ItemIndex of
0 : JvTFDays1.Template.LinearDayCount := 31;
1 : JvTFDays1.Template.LinearDayCount := 14;
2 : JvTFDays1.Template.LinearDayCount := 7;
3 : JvTFDays1.Template.LinearDayCount := 5;
4 : JvTFDays1.Template.LinearDayCount := 3;
5 : JvTFDays1.Template.LinearDayCount := 2;
6 : JvTFDays1.Template.LinearDayCount := 1;
End;
end;
procedure TPhotoOpMain.ShareButtonClick(Sender: TObject);
begin
If JvTFDays1.SelAppt <> nil Then
Share.ShowModal
Else
MessageDlg('Please select an appointment.', mtInformation, [mbOK], 0);
end;
procedure TPhotoOpMain.PrevDateButtonClick(Sender: TObject);
begin
JvTFDays1.PrevDate;
end;
procedure TPhotoOpMain.NextDateButtonClick(Sender: TObject);
begin
JvTFDays1.NextDate;
end;
procedure TPhotoOpMain.GotoDatePickerChange(Sender: TObject);
begin
// GotoDatePicker.OnCloseUp should also point to this handler
JvTFDays1.GotoDate(GotoDatePicker.Date);
JvTFWeeks1.DisplayDate := GotoDatePicker.Date;
JvTFWeeks1.DisplayDate := GotoDatePicker.Date;
end;
procedure TPhotoOpMain.GotoDatePickerUserInput(Sender: TObject;
const UserString: String; var DateAndTime: TDateTime;
var AllowChange: Boolean);
begin
AllowChange := True;
GotoDatePicker.OnChange(nil);
end;
procedure TPhotoOpMain.TimeIncComboChange(Sender: TObject);
begin
Case TimeIncCombo.ItemIndex of
0 : JvTFDays1.Granularity := 60;
1 : JvTFDays1.Granularity := 30;
2 : JvTFDays1.Granularity := 20;
3 : JvTFDays1.Granularity := 15;
4 : JvTFDays1.Granularity := 12;
5 : JvTFDays1.Granularity := 10;
6 : JvTFDays1.Granularity := 6;
7 : JvTFDays1.Granularity := 5;
8 : JvTFDays1.Granularity := 4;
9 : JvTFDays1.Granularity := 3;
10 : JvTFDays1.Granularity := 2;
11 : JvTFDays1.Granularity := 1;
End;
end;
procedure TPhotoOpMain.NewApptButtonClick(Sender: TObject);
begin
// Simply open the EditAppt window. The Appt var of the
// EditAppt form will already be nil (which indicates
// that the appoinment is being created).
ApptEdit.ShowModal;
end;
procedure TPhotoOpMain.EditApptButtonClick(Sender: TObject);
begin
If Assigned(JvTFDays1.SelAppt) Then
Begin
// Set EditAppt's Appt var to the selected appointment to
// indicate that the appointment should be edited.
ApptEdit.Appt := JvTFDays1.SelAppt;
ApptEdit.ShowModal;
End
Else
MessageDlg('Please select an appointment to edit.', mtInformation,
[mbOK], 0);
end;
procedure TPhotoOpMain.DeleteApptButtonClick(Sender: TObject);
var
Appt : TJvTFAppt;
dbDel : Boolean;
SelSchedName : String;
begin
// This routine employs a simple business that asks the user what to
// do in the case where the user is attempting to delete a shared appt.
// NOTE: This is NOT required. You are completely free to implement
// any business rules you see fit.
// Another shortcut to save typing
Appt := JvTFDays1.SelAppt;
If Assigned(Appt) Then
Begin
dbDel := True;
If Appt.Shared Then
If MessageDlg('This appointment is shared with other schedules.' + #13#10 +
'Do you want to delete the appointment from ' +
'all schedules?' + #13#10#13#10 +
'Choose ''No'' to delete the appointment from the ' +
'selected schedule only.' + #13#10 +
'Choose ''All'' to delete the appointment from all schedules.',
mtConfirmation, [mbNo, mbAll], 0) = mrNo Then
Begin
// Don't delete the appointment, but remove it from the schedule
// of the selected resource.
dbDel := False;
With JvTFDays1 do
Begin
SelSchedName := '';
If ValidSelection and Cols[SelStart.X].Connected Then
SelSchedName := Cols[SelStart.X].Schedule.SchedName;
End;
If SelSchedName <> '' Then
Appt.RemoveSchedule(SelSchedName)
Else
MessageDlg('No schedule is selected.' + #13#10 +
'Could not remove appointment from schedule.',
mtInformation, [mbOK], 0);
End;
If dbDel Then
If MessageDlg('Are you sure you want to delete the selected appointment?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
// Delete the appointment (removes it from the db)
// Note: Could substitute Appt.Delete; for the line below
JvTFDays1.ScheduleManager.dbDeleteAppt(JvTFDays1.SelAppt);
End
Else
MessageDlg('Please select an appointment to delete.',
mtInformation, [mbOK], 0);
end;
procedure TPhotoOpMain.JvTFDays1DateChanging(Sender: TObject;
var NewDate: TDate);
begin
// Make sure all appts are posted before moving on.
JvTFDays1.ScheduleManager.PostAppts;
end;
procedure TPhotoOpMain.JvTFDays1DateChanged(Sender: TObject);
begin
// Synchronize the tool bar
With JvTFDays1.Template do
If ActiveTemplate = agtLinear Then
GotoDatePicker.Date := LinearStartDate
Else
GotoDatePicker.Date := CompDate;
end;
procedure TPhotoOpMain.JvTFDays1GranularityChanged(Sender: TObject);
begin
// Update the TimeIncCombo when the granularity is changed.
// (This can be done by <Ctrl> + <Insert> and <Ctrl> + <Delete>)
Case JvTFDays1.Granularity of
60 : TimeIncCombo.ItemIndex := 0;
30 : TimeIncCombo.ItemIndex := 1;
20 : TimeIncCombo.ItemIndex := 2;
15 : TimeIncCombo.ItemIndex := 3;
12 : TimeIncCombo.ItemIndex := 4;
10 : TimeIncCombo.ItemIndex := 5;
6 : TimeIncCombo.ItemIndex := 6;
5 : TimeIncCombo.ItemIndex := 7;
4 : TimeIncCombo.ItemIndex := 8;
3 : TimeIncCombo.ItemIndex := 9;
2 : TimeIncCombo.ItemIndex := 10;
Else
TimeIncCombo.ItemIndex := 11;
End;
end;
procedure TPhotoOpMain.JvTFDays1DblClick(Sender: TObject);
begin
With JvTFDays1 do
If ValidSelection Then
If Assigned(SelAppt) Then
EditApptButtonClick(nil)
Else
NewApptButtonClick(nil);
end;
procedure TPhotoOpMain.FormShow(Sender: TObject);
var
ResName : String;
begin
// Initialize the date
//GotoDatePicker.Date := Date;
GotoDatePicker.Date := EncodeDate(2002, 1, 1);
// Initialize the granularity
TimeIncCombo.ItemIndex := 1; // 30 mins
// Initialize the mode
ModeCombo.ItemIndex := 0; // Single mode
DaysCombo.ItemIndex := 6; // One day
// Populate the resource related controls
With SchedulesQuery do
try
Open;
First;
While not EOF do
Begin
ResName := SchedulesQuery.FieldByName('SchedName').AsString;
ResourceCombo.Items.Add(ResName);
VisibleResources.ResourcesCheckList.Items.Add(ResName);
Share.ResourcesCheckList.Items.Add(ResName);
Next;
End;
Close;
except
//on E:EDBEngineError do
on E: EDatabaseError do
begin
ShowMessageFmt('%s:'#13#10'Try moving the database to a shorter path.',[E.Message]);
Application.Terminate;
Exit;
end;
end;
// Initialize the resource related controls
ResourceCombo.ItemIndex := 0;
VisibleResources.ResourcesCheckList.Checked[0] := True;
// Initialize the comparative template
JvTFDays1.Template.CompNames.Add(VisibleResources.ResourcesCheckList.Items[0]);
// Now run the events to synchronize JvTFDays, etc.
ResourceComboChange(nil);
DaysComboChange(nil);
ModeComboChange(nil);
GotoDatePicker.Date := EncodeDate(2002, 1, 1);
GotoDatePickerChange(nil);
TimeIncComboChange(nil);
end;
procedure TPhotoOpMain.PrintButtonClick(Sender: TObject);
begin
(******************** wp: deactivated due to stack overflow ************
With JvTFDaysPrinter1 do
Begin
// "Copy" the display properties from the JvTFDays control
SetProperties(JvTFDays1);
// Set gridline color to black for sharp display on printed page
GridLineColor := clBlack;
// print 48 rows on each page
PageLayout.RowsPerPage := 48;
// fit all the columns onto one page wide
PageLayout.ColsPerPage := 0;
// "Copy" the schedules from the JvTFDays control
Cols.Assign(JvTFDays1.Cols);
PrintProgress.Show;
Application.ProcessMessages;
// print the document
PrintDirect;
PrintProgress.Close;
End;
************************)
end;
procedure TPhotoOpMain.JvTFDaysPrinter1ApptProgress(Sender: TObject;
Current, Total: Integer);
begin
If Current > Total Then
Total := Current;
PrintProgress.Label2.Caption := 'Processing appointment ' + IntToStr(Current) +
' of ' + IntToStr(Total) + ' (estimated)';
PrintProgress.ProgressBar1.Max := Total;
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.JvTFDaysPrinter1AssembleProgress(Sender: TObject;
Current, Total: Integer);
begin
PrintProgress.Label2.Caption := 'Assembling page ' + IntToStr(Current) +
' of ' + IntToStr(Total);
PrintProgress.ProgressBar1.Max := Total;
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.JvTFDaysPrinter1PrintProgress(Sender: TObject;
Current, Total: Integer);
begin
PrintProgress.Label2.Caption := 'Printing page ' + IntToStr(Current) +
' of ' + IntToStr(Total);
PrintProgress.ProgressBar1.Max := Total;
PrintProgress.ProgressBar1.Position := Current;
end;
procedure TPhotoOpMain.Label2Click(Sender: TObject);
begin
OpenURL('https://icons8.com');
end;
procedure TPhotoOpMain.Label2MouseEnter(Sender: TObject);
begin
Label2.Font.Style := Label2.Font.Style + [fsUnderline];
Screen.Cursor := crHandPoint;
end;
procedure TPhotoOpMain.Label2MouseLeave(Sender: TObject);
begin
Label2.Font.Style := Label2.Font.Style - [fsUnderline];
Screen.Cursor := crDefault;
end;
procedure TPhotoOpMain.utfScheduleManager1LoadBatch(Sender: TObject;
BatchName: String; BatchStartDate, BatchEndDate: TDate);
var
Appt : TJvTFAppt;
NewAppt : Boolean;
begin
With NeedApptsQuery do
Begin
// Set the query parameters so the query will return
// all appointments for the given resource that fall
// on the given date.
ParamByName('D1').AsDate := BatchStartDate;
ParamByName('D2').AsDate := BatchEndDate;
ParamByName('SchedName').AsString := BatchName;
// Next, loop through the returned records to add the data
Open;
First;
While not EOF do
Begin
// Request an appointment object from the server
utfScheduleManager1.RequestAppt(FieldByName('ApptID').AsString,
Appt, NewAppt);
// If it is a newly loaded appt we want to set its properties
If NewAppt Then
Begin
Appt.SetStartEnd(FieldByName('StartDate').AsDateTime,
FieldByName('StartTime').AsDateTime,
FieldByName('EndDate').AsDateTime,
FieldByName('EndTime').AsDateTime);
Appt.Description := FieldByName('Description').AsString;
Appt.AlarmEnabled := FieldByName('AlarmEnabled').AsBoolean;
Appt.AlarmAdvance := FieldByName('AlarmAdvance').AsInteger;
// Now manage the Appt --> Schedule(s) relationship
With ApptSchedulesQuery do
Begin
ParamByName('ApptID').AsString := Appt.ID;
Open;
First;
While not EOF do
Begin
Appt.AddSchedule(FieldByName('SchedName').AsString);
Next;
End;
Close; // ApptSchedulesQuery
End;
End;
Next; // NeedApptsQuery record
End;
Close; // NeedApptsQuery
End;
end;
procedure TPhotoOpMain.FormCreate(Sender: TObject);
var
fn: String;
begin
fn := Application.Location + 'data.sqlite';
dbUTF.DatabaseName := fn;
dbUTF.Connected := FileExists(fn);
end;
end.

View File

@ -0,0 +1,78 @@
object PrintProgress: TPrintProgress
Left = 613
Height = 161
Top = 250
Width = 367
BorderIcons = []
BorderStyle = bsSingle
Caption = 'Print Progress'
ClientHeight = 161
ClientWidth = 367
Color = clBtnFace
Font.Color = clWindowText
FormStyle = fsStayOnTop
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.1.0.0'
Scaled = False
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 16
Height = 33
Top = 16
Width = 335
Anchors = [akTop, akLeft, akRight]
AutoSize = False
BorderSpacing.Left = 16
BorderSpacing.Top = 16
BorderSpacing.Right = 16
Caption = 'Generating Report. This may take a while. Please be patient.'
ParentColor = False
WordWrap = True
end
object Label2: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label1
AnchorSideRight.Side = asrBottom
Left = 16
Height = 16
Top = 49
Width = 335
Alignment = taCenter
Anchors = [akTop, akLeft, akRight]
AutoSize = False
Caption = 'Processing...'
ParentColor = False
end
object ProgressBar1: TProgressBar
AnchorSideLeft.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label1
AnchorSideRight.Side = asrBottom
Left = 16
Height = 20
Top = 80
Width = 335
Anchors = [akTop, akLeft, akRight]
Max = 200
TabOrder = 0
end
object CancelButton: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
Left = 142
Height = 26
Top = 120
Width = 82
AutoSize = True
Caption = 'Cancel'
Kind = bkCancel
OnClick = CancelButtonClick
TabOrder = 1
end
end

View File

@ -0,0 +1,69 @@
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.delphi-jedi.org
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit tfPrintProgress;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls;
type
TPrintProgress = class(TForm)
Label1: TLabel;
Label2: TLabel;
ProgressBar1: TProgressBar;
CancelButton: TBitBtn;
procedure CancelButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PrintProgress: TPrintProgress;
implementation
uses tfMain;
{$R *.lfm}
procedure TPrintProgress.CancelButtonClick(Sender: TObject);
begin
// PhotoOpMain.JvTFDaysPrinter1.AbortPrint;
end;
procedure TPrintProgress.FormShow(Sender: TObject);
begin
ProgressBar1.Position := 0;
Label2.Caption := 'Processing...';
end;
end.

View File

@ -0,0 +1,44 @@
object Share: TShare
Left = 738
Top = 285
Width = 271
Height = 216
Caption = 'Share'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
Position = poScreenCenter
Scaled = False
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 16
object ResourcesCheckList: TCheckListBox
Left = 16
Top = 8
Width = 225
Height = 129
ItemHeight = 16
TabOrder = 0
end
object OKButton: TBitBtn
Left = 40
Top = 152
Width = 75
Height = 25
TabOrder = 1
Kind = bkOK
end
object CancelButton: TBitBtn
Left = 152
Top = 152
Width = 75
Height = 25
TabOrder = 2
Kind = bkCancel
end
end

View File

@ -0,0 +1,114 @@
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.delphi-jedi.org
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit tfShare;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst;
type
TShare = class(TForm)
ResourcesCheckList: TCheckListBox;
OKButton: TBitBtn;
CancelButton: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Share: TShare;
implementation
uses
tfMain, JvTFManager;
{$R *.lfm}
procedure TShare.FormShow(Sender: TObject);
var
Appt : TJvTFAppt;
I : Integer;
begin
// First, get the selected appointment
Appt := PhotoOpMain.JvTFDays1.SelAppt;
// now roll through the resource list and check all resources
// that are found in the appointment's list of schedules.
With ResourcesCheckList do
For I := 0 to Items.Count - 1 do
Checked[I] := Appt.IndexOfSchedule(Items[I]) > -1;
end;
procedure TShare.FormClose(Sender: TObject; var TheAction: TCloseAction);
var
TempList : TStringList;
I : Integer;
begin
If ModalResult = mrOK Then
Begin
// create and populate a temporary list of the selected resources
// from the checklistbox.
TempList := TStringList.Create;
Try
With ResourcesCheckList do
For I := 0 to Items.Count - 1 do
If Checked[I] Then
TempList.Add(Items[I]);
// Enforce a business rule where removing all resources from an
// appointment causes the appointment to be deleted.
// NOTE: This is NOT a requirement. Feel free to implement any
// business rules as you see fit.
If TempList.Count > 0 Then
// If at least one resource then change the appointment's
// schedule list to match the temp list.
PhotoOpMain.JvTFDays1.SelAppt.AssignSchedules(TempList)
Else
If MessageDlg('You have removed this appointment from all schedules.' +
' This will cause the appointment to be deleted.' + #13#10 +
'Are you sure this is what you want to do?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
With PhotoOpMain.JvTFDays1 do
// Delete the appointment if that is what the user wants to do.
ScheduleManager.dbDeleteAppt(SelAppt)
Else
TheAction := caNone;
Finally
TempList.Free;
End;
End;
end;
end.

View File

@ -0,0 +1,53 @@
object VisibleResources: TVisibleResources
Left = 707
Height = 205
Top = 215
Width = 271
Caption = 'Visible Resources'
ClientHeight = 205
ClientWidth = 271
Font.Color = clWindowText
OnClose = FormClose
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.1.0.0'
Scaled = False
object ResourcesCheckList: TCheckListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 16
Height = 129
Top = 16
Width = 239
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 16
BorderSpacing.Top = 16
BorderSpacing.Right = 16
ItemHeight = 0
TabOrder = 0
end
object OKButton: TBitBtn
AnchorSideLeft.Control = ResourcesCheckList
Left = 40
Height = 25
Top = 160
Width = 75
BorderSpacing.Left = 24
Kind = bkOK
TabOrder = 1
end
object CancelButton: TBitBtn
AnchorSideRight.Control = ResourcesCheckList
AnchorSideRight.Side = asrBottom
Left = 156
Height = 25
Top = 160
Width = 75
Anchors = [akTop, akRight]
BorderSpacing.Right = 24
Kind = bkCancel
TabOrder = 2
end
end

View File

@ -0,0 +1,94 @@
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.delphi-jedi.org
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit tfVisibleResources;
{$mode objfpc}{$H+}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, checklst;
type
TVisibleResources = class(TForm)
ResourcesCheckList: TCheckListBox;
OKButton: TBitBtn;
CancelButton: TBitBtn;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
VisibleResources: TVisibleResources;
implementation
Uses tfMain;
{$R *.lfm}
procedure TVisibleResources.FormShow(Sender: TObject);
var
I : Integer;
begin
// Check the template and check any resources currently
// visible in the grid
With PhotoOpMain.JvTFDays1.Template do
For I := 0 to ResourcesCheckList.Items.Count - 1 do
ResourcesCheckList.Checked[I] :=
CompNames.IndexOf(ResourcesCheckList.Items[I]) > -1;
end;
procedure TVisibleResources.FormClose(Sender: TObject;
var TheAction: TCloseAction);
var
I : Integer;
begin
If ModalResult = mrOK Then
begin
// First, clear the old resources from the template
PhotoOpMain.JvTFDays1.Template.CompNames.Clear;
PhotoOpMain.JvTFWeeks1.SchedNames.Clear;
PhotoOpMain.JvTFMonths1.SchedNames.Clear;
// Next, add the new resources to the template
For I := 0 to ResourcesCheckList.Items.Count - 1 do
If ResourcesCheckList.Checked[I] Then
begin
PhotoOpMain.JvTFDays1.Template.CompNames.Add(ResourcesCheckList.Items[I]);
PhotoOpMain.JvTFWeeks1.SchedNames.Add(ResourcesCheckList.Items[I]);
PhotoOpMain.JvTFMonths1.SchedNames.Add(ResourcesCheckList.Items[I]);
end;
end;
end;
end.