狐爸问个问题啊,我现在在用窗口做一个表格的导入功能。
先上贴图。。再说问题。
在我上传的excel表中,第15行,有个单元格合并了,这样的话,我在狐表中的表,订单明细表中
DataColChanged事件中会提示错误,我如何在下面的代码中取消这种错误提示?也就是说,我通过代码增加行时,如果取消数据列数据变化而发生的事件?
Dim path As WinForm.TextBox = e.Form.Controls("TextBox5") '目录
Dim cmd As new SQLCommand
cmd.C '指定数据源
Dim Listo As String
Dim filess As String
Dim tb As Table = Tables("订单")
Dim oi As Table = Tables("orderitem") '订单明细表
Dim rm As Table = Tables("remarks") '订单备注
Dim d As Integer
For Each file As String In filesys.GetFiles(path.Value)
' filess = filesys.GetName(file)
Dim Book As New XLS.Book(file)
Dim Sheet1 As XLS.Sheet = Book.Sheets(0)
cmd.CommandText = "Select listorder From {订单} Where listorder = '" & (sheet1(2,15).Value.Remove(0,5)) & " ' "
Listo = cmd.ExecuteScalar()
' MessageBox.Show(cmd.CommandText)
' MessageBox.Show(Listo)
If Listo = "" Then
tb.AddNew()
tb.Current("listorder") = sheet1(2,15).Value.Remove(0,5) '订单编号
tb.Current("area") = sheet1(4,0).Value.Remove(0,5) '销售区域
tb.Current("contact") = sheet1(4,4).Value.Remove(0,4) '联系人
tb.Current("tel") = sheet1(4,7).Value.Remove(0,5) '联系电话
tb.Current("setusers") = sheet1(4,10).Value.Remove(0,5) '安装用户
tb.Current("dhdate") = sheet1(3,15).Value.Remove(0,5) '订货日期
tb.Current("jhdate") = sheet1(4,15).Value.Remove(0,5) '交货日期
'_____________________________以上是对订单表进行导入____________________________________
For i As Integer = 8 To sheet1.Rows.Count
If Integer.TryParse(sheet1(i,0).Value,d) And sheet1(i,0).Value <> "" And tb.Current("listorder") <> "" Then
oi.AddNew()
oi.Current("listorder") = sheet1(2,15).Value.Remove(0,5) '删除空格,订单号
oi.Current("dooropen") = Replace(sheet1(i,1).Value," ","") '删除空格,门洞尺寸
oi.Current("doorcasesize") = Replace(sheet1(i,2).Value," ","") '删除空格,门框尺寸
oi.Current("modelname") = Replace(sheet1(i,3).Value," ","") '删除空格,产品型号
oi.Current("doorcase") = Replace(sheet1(i,4).Value," ","") '删除空格,门扇材质
oi.Current("doorsize") = Replace(sheet1(i,5).Value," ","") '删除空格,门框尺寸
oi.Current("doorcolor") = Replace(sheet1(i,6).Value," ","") '删除空格,门扇油漆
oi.Current("doorglass") = Replace(sheet1(i,7).Value," ","") '删除空格,门框玻璃
oi.Current("doornum") = Replace(sheet1(i,8).Value," ","") '删除空格,门扇数量
oi.Current("doorcasemodel") = Replace(sheet1(i,9).Value," ","") '删除空格,门框型号
oi.Current("doorline") = Replace(sheet1(i,10).Value," ","") '删除空格,门套线
oi.Current("dccz") = Replace(sheet1(i,11).Value," ","") '删除空格,门框材质
oi.Current("doorcasecolor") = Replace(sheet1(i,12).Value," ","") '删除空格,门框油漆
oi.Current("doorcasenum") = Replace(sheet1(i,13).Value," ","") '删除空格,门框数量
oi.Current("doorcaseprice") = Replace(sheet1(i,14).Value," ","") '删除空格,门框单价
oi.Current("partsname") = Replace(sheet1(i,16).Value," ","") '删除空格,配件名称
oi.Current("partsnum") = Replace(sheet1(i,17).Value," ","") '删除空格,配件数量
oi.Current("partsprice") = Replace(sheet1(i,18).Value," ","") '删除空格,配件单价
oi.Current("listgod") = Replace(sheet1(i,19).Value," ","") '删除空格,输入日期
oi.Current("putdate") = CDate(sheet1(3,15).Value.Remove(0,5)) '删除空格,输入日期
oi.Current("listgod") = Replace(sheet1(i,19).Value," ","") '删除空格,输入日期
Else
End If
Next
'_______________________________以上是明细表数据导入______________________
For rs As Integer = 18 To sheet1.Rows.Count
If sheet1(rs,0).Value = "备注" And tb.Current("listorder") <> "" Then
rm.AddNew()
rm.Current("listorder") = sheet1(2,15).Value.Remove(0,5)
rm.Current("remark") = sheet1(rs,1).Value
End If
Next
End If
Next
此主题相关图片如下:qq截图20120524092910.png
此主题相关图片如下:qq截图20120524093021.png