That was my first thought but the 2000 machine has the same versions of the .net framework installed and also has bean patched to the max.
Anyway here is the code.
Cursor = Windows.Forms.Cursors.WaitCursor
durationD = DateDiff(DateInterval.Day, frm.expected_date, frm.DTPdays.Value)
durationH = IIf(frm.txthours.Text = "", "0", frm.txthours.Text)
frm.Close()
cbo_productselect.SelectedIndex = currentindex
' new_stage_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, durationH, DateAdd(DateInterval.Day, durationD, CDate(txt_exp_stream_comp.Text))))
Dim conn As New ADODB.Connection()
Dim cmd As New ADODB.Command()
Dim rs As New ADODB.Recordset()
conn.ConnectionString = connection_Str
conn.Open()
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.CommandText = "select * from stream where diwor = " & cbo_productselect.SelectedValue
cmd.ActiveConnection = conn
rs.Open(cmd, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
new_stage_date = rs.Fields("exp_stage_comp_date").Value
new_stage_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, durationH, DateAdd(DateInterval.Day, durationD, new_stage_date)))
Do Until isworkingday(new_stage_date)
new_stage_date = DateAdd(DateInterval.Day, 1, new_stage_date)
Loop
Dim cmd1 As New ADODB.Command()
Dim rs1 As New ADODB.Recordset()
cmd1.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd1.CommandText = "SELECT SUM(dbo.Stages.P_duration_H) AS Hours, SUM(dbo.Stages.p_duration_D) AS Days from Product_Stages LEFT OUTER JOIN Stages ON Product_Stages.Stage_diwor = Stages.Diwor RIGHT OUTER JOIN Stream ON Product_Stages.Product_Diwor = Stream.Product_Diwor WHERE (dbo.Product_Stages.Diwor NOT IN (SELECT product_stage_diwor FROM stream_stages WHERE stream_diwor = " & cbo_productselect.SelectedValue & ")) AND (dbo.Stream.Diwor = " & cbo_productselect.SelectedValue & ") GROUP BY Stream.Diwor HAVING(SUM(Stages.P_duration_H) > 0) OR (SUM(Stages.p_duration_D) > 0)"
cmd1.ActiveConnection = conn
rs1.Open(cmd1, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
If rs1.EOF = False And rs1.BOF = False Then
new_stream_date = get_working_hours_datetime(DateAdd(DateInterval.Hour, rs1.Fields("Hours").Value, DateAdd(DateInterval.Day, get_totaldays_from_working_days(new_stage_date, rs1.Fields("days").Value), new_stage_date)))
Else
MsgBox("Unable to calculate completion time!", MsgBoxStyle.Exclamation, "Error")
End If
rs.Fields("exp_stream_comp_date").Value = new_stream_date
rs.Fields("exp_stage_comp_date").Value = new_stage_date
rs.Update()
Case_info1.Delayes.Clear()
get_case_info.SelectCommand.CommandText = "SELECT Delayes.Diwor, Delayes.Stage, Delayes.case_diwor, Delayes.Stream_diwor, Delayes.Delayed_Reason, Delayes.Delay_duration_days, Delayes.Delay_duration_Hours, Delayes.comments, Users.Users_name FROM Delayes LEFT OUTER JOIN Users ON Delayes.user_diwor = Users.Diwor WHERE case_diwor = " & IIf(Stream_diwor = 0, case_diwor, "(SELECT MAX(case_diwor) AS case_diwor FROM stream WHERE diwor = " & Stream_diwor & ")")
get_case_info.Fill(Case_info1, "Delayes")
Case_info1.VW_Cases.Clear()
get_case_info.SelectCommand.CommandText = "SELECT * FROM VW_Cases WHERE case_diwor = " & IIf(Stream_diwor = 0, case_diwor, "(SELECT MAX(case_diwor) AS case_diwor FROM stream WHERE diwor = " & Stream_diwor & ")")
get_case_info.Fill(Case_info1, "VW_Cases")
mainfrm.get_todays_tasks()
cbo_productselect.SelectedIndex = currentindex
txt_exp_stream_comp.Text = new_stream_date
txt_exp_stage_comp.Text = new_stage_date
Cursor = Windows.Forms.Cursors.Default
'Just checks to see if a date is on a working day
Public Function isworkingday(ByVal start_date As Date) As Boolean
Dim conn As New ADODB.Connection()
Dim cmd As New ADODB.Command()
Dim rs As New ADODB.Recordset()
'get the public holidays from the database
'checks to see that the day of the week is ok
If Weekday(start_date) <> 1 And Weekday(start_date) <> 7 Then
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=MortTrak;Data Source=PHEONIX"
conn.Open()
cmd.CommandType = ADODB.CommandTypeEnum.adCmdText
cmd.CommandText = "select * from public_holidays where convert(datetime,hol_Datetime,103) > convert(datetime,'" & start_date & "',103)"
cmd.ActiveConnection = conn
rs.Open(cmd, , ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
'checks to see if the start date is equall to any of the public hols
Do Until rs.EOF
If rs.Fields("hol_Datetime").Value = start_date Then
Return False
Exit Function
End If
rs.MoveNext()
Loop
Return True
Else
Return False
End If
rs.Close()
End Function
Cheers,
Hugh