Weekly shift cycles. The number of employees and number of persons on duty can be customized.
Unit File
Unit unit15; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform15 = Class (tform) mmo1: tmemo; cbb_month: tcombobox; procedure formcreate (Sender: tobject); Procedure Week (Sender: tobject); private type // defines weekly tweekenum = (wksunday, wkmonday, week, wkfriday, wksaturday ); const // defines the number of persons on duty on each day of a week. weekarr: array [tweekenum] of integer = (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; implementationuses dateutils; {$ R *. DFM} procedure tform15.formcreate (Sender: tobject); var I: integer; begin fcurremployee: = 1; // start from 1st employees // initialize the month cbb_month.clear; for I: = 1 to 12 do cbb_month.items.add (inttostr (I); cbb_month.itemindex: = 0; // shift cbb_monthchange (cbb_month) from January 1, January; // trigger shift event end; procedure tform15.cbb _ monthchange (Sender: tobject); // obtain the employee list on duty on the current day. 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] do result: = Result + getemployee; end; var I: integer; vweekday: tweekenum; Days: integer; begin // days of the current month days: = daysinamonth (2013, strtoint (cbb_month.text); // The number of start days of the week on the first day of the current month vweekday: = tweekenum (dayofweek (strtodatetime ('000000' + dateseparator + cbb_month.text + dateseparator + '01'); // print the shift table mmo1.lines. beginupdate; try mmo1.clear; for I: = 1 to days do begin mmo1.lines. add (format ('1970-% s-% d (week % d), employee on duty: % s', [cbb_month.text, I, ord (vweekday ), getemployees (vweekday)]); If vweekday = %then vweekday: = wksunday else vweekday: = tweekenum (ord (vweekday) + 1); end; finally mmo1.lines. endupdate; end.
Form file
object Form15: TForm15 Left = 0 Top = 0 Caption = 'Form15' ClientHeight = 562 ClientWidth = 712 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 106 TextHeight = 14 object mmo1: TMemo Left = 216 Top = 72 Width = 481 Height = 482 Lines.Strings = ( 'mmo1') ScrollBars = ssBoth TabOrder = 0 end object cbb_Month: TComboBox Left = 8 Top = 72 Width = 145 Height = 22 TabOrder = 1 OnChange = cbb_MonthChange endend