Imports MySql.Data.MySqlClient
Imports System.Configuration
Imports Oracle.ManagedDataAccess.Client
Imports Oracle.ManagedDataAccess.Types
<AjaxPro.AjaxNamespace("Principal")> _
Public Class Principal
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Register Ajax.NET methods from this class
AjaxPro.Utility.RegisterTypeForAjax(GetType(Principal))
Dim textBuscar As New TextBox()
Dim conn As New MySqlConnection
'se apunta a la cadena de conexion guardada en el archivo Web.config
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString
Dim mysql_comando As New MySqlCommand("select distinct noperario, operario from cdp_operaciones order by operario asc", conn)
Dim reader As MySqlDataReader
Dim da As New MySqlDataAdapter(mysql_comando)
Dim objRow As New TableRow()
Dim numoperario, nombre As String
Try
Using conn
'se abre la conexion
conn.Open()
With mysql_comando
reader = .ExecuteReader()
While reader.Read()
objRow = New TableRow()
Dim objCell1, objCell2, objCell3, objCell4 As New TableCell()
Dim linkDetalle, linkMes As New HyperLink()
numoperario = reader.GetValue(0)
nombre = reader.GetValue(1)
objCell1.Controls.Add(New LiteralControl(numoperario))
objCell1.HorizontalAlign = HorizontalAlign.Center
objCell2.Controls.Add(New LiteralControl(nombre))
objCell2.HorizontalAlign = HorizontalAlign.Left
linkDetalle.Text = "Detalle"
linkDetalle.NavigateUrl = "~/HorasOperarios.aspx"
objCell3.Controls.Add(New LiteralControl(linkDetalle.Text))
objCell4.Controls.Add(New LiteralControl(numoperario))
objCell4.Visible = False
objRow.Cells.Add(objCell1)
objRow.Cells.Add(objCell2)
objRow.Cells.Add(objCell3)
'objRow.Cells.Add(objCell4)
Table2.Rows.Add(objRow)
End While
.Dispose()
End With
End Using
Catch ex As Exception
'mensaje("Error en BD" & Chr(13) & Chr(13) & ex.Message)
Finally
conn.Dispose()
End Try
End Sub
<AjaxPro.AjaxMethod()> _
Public Function obtener_operarios(ByVal nombre As String) As String
Dim conn As New MySqlConnection
Dim nombreBuscar As String
'se apunta a la cadena de conexion guardada en el archivo Web.config
nombreBuscar
= UCase(nombre
) conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("conexionMySQL").ConnectionString
Dim mysql_comando As New MySqlCommand("select distinct noperario, operario from cdp_operaciones where operario like '%" & nombreBuscar & "%'order by operario asc", conn)
Dim reader As MySqlDataReader
Dim da As New MySqlDataAdapter(mysql_comando)
Dim objRow As New TableRow()
Dim numoperario, nombreoperario As String
Try
Using conn
'se abre la conexion
conn.Open()
With mysql_comando
reader = .ExecuteReader()
While reader.Read()
objRow = New TableRow
Dim objCell1, objCell2 As New TableCell()
numoperario = reader.GetValue(0)
nombreoperario = reader.GetValue(1)
objCell1.Controls.Add(New LiteralControl(numoperario))
objCell1.HorizontalAlign = HorizontalAlign.Center
objCell2.Controls.Add(New LiteralControl(nombreoperario))
objCell2.HorizontalAlign = HorizontalAlign.Left
objRow.Cells.Add(objCell1)
objRow.Cells.Add(objCell2)
Table2.Rows.Add(objRow)
End While
.Dispose()
End With
End Using
'Return FormatNumber(CDec(valor1) + CDec(valor2) + CDec(valor3), 2)
Catch ex As Exception
Return "0"
Finally
conn.Dispose()
End Try
End Function
End Class