📄 rl_unit1.pas
字号:
Form3.rl_lv_rc.Clear;
form3.rl_lv_rc.Parent:=form3.rl_fp4;
form3.rl_lv_rc.Align:=alClient;
form3.rl_lv_rc.ViewStyle := vsReport;
if sign=false then
begin
NewColumn := form3.rl_lv_rc.Columns.Add;
NewColumn.Caption := '日程安排';
NewColumn := form3.rl_lv_rc.Columns.Add;
NewColumn.Caption := '时间';
form3.rl_lv_rc.Columns[0].Width:=105;
form3.rl_lv_rc.Columns[1].Width:=70;
sign:=true;
end;
Count:=FileSize(ts_info);
if browse_sign then //浏览所有记录.
begin
For i:=0 to Count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
ListItem:=form3.rl_lv_rc.Items.Add;
listItem.Caption:=infoRec.ts_title;
str:=inforec.ts_date+' '+inforec.ts_time;
listItem.SubItems.Add(str);
end;
end
else if not browse_sign then //显示当天记录.
For i:=0 to Count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
if browse_date=strtodate(infoRec.ts_date) then
begin
listItem:=form3.rl_lv_rc.Items.Add;
listItem.Caption:=infoRec.ts_title;
str:=inforec.ts_date+' '+infoRec.ts_time;
listItem.SubItems.Add(str);
end;
end;
closefile(ts_info);
end;
end;
//------------------------------------------------------------------------------
//查询记录
function query(query_title:string;query_datetime:Tdatetime):boolean;
var i:integer;
ts_info:file of info;
infoRec:info;
count:integer;
begin
if check() then
begin
AssignFile(ts_info,'wjt.wss');
reset(ts_info);
count:=filesize(ts_info);
for i:=0 to count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
if (infoRec.ts_title=query_title) and (StrToDatetime(infoRec.ts_date+' '+infoRec.ts_time)=query_datetime) then
begin
Form4.rl_title.Text:=infoRec.ts_title;
Form4.rl_dtp_date.Date:=StrToDate(infoRec.ts_date);
Form4.rl_dtp_time.Time:=StrToTime(infoRec.ts_time);
Form4.rl_memo_txnr.Text:=infoRec.ts_text;
Form4.rl_Check_sound.Checked:=infoRec.ts_clock;
Form4.TabSheet1.Caption:='修改信息';
Form4.rl_delete.Enabled:=true;
Form4.Caption:='更新记录';
closefile(ts_info);
Form4.ShowModal;
break;
end;
end;
end;
end;
//------------------------------------------------------------------------------
//对当前时间以前发生事件进行检查
procedure check_ago;
var
i:integer;
ts_info:file of info;
infoRec:info;
count:integer;
Form3_show_sign:boolean;
begin
if check then
begin
Form5.rl_lb_title.Caption:='到期的日程安排,没办要快啊!!!:';
Form5.rl_memo_xsnr.Clear; //初始化
Form3_show_sign:=false;
AssignFile(ts_info,'wjt.wss');
reset(ts_info);
count:=filesize(ts_info);
for i:=0 to count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
if (strTodate(infoRec.ts_date)<date) or ((strTodate(infoRec.ts_date)=date) and (strToTime(infoRec.ts_time)<=time)) then
begin
if infoRec.ts_clock=true then
begin
//提示窗体
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'日期:'+infoRec.ts_date+' '+infoRec.ts_time+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'标题:'+infoRec.ts_title+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'内容:'+infoRec.ts_text+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'========================================'+chr(13)+chr(10);
infoRec.ts_clock:=false;
seek(ts_info,i);
write(ts_info,infoRec); //提示后将开启的时钟关闭
Form4.rl_Check_sound.Checked:=false;
Form3_show_sign:=true;
end;
end;
end;
end;
closefile(ts_info);
if Form3_show_sign then
begin
Form5.Caption:='忘了吗?';
Form5.Show;
sndPlaySound('music\baby.wav',SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
end;
//------------------------------------------------------------------------------
//关闭发生过事件的闹钟开关
procedure close_ring;
var
i:integer;
ts_info:file of info;
infoRec:info;
count:integer;
begin
Form5.rl_memo_xsnr.Clear; //初始化
AssignFile(ts_info,'wjt.wss');
reset(ts_info);
count:=filesize(ts_info);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'日期:'+datetimetostr(datetime_back)+chr(13)+chr(10);
for i:=0 to count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
if strtodatetime(infoRec.ts_date+' '+infoRec.ts_time)=datetime_back then
begin
if infoRec.ts_clock=true then
begin
//提示窗体
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'========================================'+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'标题:'+infoRec.ts_title+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'内容:'+infoRec.ts_text+chr(13)+chr(10);
infoRec.ts_clock:=false;
seek(ts_info,i);
write(ts_info,infoRec); //提示后将开启的时钟关闭
Form4.rl_Check_sound.Checked:=false;
end;
end;
end;
closefile(ts_info);
Form5.Caption:='到点了!!!';
Form5.rl_lb_title.Caption:='小秘手提醒您:';
Form5.Show;
end;
//------------------------------------------------------------------------------
//查看详细记录过程
procedure look_record_text;
var
i:integer;
ts_info:file of info;
infoRec:info;
count:integer;
begin
Form5.Caption:='日程浏览';
Form5.rl_lb_title.Caption:='所有日程详细内容浏览:';
Form5.rl_memo_xsnr.Clear; //初始化
AssignFile(ts_info,'wjt.wss');
reset(ts_info);
count:=filesize(ts_info);
for i:=0 to count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
//提示窗体
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'日期:'+infoRec.ts_date+' '+infoRec.ts_time+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'标题:'+infoRec.ts_title+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'内容:'+infoRec.ts_text+chr(13)+chr(10);
Form5.rl_memo_xsnr.Text:=Form5.rl_memo_xsnr.Text+'========================================'+chr(13)+chr(10);
end;
Form5.Show;
closefile(ts_info);
end;
//------------------------------------------------------------------------------
//每次事件文件改变时调用该过程,获取一条距当前时间最近的将来记录 ****************************
function get_ts_datetime():TDatetime; //返回一个日期,作为时钟开始工作的对象
var i,count:integer;
ts_info:file of info;
infoRec:info;
begin
AssignFile(ts_info,'wjt.wss');
reset(ts_info);
count:=filesize(ts_info);
for i:=0 to count-1 do
begin
seek(ts_info,i);
read(ts_info,infoRec);
if infoRec.ts_clock=true then
begin
if (strToDate(infoRec.ts_date)>date) or ((StrToDate(infoRec.ts_date)=date) and (strTotime(infoRec.ts_time)>time)) then
begin
result:=strToDatetime(infoRec.ts_date+' '+infoRec.ts_time);
closefile(ts_info);
exit;
end;
end;
end;
closefile(ts_info);
end;
//------------------------------------------------------------------------------
procedure check_file;//判断文件是否存在
var
f:textfile;
str:string;
str1:string;
begin
str1:=datetimetostr(Encodedate(strtoint(form3.rl_year.Text),strtoint(form3.rl_month.Text),click_tag));
str:=str1+'.txt';
assignfile(f,str);
try
reset(f);
except
on Einouterror do
begin
try
if fileexists(str)=false then
begin
rewrite(f);
end;
except
on Einouterror do
showmessage('not create file!');
end;
end;
end;
closefile(f);
end;
//-------------------------------------------
//rl_pm1中加入新记录
procedure tForm3.N4Click(Sender: TObject);
begin
show_add(click_tag);
end;
//-------------------------------------------
//rl_pm1中查看当天记录
procedure tForm3.N7Click(Sender: TObject);
begin
if rl_fp3.Caption='显示日程>>' then
begin
rl_fp3.Caption:='隐藏日程>>';
rl_tm3.Enabled:=true;
end;
browse(false,EncodeDate(StrToInt(form3.rl_year.Text),StrToInt(form3.rl_month.Text),enter_tag));
end;
//-------------------------------------------
//rl_pm1中查看所有记录
procedure tForm3.N8Click(Sender: TObject);
begin
if rl_fp3.Caption='显示日程>>' then
begin
rl_fp3.Caption:='隐藏日程>>';
rl_tm3.Enabled:=true;
end;
browse(true,date);
end;
//-------------------------------------------
//rl_pm1中查看详细记录
procedure tForm3.N9Click(Sender: TObject);
begin
look_record_text;
end;
//-------------------------------------------
procedure tForm3.N10Click(Sender: TObject);
begin
look_record_text;
end;
//------------------------------------------------------------------------------
procedure tForm3.N11Click(Sender: TObject);
begin
if rl_lv_rc.ItemIndex<>-1 then
begin
enter:=2;
query(rl_lv_rc.Selected.Caption,StrToDatetime(rl_lv_rc.Selected.SubItems.Text));
end;
end;
//------------------------------------------------------------------------------
procedure tForm3.N12Click(Sender: TObject);
begin
if rl_lv_rc.ItemIndex<>-1 then
begin
if MessageDlg('确定要删除该记录吗?', mtConfirmation,[mbYes, mbNo], 0) = idYes then
begin
Del_Rec();
browse(false,date);
end;
end;
end;
//-------------------------------------------------------------------------------
procedure tForm3.rl_tm_soundTimer(Sender: TObject);
begin
if strtodate(datetostr(datetime_back))=date then
begin
if strtotime(timetostr(get_ts_datetime-time))<=Encodetime(0,10,0,0) then
rl_tm_sound.Interval:=1000
else if strtotime(timetostr(get_ts_datetime-time))<=Encodetime(1,0,0,0) then
rl_tm_sound.Interval:=60000
else if strtotime(timetostr(get_ts_datetime-time))<=Encodetime(23,59,59,59) then
rl_tm_sound.Interval:=86400;
if strtotime(timetostr(get_ts_datetime-time))=Encodetime(0,0,0,0) then
begin //当事件发生后,关闭发生过事件的开关,重新得到datetime_back
close_ring;
datetime_back:=get_ts_datetime;
sndPlaySound('music\Trumpet.wav',SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;
end;
end;
procedure tForm3.rl_nt_saveClick(Sender: TObject);
var
str:string;
str1:string;
begin
check_file;
str1:=datetimetostr(Encodedate(strtoint(rl_year.Text),strtoint(rl_month.Text),click_tag)); //显示几号的日记
str:=str1+'.txt';
rl_fm_nt.Lines.SaveToFile(str);
rl_fp6.Update;
end;
procedure tForm3.FormShow(Sender: TObject);
begin
end;
//------------------------------------------------------
//listview的双击事件
procedure tForm3.rl_lv_rcDblClick(Sender: TObject);
begin
if rl_lv_rc.ItemIndex<>-1 then
begin
enter:=2;
//将选中记录显示在更新窗体中.
query(rl_lv_rc.Selected.Caption,StrToDatetime(rl_lv_rc.Selected.SubItems.Text));
end;
end;
//------------------------------------------------------------------------------
procedure tForm3.rl_tm_dbclickTimer(Sender: TObject);
begin
if dbclick_count<2 then
dbclick_count:=0;
rl_tm_dbclick.Enabled:=false;
end;
procedure tForm3.rl_fp6Click(Sender: TObject);
begin
rl_fm_nt.Lines.LoadFromFile(rl_fp6.FileName);
if rl_fp_nt1.Caption='显示日记内容>>' then
begin
rl_fp_nt1.Caption:='隐藏日记内容>>';
rl_tm8.Enabled:=true;
rl_nt_save.Visible:=true;
end;
end;
//查看当天日记
procedure tForm3.N1Click(Sender: TObject);
var
str:string;
path_note:string;
begin
rl_fm_nt.Clear; //当存在该日文件时,显示出来
str:=datetimetostr(Encodedate(strtoint(rl_year.Text),strtoint(rl_month.Text),enter_tag)); //显示几号的日记
path_note:=str+'.txt';
if FileExists(path_note)=true then
rl_fm_nt.Lines.LoadFromFile(path_note);
if rl_fp_nt1.Caption='显示日记内容>>' then
begin
rl_fp_nt1.Caption:='隐藏日记内容>>';
rl_tm8.Enabled:=true;
rl_nt_save.Visible:=true;
end;
end;
procedure TForm3.rl_nt_deleteClick(Sender: TObject);
begin
deletefile(rl_fp6.FileName);
rl_fp6.DeleteSelected;
rl_fm_nt.Clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -