以文本方式查看主题
- Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2)
---- [求助]同表引用 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=123146)
|
-- 作者:天一生水
-- 发布时间:2018/8/8 21:37:00
-- [求助]同表引用
如图,把红框中的单元格内容剪切,然后再粘贴回原单元格。 这样,[合并审理]单元格中含有的案号所在的行,都会复制一份数据。
但下面的功能不能实现: 1、删除[合并审理]单元格中的部分案号,案号所在行的数据怎样清除? 2、[原告出庭]或[被告出庭]内容变化时,相关案号的行数据也相应变化。 请老师指教!谢谢!  此主题相关图片如下:image 1.jpg 
[此贴子已经被作者于2018/8/8 21:37:52编辑过]
|
-- 作者:有点甜
-- 发布时间:2018/8/8 22:09:00
--
删除要还原很麻烦的。不可能知道之前的内容是什么,不可能还原的,所以合并必须很谨慎。(除非你用辅助列把本来的列的值记录下来)
清空删除的内容,参考
\'\'\' Select Case e.DataCol.Name Case "合并审理","原告出庭","被告出庭" Dim str As String = e.DataRow("合并审理") Dim drs = e.DataTable.Select("合并审理 =\'" & str & "\'") systemready = False If e.DataCol.name = "合并审理" AndAlso e.OldValue <> Nothing Then For Each dr As DataRow In e.DataTable.Select("合并审理 =\'" & e.oldvalue & "\' and _Identify <> \'" & e.DataRow("_Identify") & "\'") dr("原告出庭") = Nothing dr("被告出庭") = Nothing dr("合并审理") = Nothing Next End If Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(\\([0-9]+\\)[鲁0-9]+)|(行初[0-9\\-]+)|(赔初[0-9\\-]+)|(行终[0-9\\-]+)|([0-9\\-]+)") Dim qz As String = "" Dim lx As String = "" For i As Integer = 0 To mc.count-1 Dim s As String = mc(i).value \'msgbox(s) If i = 0 Then qz = s Else If s.StartsWith("行初") Then lx = "行初" s = s.replace("行初", "") ElseIf s.StartsWith("赔初") Then lx = "行赔初" s = s.replace("赔初", "") ElseIf s.StartsWith("行终") Then lx = "行终" s = s.replace("行终", "") End If Dim ii = 0 Dim jj = 0 If s.Indexof("-") >= 0 Then ii = s.split("-")(0) jj = s.split("-")(1) Else ii = s jj = s End If For k As Integer = ii To jj \'msgbox(qz & lx & k & "号") Dim dr1 As DataRow dr1 = DataTables("数据表").Find("[案号] = \'" & qz & lx & k & "号" & "\'") If dr1 IsNot Nothing Then Dim ls As new List(of String) Dim ls1 As new List(of String) For Each cdr As DataRow In drs For Each l As String In cdr.lines("原告出庭") If ls.Contains(l) = False Then ls.Add(l) End If Next For Each l1 As String In cdr.lines("被告出庭") If ls1.Contains(l1) = False Then ls1.Add(l1) End If Next Next dr1.lines("原告出庭") = ls dr1.lines("被告出庭") = ls1 dr1("合并审理") = str End If Next End If Next systemready = True End Select
|
-- 作者:天一生水
-- 发布时间:2018/8/9 11:52:00
--
合并审理的案件数量怎样计算?
谢谢!
|
-- 作者:有点甜
-- 发布时间:2018/8/9 12:06:00
--
以下是引用天一生水在2018/8/9 11:52:00的发言:
合并审理的案件数量怎样计算?
谢谢!
在循环里面累加1即可。
For k As Integer = ii To jj
count += 1
next
|
-- 作者:天一生水
-- 发布时间:2018/8/9 13:34:00
--
怎样把count的最终值赋值给[案件数量]列呢?
现在是把每次循环的值赋值给当前行,我想给每行都赋值为最终值。
此主题相关图片如下:image 2.png

