以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何解决代码冲突? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=187015) |
||||
-- 作者:lin98 -- 发布时间:2023/6/15 10:35:00 -- 如何解决代码冲突? If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then Dim nma() As String = {"型号","规格","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"型号","规格","B3","B4"} \'B表数据接收列 Dim dr As DataRow = DataTables("表B").AddNew For i As Integer = 0 To nma.Length - 1 dr(nmb(i)) = e.DataRow(nma(i)) Next End If 用上面的代码,下面的代码失效,如何解决? Select Case e.DataCol.name
Case "型号","规格" Dim xh As String Dim gg As String If e.DataCol.Name= "型号" Then xh = e.NewValue gg = e.DataRow("规格") Else gg = e.NewValue xh = e.DataRow("型号") End If If xh > "" AndAlso gg > "" Then Dim dr As DataRow = e.DataRow If e.DataTable.Find("型号 = \'" & xh & "\' And 规格 = \'" & gg & "\'") IsNot Nothing Then MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True End If End If End Select |
||||
-- 作者:有点蓝 -- 发布时间:2023/6/15 10:40:00 -- If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then If DataTables("表B").Find("型号 = \'" & e.DataRow("型号") & "\' And 规格 = \'" & e.DataRow("规格") & "\'") Is Nothing Then Dim nma() As String = {"型号","规格","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"型号","规格","B3","B4"} \'B表数据接收列 Dim dr As DataRow = DataTables("表B").AddNew For i As Integer = 0 To nma.Length - 1 dr(nmb(i)) = e.DataRow(nma(i)) Next End If
End If |
||||
-- 作者:lin98 -- 发布时间:2023/6/15 15:20:00 -- 老师,实例还是无法实现 不重复值录入,请帮处理 |
||||
-- 作者:有点蓝 -- 发布时间:2023/6/15 15:42:00 --
|
||||
-- 作者:lin98 -- 发布时间:2023/6/15 16:56:00 -- 测试一下,下面没有作用,在执行后,再执行没提示,如何实现重复提示? Case "型号","规格" Dim xh As String Dim gg As String If e.DataCol.Name= "型号" Then xh = e.NewValue gg = e.DataRow("规格") Else gg = e.NewValue xh = e.DataRow("型号") End If If xh > "" AndAlso gg > "" Then Dim dr As DataRow = e.DataRow If e.DataTable.Find("型号 = \'" & xh & "\' And 规格 = \'" & gg & "\'") IsNot Nothing Then MessageBox.Show("已经存在相同型号和规格的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True End If End If End Select |
||||
-- 作者:有点蓝 -- 发布时间:2023/6/15 17:05:00 -- 没有认真看帮助,用错事件了。 |