以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何利用列名进行自定义表达式计算 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=106792) |
-- 作者:有点甜 -- 发布时间:2017/9/15 16:32:00 -- DataColChanged事件
\'If e.DataRow.IsNull("应发工资公式") Then
|
-- 作者:有点甜 -- 发布时间:2017/9/17 16:13:00 -- If e.DataRow.IsNull("费用计算式") Then e.DataRow("金额") = Nothing Else Dim str As String = e.DataRow("费用计算式") For Each dc As DataCol In e.DataTable.DataCols str = str.replace("[" & dc.name & "]", dc.name).Replace(dc.name, "[" & dc.name & "]") Next For Each dr As DataRow In e.DataTable.Select("项目编号 = \'" & e.DataRow("项目编号") & "\'") Dim fymc = dr("费用名称") If fymc <> "" Then str = str.replace("[" & fymc & "]", fymc).Replace(fymc, dr("金额")) End If Next If TryEval(str, e.DataRow) Then e.DataRow("金额") = Eval2(str,e.DataRow) Else msgbox("公式错误") End If End If |
-- 作者:有点甜 -- 发布时间:2017/9/24 21:26:00 -- 控件不能直接绑定列【费用汇总.费用计算式】
如果要赋值,请在窗口关闭的时候给表列赋值。 |
-- 作者:有点蓝 -- 发布时间:2017/9/26 20:49:00 -- 改下公式的规则,序号使用大括号括起来,列名使用中括号括起来,这样就方便处理了 |
-- 作者:有点蓝 -- 发布时间:2017/9/26 23:28:00 -- 方法一样。看懂15楼代码。 只是不同的序号列都有相同的内容,就不知道要到哪个列去查数据。要想办法区分
|
-- 作者:有点甜 -- 发布时间:2017/9/27 9:30:00 -- If e.DataRow.IsNull("费用计算式") = False Then [此贴子已经被作者于2017/9/28 15:38:42编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/9/28 13:09:00 -- 项目发上来测试。 |
-- 作者:有点甜 -- 发布时间:2017/9/28 14:52:00 -- rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) For Each match As System.Text.RegularExpressions.Match In rgx.Matches(str) str = "监理单位审核_" & str.replace(match.Value, e.DataRow(match.Value.trim("[","]"))).Replace("监理单位审核_", "") Next |
-- 作者:有点甜 -- 发布时间:2017/9/28 15:40:00 -- pattern = "\\[.+?\\]" rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) For Each match As System.Text.RegularExpressions.Match In rgx.Matches(str) str = str.replace(match.Value, e.DataRow("监理单位审核_" & match.Value.Replace("监理单位审核_", "").trim("[","]"))) Next |
-- 作者:有点甜 -- 发布时间:2017/9/28 16:35:00 -- 测试没问题。 |