部分代码:
1、EXCEL预算报表导入:
If User.Group = "录入" Or User.Group = "施工单位" Then
Dim dtb As New DataTableBuilder("表d")
dtb.AddDef("序号", Gettype(Integer), 10)
dtb.AddDef("维修单编号", Gettype(Integer), 10)
dtb.AddDef("清单项目名称", Gettype(String), 255)
dtb.AddDef("内容特征", Gettype(String), 255)
dtb.AddDef("单位", Gettype(String), 255)
dtb.AddDef("预算金额_数量", Gettype(Double), 15)
dtb.AddDef("预算金额_综合单价", Gettype(Double), 15)
dtb.Build()
MainTable= Tables("表d")
Dim txt As String = Forms("工程造价").Controls("tb1").text
Dim int As Integer = Forms("工程造价").Controls("tb1").value
If Forms("工程造价").Controls("tb1").value Is Nothing Then
Messagebox.show("需导入的维修单编号不能为空,请选择或输入维修单编号!","提示")
Else
Dim dr As DataRow
dr = DataTables("维修单").Find("[维修单编号] = '" & txt & "'")
If dr("预算状态")=True Then
Messagebox.show("该维修单记录报价表数据已导入!","提示")
Else
Dim g As String = " D:\基建信息管理系统\报价表数据库\"
Dim r As String = Forms("工程造价").Controls("tb1").text
Dim rr As String = ".xls"
If FileSys.FileExists(g & r & rr) Then
Messagebox.show("报价表数据源文件存在!,开始校验子目的维修单编号……,请稍后","提示")
Dim mg As New Merger
mg.SourcePath =("D:\基建信息管理系统\报价表数据库\" & txt & ".xls")
mg.Format = "excel"
mg.SourceTableName = "报价表$"
mg.DataTableName = "表d"
mg.Merge()
Dim drs As List(of DataRow) = DataTables("表d").Select("", "维修单编号")
For i As Integer = 0 To drs.Count-1
If drs(i)("维修单编号")<> int Then
If MessageBox.Show("第"& i &"行的维修单编号有误,是否修正?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.yes Then
drs(i)("维修单编号")=int
End If
Else
MessageBox.Show("第"& i &"行的维修单编号正确")
End If
Next
Dim f As New Filler
f.SourceTable = DataTables("表d") '指定数据来源
f.DataTable = DataTables("报价表")
f.Fill()
Dim dr1 As DataRow
Dr1 = DataTables("维修单").Find("[维修单编号] = '" & txt & "'")
If dr1("预算金额")<>0 Then
Dr1("预算状态")=True
Dr1("预算时间")=Date.Now
Syscmd.Project.Save()
Messagebox.show("数据已成功导入!","提示")
Else
MessageBox.Show("导入的维修单预算金额为0,请检查报价表数据源是否正确无误!")
End If
Else
MessageBox.Show("报价表数据源文件不存在!")
End If
End If
End If
Else
MessageBox.show("对不起,你无此权限!")
End If