以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151004) |
-- 作者:13775189031 -- 发布时间:2020/6/12 13:24:00 -- 代码 请教!代码提示错误: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.5.29.8 错误所在事件:表,考勤,DataColChanged 详细错误信息: 调用的目标发生了异常。 未将对象引用设置到对象的实例。 要怎么修改? Select Case e.DataCol.Name Case "编号","考勤日期_1_考勤","考勤日期_1_小时" If e.DataRow.IsNull("编号") = True OrElse e.DataRow("考勤日期_1_考勤").Contains("/") = False Then DataTables("平时出勤").DeleteFor("编号=\'" & e.DataRow("编号") & "\'") Else Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") If e.DataRow("考勤日期_1_考勤").Contains("/") = True Then Dim ndr As Row = Tables("平时出勤").AddNew ndr("编号") = e.DataRow("编号") ndr("考勤年份") = e.DataRow("考勤年份") ndr("考勤月份") = e.DataRow("考勤月份") ndr("班组") = e.DataRow("班组") ndr("用工性质") = e.DataRow("用工性质") ndr("姓名") = e.DataRow("姓名") ndr.Move(0) End If If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr1("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr1("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If End If End Select |
-- 作者:有点蓝 -- 发布时间:2020/6/12 14:16:00 -- Find出来的行都要判断是不是空的,比如没有结果的时候:http://www.foxtable.com/webhelp/topics/2044.htm Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") if ndr1 isnot nothing then ‘其它代码’ end if
|
-- 作者:13775189031 -- 发布时间:2020/6/12 15:12:00 -- Select Case e.DataCol.Name Case "编号","考勤日期_1_考勤","考勤日期_1_小时" If e.DataRow.IsNull("编号") = True Then DataTables("平时出勤").DeleteFor("编号=\'" & e.DataRow("编号") & "\'") Else Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") If e.DataRow("考勤日期_1_考勤").Contains("/") = True Then Dim ndr As Row = Tables("平时出勤").AddNew ndr("编号") = e.DataRow("编号") ndr("考勤年份") = e.DataRow("考勤年份") ndr("考勤月份") = e.DataRow("考勤月份") ndr("班组") = e.DataRow("班组") ndr("用工性质") = e.DataRow("用工性质") ndr("姓名") = e.DataRow("姓名") ndr.Move(0) End If End If End Select 试了一下,按上面的代码增加行没问题! 增加下面的代码后就有问题了! End If If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr1("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr1("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If End If End Select |
-- 作者:有点蓝 -- 发布时间:2020/6/12 15:50:00 -- 都说要判断一下咯 Select Case e.DataCol.Name Case "编号","考勤日期_1_考勤","考勤日期_1_小时" If e.DataRow.IsNull("编号") = True Then DataTables("平时出勤").DeleteFor("编号=\'" & e.DataRow("编号") & "\'") Else If e.DataRow("考勤日期_1_考勤").Contains("/") = True Then Dim ndr As Row = Tables("平时出勤").AddNew ndr("编号") = e.DataRow("编号") ndr("考勤年份") = e.DataRow("考勤年份") ndr("考勤月份") = e.DataRow("考勤月份") ndr("班组") = e.DataRow("班组") ndr("用工性质") = e.DataRow("用工性质") ndr("姓名") = e.DataRow("姓名") ndr.Move(0) End If Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") if ndr1 isnot nothing then If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr1("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr1("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If end if End If End Select |
-- 作者:13775189031 -- 发布时间:2020/6/12 16:29:00 -- 按上面的代码,列"考勤日期_1_小时"发生变化时,会重新再生成一行 |
-- 作者:有点蓝 -- 发布时间:2020/6/12 16:44:00 -- 想要怎么做? |
-- 作者:13775189031 -- 发布时间:2020/6/12 16:59:00 -- ("考勤日期_1_考勤").Contains("/") = True 时增加行,但"考勤日期_1_小时"变化时,只要编号一致就不再增加行 |
-- 作者:有点蓝 -- 发布时间:2020/6/12 17:21:00 -- Select Case e.DataCol.Name Case "编号","考勤日期_1_考勤","考勤日期_1_小时" If e.DataRow.IsNull("编号") = True Then DataTables("平时出勤").DeleteFor("编号=\'" & e.DataRow("编号") & "\'") Else Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") If e.DataRow("考勤日期_1_考勤").Contains("/") = True andalso ndr1 is nothing Then Dim ndr As Row = Tables("平时出勤").AddNew ndr("编号") = e.DataRow("编号") ndr("考勤年份") = e.DataRow("考勤年份") ndr("考勤月份") = e.DataRow("考勤月份") ndr("班组") = e.DataRow("班组") ndr("用工性质") = e.DataRow("用工性质") ndr("姓名") = e.DataRow("姓名") ndr.Move(0) End If if ndr1 isnot nothing then If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr1("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr1("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If end if End If End Select |
-- 作者:13775189031 -- 发布时间:2020/6/15 9:39:00 -- 按上面的代码填写"考勤日期_1_考勤"="/"增加行后, ("出勤时长_1") = "8"没有自动显示,只能对"考勤日期_1_小时"修改一次后才能自动显示, "出勤时长_1"大多数情况下都是“8”,所以想实现增加行后,如果"考勤日期_1_小时"不填写,首先默认("出勤时长_1") = "8",不要修改后才能显示
|
-- 作者:有点蓝 -- 发布时间:2020/6/15 9:55:00 -- Select Case e.DataCol.Name Case "编号","考勤日期_1_考勤","考勤日期_1_小时" If e.DataRow.IsNull("编号") = True Then DataTables("平时出勤").DeleteFor("编号=\'" & e.DataRow("编号") & "\'") Else Dim ndr1 As DataRow = DataTables("平时出勤").Find("编号=\'" & e.DataRow("编号") & "\'") If e.DataRow("考勤日期_1_考勤").Contains("/") = True AndAlso ndr1 Is Nothing Then Dim ndr As Row = Tables("平时出勤").AddNew ndr("编号") = e.DataRow("编号") ndr("考勤年份") = e.DataRow("考勤年份") ndr("考勤月份") = e.DataRow("考勤月份") ndr("班组") = e.DataRow("班组") ndr("用工性质") = e.DataRow("用工性质") ndr("姓名") = e.DataRow("姓名") If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If ndr.Move(0) End If If ndr1 IsNot Nothing Then If e.DataRow.IsNull("考勤日期_1_小时") = True Then ndr1("出勤时长_1") = "8" Else If e.DataRow.IsNull("考勤日期_1_小时") = False Then ndr1("出勤时长_1") = e.DataRow("考勤日期_1_小时") End If End If End If End If End Select
|