ufrmAwake.pas
上传用户:yjb1804
上传日期:2021-01-30
资源大小:3105k
文件大小:8k
- unit ufrmAwake;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, cxTextEdit, cxSpinEdit, cxTimeEdit, cxControls, cxContainer,
- cxEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, StdCtrls, cxRadioGroup,
- ExtCtrls, cxGroupBox, cxMemo, cxPC, cxGraphics, cxImageComboBox, cxLabel,
- Menus, cxLookAndFeelPainters, cxButtons, dxSkinsCore, dxSkinBlack,
- dxSkinBlue, dxSkinCaramel, dxSkinCoffee, {dxSkinDarkRoom,} dxSkinDarkSide,
- {dxSkinFoggy,} dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian,
- dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
- dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
- dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin, {dxSkinSeven,}
- {dxSkinSharp,} dxSkinSilver, {dxSkinSpringTime,} dxSkinStardust,
- dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
- dxSkinXmas2008Blue, dxSkinscxPCPainter;
- type
- TfrmAwake = class(TForm)
- pnl1: TPanel;
- rbSingle: TcxRadioButton;
- rbRepeat: TcxRadioButton;
- edtTitle: TcxTextEdit;
- pcAwake: TcxPageControl;
- tsByOne: TcxTabSheet;
- tsRepeat: TcxTabSheet;
- edByOne_Date: TcxDateEdit;
- edTips: TcxMemo;
- lbl13: TcxLabel;
- lbl14: TcxLabel;
- lbl15: TcxLabel;
- bvl1: TBevel;
- btnOk: TcxButton;
- btnCancel: TcxButton;
- bvl2: TBevel;
- rgModal: TcxRadioGroup;
- bvl3: TBevel;
- pcByWhich: TcxPageControl;
- tsByHour: TcxTabSheet;
- edIntervalHour: TcxSpinEdit;
- lbl10: TcxLabel;
- lbl11: TcxLabel;
- tsByDay: TcxTabSheet;
- edIntervalDay: TcxSpinEdit;
- lbl7: TcxLabel;
- lbl9: TcxLabel;
- tsByWeek: TcxTabSheet;
- edWeekInterval: TcxSpinEdit;
- rgWeek: TcxRadioGroup;
- lbl1: TcxLabel;
- lbl4: TcxLabel;
- tsByManth: TcxTabSheet;
- edManthDay: TcxSpinEdit;
- lbl2: TcxLabel;
- edManthWeek: TcxSpinEdit;
- cbWeek_Day: TcxImageComboBox;
- lbl5: TcxLabel;
- rbManthDay: TcxRadioButton;
- rbManthWeek: TcxRadioButton;
- cbManthWeek_Week: TcxImageComboBox;
- cbManthDay_Day: TcxImageComboBox;
- tsByYear: TcxTabSheet;
- cbByDay_YearInterval: TcxImageComboBox;
- rbByDay: TcxRadioButton;
- rbByWeek: TcxRadioButton;
- cbByDay_Day: TcxImageComboBox;
- cbByWeek_YearInterval: TcxImageComboBox;
- cbByWeek_Week: TcxImageComboBox;
- cbByWeek_Sort: TcxImageComboBox;
- edTime: TcxTimeEdit;
- lbl3: TcxLabel;
- edMemoRepeat: TcxMemo;
- lbl6: TcxLabel;
- procedure FormCreate(Sender: TObject);
- procedure rbSingleClick(Sender: TObject);
- procedure rbRepeatClick(Sender: TObject);
- procedure cxRadioGroup1PropertiesChange(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure btnOkClick(Sender: TObject);
- procedure edMemoRepeatClick(Sender: TObject);
- procedure edTipsClick(Sender: TObject);
- private
- { Private declarations }
- procedure LoadInitData;
- function CheckInput:Boolean;
- public
- { Public declarations }
- FEmailAddr, //显示窗体前必须设置这2个变量的值
- FContentFilePath:String;
- end;
- var
- frmAwake: TfrmAwake;
- implementation
- uses DateUtils, uEmailAwake, uCommon;
- {$R *.dfm}
- procedure TfrmAwake.FormCreate(Sender: TObject);
- begin
- LoadInitData;
- end;
- procedure TfrmAwake.LoadInitData;
- begin
- pcAwake.HideTabs:=true;
- pcByWhich.HideTabs:=true;
- edByOne_Date.Date:=now;
- edTime.Time:=now;
- edTips.SelStart:=0;
- edTips.SelLength:=Length(edTips.Lines.Text);
- pcAwake.ActivePageIndex:=0;
- pcByWhich.ActivePageIndex:=0;
- end;
- procedure TfrmAwake.rbSingleClick(Sender: TObject);
- begin
- pcAwake.ActivePageIndex:=0;
- end;
- procedure TfrmAwake.rbRepeatClick(Sender: TObject);
- begin
- pcAwake.ActivePageIndex:=1;
- end;
- procedure TfrmAwake.cxRadioGroup1PropertiesChange(Sender: TObject);
- begin
- pcByWhich.ActivePageIndex:=rgModal.Properties.Items[rgModal.ItemIndex].Value;
- end;
- procedure TfrmAwake.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- Action:=caFree;
- end;
- procedure TfrmAwake.btnOkClick(Sender: TObject);
- var
- EmailAwake:TBaseAwake;
- AwakeWeek:TAwakeWeek;
- begin
- if not CheckInput then exit;
- if rbSingle.Checked then
- EmailAwake:=TSingleAwake.Create
- else
- EmailAwake:=TRepeatAwake.Create;
- EmailAwake.BaseTime:=Now;
- EmailAwake.AwakeTime:=TimeOf(edTime.Time);
- EmailAwake.ContentFilePath:=FContentFilePath;
- EmailAwake.EmailAddr:=FEmailAddr;
- try
- try
- EmailAwake.Title:=trim(edtTitle.Text);
- EmailAwake.EmailAddr:=FEmailAddr;
- EmailAwake.ContentFilePath:=FContentFilePath;
- if rbSingle.Checked then
- begin
- TSingleAwake(EmailAwake).AwakeTime:=edTime.Time;
- TSingleAwake(EmailAwake).AwakeDate:=edByOne_Date.Date;
- if trim(edTips.Text)='您可以在这里输入提醒时显示的文字'then edTips.Text:='';
- EmailAwake.Memo:=edTips.Text;
- end
- else
- begin
- EmailAwake.Memo:=edMemoRepeat.Text;
- TRepeatAwake(EmailAwake).AwakeModal:=TAwakeModal(rgModal.ItemIndex);
- case TRepeatAwake(EmailAwake).AwakeModal of
- amHour:
- TRepeatAwake(EmailAwake).AwakeHour:=edIntervalHour.Value;
- amDay:
- TRepeatAwake(EmailAwake).AwakeHour:=edIntervalHour.Value;
- amWeek:
- begin
- AwakeWeek.WeekInterval:=edWeekInterval.Value;
- AwakeWeek.WeekDay:=rgWeek.ItemIndex;
- TRepeatAwake(EmailAwake).AwakeWeek:=AwakeWeek;
- end;
- amManth:
- begin
- if rbManthDay.Checked then
- begin
- TRepeatAwake(EmailAwake).AwakeManth.FManthDayOrWeek:=mdwDay ;
- TRepeatAwake(EmailAwake).AwakeManth.FManthInterval:=edManthDay.Value;
- TRepeatAwake(EmailAwake).AwakeManth.FManthDay:=cbManthDay_Day.ItemIndex+1;
- end
- else
- begin
- TRepeatAwake(EmailAwake).AwakeManth.FManthDayOrWeek:=mdwWeek;
- TRepeatAwake(EmailAwake).AwakeManth.FManthInterval:=edManthWeek.Value;
- TRepeatAwake(EmailAwake).AwakeManth.FManthWeek:=cbManthWeek_Week.ItemIndex+1;
- TRepeatAwake(EmailAwake).AwakeManth.FWeekDay:=cbWeek_Day.ItemIndex+1;
- end;
- end;
- amYear:
- begin
- if rbByDay.Checked then
- begin
- TRepeatAwake(EmailAwake).FAwakeYear.FYearDayOrWeek:=mdwDay;
- TRepeatAwake(EmailAwake).FAwakeYear.FYearInterval:=cbByDay_YearInterval.ItemIndex+1;
- TRepeatAwake(EmailAwake).FAwakeYear.FYearDay:=cbByDay_Day.ItemIndex+1;
- end
- else
- begin
- TRepeatAwake(EmailAwake).FAwakeYear.FYearDayOrWeek:=mdwWeek;
- TRepeatAwake(EmailAwake).FAwakeYear.FYearInterval:=cbByWeek_Week.ItemIndex+1;
- TRepeatAwake(EmailAwake).FAwakeYear.FYearWeek:=cbByWeek_YearInterval.ItemIndex+1;
- TRepeatAwake(EmailAwake).FAwakeYear.FWeekDay:=cbByWeek_Sort.ItemIndex+1;
- end;
- end;
- end;
- end;
- EmailAwake.SaveToXml(AppPath+'EmailServers.xml');
- except
- raise;
- exit;
- end;
-
- finally
- EmailAwake.Free;
- end;
-
- self.ModalResult:=mrOk;
- end;
- function TfrmAwake.CheckInput: Boolean;
- begin
- Result:=false;
- if Length(trim(edtTitle.Text))=0 then
- begin
- MsgBoxError('标题不能为空');
- edtTitle.SetFocus;
- exit;
- end;
- if rbSingle.Checked then
- begin
- if edByOne_Date.Date<= DateOf(Now) then
- begin
- MsgBoxError('提醒日期不能小于当天日期');
- edByOne_Date.SetFocus;
- exit;
- end;
- if (edByOne_Date.Date= DateOf(Now))and (edTime.Time<= Timeof(Now)) then
- begin
- MsgBoxError('提醒时间不能小于当前时间');
- edByOne_Date.SetFocus;
- exit;
- end;
- end;
- Result:=true;
- end;
- procedure TfrmAwake.edMemoRepeatClick(Sender: TObject);
- begin
- if edMemoRepeat.Lines.Text='您可以在这里输入提醒时显示的文字' then
- edMemoRepeat.Lines.Delete(0);
- end;
- procedure TfrmAwake.edTipsClick(Sender: TObject);
- begin
- if edTips.Lines.Text='您可以在这里输入提醒时显示的文字' then
- edTips.Lines.Delete(0);
- end;
- end.