两个问题求大神解决
1.
Dim d As Date = e.Form.Controls("DateTimePicker1").text
Dim y As Integer = Format(d,"yyyy") '取年
Dim m As Integer = Format(d,"MM") '取月
Dim ym As String = Format(d,"yyyyMM") '取年月
Dim ts As String = Date.DaysInMonth(y,m) '取指定月份的天数
Dim n As Integer = 0
For Each dr As DataRow In DataTables("巡查统计_table1").DataRows
If n < ts Then '新增的行数
Dim i As Integer = 0
Dim r As Row = Tables("巡查统计_table1").AddNew()
dr("巡查时间") = New Date(y, m, 1).AddDays(i)
i = i + 1
n = n + 1
End If
Next
e.Form.Close
红色代码附值 ,将新增的行”巡查时间“列按日期自动填入
2.
另一代码也无效
'显示巡查数据
CLICK代码
Dim tb As Table = Tables("巡查统计_Table1")
Dim r As Row = tb.Current
For Each lm As DataCol In DataTables("巡查统计_table1").DataCols
Dim Names As String() = lm
For i As Integer = 0 To lm.Length -1
Dim cmd As New SQLCommand '后台查找
cmd.C
cmd.CommandText = "sele ct * from {SK_日常巡查} where 结束时间='" & r("巡查时间") & "'"
Dim dt As DataTable = cmd.ExecuteReader()
Dim dr As DataRow = dt.Find("水库名称 = '" & i & "'") '名称等于列名
If dr IsNot Nothing Then
r(i) = 1 '当前列名下行内容填入1
End If
Next
Next
新增行自动输入日期,鼠标点击后从另一张表取值
此主题相关图片如下:微信截图_20190920133651.png
从下表取值
此主题相关图片如下:微信截图_20190920133731.png
[此贴子已经被作者于2019/9/20 13:45:51编辑过]