以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  到期提醒一个表只提醒一次  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=126486)

--  作者:deliangzhaoe
--  发布时间:2018/10/22 17:33:00
--  到期提醒一个表只提醒一次
一个表中有两个或三个到期,只提醒一次,如何解决,代码如何改?谢谢

Dim dt4 As Date = Date.Today.AddDays(30)
Dim dr20 As DataRow = DataTables("安全资格培训").Find("下次培训日期 <= #" & dt4 & "#")
Dim dtdq As Date = Date.Today
Dim dr21 As DataRow = DataTables("安全资格培训").Find("下次培训日期 < #" & dtdq & "#")
If dr21 IsNot Nothing Then
    MessageBox.Show(dr21("企业名称") & ":" & vbcrlf & "    企业负责人/安全员培训合格证已过期未复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
ElseIf dr20 IsNot Nothing Then
    MessageBox.Show(dr20("企业名称") & ":" & vbcrlf & "    企业负责人/安全员培训合格证即将到期复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If


--  作者:有点甜
--  发布时间:2018/10/22 17:45:00
--  
Dim dt4 As Date = Date.Today.AddDays(30)
Dim dr20 As String= DataTables("安全资格培训").GetComboListString("企业名称", "下次培训日期 <= #" & dt4 & "#")
Dim dtdq As Date = Date.Today
Dim dr21 As String= DataTables("安全资格培训").GetComboListString("企业名称", "下次培训日期 < #" & dtdq & "#")
If dr21 > "" Then
    MessageBox.Show(dr21 & ":" & vbcrlf & "    企业负责人/安全员培训合格证已过期未复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If
If dr20 > "" Then
    MessageBox.Show(dr20 & ":" & vbcrlf & "    企业负责人/安全员培训合格证即将到期复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

--  作者:deliangzhaoe
--  发布时间:2018/10/23 7:13:00
--  
1.使用你的代码:
f dr21 > "" Then
    MessageBox.Show(dr21 & ":" & vbcrlf & "    企业负责人/安全员培训合格证已过期未复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If
If dr20 > "" Then
    MessageBox.Show(dr20 & ":" & vbcrlf & "    企业负责人/安全员培训合格证即将到期复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
出现以下问题:一个表中有已过期的记录,那么本条记录既提示已过期,也提示即将过期。提示两次

2.使用如下代码:
f dr21 > "" Then
    MessageBox.Show(dr21 & ":" & vbcrlf & "    企业负责人/安全员培训合格证已过期未复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
elseIf dr20 > "" Then
    MessageBox.Show(dr20 & ":" & vbcrlf & "    企业负责人/安全员培训合格证即将到期复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
出现以下问题:一个表中有几条需要提示记录时,既有即将到期的记录,也有已过期的记录时,只提示已过期的记录,不提示即将到期的记录

要实现:一个表有多条需要提醒的记录,既有即将到期的,也有已过期的时,要分别提醒。有即将到期的记录,提示即将到期;有过期的记录,提示已过期,不能再重复提示即将到期。
如何解决这个问题?谢谢
[此贴子已经被作者于2018/10/23 7:48:27编辑过]

--  作者:有点甜
--  发布时间:2018/10/23 9:06:00
--  

Dim dt4 As Date = Date.Today.AddDays(30)
Dim dtdq As Date = Date.Today

Dim dr20 As String= DataTables("安全资格培训").GetComboListString("企业名称", "下次培训日期 >= #" & dtdq & "# and 下次培训日期 <= #" & dt4 & "#")
Dim dr21 As String= DataTables("安全资格培训").GetComboListString("企业名称", "下次培训日期 < #" & dtdq & "#")
If dr21 > "" Then
    MessageBox.Show(dr21 & ":" & vbcrlf & "    企业负责人/安全员培训合格证已过期未复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
End If
If dr20 > "" Then
    MessageBox.Show(dr20 & ":" & vbcrlf & "    企业负责人/安全员培训合格证即将到期复审","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If