Dim filenamestr As String = args(0).controls("bookName").Text
Dim str As String = FileSys.ReadAllText(filenamestr, Encoding.Default)
'str = str.replace(chr(13),"")
Dim ary() As String = str.Split(chr(10))
Dim Total, addlist, uplist,nochange As Integer
Dim lentemp As Integer
Dim temp2 As String
Dim dr As DataRow
Dim drs As List(of DataRow)
Dim updateflag As Integer
'Tables("订单表").StopRedraw()
Dim nms() As String = { "订单编号","买家会员名","买家支付宝账号","买家应付货款","买家应付邮费","买家支付积分","总金额","返点积分","买家实际支付金额","买家实际支付积分","订单状态","买家留言","收货人姓名","收货地址","运送方式","联系电话","联系手机","订单创建时间","订单付款时间","宝贝标题","宝贝种类","物流单号","物流公司","订单备注","宝贝总数量","店铺Id","店铺名称","订单关闭原因","卖家服务费","买家服务费","fa piao抬头","是否手机订单","分阶段订单信息","定金排名","修改后的sku","修改后的收货地址","异常信息","天猫卡券抵扣","集分宝抵扣","是否是O2O交易","O2O交易类型","O2O店铺id","O2O店铺名称","O2O导购员id","O2O导购员姓名","O2O提货类型","O2O外部订单id" }
Total = ary.Length - 2
addlist = 0
uplist = 0
nochange = 0
lentemp = nms.Length - 1-7
For i As Integer = 1 To ary.Length - 2
Dim s() As String = ary(i).Split(",")
'Dim nr As DataRow = DataTables("订单表").AddNew
' nr(1) = s(0).replace("""", "").trim()
Dim bh As String = s(0).trim(""""," ")
'Dim dr As DataRow = DataTables("订单表").SQLFind("订单编号 = '" & bh & "'")
drs = DataTables("订单表").SQLSelect("订单编号 = '" & bh & "'")
'dr = drs(0)
'messagebox.show(dr(nms(0)))
If drs.count = 0 Then '如果不存在同编号的订单
'messagebox.show(333)
Dim cmd As New SQLCommand
cmd.C
'cmd.CommandText="Insert Into {订单表} ( 订单编号,买家会员名,买家支付宝账号,买家应付货款,买家应付邮费,买家支付积分,总金额,返点积分,买家实际支付金额,买家实际支付积分,订单状态,买家留言,收货人姓名,收货地址,运送方式,联系电话,联系手机,订单创建时间,订单付款时间,宝贝标题,宝贝种类,物流单号,物流公司,订单备注,宝贝总数量,店铺Id,店铺名称,订单关闭原因,卖家服务费,买家服务费,fa piao抬头,是否手机订单,分阶段订单信息,定金排名,修改后的sku,修改后的收货地址,异常信息,天猫卡券抵扣,集分宝抵扣,是否是O2O交易,O2O交易类型,O2O店铺id,O2O店铺名称,O2O导购员id,O2O导购员姓名,O2O提货类型,O2O外部订单id ) Values( "
cmd.CommandText="Insert Into {订单表} ( 订单编号,买家会员名,买家支付宝账号,买家应付货款,买家应付邮费,买家支付积分,总金额,返点积分,买家实际支付金额,买家实际支付积分,订单状态,买家留言,收货人姓名,收货地址,运送方式,联系电话,联系手机,订单创建时间,订单付款时间,宝贝标题,宝贝种类,物流单号,物流公司,订单备注,宝贝总数量,店铺Id,店铺名称,订单关闭原因,卖家服务费,买家服务费,fa piao抬头,是否手机订单,分阶段订单信息,定金排名,修改后的sku,修改后的收货地址,异常信息,天猫卡券抵扣,集分宝抵扣,是否是O2O交易 ) Values( "
'messagebox.show(s(0).trim(""""," ","'"))
For m As Integer = 0 To lentemp
Dim temp As String
temp = s(m).trim(""""," ","'")
temp = temp.Replace("'","")
'messagebox.show(nms(m))
'temp = s(m).replace(" ", "")
If temp = "" Then
If ((m = 17) Or (m = 18)) Then
temp = "'" & Nothing & "'"
Else
temp = "'" & " " & "'"
End If
Else
temp = "'" & temp & "'"
End If
If m = lentemp Then
cmd.CommandText = cmd.CommandText & temp & " )"
Else
cmd.commandtext = cmd.commandtext & temp & ","
End If
'dr(nms(m)) =s(m).trim(""""," ")
Next
'messagebox.show(cmd.commandtext)
cmd.ExecuteNonQuery()
addlist = addlist + 1
Else
dr = drs(0)
'Dim drs As List(of DataRow) = DataTables("订单表").SQLSelect("订单编号 = '" & bh & "'")
Dim Colnum As Integer
'messagebox.show(s(0).trim(""""," ","'"))
updateflag = 0
For Colnum = 1 To lentemp
temp2 = s(Colnum).trim(""""," ","'")
temp2 = temp2.Replace("'","")
If temp2 = "" And Colnum = 18 Then
temp2 = Nothing
End If
'messagebox.show(nms(Colnum))
If temp2 <> dr(nms(Colnum)) Then
' If ((nms(Colnum) = "订单创建时间") Or (nms(Colnum) = "订单付款时间")) Then
' If temp2 = "" Then
' dr(nms(Colnum)) = Nothing
' Else
' dr(nms(Colnum)) = temp2
' End If
' Else
'messagebox.show(222)
'messagebox.show(nms(Colnum))
dr(nms(Colnum)) = temp2
' End If
updateflag = 1
'DataTables("订单表").SQLReplaceFor(nms(Colnum),temp2, "订单编号 = '" & bh & "'")
End If
temp2 = ""
Next
'DataTables("订单表").SQLReplaceFor(nms(Colnum),temp2, "订单编号 = '" & bh & "'")
'messagebox.show(3)
If updateflag = 1 Then
DataTables("订单表").SQLUpdate(drs)
uplist = uplist + 1
Else
nochange = nochange + 1
End If
End If
Next
'Tables("订单表").ResumeRedraw()
'DataTables("订单表").LoadFilter = "[订单付款时间] = #" & Date.Today & "#"
DataTables("订单表").LoadFilter = "[_Identify] Is Null"
'DataTables("订单表").LoadTop = "20"
'DataTables("订单表").LoadOrder = "订单付款时间 Desc"
DataTables("订单表").Load
messagebox.show("成功导入:" & Total & "条记录" & Chr(13) & Chr(10) & "更新:" & uplist & Chr(13) & Chr(10) & "增加:" & addlist & Chr(13) & Chr(10) & "未变化:" & nochange)