以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]合并(导入)去重的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=104041) |
||||
-- 作者:轩辕绝 -- 发布时间:2017/7/21 16:17:00 -- [求助]合并(导入)去重的问题 狐表爸爸,我重新发一次求助, 航班排班表需要每日导入次日的排班信息到系统“勤务信息表”中,为避免重复操作造成航班信息重复。请问如何编写“勤务信息管理窗口”中“导入”按钮的代码
当每行数据“日期”、“航班号”、“安全员”3个字段信息同时重复时,确定为重复数据,自动合并或者去重。
另外问一下,安全员中有多个安全员执行时用“/”分割,这个字段能与人员信息表做关联么?
|
||||
-- 作者:有点甜 -- 发布时间:2017/7/21 17:16:00 -- Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog =DialogResult.OK Then Dim t As Table = Tables("勤务信息表") t.ResumeRedraw() t.StopRedraw() Dim App As New MSExcel.Application try Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.UsedRange Dim arg = rg.value For n As Integer = 2 To rg.Rows.Count Dim r As DataRow = t.DataTable.Find("日期 = #" & arg(n, 1) & "# and 航班号 = \'" & arg(n, 3) & "\' and 安全员 = \'" & arg(n, 11) & "\'") If r Is Nothing Then r = t.DataTable.AddNew() For i As Integer = 1 To rg.Columns.count Dim cname As String = arg(1,i) If cname > "" AndAlso t.Cols.Contains(cname) Then If t.Cols(cname).IsDate AndAlso arg(n,i).Gettype.name = "double" Then r(cname) = DateTime.FromOADate(arg(n,i)) Else r(cname) = arg(n, i) End If End If Next Next catch ex As exception msgbox(ex.message) MessageBox.Show("导入失败!","恭喜!") finally t.ResumeRedraw() app.quit End try End If |
||||
-- 作者:轩辕绝 -- 发布时间:2017/7/21 22:22:00 -- 谢谢 |