-- 作者:雨中的泪
-- 发布时间:2010/8/25 8:20:00
--
Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog dlg.Filter= "上报文件|*.DSB" \'设置筛选器 dlg. title= "接收上报文件" If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 FileSys.CopyFile(dlg.filename, dlg.filename & ".bak",False) FileSys.CopyFile(dlg.filename, dlg.filename & ".bak1",False) FileSys.DeleteFile(dlg.filename, 2, 2)
Try DecryptFile (dlg.filename & ".bak", dlg.filename, "8888") Catch ex As Exception MessageBox.Show("数据库格式不对!","提示",MessageBoxButtons.OK) Return End Try
FileSys.DeleteFile(dlg.filename & ".bak", 2, 2) Dim ip As New Merger ip.SourcePath = dlg.filename \'指定数据文件 ip.SourceTableName = "调资基础数据" \'指定要合并的表 ip.Format = "Access" \'指定合并文件格式 ip. PassWord = "TZX_GWY_JT_8888" \'用此属性指定合并文件的密码 ip.Fields = "单位名称" \' 指定要合并的字段(列) ip. DataTableName ="数据接收临时判断" \'合并后的表名 ip. Merge() \'开始合并 If Tables("数据接收临时判断").Rows.Count <> 0 Then Dim dws As List(Of String) \'定义一个字符型数组集合 dws = DataTables("调资基础数据").GetUniqueValues("", "单位名称") \'列出所有单位 For Each dw As String In dws \'逐个单位判断 Dim dr As DataRow = DataTables("数据接收临时判断").find("[单位名称] = \'" & dw & "\'") If dr IsNot Nothing Then If MessageBox.Show( dw & "的记录已经存在,确定是否请删除?","提示",MessageBoxButtons. YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then For Each Sr As DataRow In DataTables("调资基础数据").datarows If Sr("单位名称") <> "" Then Sr.locked = False End If Next DataTables("调资基础数据").DeleteFor("[单位名称] = \'" & dw & "\'") Else FileSys.DeleteFile(dlg.filename, 2, 2) FileSys.CopyFile(dlg.filename & ".bak1",dlg.filename ,False) FileSys.DeleteFile(dlg.filename & ".bak1", 2, 2) Return \'点击否终止代码的执行 End If End If Next Dim mg As New Merger mg.SourcePath = dlg.filename mg.SourceTableName = "调资基础数据" mg.Format = "Access" mg. PassWord = "TZX_GWY_JT_8888" mg.DataTableName = "调资基础数据" mg.Merge() MessageBox.Show("接收上报数据完成!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) DataTables("数据接收临时判断").DataRows.Clear() \'清空指定表数据 FileSys.DeleteFile(dlg.filename) FileSys.CopyFile(dlg.filename & ".bak1",dlg.filename ,False) FileSys.DeleteFile(dlg.filename & ".bak1", 2, 2) Else FileSys.DeleteFile(dlg.filename) FileSys.CopyFile(dlg.filename & ".bak1",dlg.filename ,False) FileSys.DeleteFile(dlg.filename & ".bak1", 2, 2) MessageBox.Show("请核实数据格式!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning) Return END IF \'点击否终止代码的执行 Else Return \'点击否终止代码的执行 End If
|