\'\'\' Select Case e.DataCol.Name Case "合并审理","原告出庭","被告出庭" Dim str As String = e.DataRow("合并审理") Dim drs = e.DataTable.Select("合并审理 =\'" & str & "\'") systemready = False If e.DataCol.name = "合并审理" AndAlso e.OldValue <> Nothing Then For Each dr As DataRow In e.DataTable.Select("合并审理 =\'" & e.oldvalue & "\' and _Identify <> \'" & e.DataRow("_Identify") & "\'") dr("原告出庭") = Nothing dr("被告出庭") = Nothing dr("合并审理") = Nothing Next End If Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(\\([0-9]+\\)[鲁0-9]+)|(行初[0-9\\-]+)|(赔初[0-9\\-]+)|(行终[0-9\\-]+)|([0-9\\-]+)") Dim qz As String = "" Dim lx As String = "" For i As Integer = 0 To mc.count-1 Dim s As String = mc(i).value If i = 0 Then qz = s Else If s.StartsWith("行初") Then lx = "行初" s = s.replace("行初", "") ElseIf s.StartsWith("赔初") Then lx = "行赔初" s = s.replace("赔初", "") ElseIf s.StartsWith("行终") Then lx = "行终" s = s.replace("行终", "") End If Dim ii = 0 Dim jj = 0 If s.Indexof("-") >= 0 Then ii = s.split("-")(0) jj = s.split("-")(1) Else ii = s jj = s End If Dim count As Integer For k As Integer = ii To jj count += 1 \'msgbox(qz & lx & k & "号") Dim dr1 As DataRow dr1 = DataTables("数据表").Find("[案号] = \'" & qz & lx & k & "号" & "\'") If dr1 IsNot Nothing Then Dim ls As new List(of String) Dim ls1 As new List(of String) For Each cdr As DataRow In drs For Each l As String In cdr.lines("原告出庭") If ls.Contains(l) = False Then ls.Add(l) End If Next For Each l1 As String In cdr.lines("被告出庭") If ls1.Contains(l1) = False Then ls1.Add(l1) End If Next Next dr1.lines("原告出庭") = ls dr1.lines("被告出庭") = ls1 dr1("合并审理") = str dr1("案件数量") = count \'msgbox(count) End If Next End If Next systemready = True End Select
|
-- 作者:有点甜
-- 发布时间:2018/8/9 14:28:00
--
\'\'\' Select Case e.DataCol.Name Case "合并审理","原告出庭","被告出庭" Dim str As String = e.DataRow("合并审理") Dim drs = e.DataTable.Select("合并审理 =\'" & str & "\'") systemready = False If e.DataCol.name = "合并审理" AndAlso e.OldValue <> Nothing Then For Each dr As DataRow In e.DataTable.Select("合并审理 =\'" & e.oldvalue & "\' and _Identify <> \'" & e.DataRow("_Identify") & "\'") dr("原告出庭") = Nothing dr("被告出庭") = Nothing dr("合并审理") = Nothing Next End If Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(\\([0-9]+\\)[鲁0-9]+)|(行初[0-9\\-]+)|(赔初[0-9\\-]+)|(行终[0-9\\-]+)|([0-9\\-]+)") Dim qz As String = "" Dim lx As String = "" Dim drs_ls As new List(Of DataRow) For i As Integer = 0 To mc.count-1 Dim s As String = mc(i).value If i = 0 Then qz = s Else If s.StartsWith("行初") Then lx = "行初" s = s.replace("行初", "") ElseIf s.StartsWith("赔初") Then lx = "行赔初" s = s.replace("赔初", "") ElseIf s.StartsWith("行终") Then lx = "行终" s = s.replace("行终", "") End If Dim ii = 0 Dim jj = 0 If s.Indexof("-") >= 0 Then ii = s.split("-")(0) jj = s.split("-")(1) Else ii = s jj = s End If For k As Integer = ii To jj \'msgbox(qz & lx & k & "号") Dim dr1 As DataRow dr1 = DataTables("数据表").Find("[案号] = \'" & qz & lx & k & "号" & "\'") If dr1 IsNot Nothing Then Dim ls As new List(of String) Dim ls1 As new List(of String) For Each cdr As DataRow In drs For Each l As String In cdr.lines("原告出庭") If ls.Contains(l) = False Then ls.Add(l) End If Next For Each l1 As String In cdr.lines("被告出庭") If ls1.Contains(l1) = False Then ls1.Add(l1) End If Next Next drs_ls.add(dr1) dr1.lines("原告出庭") = ls dr1.lines("被告出庭") = ls1 dr1("合并审理") = str \'msgbox(count) End If Next End If Next For Each dr As DataRow In drs_ls dr("案件数量") = drs_ls.count Next systemready = True End Select
|
-- 作者:天一生水
-- 发布时间:2018/8/9 16:28:00
--
我在[合并审理]列的单元格,减少案号,相应行的数据将删除。
但是相应行的[案件数量]却没有被删除。
我在上述代码后添加一段代码,结果也一样。
只能手动重置[合并审理]列,才能清除相应行的[案件数量]数据。代码重置也不行。
是什么原因?
添加的代码如下:
Select Case e.DataCol.Name Case "合并审理" If e.DataRow.isnull("合并审理") Then e.DataRow("案件数量") = Nothing End If
\'Dim drs As New List(of DataRow) \'For Each dr As DataRow In drs \'DataTables("数据表").DataCols("合并审理").RaiseDataColChanged(dr) \'重置列 \'Next End Select
|
-- 作者:有点甜
-- 发布时间:2018/8/9 17:36:00
--
If e.DataCol.name = "合并审理" AndAlso e.OldValue <> Nothing Then For Each dr As DataRow In e.DataTable.Select("合并审理 =\'" & e.oldvalue & "\' and _Identify <> \'" & e.DataRow("_Identify") & "\'") dr("原告出庭") = Nothing dr("被告出庭") = Nothing dr("合并审理") = Nothing
dr("案件数量") = nothing Next End If
|
-- 作者:天一生水
-- 发布时间:2018/8/10 11:43:00
--
还是不行,并且手动重置[合并审理],就把该列清除了。
请老师测试。
谢谢!
|
-- 作者:有点甜
-- 发布时间:2018/8/10 12:06:00
--
\'\'\'
Select Case e.DataCol.Name Case "合并审理","原告出庭","被告出庭","案件数量" Dim str As String = e.DataRow("合并审理") Dim drs = e.DataTable.Select("合并审理 =\'" & str & "\'") systemready = False If e.DataCol.name = "合并审理" AndAlso e.OldValue <> Nothing Then For Each dr As DataRow In e.DataTable.Select("合并审理 =\'" & e.oldvalue & "\' and _Identify <> \'" & e.DataRow("_Identify") & "\'") dr("案件数量") = Nothing dr("原告出庭") = Nothing dr("被告出庭") = Nothing dr("合并审理") = Nothing Next End If Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(\\([0-9]+\\)[鲁0-9]+)|(行初[0-9\\-]+)|(赔初[0-9\\-]+)|(行终[0-9\\-]+)|([0-9\\-]+)") Dim qz As String = "" Dim lx As String = "" Dim drs_ls As new List(Of DataRow) For i As Integer = 0 To mc.count-1 Dim s As String = mc(i).value If i = 0 Then qz = s Else If s.StartsWith("行初") Then lx = "行初" s = s.replace("行初", "") ElseIf s.StartsWith("赔初") Then lx = "行赔初" s = s.replace("赔初", "") ElseIf s.StartsWith("行终") Then lx = "行终" s = s.replace("行终", "") End If Dim ii = 0 Dim jj = 0 If s.Indexof("-") >= 0 Then ii = s.split("-")(0) jj = s.split("-")(1) Else ii = s jj = s End If For k As Integer = ii To jj \'msgbox(qz & lx & k & "号") Dim dr1 As DataRow dr1 = DataTables("数据表").Find("[案号] = \'" & qz & lx & k & "号" & "\'") If dr1 IsNot Nothing Then Dim ls As new List(of String) Dim ls1 As new List(of String) For Each cdr As DataRow In drs For Each l As String In cdr.lines("原告出庭") If ls.Contains(l) = False Then ls.Add(l) End If Next For Each l1 As String In cdr.lines("被告出庭") If ls1.Contains(l1) = False Then ls1.Add(l1) End If Next Next drs_ls.add(dr1) dr1.lines("原告出庭") = ls dr1.lines("被告出庭") = ls1 dr1("合并审理") = str \'msgbox(count) End If Next End If Next For Each dr As DataRow In drs_ls dr("案件数量") = drs_ls.count Next systemready = True End Select
|