Weekly cycle scheduling, the number of employees and the number of people on duty can be customized.
Unit file
Unit Unit15;
Interface uses Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;
Type TFORM15 = Class (Tform) Mmo1:tmemo;
Cbb_month:tcombobox;
Procedure Formcreate (Sender:tobject);
Procedure Cbb_monthchange (Sender:tobject); Private type//definition Week Tweekenum = (Wksunday, Wkmonday, Wktuesday, Wkwednesday, Wkthursday, Wkfriday, Wksaturd
AY);
Const//define the number of days of the week on duty weekarr:array[tweekenum] of integers = (2, 1, 1, 1, 1, 1, 2);
Define the number of employees on duty femployeecount = 13;
{Private declarations} private Fcurremployee:integer;
Public {public declarations} end;
var form15:tform15;
implementation uses dateutils;
{$R *.DFM} procedure tform15.formcreate (Sender:tobject);
var I:integer; Begin Fcurremployee: = 1;
Initialize month cbb_month.clear from start of 1th employee;
For I: = 1 todo cbb_Month.Items.Add (IntToStr (i)); Cbb_month.itemindex: = 0; Starting from January Cbb_monthchange (cbb_Month);
Triggers the scheduling event end;
Procedure Tform15.cbb_monthchange (Sender:tobject);
Get the list of employees on the day of Duty function GetEmployees (const aweekday:tweekenum): string;
function getemployee:string;
Begin Result: = Format (' Employee%d ', [Fcurremployee]);
INC (Fcurremployee);
If Fcurremployee > Femployeecount then fcurremployee: = 1;
End
var I:integer;
Begin Result: = ';
For I: = 1 to Weekarr[aweekday] does result: = result + GetEmployee;
End
var I:integer;
Vweekday:tweekenum;
Days:integer;
Days of Begin//month: = Daysinamonth (2013, Strtoint (Cbb_month.text)); The number of weeks starting on the first day of the month Vweekday: = Tweekenum (DayOfWeek (Strtodatetime (' 2013 ' + dateseparator + cbb_month.text + dateseparator + ' 0)
1 '))-1); Print the Schedule mmo1.
Lines.beginupdate;
Try Mmo1.clear; For I: = 1 to, do begin MMO1.
Lines.add (Format (' 2013-%s-%d (week%d), on-duty employee:%s ', [Cbb_month.text, I, Ord (Vweekday), GetEmployees (Vweekday)]
)); If VWEekday = Wksaturday then vweekday: = Wksunday else Vweekday: = Tweekenum (ord (vweekday) + 1);
End Finally Mmo1.
Lines.endupdate;
End
End
End.
Form file
Object Form15:tform15 Left
= 0 Top
= 0
Caption = ' Form15 '
clientheight = 562 clientwidth
= 712
Co Lor = clbtnface
font.charset = default_charset
font.color = clwindowtext font.height
= -12
font.name = ' Tahoma '
font.style = []
oldcreateorder = False
OnCreate = formcreate pixelsperinch
=
? TextHeight =
Mmo1:tmemo Left
= 216 Top
=
Width = 481
Height = 482
lines.string s = (
' mmo1 ')
ScrollBars = ssboth
taborder = 0
End
Object Cbb_month:tcombobox Left
= 8< C27/>top =
Width = 145
Height =
taborder = 1
OnChange = cbb_monthchange
End