RTFormwork/项目代码/RTBasicsV1/A00通用组件/FrameDateSel10.pas

126 lines
3.9 KiB
ObjectPascal
Raw Normal View History

2024-10-12 10:46:39 +08:00
unit FrameDateSel10;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics,
cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
Vcl.ComCtrls, dxCore, cxDateUtils, dxSkinsCore, dxSkinsDefaultPainters,
dxSkinWXI, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, Vcl.StdCtrls,
Vcl.Menus, cxButtons, Vcl.ExtCtrls, DateUtils, cxCheckBox,
dxLayoutcxEditAdapters, dxLayoutContainer, cxClasses, dxLayoutControl,
dxLayoutControlAdapters;
type
TfrmFrameDateSel10 = class(TFrame)
BegDate: TcxDateEdit;
EndDate: TcxDateEdit;
cxButton1: TcxButton;
cxButton2: TcxButton;
cxButton3: TcxButton;
cbbType: TcxComboBox;
cxButton4: TcxButton;
cxButton5: TcxButton;
TimeType: TcxComboBox;
jqModel: TcxCheckBox;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutItem1: TdxLayoutItem;
dxLayoutItem2: TdxLayoutItem;
dxLayoutItem3: TdxLayoutItem;
dxLayoutItem4: TdxLayoutItem;
dxLayoutItem5: TdxLayoutItem;
dxLayoutItem6: TdxLayoutItem;
dxLayoutItem7: TdxLayoutItem;
dxLayoutItem8: TdxLayoutItem;
dxLayoutItem9: TdxLayoutItem;
dxLayoutItem10: TdxLayoutItem;
procedure cxButton4Click(Sender: TObject);
procedure cxButton1Click(Sender: TObject);
procedure cxButton5Click(Sender: TObject);
procedure cxButton2Click(Sender: TObject);
procedure cxButton3Click(Sender: TObject);
private
{ Private declarations }
public
procedure initTimeType(mType:string);
end;
implementation
//uses
// U_RTFun;
{$R *.dfm}
procedure TfrmFrameDateSel10.cxButton1Click(Sender: TObject);
begin
BegDate.Date := StartOfTheMonth(strToDate(FormatDateTime('yyyy-MM-dd', Now)));
EndDate.Date := EndOfTheMonth(strToDate(FormatDateTime('yyyy-MM-dd', Now)));
end;
procedure TfrmFrameDateSel10.cxButton2Click(Sender: TObject);
begin
if cbbType.Text = '<27><>' then
begin
BegDate.Date := BegDate.Date - 1;
EndDate.Date := EndDate.Date - 1;
end;
if cbbType.Text = '<27><>' then
begin
BegDate.Date := StartOfTheMonth(StartOfTheMonth(EndDate.Date) - 1);
EndDate.Date := EndOfTheMonth(StartOfTheMonth(EndDate.Date) - 1);
end;
if cbbType.Text = '<27><>' then
begin
BegDate.Date := StartOfTheMonth(strToDate(FormatDateTime('yyyy-01-01', strToDate(FormatDateTime('yyyy-01-01', EndDate.Date)) - 1)));
EndDate.Date := EndOfTheMonth(strToDate(FormatDateTime('yyyy-12-01', BegDate.Date)));
end;
end;
procedure TfrmFrameDateSel10.cxButton3Click(Sender: TObject);
begin
if cbbType.Text = '<27><>' then
begin
BegDate.Date := BegDate.Date + 1;
EndDate.Date := EndDate.Date + 1;
end;
if cbbType.Text = '<27><>' then
begin
BegDate.Date := EndOfTheMonth(EndDate.Date) + 1;
EndDate.Date := EndOfTheMonth(EndOfTheMonth(EndDate.Date) + 1);
end;
if cbbType.Text = '<27><>' then
begin
BegDate.Date := StartOfTheMonth(strToDate(FormatDateTime('yyyy-01-01', strToDate(FormatDateTime('yyyy-12-31', EndDate.Date)) + 1)));
EndDate.Date := EndOfTheMonth(strToDate(FormatDateTime('yyyy-12-01', BegDate.Date)));
end;
end;
procedure TfrmFrameDateSel10.cxButton4Click(Sender: TObject);
begin
BegDate.Date := strToDate(FormatDateTime('yyyy-MM-dd', Now));
EndDate.Date := strToDate(FormatDateTime('yyyy-MM-dd', Now));
end;
procedure TfrmFrameDateSel10.cxButton5Click(Sender: TObject);
begin
BegDate.Date := StartOfTheMonth(strToDate(FormatDateTime('yyyy-01-01', Now)));
EndDate.Date := EndOfTheMonth(strToDate(FormatDateTime('yyyy-12-01', Now)));
end;
/////////////////////////////////////////////////
///
procedure TfrmFrameDateSel10.initTimeType(mType:string);
var
array_str:TArray<string>;
begin
if trim(mType)='' then exit;
array_str:=mtype.Split([',']) ;
TimeType.Properties.Items.Clear;
TimeType.Properties.Items.AddStrings(array_str) ;
TimeType.ItemIndex:=0;
end;
end.