Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.Ok Then
Dim mg As New Merger
mg.SourcePath = dlg.FileName
mg.Format = "excel"
mg.SourceTableName = "运单导入$"
mg.DataTableName = "运单导入"
mg.Merge()
If Tables("运单导入").Rows.Count > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("确定导入数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim db = HySql.DataBaseFactory.CreateDatabase()
db.BulkInsert(DataTables("运单导入").BaseTable, "运单管理")
Dim M1 As Date = DataTables("运单导入").SQLCompute("max(操作日期)")
Dim M2 As Date = DataTables("运单导入").SQLCompute("min(操作日期)")
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.到达省份 = {动态管理}.省份 from {运单管理} as {运单管理} inner join {动态管理} as {动态管理} on {运单管理}.[上游到达地] ={动态管理}.[城市] And {运单管理}.[操作员] = '" & User.Name & "' And {运单管理}.[操作日期] Between '" & M2 & "' And '" & M1 & "'"
cmd.ExecuteNonQuery()
cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.品牌 = {客户管理}.品牌 from {运单管理} as {运单管理} inner join {客户管理} as {客户管理} on {运单管理}.[上游客户] ={客户管理}.[上游客户] and {运单管理}.[商品车] ={客户管理}.[商品车] And {运单管理}.[操作员] = '" & User.Name & "' And {运单管理}.[操作日期] Between '" & M2 & "' And '" & M1 & "'"
cmd.ExecuteNonQuery()
cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.上游单价 = {上游运价管理}.上游单价 from {运单管理} as {运单管理} inner join {上游运价管理} as {上游运价管理} on {运单管理}.[上游客户] ={上游运价管理}.[上游客户] And {运单管理}.[品牌] ={上游运价管理}.[品牌] And {运单管理}.[上游动态] ={上游运价管理}.[上游动态] And {运单管理}.[计划日期] between {上游运价管理}.[起始日期] And {上游运价管理}.[终止日期] And {运单管理}.[二次] = 0 And {运单管理}.[上游对账] = 0 And {运单管理}.[操作员] = '" & User.Name & "' And {运单管理}.[操作日期] Between '" & M2 & "' And '" & M1 & "'"
cmd.ExecuteNonQuery()
cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.上游金额 = {运单管理}.台数*{运单管理}.上游单价 from {运单管理} where {运单管理}.[二次] = 0 And {运单管理}.[操作员] = '" & User.Name & "' And {运单管理}.[操作日期] Between '" & M2 & "' And '" & M1 & "'"
cmd.ExecuteNonQuery()
DataTables("运单管理").LoadFilter = "[操作员] = '" & user.Name & "' and [操作日期] Between '" & M2 & "' And '" & M1 & "'"
DataTables("运单管理").Load()
End If
End If