0

Hi
I Currently working on a project to schedule installers to do installations.
When scheduling the user will select the day of intall and if the number of days the instalation will take or motning or afternoon if its only hafday and I want the application to search which installer is available for that specific day or halfday
I currently have it working with full day install. I need help on how to find if an nstaller is available for a half day (morning or afternoon).
This is how i'm searching for full day.
Thanks

  Private Sub Available_instalers()
        Dim Available_instalers = New DataTable
        Dim installer_nme As String
        Dim available As Boolean = True
        Dim dte_current As Date = CDate(val_from.Date.ToString("MMM/dd/yy"))
        Dim dte_inst_From, dte_inst_To As Date
        Dim st_inst_from, st_inst_to As String
        Dim dr As DataRow
        Try
            With Available_instalers
                .Columns.Add("Installer", GetType(System.String))
            End With
            dv_installer_Schedule = New DataView(dt_installer_Schedule)
            'This loops through every installer and checks who is avalable for the selected day
            For Each inRow In ds_Installer.Tables("Installer").Rows
                dte_current = CDate(val_from.Date.ToString("MMM/dd/yy"))
                available = True
                installer_nme = inRow("ins_Name").ToString
                If UCase(installer_nme) = "LUIS" Or UCase(installer_nme) = "STEPHAN" Then
                    dv_installer_Schedule.RowFilter = "(Installer ='" & installer_nme & "' OR Installer='L&S')  AND insFrom >'" & Today() & "'"
                Else
                    dv_installer_Schedule.RowFilter = "Installer='" & installer_nme & "' AND insFrom >'" & Today() & "'"
                End If

                dv_installer_Schedule.Sort = "insFrom asc"
  'This loops each day to find if the installer is available
                Do While dte_current <= Val_to
                    For Each schInstall In dv_installer_Schedule.ToTable.Rows
                        st_inst_from = schInstall("insFrom").ToString
                        st_inst_to = schInstall("insto").ToString
                        dte_inst_From = CDate(st_inst_from)
                        dte_inst_To = CDate(st_inst_to)
                        If dte_current >= dte_inst_From And dte_current <= dte_inst_To Then
                            available = False
                            Exit Do
                        End If
                    Next
                    dte_current = dte_current.AddDays(1)
                Loop
                If available Then
                    dr = Available_instalers.NewRow
                    dr("Installer") = installer_nme
                    Available_instalers.Rows.Add(dr)
                End If
            Next
        Catch ex As Exception
            MsgBox(Me.Text & " Available_instalers " & ex.Message, MsgBoxStyle.Critical)
        End Try
        dgv_Installer.DataSource = Available_instalers
        End Sub
2
Contributors
6
Replies
47
Views
7 Months
Discussion Span
Last Post by VIPER5646
0

I would suggest that you refactor your data table so that you store the hours each day a specific installer is available, with perhaps a flag to indicate that there are no available hours for that installer, that day.

This would give you much more flexibility in your searches as well as making it easier for more changes later on.

Edited by tinstaafl

0

thanks
but I can't refactor the database because I didn't created it.
It belongs to another program.

1

If the database doesn't have the ability to break down the day, it's going to be nearly impossible to break it down yourself.

0

The Database currently has a column with the day an install is scheduled and another with the number of days and if it is am or pm install.
this is the format of the number of days column it is a mask field AM-PM-#days_.

Edited by VIPER5646

0

So basically you will have to get that column from the database and parse it. How, will depend on how the database is set up to store the bitmask.

0

Thanks Tinstaaf
I Solved by adding Time.
For Example if its an AM install the start would be 7:00 am and compleate would be noon. This way I can alwas search for available installers the same way I was using for full days, accept of using the date I will use date and time.

Edited by VIPER5646

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.