Dim d1 As Date = Date.Today
Dim dh As WinForm.TextBox =e.Form.Controls("TB代号")
Dim fl As String = ProjectPath & "Reports" & "\" & "机械管理记录" & "\" & d1.year & "\" & Tables("机械管理表").Current("装备代号") & "机械管理使用情况登记表.xls"
If FileSys.FileExists(fl)= False Then
Dim Result As DialogResult
Result = MessageBox.Show("文件还未生成,是否新建?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
MessageBox.Show("请开始新建文件","提示")
Else
Forms("新式管理记录窗口").Close
End If
End If
Dim Book As New XLS.Book(fl)
Dim Sheet As XLS.Sheet = Book.Sheets("作业登记表")
Tables("作业登记表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"日期时间","操作手","作业地点","作业内容","出库时间","入库时间","净作业时间","作业量","批准部门","批准人","备注"}
'注意下面的循环变量从4开始,而不是从0开始,因为Excel表的前6行是标题
For n As Integer = 4 To Sheet.Rows.Count -1
Dim r As Row = Tables("作业登记表").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
Next
Tables("作业登记表").ResumeRedraw()
Dim Sheet1 As XLS.Sheet = Book.Sheets("充电登记表")
Tables("充电登记表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms1() As String = {"充电情况1","充电情况2","充电情况3","充电情况4","充电情况5","充电情况6","充电情况7","充电情况8","蓄电池电压1","蓄电池电压2","电解液比重1","电解液比重2","充电检查情况1","充电检查情况2","充电检查情况3"}
'注意下面的循环变量从5开始,而不是从0开始,因为Excel表的前5行是标题
For n As Integer = 5 To Sheet1.Rows.Count -1
Dim r As Row = Tables("充电登记表").AddNew()
For m As Integer = 0 To nms1.Length - 1
If Tables("充电登记表").Cols(nms1(m)).IsBoolean Then
r(nms1(m)) = IIF(Sheet1(n,m).Value=1,True ,False)
Else
r(nms1(m)) = Sheet1(n,m).Value
End If
Next
Next
Tables("充电登记表").ResumeRedraw()
Dim Sheet2 As XLS.Sheet = Book.Sheets("维修保养情况登记表")
Tables("维修保养情况登记表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms2() As String = {"日期时间","维修保养项目","故障情况1","故障情况2","故障情况3","修理措施","修理结果","修理工","操作手","备注"}
'注意下面的循环变量从5开始,而不是从0开始,因为Excel表的前4行是标题
For n As Integer = 5 To Sheet2.Rows.Count -1
Dim r As Row = Tables("维修保养情况登记表").AddNew()
For m As Integer = 0 To nms2.Length - 1
r(nms2(m)) = Sheet2(n,m).Value
Next
Next
Tables("维修保养情况登记表").ResumeRedraw()
Dim Sheet3 As XLS.Sheet = Book.Sheets("检查情况登记表")
Tables("检查情况登记表").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms3() As String = {"检查时间","检查情况","检查人","审核","备注"}
'注意下面的循环变量从4开始,而不是从0开始,因为Excel表的前4行是标题
For n As Integer = 4 To Sheet3.Rows.Count -1
Dim r As Row = Tables("检查情况登记表").AddNew()
For m As Integer = 0 To nms3.Length - 1
r(nms3(m)) = Sheet3(n,m).Value
Next
Next
Tables("检查情况登记表").ResumeRedraw()