Dim cmd As new SQLCommand
cmd.C
cmd.CommandTimeOut = 600
Dim wjm As String = Date.Today.year & Date.Today.Month & Date.Today.Day & Date.now.Hour & Date.now.Minute & Date.now.Second
Dim wjlj As String = fl1 & "盘点\" & wjm & ".txt"
FileSys.CopyFile(fl1 & "wj\pd.txt", wjlj ,True)
FileSys.WriteAllText(wjlj , e.PostValues("txm"), True)
Dim strs As String = FileSys.ReadAllText(wjlj,Encoding.Default)
Dim h As String
Dim m As String
Dim kw As String
Dim djbh As String
//从txt合并数据到表格
strs = strs.Trim()
Dim rs() As String = strs.Split("#")
For i As Integer = 0 To rs.Length - 1
Dim cs() As String = rs(i).Split(",")
If cs.Length = 6 Then
Dim dr2 As DataRow = DataTables("明细表导入").Addnew()
dr2("首列") = cs(0)
dr2("门店名称") = e.PostValues("username")
dr2("姓名") = e.PostValues("dy")
dr2("库位") = cs(1)
dr2("条码") = cs(3)
dr2("数量") = cs(4)
dr2("扫码时间") = cs(5)
dr2("盘点日期") = Date.Today
dr2("上传时间") = Date.now
End If
Next
If Date.now.Hour < 10 Then
h = "0" & Date.now.Hour
Else
h = Date.now.Hour
End If
If Date.now.Minute < 10 Then
m = "0" & Date.now.Minute
Else
m = Date.now.Minute
End If
//从明细表导入 插入保存到 盘点明细表 ,其实表结构是一样的,当初这样设计是怕并发,多个用户同时上传,也不知道对不对~
For Each dr3 As DataRow In DataTables("明细表导入").DataRows
dr3("单据编号") = dr3("库位") & h & m
dr3("扫码时间条码") = dr3("库位") & h & m & dr3("扫码时间") & dr3("条码") //多做这一列是为了做是否重复上传的判断
cmd.CommandText =" insert into 盘点明细表(首列,门店名称,姓名,条码,扫码时间,数量,盘点日期,库位,上传时间,单据编号,扫码时间条码) values ('" & dr3("首列") & "' , '" & dr3("门店名称") & "' , '" & dr3("姓名") & "' , '" & dr3("条码") & "', '" & dr3("扫码时间") & "' , '" & dr3("数量") & "','" & dr3("盘点日期") & "','" & dr3("库位") & "','" & dr3("上传时间") & "' ,'" & dr3("单据编号") & "' ,'" & dr3("扫码时间条码") & "' )"
cmd.ExecuteNonQuery()
dr3.Delete //插入一条,从明细表导入就删除一条
Next
e.WriteString("服务器接收数据成功")