Public Class Form2
    Private Sub btncerrarform_Click(sender As Object, e As EventArgs) Handles btncerrarform.Click
        Me.Close()
    End Sub
    Dim Table As New DataTable
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Table.Columns.Add("Departamento", Type.GetType("System.String"))
        Table.Columns.Add("Sección", Type.GetType("System.String"))
        Table.Columns.Add("Operación", Type.GetType("System.String"))
        Table.Columns.Add("Fecha Inicial", Type.GetType("System.DateTime"))
        Table.Columns.Add("Fecha Final", Type.GetType("System.DateTime"))
        Table.Columns.Add("Días", Type.GetType("System.DateTime"))

        DataGridView1.DataSource = Table

        DataGridView1.Columns(0).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
        DataGridView1.Columns(1).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
        DataGridView1.Columns(2).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
        DataGridView1.Columns(3).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
        DataGridView1.Columns(4).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)
        DataGridView1.Columns(5).HeaderCell.Style.Font = New Font("Microsoft Sans Serif", 10, FontStyle.Bold)

        DataGridView1.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(3).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(4).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(5).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells

    End Sub

    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

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim date1 As Date = CType(TextBox1.Text, Date)

        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

        Dim numRows As Integer

        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
        Table.Rows.Add("Habilitado", "Materials", "Sending drawings for approval", DateAdd(DateInterval.Day, 1, date1), DateAdd(DateInterval.Day, 2, date1))
        Table.Rows.Add("Habilitado", "Materials", "Approval by the client", DateAdd(DateInterval.Day, 2, date1), DateAdd(DateInterval.Day, 5, date1))

        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, 4, date1), DateAdd(DateInterval.Day, 4, date1))
                    Table.Rows.Add("Manufacturing", "Channel", "Rolled plate C" & i, DateAdd(DateInterval.Day, 4, date1), DateAdd(DateInterval.Day, 1, date1))
                    Table.Rows.Add("Manufacturing", "Channel", "Longituid welding C" & i, DateAdd(DateInterval.Day, 4, date1), DateAdd(DateInterval.Day, 5, date1))
                    Table.Rows.Add("Manufacturing", "Channel", "Re rolled C" & i, DateAdd(DateInterval.Day, 7, date1), DateAdd(DateInterval.Day, 7, date1))
                    date1 = DateAdd(DateInterval.Day, 6, date1)
                    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
                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

        If Integer.TryParse(TextBox3.Text, numRows) Then
            If (numRows >= 1) Then
                For i As Integer = 1 To numRows
                    Table.Rows.Add("Manufacturing", "Nozzlez", "Cut pipe for nozzles" & i, DateAdd(DateInterval.Day, 4, date1), DateAdd(DateInterval.Day, 4, date1))
                    Table.Rows.Add("Manufacturing", "Nozzlez", "Assembly of flange to shell" & i, DateAdd(DateInterval.Day, 4, date1), DateAdd(DateInterval.Day, 4, date1))
                    Table.Rows.Add("Manufacturing", "Nozzlez", "Welding of flange" & i, DateAdd(DateInterval.Day, 4, date1), DateAdd(DateInterval.Day, 5, 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

        DataGridView1.Columns(0).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(2).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(3).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(4).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
        DataGridView1.Columns(5).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells

    End Sub

    Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
        Table.Rows.Clear()
    End Sub
End Class
