unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtrls, DbOleCtl, CALENDARXLib_TLB, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    Label4: TLabel;
    Edit4: TEdit;
    GroupBox2: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    CheckBox1: TCheckBox;
    GroupBox3: TGroupBox;
    BitBtn1: TBitBtn;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label9: TLabel;
    CalendarX1: TCalendarX;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
    procedure refreshData;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
const
  DWeekDay :array[0..6] of string =('ÈÕ', 'Ò»', '¶þ', 'Èý', 'ËÄ', 'Îå', 'Áù');
  DShengXiao :array[0..11] of string =('Êó', 'Å£', '»¢', 'ÍÃ', 'Áú', 'Éß', 'Âí', 'Ñò', 'ºï', '¼¦', '¹·', 'Öí');
  DGan :array[0..9] of string =('¼×', 'ÒÒ', '±û', '¶¡', 'Îì', '¼º', '¸ý', 'ÐÁ', 'ÈÉ', '¹ï');
  DZhi :array[0..11] of string =('×Ó', '³ó', 'Òú', 'Ã®', '³½', 'ËÈ', 'Îç', 'Î´', 'Éê', 'ÓÏ', 'Ðç', 'º¥');

implementation

{$R *.DFM}

procedure TForm1.refreshData;
begin
  with CalendarX1 do
  begin
    Edit1.Text := inttostr(SolarYear);
    Edit2.Text := inttostr(SolarMonth);
    Edit3.Text := inttostr(SolarDay);
    Edit4.Text := inttostr(TheHour);
    Edit5.Text := inttostr(LunarYear);
    Edit6.Text := inttostr(LunarMonth);
    Edit7.Text := inttostr(LunarDay);
    Edit8.Text := inttostr(TheHour);
    CheckBox1.Checked := LeapFlag;
    Label9.Caption := 'ÐÇÆÚ' + DWeekDay[WeekDay];
    Label14.Caption := 'ÉúÐ¤£º' + DShengXiao[Animal];
    Label10.Caption := DGan[GzYear div 100] + DZhi[GzYear mod 100] + 'Äê';
    Label11.Caption := DGan[GzMonth div 100] + DZhi[GzMonth mod 100] + 'ÔÂ';
    Label12.Caption := DGan[GzDay div 100] + DZhi[GzDay mod 100] + 'ÈÕ';
    Label13.Caption := DGan[GzHour div 100] + DZhi[GzHour mod 100] + 'Ê±';
  end;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  try
    CalendarX1.SolarYear := strtoint(Edit1.Text);
    CalendarX1.SolarMonth := strtoint(Edit2.Text);
    CalendarX1.SolarDay := strtoint(Edit3.Text);
    CalendarX1.TheHour := strtoint(Edit4.Text);
  except
    showmessage('Error input!');
  end;
  CalendarX1.Solar2Lunar;
  refreshData;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
  try
    CalendarX1.LunarYear := strtoint(Edit5.Text);
    CalendarX1.LunarMonth := strtoint(Edit6.Text);
    CalendarX1.LunarDay := strtoint(Edit7.Text);
    CalendarX1.TheHour := strtoint(Edit8.Text);
    CalendarX1.LeapFlag := CheckBox1.Checked;
  except
    showmessage('Error input!');
  end;
  CalendarX1.Lunar2Solar;
  refreshData;

end;

end.
