需要帮助计算时间值 [英] Need Help Calculating Time Values
问题描述
大家好,你好
我在尝试使其工作时遇到问题.让我解释一下我要做什么.我有一个表单,其中包含2个日期编辑文本,2个timeedit文本. 2个文本框,一个用于常规时间,另一个用于加班时间.
结果(只读模式).我希望能够选择工作日期和工作日结束日期,以及工作日期的开始时间和结束时间.如果小时数超出了每日的默认小时数,则多余的小时数应记录为加班时间. (这
原因是它不是硬编码的,即..40是因为可能的4-10时间表)I子过程读取数据库中已记录的小时数并将其与当前编辑进行比较,以查看当前编辑是否会超过默认值小时.如果有的话
或不超过默认时间,则编辑时间应记录为加班时间.这是我到目前为止的内容,但是当编辑小时和总小时数超过默认小时数时,它将不起作用,例如,如果我有36个常规小时数和默认时间
小时设置为40,那么如果员工工作8小时,我希望将4小时记录为正常时间,将4小时记录为加班时间.
如果有人可以帮助我,我将不胜感激.这可能很简单,我想从中获得更多收益,我想我正遭受代码重载的困扰. :脸红:
Hello, Everyone
I'm having problems trying to get this to work. Let me explain what I'm trying to do. I have a form which has 2 date edit text, 2 timeedit text. 2 textboxes one for regular hours and the other for overtime hours., I also have a datagrid which displays
the results(read only mode). I want to be able to select the date worked and end of the workweek date, the start time and end time for the work date. if the hours exceed the daily default hours then the extra hours should be recorded as overtime hours. (the
reason this is not hard coded ie..40 is because of a possible 4-10 schedule) I a sub procedure that reads the hours already recorded in the database and compares it with the current edit to see if the current edit will exceed the default hours. If it does
or up to the default hours, then the edit hours should be recorded as overtime hours. Here is what I have so far but it does not work when the edit hours and the total hours exceed the default hours an example would be if I have 36 regular hours and the default
hours are set to 40 then if the employee works 8 hours I want 4 hours to be recorded as regular time and 4 hours to be recorded as overtime hours.
If anyone could help me with this I would appreciate it. It is probably simple and I'm making more out of it I guess I'm suffering from code overload. :blush:
提取已在数据库中输入的小时数的程序,此方法有效:
Procedure to extract the hours already entered in the database, this works:
Private Sub CheckWorkHours(ByVal TotalHrs As Double, ByVal OverHrs As Double, ByVal TotalDays As Integer)
tEmployee = Me.CbEmployee.EditValue
tWeek = Me.DateWeekEnd.EditValue
strSql = "SELECT COUNT(*) AS TotalDays, SUM(RegHours) AS TotalHrs, SUM(OverHours) AS OverHrs FROM(TimeSheet)WHERE (Employee = @Employee) AND (WeekEnd = @WeekEnd)"
Using conn As New VistaDBConnection(vDbConn)
Using cmd As New VistaDBCommand(strSql, conn)
Dim dr As VistaDBDataReader
cmd.Parameters.AddWithValue("@Employee", tEmployee)
cmd.Parameters.AddWithValue("@WeekEnd", tWeek)
'Open connection
conn.Open()
'Get the Values from the Statement
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Do While dr.Read
TotalHrs = (dr.Item("TotalHrs"))
OverHrs = (dr.Item("OverHrs"))
TotalDays = (dr.Item("TotalDays"))
Loop
'Close connection
conn.Close()
End Using
End Using
Me.rDays.EditValue = TotalDays
Me.rHours.EditValue = TotalHrs
Me.oHours1.EditValue = OverHrs
End Sub
推荐答案
在子
Private Sub CheckWageType()
如果
CheckWorkHours(TotalHrs, Overhrs, Totaldays)
TotalHrs,Overhrs,Totaldays超出了此类的范围,那么在将其传递给
which are TotalHrs, Overhrs, Totaldays is outside the scope of this class, then the values will revert back to what ever the values where before you pass it to the
Private Sub CheckWorkHours(ByVal TotalHrs As Double, ByVal OverHrs As Double, ByVal TotalDays As Integer)
这些变量(TotalHrs,Overhrs,Totaldays)在哪里声明?
Where are these variables (TotalHrs, Overhrs, Totaldays) declared?
这篇关于需要帮助计算时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!