以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 按条件统计列数 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151383) |
-- 作者:13775189031 -- 发布时间:2020/6/22 13:43:00 -- 按条件统计列数 考勤汇总表中列“应出勤天数” 考勤表中列“休息日1”、“休息日2”,“休息日3”....“休息日31” 想实现“应出勤天数”等于考勤表中“休息日”等于空值的列数(不是空值时显示周末、法定假日、调休等),同时本月若没有29、30或31的要减掉 代码应该怎么写 |
-- 作者:有点蓝 -- 发布时间:2020/6/22 13:50:00 -- 请上传实例说明 |
-- 作者:13775189031 -- 发布时间:2020/6/22 14:09:00 -- 为什么传不上去呢? 一直显示“一次只能上传3个文件!” 但我只传了1个 有时显示“请正确选择要上传的文件” [此贴子已经被作者于2020/6/22 14:11:53编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/6/22 14:15:00 -- 刷新网页重新上传,重复试 |
-- 作者:13775189031 -- 发布时间:2020/6/22 15:05:00 -- [此贴子已经被作者于2020/6/22 16:00:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/6/22 15:20:00 -- 大概: 汇总表datacolchanged If e.DataCol.Name = "姓名" Then Dim dr As DataRow = DataTables("考勤").Find("姓名=\'" & e.NewValue & "\' and 考勤月份=\'" & Format(Date.Today,"yyyy-MM") & "\'") If dr IsNot Nothing Then Dim cnt As Integer = 0 For i As Integer = 1 To Date.DaysInMonth(Date.Today.Year,Date.Today.Month) If dr.IsNull("考勤日期_" & i & "_休息日") cnt = cnt +1 End If Next e.DataRow("应出勤天数") = cnt End If End If |
-- 作者:13775189031 -- 发布时间:2020/6/22 17:19:00 -- If e.DataCol.Name = "编号" Then Dim dr As DataRow = DataTables("考勤").Find("编号=\'" & e.NewValue & "\'") If dr IsNot Nothing Then Dim cnt As Integer = 0 For i As Integer = 1 To Date.DaysInMonth(Date.Today.Year,Date.Today.Month) If dr.IsNull("考勤日期_" & i & "_休息日") cnt = cnt +1 End If Next e.DataRow("应出勤天数") = cnt End If End If 每月考勤日期是从上一个月的21号开始到本月的20号结束,例如7月份考勤是从6月21日开始到7月20日结束 按上面的代码发现有31日的月计算出来的天数会少一天,例如从7月21日开始到8月20日结束,是23个工作日,也就是应出勤23天,但计算下来是22天 7月份没有31号,就没问题是因为考勤不是自然月的问题么?
|
-- 作者:有点蓝 -- 发布时间:2020/6/22 17:22:00 -- 我给的代码算的是自然月。跨月自己参考改改 |
-- 作者:13775189031 -- 发布时间:2020/6/23 10:43:00 -- 请老师帮忙改改 If e.DataCol.Name = "编号" Then Dim dr As DataRow = DataTables("考勤").Find("编号=\'" & e.NewValue & "\'") If dr IsNot Nothing Then Dim cnt As Integer = 0 Dim dt1 As Date = Date(year,addmonth(-1),21) Dim dt2 As Date = Date(year,month,20) For i As Integer = dt1 To dt2 If dr.IsNull("考勤日期_" & i & "_休息日") cnt = cnt +1 End If Next e.DataRow("应出勤天数") = cnt End If End If
|
-- 作者:有点蓝 -- 发布时间:2020/6/23 11:10:00 -- If e.DataCol.Name = "编号" Then Dim dr As DataRow = DataTables("考勤").Find("编号=\'" & e.NewValue & "\'") If dr IsNot Nothing Then Dim cnt As Integer = 0 Dim dt1 As Date = Date(year,addmonth(-1),21) Dim dt2 As Date = Date(year,month,20) Do While dt1 <= dt2 If dr.IsNull("考勤日期_" & dt1.Day & "_休息日") cnt = cnt +1 End If dt1.AddDays(1) Loop e.DataRow("应出勤天数") = cnt End If End If
|