Good Morning,
I'm working on a project where the user adds a date in a textbox and the program creates a list of activities with initial and final dates, also creates activities depending on the number of reels Ci, what I'm looking for is that the program creates the list of activities with dates from Monday to Friday or Monday to Saturday or Monday to Sunday, because if you do not do this the program calculates the days without conditions.
How can i solve this?
Dim Table As New DataTable
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim date1 As Date
Try
date1 = CType(TextBox1.Text, Date)
Catch
Exit Sub
End Try
Dim numRows As Integer
If Integer.TryParse(TextBox4.Text, numRows) Then
If (numRows >= 1) Then
For i As Integer = 1 To numRows
Table.Rows.Add("Manufacturing", "Channel", "Cut plate C" & i, DateAdd(DateInterval.Day, 1, date1), DateAdd(DateInterval.Day, 2, date1))
Table.Rows.Add("Manufacturing", "Channel", "Rolled plate C" & i, DateAdd(DateInterval.Day, 3, date1), DateAdd(DateInterval.Day, 4, date1))
Table.Rows.Add("Manufacturing", "Channel", "Longituid welding C" & i, DateAdd(DateInterval.Day, 5, date1), DateAdd(DateInterval.Day, 6, date1))
Table.Rows.Add("Manufacturing", "Channel", "Re rolled C" & i, DateAdd(DateInterval.Day, 7, date1), DateAdd(DateInterval.Day, 8, date1))
date1 = DateAdd(DateInterval.Day, 8, date1)
Next
Else
MessageBox.Show("Value: " & TextBox4.Text & " El numero de filas debe ser mayor o igual a 1", "Error")
End If
Else
MessageBox.Show("Value: " & TextBox4.Text & " Número invalido", "Error")
End If
For C As Integer = 0 To DataGridView1.Columns.Count - 1
DataGridView1.Columns(C).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
Next C
End Sub
What I have tried:
Dim Eleccion As Integer = 0
Private Sub RBEleccionXXX_CheckedChanged(sender As Object, e As EventArgs) Handles RBEleccion1.CheckedChanged, RBEleccion2.CheckedChanged, RBEleccion3.CheckedChanged
Select Case sender.name
Case "RBEleccion1"
Eleccion = 1
Case "RBEleccion2"
Eleccion = 2
Case "RBEleccion3"
Eleccion = 3
End Select
Select Case Eleccion ' Los días son Domigo = 0, Lunes = 1, …, Sabado = 6.
Case 1
If date1.DayOfWeek = 6 Then
date1 = date1.AddDays(2)
ElseIf date1.DayOfWeek = 0 Then
date1 = date1.AddDays(1)
End If
Case 2
If date1.DayOfWeek = 0 Then
date1 = date1.AddDays(1)
End If
Case 3
' Nada hacer
End Select