Dim dide As String
Dim dnam As String
Dim ts As Integer = 6 '未来天数,含今天,所以实际是未来7天
For Each dr As DataRow In DataTables("员工").DataRows '循环指定表的所有行
Dim dt As Date = dr("出生日期") '记录出生日期
Dim dt1 As New Date(Date.Today.Year,dt.Month,dt.Day)
Dim dt2 As New Date(Date.Today.AddDays(ts).Year,dt.Month,dt.Day) '给日期值加上指定的天数[AddDays(n)]
If (dt1 >= Date.Today AndAlso dt1 < Date.Today.AddDays(ts)) OrElse (dt2 >= Date.Today AndAlso dt2 < Date.Today.AddDays(ts)) Then
dide = dide & "," & dr("_Identify") '记录行号
dnam = dnam & "," & dr("姓名") '记录姓名
End If
Next
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.StopRedraw() '暂停绘制
lvw.Images.Clear() '清除之前的图片
lvw.Rows.Clear() '清除之前的行
lvw.View = ViewMode.Details '显示模式为详细内容
lvw.GridLines = True '显示网格线
Dim cls() As String = {"编号","姓名","性别","出生日期","部门","职务"} '指定要显示的各列
Dim wds() As Integer = {100,68,36,72,80,132} '定义列宽
For i As Integer = 0 To cls.Length - 1
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Name = cls(i) '指定列名
c.Text = cls(i)'指定列标题
c.Width = wds(i) '指定列宽
Next
lvw.Columns("编号").TextAlign = HorizontalAlignment.Center '编号列居中对齐 这行已设置"居中",但实际却居不了中
lvw.Columns("姓名").TextAlign = HorizontalAlignment.Center '姓名列居中对齐
lvw.Columns("性别").TextAlign = HorizontalAlignment.Center '性别列居中对齐
lvw.Columns("出生日期").TextAlign = HorizontalAlignment.Center '出生日期列居中对齐
lvw.Columns("部门").TextAlign = HorizontalAlignment.Center '部门列居中对齐
lvw.Columns("职务").TextAlign = HorizontalAlignment.Center '职务列居中对齐
If dide > "" Then '如果符合条件的行不止一行
dide = dide.Trim(",") '加入","逗号分隔符
dnam = dnam.Trim(",") '加入","逗号分隔符
Messagebox.Show("未来 "& ts & " 天内是【" & dide & "】的生日,给他们送去祝福吧.","生日提醒")
Messagebox.Show("未来 "& ts & " 天内是【" & dnam & "】的生日,给他们送去祝福吧.","生日提醒")
msgbox(dide)
For Each dr As DataRow In DataTables("员工").Select("[_Identify] In (" & dide &")")
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '在ListView增加一行
For Each cl As WinForm.ListViewColumn In lvw.Columns '逐列取值
vr(cl.name) = dr(cl.name)
Next
Next
End If
lvw.ResumeRedraw() '恢复绘制