Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim conn As New MySqlConnection
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString
Dim mysql_comando As New MySqlCommand("Select distinct noperario,operario from cdp_operaciones where noperario = 2177", conn)
Dim reader As MySqlDataReader
Dim da As New MySqlDataAdapter(mysql_comando)
Dim numoperario, longitud1, longitud2, longitud3, longitud4, i, j, tiempoteorico, totalCapturadas, capturadas As Integer
Dim nombre, mes, fechaActual, reglaplantrabajo, mesActual, anoActual, fecha, horas As String
Dim tpr29, tpr30, tpr31 As String
Dim tiempotprX As Integer
Dim valoresarray1, valoresarray2, valoresarray3, valoresarray4 As String()
Dim objRow As New TableRow()
fechaActual = Now.Date
mesActual
= Month(fechaActual
) anoActual
= Year(fechaActual
) fecha = mesActual + "/" + anoActual
i = 0
j = 0
valoresarray1 = calculoFechaHorasReales(numoperario, fechaActual)
longitud1 = valoresarray1.Length
reglaplantrabajo = calculoReglaPlanTrabajo(numoperario, fechaActual)
valoresarray2 = calculoPeriodosTrabajo(reglaplantrabajo, fechaActual)
longitud2 = valoresarray2.Length
For i = 0 To longitud1 - 1
tiempoteorico = 0
Try
objRow = New TableRow
Dim objCell1, objCell2, objCell3, objCell4, objCell5, objCell6, objCell7, objCell8 As New TableCell()
Using conn
conn.Open()
With mysql_comando
reader = .ExecuteReader()
While reader.Read()
numoperario = reader.GetValue(0)
nombre = reader.GetValue(1)
mes = fecha
objCell1.Controls.Add(New LiteralControl(numoperario))
objCell1.HorizontalAlign = HorizontalAlign.Center
objCell2.Controls.Add(New LiteralControl(nombre))
objCell2.HorizontalAlign = HorizontalAlign.Center
'objCell3.Controls.Add(New LiteralControl(mes))
objCell3.Controls.Add(New LiteralControl(valoresarray1(i)))
objCell3.HorizontalAlign = HorizontalAlign.Center
objRow.Cells.Add(objCell1)
objRow.Cells.Add(objCell2)
objRow.Cells.Add(objCell3)
End While
.Dispose()
End With
objCell5.Controls.Add(New LiteralControl("%"))
objCell5.HorizontalAlign = HorizontalAlign.Center
objRow.Cells.Add(objCell5)
horas = calcularHorasDia(valoresarray1(i))
Dim longitud5, longitud6, longitud7 As Integer
Dim h, minCortar, min, s, horasdia As String
longitud5 = horas.Length
If longitud5 = 5 Then
h = horas.Substring(0, 1)
minCortar = horas.Substring(0, 3)
longitud6 = minCortar.Length
min
= Right(minCortar, longitud6
- 1) s
= Right(horas, longitud5
- 3) horasdia = h + ":" + min + ":" + s
ElseIf longitud5 = 6 Then
h = horas.Substring(0, 2)
minCortar = horas.Substring(0, 4)
longitud6 = minCortar.Length
min
= Right(minCortar, longitud6
- 2) s
= Right(horas, longitud5
- 4) horasdia = h + ":" + min + ":" + s
End If
objCell6.Controls.Add(New LiteralControl(horasdia))
'objCell6.Controls.Add(New LiteralControl("horasReales"))
objCell6.HorizontalAlign = HorizontalAlign.Center
objRow.Cells.Add(objCell6)
objCell7.Controls.Add(New LiteralControl("%"))
objCell7.HorizontalAlign = HorizontalAlign.Center
objRow.Cells.Add(objCell7) 'porcentaje horas reales
Dim long1, long2 As Integer
Dim ano, mesCortar, mes1, dia, fechaformato As String
long1 = valoresarray1(i).Length
dia
= Right(valoresarray1
(i
), longitud1
- 8)
If dia = "01" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(0))
ElseIf dia = "02" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(1))
ElseIf dia = "03" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(2))
ElseIf dia = "04" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(3))
ElseIf dia = "05" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(4))
ElseIf dia = "06" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(5))
ElseIf dia = "07" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(6))
ElseIf dia = "08" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(7))
ElseIf dia = "09" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(8))
ElseIf dia = "10" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(9))
ElseIf dia = "11" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(10))
ElseIf dia = "12" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(11))
ElseIf dia = "13" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(12))
ElseIf dia = "14" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(13))
ElseIf dia = "15" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(14))
ElseIf dia = "16" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(15))
ElseIf dia = "17" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(16))
ElseIf dia = "18" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(17))
ElseIf dia = "19" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(18))
ElseIf dia = "20" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(19))
ElseIf dia = "21" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(20))
ElseIf dia = "22" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(21))
ElseIf dia = "23" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(22))
ElseIf dia = "24" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(23))
ElseIf dia = "25" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(24))
ElseIf dia = "26" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(25))
ElseIf dia = "27" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(26))
ElseIf dia = "28" Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(27))
ElseIf dia = "29" Then
If tpr29 <> " " Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(28))
End If
ElseIf dia = "30" Then
If tpr30 <> " " Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(29))
End If
ElseIf dia = "31" Then
If tpr31 <> " " Then
tiempotprX = calcularTiempoTeoricoDia(valoresarray2(30))
End If
End If
tiempoteorico = tiempotprX
objCell8.Controls.Add(New LiteralControl(tiempoteorico))
objCell8.HorizontalAlign = HorizontalAlign.Center
objRow.Cells.Add(objCell8) 'horas teoricas
End Using
Catch ex As Exception
Finally
conn.Dispose()
End Try
Table1.Rows.Add(objRow)
Next
End Sub