Duty table implemented by Delphi

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.