You've already forked lazarus-ccr
jvcllaz: Add code to create an empty database in JvTimeFrame demo.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7138 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -18,13 +18,14 @@ var
|
||||
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;
|
||||
end; *)
|
||||
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.CreateForm(TVisibleResources, VisibleResources);
|
||||
Application.CreateForm(TShare, Share);
|
||||
|
@ -134,6 +134,8 @@ type
|
||||
procedure utfScheduleManager1PostAppt(Sender: TObject; Appt: TJvTFAppt);
|
||||
procedure utfScheduleManager1RefreshAppt(Sender: TObject; Appt: TJvTFAppt);
|
||||
|
||||
procedure CreateDatabase(const AFileName: String);
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
@ -142,6 +144,8 @@ type
|
||||
procedure WeeksComboChange(Sender: TObject);
|
||||
|
||||
private
|
||||
FNewDatabase: Boolean;
|
||||
|
||||
{ Private declarations }
|
||||
procedure ApplySettings;
|
||||
procedure ReadIni;
|
||||
@ -193,6 +197,12 @@ begin
|
||||
ShareButton.Images := images[IconSet];
|
||||
NewSchedButton.Images := images[IconSet];
|
||||
utfScheduleManager1.StateImages := images[IconSet];
|
||||
|
||||
if StartToday then
|
||||
GotoDatePicker.Date := Date()
|
||||
else
|
||||
GotoDatePicker.Date := StartDate;
|
||||
GotoDatePickerChange(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -634,18 +644,12 @@ var
|
||||
ResName : String;
|
||||
begin
|
||||
// Initialize the date
|
||||
//GotoDatePicker.Date := Date;
|
||||
GotoDatePicker.Date := EncodeDate(2002, 1, 1);
|
||||
|
||||
ReadIni;
|
||||
(*
|
||||
// Initialize the granularity
|
||||
TimeIncCombo.ItemIndex := 1; // 30 mins
|
||||
|
||||
// Initialize the mode
|
||||
ModeCombo.ItemIndex := 0; // Single mode
|
||||
DaysCombo.ItemIndex := 0; // One day
|
||||
*)
|
||||
// GotoDatePicker.Date := EncodeDate(2002, 1, 1);
|
||||
|
||||
if FNewDatabase then
|
||||
NewSchedButtonClick(nil);
|
||||
|
||||
// Populate the resource related controls
|
||||
With SchedulesQuery do
|
||||
@ -849,6 +853,35 @@ begin
|
||||
End;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CreateDatabase(const AFileName: String);
|
||||
var
|
||||
sql: String;
|
||||
begin
|
||||
dbUTF.Open;
|
||||
SQLTransaction.Active := true;
|
||||
|
||||
sql := 'CREATE TABLE "GroupAppt" (' +
|
||||
'"ApptID" STRING PRIMARY KEY,'+
|
||||
'"StartDate" DATE,'+
|
||||
'"StartTime" TIME,'+
|
||||
'"EndDate" DATE,'+
|
||||
'"EndTime" TIME,'+
|
||||
'"Description" TEXT,'+
|
||||
'"AlarmEnabled" BOOL,'+
|
||||
'"AlarmAdvance" REAL);';
|
||||
dbUTF.ExecuteDirect(sql);
|
||||
SQLTransaction.Commit;
|
||||
|
||||
sql := 'CREATE TABLE "GroupLink" ('+
|
||||
'"SchedName" String,'+
|
||||
'"ApptID" String);';
|
||||
dbUTF.ExecuteDirect(sql);
|
||||
SQLTransaction.Commit;
|
||||
|
||||
FNewDatabase := true;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
fn: String;
|
||||
@ -911,7 +944,11 @@ begin
|
||||
|
||||
fn := Application.Location + 'data.sqlite';
|
||||
dbUTF.DatabaseName := fn;
|
||||
dbUTF.Connected := FileExists(fn);
|
||||
if FileExists(fn) then begin
|
||||
dbUTF.Open;
|
||||
SQLTransaction.Active := true;
|
||||
end else
|
||||
CreateDatabase(fn);
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormDestroy(Sender: TObject);
|
||||
@ -933,6 +970,8 @@ begin
|
||||
PageControl1.ActivePageIndex := ini.ReadInteger('MainForm', 'PageIndex', 0);
|
||||
PageControl1Change(nil);
|
||||
|
||||
GlobalSettings.StartToday := ini.ReadBool('Settings', 'StartToday', GlobalSettings.StartToday);
|
||||
GlobalSettings.StartDate := ini.ReadDate('Settings', 'StartDate', GlobalSettings.StartDate);
|
||||
GlobalSettings.Hr2400 := ini.ReadBool('Settings', 'Hr2400', GlobalSettings.Hr2400);
|
||||
GlobalSettings.FirstDayOfWeek := TTFDayofWeek(ini.ReadInteger('Settings', 'FirstDayOfWeek', ord(GlobalSettings.FirstDayOfWeek)));
|
||||
GlobalSettings.PrimeTimeStart := ini.ReadTime('Settings', 'PrimeTimeStart', GlobalSettings.PrimeTimeStart);
|
||||
@ -958,6 +997,8 @@ begin
|
||||
ini.WriteInteger('MainForm', 'DaysCombo', DaysCombo.ItemIndex);
|
||||
ini.WriteInteger('MainForm', 'WeeksCombo', WeeksCombo.ItemIndex);
|
||||
|
||||
ini.WriteBool('Settings', 'StartToday', GlobalSettings.StartToday);
|
||||
ini.WriteDate('Settings', 'StartDate', GlobalSettings.StartDate);
|
||||
ini.WriteBool('Settings', 'Hr2400', GlobalSettings.Hr2400);
|
||||
ini.WriteInteger('Settings', 'FirstDayOfWeek', ord(GlobalSettings.FirstDayOfWeek));
|
||||
ini.WriteTime('Settings', 'PrimeTimeStart', GlobalSettings.PrimeTimeStart);
|
||||
|
@ -46,16 +46,18 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 288
|
||||
Height = 50
|
||||
Top = 62
|
||||
Top = 104
|
||||
Width = 37
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
Shape = bsSpacer
|
||||
end
|
||||
object cbTimeFormat: TComboBox
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 132
|
||||
AnchorSideLeft.Control = StartDatePanel
|
||||
AnchorSideTop.Control = Bevel3
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 8
|
||||
Top = 50
|
||||
Width = 124
|
||||
BorderSpacing.Top = 8
|
||||
ItemHeight = 15
|
||||
@ -72,9 +74,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Control = cbTimeFormat
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = cbTimeFormat
|
||||
Left = 59
|
||||
Left = 61
|
||||
Height = 15
|
||||
Top = 12
|
||||
Top = 54
|
||||
Width = 65
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 8
|
||||
@ -87,9 +89,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = lblTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 36
|
||||
Left = 38
|
||||
Height = 15
|
||||
Top = 39
|
||||
Top = 81
|
||||
Width = 88
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 36
|
||||
@ -103,9 +105,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = cbTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 132
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 35
|
||||
Top = 77
|
||||
Width = 124
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 4
|
||||
@ -117,9 +119,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideLeft.Control = cbTimeFormat
|
||||
AnchorSideTop.Control = cbFirstDayOfWeek
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 132
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 62
|
||||
Top = 104
|
||||
Width = 103
|
||||
ButtonWidth = 23
|
||||
BorderSpacing.Top = 4
|
||||
@ -132,9 +134,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideLeft.Control = cbTimeFormat
|
||||
AnchorSideTop.Control = edPrimeTimeStart
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 132
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 89
|
||||
Top = 131
|
||||
Width = 103
|
||||
ButtonWidth = 23
|
||||
BorderSpacing.Top = 4
|
||||
@ -148,9 +150,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = lblTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 40
|
||||
Left = 42
|
||||
Height = 15
|
||||
Top = 66
|
||||
Top = 108
|
||||
Width = 84
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Prime time start'
|
||||
@ -161,9 +163,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = lblTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 43
|
||||
Left = 45
|
||||
Height = 15
|
||||
Top = 93
|
||||
Top = 135
|
||||
Width = 81
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Prime time end'
|
||||
@ -174,9 +176,9 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Bevel1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 239
|
||||
Left = 241
|
||||
Height = 25
|
||||
Top = 75
|
||||
Top = 117
|
||||
Width = 104
|
||||
BorderSpacing.Left = 4
|
||||
BorderSpacing.Right = 36
|
||||
@ -195,7 +197,7 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 3
|
||||
Top = 120
|
||||
Top = 162
|
||||
Width = 387
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
@ -205,13 +207,16 @@ object SettingsForm: TSettingsForm
|
||||
end
|
||||
object cbIconSet: TComboBox
|
||||
AnchorSideLeft.Control = edPrimeTimeEnd
|
||||
AnchorSideTop.Control = Bevel2
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = cbTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 132
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 128
|
||||
Top = 171
|
||||
Width = 124
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
ItemHeight = 15
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
@ -227,13 +232,97 @@ object SettingsForm: TSettingsForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = lblTimeFormat
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 83
|
||||
Left = 85
|
||||
Height = 15
|
||||
Top = 132
|
||||
Top = 175
|
||||
Width = 41
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Icon set'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label1: TLabel
|
||||
AnchorSideTop.Control = StartDatePanel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = StartDatePanel
|
||||
Left = 75
|
||||
Height = 15
|
||||
Top = 12
|
||||
Width = 50
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Right = 9
|
||||
Caption = 'Start date'
|
||||
ParentColor = False
|
||||
end
|
||||
object StartDatePanel: TPanel
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 134
|
||||
Height = 23
|
||||
Top = 8
|
||||
Width = 183
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 23
|
||||
ClientWidth = 183
|
||||
TabOrder = 5
|
||||
object rbStartToday: TRadioButton
|
||||
AnchorSideLeft.Control = StartDatePanel
|
||||
AnchorSideTop.Control = deStartDate
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 19
|
||||
Top = 2
|
||||
Width = 52
|
||||
Caption = 'Today'
|
||||
Checked = True
|
||||
TabOrder = 2
|
||||
TabStop = True
|
||||
end
|
||||
object rbStartDate: TRadioButton
|
||||
AnchorSideLeft.Control = rbStartToday
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = deStartDate
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 60
|
||||
Height = 19
|
||||
Top = 2
|
||||
Width = 20
|
||||
BorderSpacing.Left = 8
|
||||
TabOrder = 0
|
||||
end
|
||||
object deStartDate: TDateEdit
|
||||
AnchorSideLeft.Control = rbStartDate
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = StartDatePanel
|
||||
Left = 80
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 103
|
||||
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
|
||||
OnAcceptDate = deStartDateAcceptDate
|
||||
DefaultToday = True
|
||||
DateOrder = doNone
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object Bevel3: TBevel
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = StartDatePanel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 3
|
||||
Top = 39
|
||||
Width = 387
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 8
|
||||
Shape = bsTopLine
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,6 +10,8 @@ uses
|
||||
|
||||
type
|
||||
TGlobalSettings = record
|
||||
StartToday: Boolean;
|
||||
StartDate: TDate;
|
||||
Hr2400: Boolean; // 24 hour or 12 hour AM/PM format
|
||||
FirstDayOfWeek: TTFDayOfWeek;
|
||||
PrimeTimeStart: TTime;
|
||||
@ -20,6 +22,8 @@ type
|
||||
|
||||
var
|
||||
GlobalSettings: TGlobalSettings = (
|
||||
StartToday: true;
|
||||
StartDate: 0;
|
||||
Hr2400: false;
|
||||
FirstDayOfWeek: dowSunday;
|
||||
PrimeTimeStart: 8 * ONE_HOUR;
|
||||
@ -34,11 +38,14 @@ type
|
||||
TSettingsForm = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
Bevel2: TBevel;
|
||||
Bevel3: TBevel;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
cbTimeFormat: TComboBox;
|
||||
cbFirstDayOfWeek: TComboBox;
|
||||
clbPrimeTimeColor: TColorButton;
|
||||
cbIconSet: TComboBox;
|
||||
deStartDate: TDateEdit;
|
||||
Label1: TLabel;
|
||||
lblIconSet: TLabel;
|
||||
lblPrimeTimeStart: TLabel;
|
||||
lblPrimeTimeEnd: TLabel;
|
||||
@ -47,6 +54,11 @@ type
|
||||
Panel1: TPanel;
|
||||
edPrimeTimeStart: TTimeEdit;
|
||||
edPrimeTimeEnd: TTimeEdit;
|
||||
StartDatePanel: TPanel;
|
||||
rbStartDate: TRadioButton;
|
||||
rbStartToday: TRadioButton;
|
||||
procedure deStartDateAcceptDate(Sender: TObject; var ADate: TDateTime;
|
||||
var AcceptDate: Boolean);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
@ -67,22 +79,37 @@ implementation
|
||||
|
||||
procedure TSettingsForm.ControlsToSettings;
|
||||
begin
|
||||
GlobalSettings.StartToday := rbStartToday.Checked;
|
||||
GlobalSettings.StartDate := deStartDate.Date;
|
||||
|
||||
GlobalSettings.Hr2400 := cbTimeFormat.ItemIndex = 0;
|
||||
GlobalSettings.FirstDayOfWeek := TTFDayOfWeek(cbFirstDayOfWeek.ItemIndex);
|
||||
GlobalSettings.PrimeTimeStart := frac(edPrimeTimeStart.Time);
|
||||
GlobalSettings.PrimeTimeEnd := frac(edPrimeTimeEnd.Time);
|
||||
GlobalSettings.PrimeTimeColor := clbPrimeTimeColor.ButtonColor;
|
||||
|
||||
GlobalSettings.IconSet := cbIconSet.ItemIndex;
|
||||
end;
|
||||
|
||||
procedure TSettingsForm.deStartDateAcceptDate(Sender: TObject;
|
||||
var ADate: TDateTime; var AcceptDate: Boolean);
|
||||
begin
|
||||
rbStartDate.Checked := true;
|
||||
end;
|
||||
|
||||
procedure TSettingsForm.SettingsToControls;
|
||||
begin
|
||||
cbTimeFormat.ItemIndex := ord(not GlobalSettings.Hr2400);
|
||||
rbStartToday.Checked := GlobalSettings.StartToday;
|
||||
deStartDate.Date := GlobalSettings.StartDate;
|
||||
if not rbStartToday.Checked and (deStartDate.Date <> 0) then
|
||||
rbStartDate.Checked := true;
|
||||
|
||||
cbTimeFormat.ItemIndex := ord(not GlobalSettings.Hr2400);
|
||||
cbFirstDayOfWeek.ItemIndex := ord(GlobalSettings.FirstDayOfWeek);
|
||||
edPrimeTimeStart.Time := GlobalSettings.PrimeTimeStart;
|
||||
edPrimeTimeEnd.Time := GlobalSettings.PrimeTimeEnd;
|
||||
clbPrimeTimeColor.ButtonColor := GlobalSettings.PrimeTimeColor;
|
||||
|
||||
cbIconSet.ItemIndex := GlobalSettings.IconSet;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user