以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]代码求助 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=70359) |
-- 作者:huangfanzi -- 发布时间:2015/6/19 14:57:00 -- [求助]代码求助 For Each dc1 As DataCol In e.DataTable.DataCols str = str & dc1.Name & "|" For Each dr1 As DataRow In e.DataTable.DataRows str = str & dr1(dc1) & "|" Next Next 做个了删除行时记录下此行所有内容的功能,上面的代码执行后得到的结果我想完善一下,目前的结果是: 合同主号|a|合同分号|s|签订日期|2015-2-1|供应商|d|代码|f|原产牌号||厚度||宽度|| 我希望的结果是: 合同主号|a|合同分号|s|签订日期|2015-2-1|供应商|d|代码|f|原产牌号|空|厚度|空|宽度|空| |
-- 作者:大红袍 -- 发布时间:2015/6/19 15:02:00 -- For Each dc1 As DataCol In e.DataTable.DataCols str = str & dc1.Name & "|" For Each dr1 As DataRow In e.DataTable.DataRows str = str & iif(dr1.IsNull(dc1), "空", dr1(dc1)) & "|" Next Next |
-- 作者:huangfanzi -- 发布时间:2015/6/19 15:19:00 -- 我的整段代码中有BUG,老师帮我看看: DataRowDeleting 事件 If e.DataRow("首审记录") <> Nothing Then Dim dr As DataRow = _dt操作日志_修改.AddNew Dim cmd As New SQLCommand Dim dt As Date cmd.C cmd.CommandText = "Select GetDate()" dt = cmd.ExecuteScalar() dr("日期") = format(dt,"yyyy-MM-dd") dr("时间") = format(dt,"HH:mm:ss") dr("表名") = e.DataTable.Name dr("行号流水") = e.DataRow("_Identify") dr("列名") = "整行删除" \'dr("原值") = e.OldValue \'dr("新值") = e.NewValue dr("操作者") = _Username Dim str As String For Each dc1 As DataCol In e.DataTable.DataCols str = str & dc1.Name & "|" For Each dr1 As DataRow In e.DataTable.DataRows str = str & iif(dr1.IsNull(dc1), "空", dr1(dc1)) & "|" Next Next dr("备注") = str dr.Save End If 我如果用选中二行再一起删除的话,以上代码执行后,得到以下结果: 在等号为129的备注中显示如下: 合同主号|空|空|合同分号|空|空|签订日期|空|空|供应商|空|空|代码|空|空|原产牌号|空|空|厚度|空|空|宽度|空|空|重量|空|空|单价|空|空|金额|空|空|付款方式|空|空|交货日期|空|空|提货方式|空|空|核心条款|空|空|扫描件|空|空|执行状态|空|空|审核|False|False|录入人|空|空|录入日期|空|空|编辑者|空|空|首审记录|admin 2015-06-19 15:12:26|admin 2015-06-19 15:12:27|末审记录|admin 2015-06-19 15:12:26|admin 2015-06-19 15:12:27|行号流水|128|129| 在行号128的备注中显示如下: 合同主号|空|合同分号|空|签订日期|空|供应商|空|代码|空|原产牌号|空|厚度|空|宽度|空|重量|空|单价|空|金额|空|付款方式|空|交货日期|空|提货方式|空|核心条款|空|扫描件|空|执行状态|空|审核|False|录入人|空|录入日期|空|编辑者|空|首审记录|admin 2015-06-19 15:12:26|末审记录|admin 2015-06-19 15:12:26|行号流水|128| 也就是说,我如果同时删除N行,在此批行中的最后一行会出现重复N次的数据,在N-1行也就出现N-1次的重复数据
|
-- 作者:huangfanzi -- 发布时间:2015/6/19 15:28:00 -- 搞定了,哈哈! If e.DataRow("首审记录") <> Nothing Then Dim dr As DataRow = _dt操作日志_修改.AddNew Dim cmd As New SQLCommand Dim dt As Date cmd.C cmd.CommandText = "Select GetDate()" dt = cmd.ExecuteScalar() dr("日期") = format(dt,"yyyy-MM-dd") dr("时间") = format(dt,"HH:mm:ss") dr("表名") = e.DataTable.Name dr("行号流水") = e.DataRow("_Identify") dr("列名") = "整行删除" \'dr("原值") = e.OldValue \'dr("新值") = e.NewValue dr("操作者") = _Username Dim str As String For Each dc1 As DataCol In e.DataTable.DataCols str = str & dc1.Name & "|" \'For Each dr1 As DataRow In e.DataTable.DataRows str = str & iif(e.DataRow.IsNull(dc1), "空", e.DataRow(dc1)) & "|" \'Next Next dr("备注") = str str = Nothing dr.Save End If |