新日期组件

This commit is contained in:
sgwp 2024-10-12 10:46:39 +08:00
parent 2e917bd27e
commit 821eecf691
2 changed files with 384 additions and 0 deletions

View File

@ -0,0 +1,259 @@
object frmFrameDateSel10: TfrmFrameDateSel10
Left = 0
Top = 0
Width = 956
Height = 45
AutoSize = True
Color = clBtnFace
ParentBackground = False
ParentColor = False
TabOrder = 0
object dxLayoutControl1: TdxLayoutControl
Left = 0
Top = 0
Width = 956
Height = 45
Align = alTop
ParentBackground = True
TabOrder = 0
Transparent = True
object BegDate: TcxDateEdit
Left = 110
Top = 5
ParentCustomHint = False
AutoSize = False
Properties.ImmediatePost = True
Properties.ShowTime = False
Style.BorderColor = clWindowFrame
Style.BorderStyle = ebs3D
Style.HotTrack = False
Style.TransparentBorder = False
Style.ButtonStyle = bts3D
Style.PopupBorderStyle = epbsFrame3D
TabOrder = 1
Height = 33
Width = 120
end
object EndDate: TcxDateEdit
Left = 250
Top = 5
AutoSize = False
Properties.ImmediatePost = True
Properties.ShowTime = False
Style.BorderColor = clWindowFrame
Style.BorderStyle = ebs3D
Style.HotTrack = False
Style.TransparentBorder = False
Style.ButtonStyle = bts3D
Style.PopupBorderStyle = epbsFrame3D
TabOrder = 2
Height = 33
Width = 120
end
object cxButton1: TcxButton
Left = 450
Top = 5
Width = 80
Height = 33
Caption = #26412#26376
TabOrder = 4
OnClick = cxButton1Click
end
object cxButton2: TcxButton
Left = 610
Top = 5
Width = 80
Height = 33
Caption = #24448#21069
TabOrder = 6
OnClick = cxButton2Click
end
object cxButton3: TcxButton
Left = 741
Top = 5
Width = 80
Height = 33
Caption = #24448#21518
TabOrder = 8
OnClick = cxButton3Click
end
object cbbType: TcxComboBox
Left = 690
Top = 5
AutoSize = False
Properties.DropDownListStyle = lsFixedList
Properties.Items.Strings = (
#26085
#26376
#24180)
Style.BorderColor = clWindowFrame
Style.BorderStyle = ebs3D
Style.HotTrack = False
Style.LookAndFeel.NativeStyle = True
Style.TransparentBorder = False
Style.ButtonStyle = bts3D
Style.PopupBorderStyle = epbsFrame3D
StyleDisabled.LookAndFeel.NativeStyle = True
StyleFocused.LookAndFeel.NativeStyle = True
StyleHot.LookAndFeel.NativeStyle = True
TabOrder = 7
Text = #26085
Height = 32
Width = 51
end
object cxButton4: TcxButton
Left = 370
Top = 5
Width = 80
Height = 33
Caption = #26412#26085
TabOrder = 3
OnClick = cxButton4Click
end
object cxButton5: TcxButton
Left = 530
Top = 5
Width = 80
Height = 33
Caption = #26412#24180
TabOrder = 5
OnClick = cxButton5Click
end
object TimeType: TcxComboBox
Left = 10
Top = 5
AutoSize = False
Properties.DropDownListStyle = lsEditFixedList
Properties.ImmediatePost = True
Properties.Items.Strings = (
#26597#35810#26085#26399)
Style.BorderColor = clWindowFrame
Style.BorderStyle = ebs3D
Style.HotTrack = False
Style.TransparentBorder = False
Style.ButtonStyle = bts3D
Style.PopupBorderStyle = epbsFrame3D
TabOrder = 0
Text = #26597#35810#26085#26399
Height = 32
Width = 100
end
object jqModel: TcxCheckBox
Left = 835
Top = 5
Caption = #31934#30830#26597#35810
Style.BorderColor = clWindowFrame
Style.BorderStyle = ebs3D
Style.HotTrack = False
Style.TransparentBorder = False
TabOrder = 9
Transparent = True
end
object dxLayoutControl1Group_Root: TdxLayoutGroup
AlignHorz = ahLeft
AlignVert = avTop
Hidden = True
LayoutDirection = ldHorizontal
Padding.Top = -5
Padding.AssignedValues = [lpavTop]
ShowBorder = False
UseIndent = False
Index = -1
end
object dxLayoutItem1: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Visible = False
Control = TimeType
ControlOptions.OriginalHeight = 32
ControlOptions.OriginalWidth = 100
ControlOptions.ShowBorder = False
Index = 0
end
object dxLayoutItem2: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Visible = False
Control = BegDate
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 120
ControlOptions.ShowBorder = False
Index = 1
end
object dxLayoutItem3: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Text = ' '#33267
Control = EndDate
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 120
ControlOptions.ShowBorder = False
Index = 2
end
object dxLayoutItem4: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
AlignVert = avClient
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButton4
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 80
ControlOptions.ShowBorder = False
Index = 3
end
object dxLayoutItem5: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButton1
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 80
ControlOptions.ShowBorder = False
Index = 4
end
object dxLayoutItem6: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButton5
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 80
ControlOptions.ShowBorder = False
Index = 5
end
object dxLayoutItem7: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButton2
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 80
ControlOptions.ShowBorder = False
Index = 6
end
object dxLayoutItem8: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Visible = False
Control = cbbType
ControlOptions.OriginalHeight = 32
ControlOptions.OriginalWidth = 51
ControlOptions.ShowBorder = False
Index = 7
end
object dxLayoutItem9: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Visible = False
Control = cxButton3
ControlOptions.OriginalHeight = 33
ControlOptions.OriginalWidth = 80
ControlOptions.ShowBorder = False
Index = 8
end
object dxLayoutItem10: TdxLayoutItem
Parent = dxLayoutControl1Group_Root
CaptionOptions.Text = ' '
Control = jqModel
ControlOptions.OriginalHeight = 17
ControlOptions.OriginalWidth = 66
ControlOptions.ShowBorder = False
Index = 9
end
end
end

View File

@ -0,0 +1,125 @@
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 = 'ÈÕ' then
begin
BegDate.Date := BegDate.Date - 1;
EndDate.Date := EndDate.Date - 1;
end;
if cbbType.Text = 'ÔÂ' then
begin
BegDate.Date := StartOfTheMonth(StartOfTheMonth(EndDate.Date) - 1);
EndDate.Date := EndOfTheMonth(StartOfTheMonth(EndDate.Date) - 1);
end;
if cbbType.Text = 'Äê' 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 = 'ÈÕ' then
begin
BegDate.Date := BegDate.Date + 1;
EndDate.Date := EndDate.Date + 1;
end;
if cbbType.Text = 'ÔÂ' then
begin
BegDate.Date := EndOfTheMonth(EndDate.Date) + 1;
EndDate.Date := EndOfTheMonth(EndOfTheMonth(EndDate.Date) + 1);
end;
if cbbType.Text = 'Äê' 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.