Public Class Propiedad
Public Property Propietario As String
Public Property IdTipoVehiculo As Integer
Public Property Fecha As Date
Public Property Lavada As Double
Public Property Brillada As Double
Public Property Grafitada As Double
Public Property Motor As Double
Public Property Full As Double
Public Property Pcambio As DateTime
Public Property Frecuencia As Integer
Public Property Costo As Double
Public Property IdEmpleadoAce As Integer
Public Property Marca As String
Public Property Placa As String
Public Property FechaT As DateTime
Public Property Idmpleado As Integer
Public Property IdVehiculo As Integer
Public Property Descripcion As String
Public Property IdTservicio As Integer
Public Property Estado As String
Public Property Turno As Integer
End Class
codigo del formulario principal
Imports System.Data
Imports System.Data.SqlClient
Public Class FrmLavado
Implements IDisposable
Private Const V As String = "Select Id_tVehiculo from TIPOVEHICULO where (Descripcion) ='"
Private Const Vh As String = "Select Id_Vehiculo from VEHICULO where (Placa) ='"
Private aux As Integer = 0
Private temp As String
ReadOnly Dlr As New DataTable
ReadOnly Reg As New Propiedad
Public Fechas As Date
Private Sub SumarFecha()
Fechas = DateAdd("m", Fc, FechaCorta)
'-------------------
End Sub
Private Sub Llenarcombox(ByVal CMBox As ComboBox)
Enlace()
Try
Comando = New SqlCommand("select Descripcion from TIPOVEHICULO", Conexion)
Respuesta = Comando.ExecuteReader
While Respuesta.Read
CMBox.Items.Add(Respuesta.Item("Descripcion"))
End While
Respuesta.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
Respuesta.Close()
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub LimpiarForm(Controles As Control.ControlCollection)
For Each control As Control In Controles
If TypeOf control Is TextBox Then
DirectCast(control, TextBox).Clear()
ElseIf TypeOf control Is TxtMoneda Then
DirectCast(control, TxtMoneda).Valor = 0
ElseIf TypeOf control Is PictureBox Then
DirectCast(control, PictureBox).Image = Nothing
ElseIf TypeOf control Is ComboBox Then
'DirectCast(control, ComboBox).Items.Clear()
'DirectCast(control, ComboBox).Items.Add("")
DirectCast(control, ComboBox).Text = Nothing
ElseIf TypeOf control Is GroupBox Or TypeOf control Is Panel Then
LimpiarForm(control.Controls)
End If
Next
End Sub
Private Sub Inicio()
CBLavada.AutoCheck = True
If CBBrillada.Checked = True Then
CBBrillada.Checked = False
ElseIf CBGrafitada.Checked = True Then
CBGrafitada.Checked = False
ElseIf CBMotor.Checked = True Then
CBMotor.Checked = False
ElseIf CBFull.Checked = True Then
CBFull.Checked = False
ElseIf CBCambioAceite.Checked = True Then
CBCambioAceite.Checked = False
End If
End Sub
Private Sub Bloquear()
'Bloquear txt de información
TxtAuto.Enabled = False
TxtMoto.Enabled = False
TxtMCarro.Enabled = False
TxtCami.Enabled = False
TxtTotalVehiculos.Enabled = False
TxtVentaDia.Enabled = False
TxtUNetaD.Enabled = False
CBLavada.AutoCheck = True
' TxtLavada.Text = 0
'TxtLavada.Text = FormatCurrency(TxtLavada.Text)
If CBBrillada.Checked = False Then
TxtBrillada.Enabled = False
Else
TxtBrillada.Enabled = True
End If
If CBGrafitada.Checked = False Then
TxtGrafitada.Enabled = False
Else
TxtGrafitada.Enabled = True
End If
If CBMotor.Checked = False Then
TxtMotor.Enabled = False
Else
TxtMotor.Enabled = True
End If
If CBFull.Checked = False Then
TxtFull.Enabled = False
Else
TxtFull.Enabled = True
End If
If CBCambioAceite.Checked = False Then
TxtCambioAceite.Enabled = False
TxtFrecuencia.Enabled = False
CmbMecanico.Enabled = False
Else
TxtCambioAceite.Enabled = True
TxtFrecuencia.Enabled = True
CmbMecanico.Enabled = True
End If
End Sub
Sub Cargar()
FechaCorta = Format(DTMFIngreso.Value.ToShortDateString, "Short Date")
Fechacorta2 = Format(DTMFecha.Value.ToShortDateString, "Short Date")
Bloquear()
Inicio()
Botonservicio()
TxtTipoVehiculo.Visible = False
CMB_TVehiculo.Visible = True
DGVPrecios.Enabled = False
Llenarcombox(CMB_TVehiculo)
LlenarcomboEmpleado()
LlenarcomboEmpleadoMeca()
LlenarcomboEmpleado2()
LlenarcomboEmpleadoMeca2()
DGVPrecios.DataSource = Llenardgv()
' ConPeso()
MostrarVehiculos()
' DGVVehiculos.DataSource = LlenarDGVVehiculos()
' DGVVehiculos.Columns(0).Visible = False
DGVLavador.DataSource = LlenarDGVEmp()
DGVMecanico.DataSource = LlenarDGVEmpMec()
DGVSAceite.DataSource = LlenarDGVServiciosAceite()
DGVServicios.DataSource = LlenarDGVServicios()
Pruebatext()
VentasDia()
End Sub
Private Sub Lavado_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Cargar()
End Sub
Private Sub SacarIDV()
Enlace()
Try
Comando = New SqlCommand(Vh & TxtPlaca.Text & "'", Conexion)
respuesta = Comando.ExecuteReader
While respuesta.Read
IdVehiculo = Respuesta.Item("Id_Vehiculo")
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
respuesta.Close()
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub MostrarVehiculos()
Enlace()
Dim DtTabla As DataTable
Comando = New SqlCommand("SM_Vehiculos", Conexion) With {
.CommandType = CommandType.StoredProcedure
}
Respuesta2 = New SqlDataAdapter(Comando)
DtTabla = New DataTable
With Comando.Parameters
.Add(New SqlParameter("@Fecha", SqlDbType.Date)).Value = Fechacorta2
End With
Try
Respuesta2.Fill(DtTabla)
DGVVehiculos.DataSource = DtTabla
DGVVehiculos.Columns(0).Visible = False
Catch ex As Exception
Finally
Conexion.Close()
Conexion.Dispose()
Estado = "Desconectado"
End Try
End Sub
Private Function LlenarDGVEmpMec() As DataTable
Dim Dlr As New DataTable
Enlace()
Try
Comando = New SqlCommand("select P_Nombre + ' '+ P_Apellido As MECANICO from Empleado E
inner join empleadoaceite EA
on ea.id_empleado=e.Id_Empleado
inner join VEHICULO v
on v.Id_Vehiculo=ea.id_vehiculo
inner join TURNOVEHICULO tv
on tv.Id_Vehiculo=v.Id_Vehiculo
inner join TURNO t
on t.Id_Turno=tv.Id_TTurno
where v.Placa='" & temp & "' and cast(t.fecha as date)='" & Fechacorta2 & "'and ea.Id_Turno='" & Turn & "'", Conexion)
respuesta = Comando.ExecuteReader
Dlr.Load(respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Conexion.Close()
Estado = "Desconectado"
Dlr.Dispose()
Finally
Dlr.Dispose()
Conexion.Close()
Estado = "Desconectado"
End Try
respuesta.Close()
DGVMecanico.ReadOnly = True
Return Dlr
End Function
Private Function LlenarDGVvehiculoslav() As DataTable
Dim Dlr As New DataTable
Enlace()
Try
Comando = New SqlCommand("select tpv.Descripcion as TIPOVEHICULO, PLACA, MARCA from vehiculo V
inner join TIPOVEHICULO tpv
on tpv.Id_TVehiculo=v.Id_Tipo_Vehiculo
inner join turnovehiculo tv
on tv.id_vehiculo=v.id_vehiculo
inner join TURNO t
on t.Id_Turno=tv.Id_TTurno
where tv.Id_Empleado='" & Id_Empleadolav & "' and cast(t.Fecha as date)='" & Fechacorta2 & "' and t.Estado='Finalizado'", Conexion)
respuesta = Comando.ExecuteReader
Dlr.Load(respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Dlr.Dispose()
Conexion.Close()
Estado = "Desconectado"
Finally
Dlr.Dispose()
Conexion.Close()
Estado = "Desconectado"
Respuesta.Close()
DGVMecanico.ReadOnly = True
DGVVehiculoslav.ReadOnly = True
End Try
Return Dlr
End Function
Private Function LlenarDGVvehiculosace() As DataTable
Dim Dlr As New DataTable
Enlace()
Try
Comando = New SqlCommand("select tpv.Descripcion as TIPOVEHICULO, PLACA, MARCA from VEHICULO V
inner join TIPOVEHICULO tpv
on tpv.Id_TVehiculo=v.Id_Tipo_Vehiculo
inner join EmpleadoAceite ea
on ea.Id_Vehiculo=v.Id_Vehiculo
inner join detalleservicioace dsa
on dsa.id_servicio=ea.Id_Servicioace
where ea.Id_Empleado='" & Id_Empleadolav & "' and cast(dsa.Fecha as date)='" & Fechacorta2 & "' and dsa.estado='Finalizado'", Conexion)
respuesta = Comando.ExecuteReader
Dlr.Load(respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Conexion.Close()
Estado = "Desconectado"
Dlr.Dispose()
Finally
Dlr.Dispose()
Respuesta.Close()
Conexion.Close()
Estado = "Desconectado"
DGVMecanico.ReadOnly = True
DGvVeCA.ReadOnly = True
End Try
Return Dlr
End Function
Private Function LlenarDGVEmp() As DataTable
Enlace()
Try
Comando = New SqlCommand("select P_Nombre +' '+P_Apellido as LAVADOR from empleado E
inner join turnovehiculo TV
on tv.Id_Empleado=e.Id_empleado
inner join vehiculo V
on v.id_vehiculo=tv.Id_vehiculo
inner join turno T
on t.Id_Turno=tv.Id_TTurno
where v.placa='" & temp & "' and cast(t.fecha as date)='" & Fechacorta2 & "'and T.Id_Turno='" & Turn & "'", Conexion)
Respuesta = Comando.ExecuteReader
Dlr.Load(Respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Conexion.Close()
Estado = "Desconectado"
Dlr.Dispose()
Finally
Dlr.Dispose()
Respuesta.Close()
DGVLavador.ReadOnly = True
Conexion.Close()
Estado = "Desconectado"
End Try
Return Dlr
End Function
Private Function LlenarDGVServicios() As DataTable
Dim Dsr As New DataTable
Enlace()
Try
Comando = New SqlCommand("select Lavada, Brillado, Grafitado,Motor,[Full] from detalleservicioLav ds
inner join turnovehiculo TV
on tv.Id_ServicioLav=ds.Id_Servicio
inner join vehiculo V
on v.id_vehiculo=tv.Id_vehiculo
inner join turno T
on t.Id_Turno=tv.Id_TTurno
where v.placa='" & temp & "' and cast(t.fecha as date)='" & Fechacorta2 & "'and T.Id_Turno='" & Turn & "'", Conexion)
respuesta = Comando.ExecuteReader
Dsr.Load(respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Dsr.Dispose()
Conexion.Close()
Estado = "Desconectado"
Finally
Dsr.Dispose()
Respuesta.Close()
DGVServicios.ReadOnly = True
Conexion.Close()
Estado = "Desconectado"
End Try
Return Dsr
End Function
Private Function LlenarDGVServiciosAceite() As DataTable
Dim Dsr As New DataTable
Enlace()
Try
Comando = New SqlCommand("SELECT FRECUENCIA, PROXIMOCAMBIO, COSTO from DETALLESERVICIOACE DSA
INNER JOIN EmpleadoAceite EA
ON EA.Id_ServicioAce=DSA.Id_Servicio
inner join VEHICULO v
on v.Id_Vehiculo=EA.ID_VEHICULO
inner join TURNOVEHICULO tv
on tv.Id_Vehiculo=v.Id_Vehiculo
inner join TURNO t
on t.Id_Turno=tv.Id_TTurno
where v.Placa='" & temp & "' and cast(dsa.fecha as date)='" & Fechacorta2 & "'and ea.Id_Turno='" & Turn & "'", Conexion)
respuesta = Comando.ExecuteReader
Dsr.Load(respuesta)
Catch ex As Exception
MsgBox(ex.Message)
Dsr.Dispose()
Conexion.Close()
Estado = "Desconectado"
Finally
Dsr.Dispose()
Respuesta.Close()
DGVSAceite.ReadOnly = True
Conexion.Close()
Estado = "Desconectado"
End Try
Return Dsr
End Function
Private Function Llenardgv() As DataTable
Enlace()
Dim moto As String = "MOTO"
Dim motocarro As String = "MOTOCARRO"
Dim automovil As String = "AUTOMOVIL"
Dim camioneta As String = "CAMIONETA"
Dim Dt As New DataTable
If CMB_TVehiculo.SelectedItem = moto Or CMB_TVehiculo.SelectedItem = motocarro Or TxtTipoVehiculo.Text = "moto" Or TxtTipoVehiculo.Text = "motocarro" Then
Comando = New SqlCommand("Select Nombre,Moto From PRECIOLAV", Conexion)
Respuesta = Comando.ExecuteReader
Dt.Load(Respuesta)
aux = 1
ElseIf CMB_TVehiculo.SelectedItem = automovil Or TxtTipoVehiculo.Text = "automovil" Then
Comando = New SqlCommand("Select Nombre,Automovil From PRECIOLAV", Conexion)
Respuesta = Comando.ExecuteReader
Dt.Load(Respuesta)
aux = 2
ElseIf CMB_TVehiculo.SelectedItem = camioneta Or TxtTipoVehiculo.Text = "camioneta" Then
Comando = New SqlCommand("Select Nombre,Camioneta From PRECIOLAV", Conexion)
Respuesta = Comando.ExecuteReader
Dt.Load(Respuesta)
aux = 3
ElseIf aux = 0 Then
Comando = New SqlCommand("Select Nombre,Moto From PRECIOLAV", Conexion)
respuesta = Comando.ExecuteReader
Dt.Load(respuesta)
aux = 1
End If
Dt.Dispose()
Respuesta.Close()
Conexion.Close()
Conexion.Dispose()
Estado = "Desconectado"
Return Dt
End Function
Private Sub Lavado_Closed(sender As Object, e As EventArgs) Handles Me.Closed
Conexion.Close()
Conexion.Dispose()
End Sub
Private Sub LavadacompletaTU()
#Disable Warning IDE0068 ' Usar el patrón de Dispose recomendado
Dim Fun As New Procedimientos
#Enable Warning IDE0068 ' Usar el patrón de Dispose recomendado
Dim Id_Empleado As Integer = CInt(CmbDocEmp.SelectedValue)
Reg.FechaT = DTMFIngreso.Value
Reg.Idmpleado = Id_Empleado
Reg.IdVehiculo = IdVehiculo
Reg.Descripcion = TxtObservación.Text
Reg.Lavada = Val(TxtLavada.Valor)
Reg.Brillada = Val(TxtBrillada.Valor)
Reg.Grafitada = Val(TxtGrafitada.Valor)
Reg.Motor = Val(TxtMotor.Valor)
Reg.Full = Val(TxtFull.Valor)
If CBCambioAceite.Checked Then
Dim Id_EmpleadoAce As Integer = CInt(CmbMecanico.SelectedValue)
Fc = Val(TxtFrecuencia.Text)
SumarFecha()
Reg.Frecuencia = Val(TxtFrecuencia.Text)
Reg.Costo = Val(TxtCambioAceite.Valor)
Reg.IdEmpleadoAce = Id_EmpleadoAce
Reg.Pcambio = Fechas
Else
Dim id_empleadoAce As Integer = 0
Fc = Val(TxtFrecuencia.Text)
SumarFecha()
Reg.Frecuencia = 0
Reg.Costo = 0
Reg.IdEmpleadoAce = id_empleadoAce
Reg.Pcambio = Fechas
End If
If Fun.CrearTurnoTU(Reg) Then
MsgBox("Servicio ingresado correctamente", vbInformation, "Registro de servicios")
Fun.Dispose()
LimpiarForm(Me.Controls)
'Cargar()
Inicio()
Pruebatext()
VentasDia()
TxtPlaca.Select()
MostrarVehiculos()
End If
End Sub
Private Sub BTNIngresar_Click(sender As Object, e As EventArgs) Handles BTNIngresar.Click
If ValidateChildren() <> True Or TxtPlaca.Text Is "" Or TxtMarca.Text Is "" Or TxtPropietario.Text Is "" Or TxtLavada.Valor = 0 Or CmbDocEmp.Text Is "" Then
MessageBox.Show("Debe rellenar los campos obligatorios", "Crear Turno", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Enlace()
Try
Dim SQLSTR1 As String
Fecha3 = Format(DTMFIngreso.Value.ToShortDateString, "Short Date")
temp = TxtPlaca.Text
SQLSTR1 = "SELECT T.Id_Turno No, T.Fecha FECHA,tIv.DESCRIPCION AS TIPO, PLACA, MARCA, PROPIETARIO from VEHICULO V
INNER Join TURNOVEHICULO TV
On TV.Id_Vehiculo=V.Id_Vehiculo
INNER Join TURNO T
On T.Id_Turno=TV.Id_TTurno
INNER Join TIPOVEHICULO TIV
On TIV.ID_TVEHICULO=V.ID_TIPO_VEHICULO
WHERE CAST(T.Fecha As Date) ='" & Fecha3 & "' And v.Placa='" & temp & "' And t.Estado='Pendiente'"
Dim Consulta As New SqlDataAdapter(SQLSTR1, Conexion)
Consulta.SelectCommand.CommandType = CommandType.Text
Dim Tabla As New DataTable
Consulta.Fill(Tabla)
If Tabla.Rows.Count > 0 Then
MsgBox("Este Vehiculo tiene un servicio pendiente", vbCritical, "Crear turno")
LimpiarForm(Me.Controls)
Inicio()
Else
'FechaCorta = Format(DTMFIngreso.Value.ToShortDateString, "Short Date")
Fechacorta2 = Format(DTMFecha.Value.ToShortDateString, "Short Date")
If TxtTipoVehiculo.Visible = True Then
Comando = New SqlCommand(V & TxtTipoVehiculo.Text & " '", Conexion)
Respuesta = Comando.ExecuteReader
While Respuesta.Read
IdtVehiculo = Respuesta.Item("Id_tVehiculo")
End While
Respuesta.Close()
Else
#Disable Warning IDE0068 ' Usar el patrón de Dispose recomendado
Dim Fun As New Procedimientos
#Enable Warning IDE0068 ' Usar el patrón de Dispose recomendado
Reg.Placa = TxtPlaca.Text.ToUpper
Reg.Marca = TxtMarca.Text.ToUpper
Reg.Propietario = TxtPropietario.Text.ToUpper
Reg.IdTipoVehiculo = IdtVehiculo
Reg.Fecha = FechaCorta
Reg.Descripcion = TxtObservación.Text.ToUpper
Fun.IngresarVehiculo(Reg)
End If
SacarIDV()
LavadacompletaTU()
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End If
End Sub
Private Sub CMB_TVehiculo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CMB_TVehiculo.SelectedIndexChanged
Enlace()
Comando = New SqlCommand(V & CMB_TVehiculo.SelectedItem & "'", Conexion)
respuesta = Comando.ExecuteReader
While respuesta.Read
IDTVEHICULO = respuesta.Item("Id_tVehiculo")
End While
respuesta.Close()
DGVPrecios.DataSource = Llenardgv()
Conexion.Close()
Estado = "Desconectado"
'ConPeso()
End Sub
Public Sub ConPeso()
If aux = 1 Then
DGVPrecios.Columns("Moto").DefaultCellStyle.Format = "C2"
ElseIf aux = 2 Then
DGVPrecios.Columns("Automovil").DefaultCellStyle.Format = "C2"
ElseIf aux = 3 Then
DGVPrecios.Columns("Camioneta").DefaultCellStyle.Format = "C2"
End If
End Sub
Private Sub FillToolStripButton_Click(sender As Object, e As EventArgs)
Try
Me.PRECIOLAVTableAdapter.Fill(Me.YesidMotosLavaderDataSet.PRECIOLAV)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Dtmfecha_ValueChanged(sender As Object, e As EventArgs) Handles DTMFecha.ValueChanged
If DTMFecha.Value <= Date.Now Then
Fechacorta2 = Format(DTMFecha.Value.ToShortDateString, "Short Date")
MostrarVehiculos()
DGVLavador.DataSource = LlenarDGVEmp()
DGVServicios.DataSource = LlenarDGVServicios()
DGVSAceite.DataSource = LlenarDGVServiciosAceite()
DGVMecanico.DataSource = LlenarDGVEmpMec()
DGVVehiculoslav.DataSource = LlenarDGVvehiculoslav()
DGvVeCA.DataSource = LlenarDGVvehiculosace()
TxtEstado.Text = ""
EstadoServicioVehiculo = ""
Botonservicio()
Pruebatext()
VentasDia()
' CMotos()
'CMCarros()
'CAutomovil()
'CCamioneta()
End If
End Sub
Private Sub LlenarcomboEmpleado()
Enlace()
Try
Dim Sql As String = "SELECT Id_empleado, P_nombre + ' '+ P_apellido As nombre FROM empleado where Cargo=1"
Dim Drs As New SqlDataAdapter(Sql, Conexion)
Dim Drt As DataTable = New DataTable("empleado")
Dim unused = Drs.Fill(Drt)
With CmbDocEmp
Dim unused1 = .Items.Add("")
.DataSource = Drt
.DisplayMember = "nombre"
.ValueMember = "id_empleado"
.SelectedIndex = -1
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub LlenarcomboEmpleado2()
Enlace()
Try
Dim Sql7 As String = "SELECT Id_empleado, P_nombre + ' '+ P_apellido As nombre FROM empleado where Cargo=1"
Dim Drs2 As New SqlDataAdapter(Sql7, Conexion)
Dim Drt2 As DataTable = New DataTable("empleado")
Dim unused = Drs2.Fill(Drt2)
With CbEmpleLav
Dim unused1 = .Items.Add("")
.DataSource = Drt2
.DisplayMember = "nombre"
.ValueMember = "id_empleado"
.SelectedIndex = -1
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With
Catch ex As Exception
Dim unused2 = MessageBox.Show(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub LlenarcomboEmpleadoMeca()
Enlace()
Try
Dim Sql As String = "SELECT Id_empleado, P_nombre + ' '+ P_apellido As nombre FROM empleado where Cargo=2"
Dim Drs As New SqlDataAdapter(Sql, Conexion)
Dim Drt As DataTable = New DataTable("empleado")
Dim unused = Drs.Fill(Drt)
With CmbMecanico
Dim unused1 = .Items.Add("")
.DataSource = Drt
.DisplayMember = "nombre"
.ValueMember = "id_empleado"
.SelectedIndex = -1
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With
Catch ex As Exception
Dim unused2 = MessageBox.Show(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub LlenarcomboEmpleadoMeca2()
Enlace()
Try
Dim Sql8 As String = "SELECT Id_empleado, P_nombre + ' '+ P_apellido As nombre FROM empleado where Cargo=2"
Dim Drs3 As New SqlDataAdapter(Sql8, Conexion)
Dim Drt3 As DataTable = New DataTable("empleado")
Dim unused = Drs3.Fill(Drt3)
With CBEmplAce
Dim unused1 = .Items.Add("")
.DataSource = Drt3
.DisplayMember = "nombre"
.ValueMember = "id_empleado"
.SelectedIndex = -1
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With
Catch ex As Exception
Dim unused2 = MessageBox.Show(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub Vehiculoexiste()
Enlace()
Dim AUX2 As Integer
Try
Comando = New SqlCommand("select Marca,Propietario,TV.Descripcion ,Observacion from VEHICULO V
inner join TipoVehiculo TV
on tv.Id_Tvehiculo=V.Id_Tipo_Vehiculo where placa='" & TxtPlaca.Text.ToUpper & "'", Conexion)
respuesta = Comando.ExecuteReader
'If respuesta = Comando.ExecuteReader Then
While respuesta.Read
TxtMarca.Text = respuesta.Item("Marca")
TxtPropietario.Text = respuesta.Item("Propietario")
TxtObservación.Text = respuesta.Item("Observacion")
TxtTipoVehiculo.Text = respuesta.Item("descripcion")
AUX2 = 1
End While
CMB_TVehiculo.Visible = False
TxtTipoVehiculo.Visible = True
respuesta.Close()
'Else
If AUX2 <> 1 Then
TxtMarca.Text = ""
TxtPropietario.Text = ""
TxtTipoVehiculo.Visible = False
CMB_TVehiculo.Visible = True
CMB_TVehiculo.Items.Clear()
Llenarcombox(CMB_TVehiculo)
End If
'Llenarcombox(CMB_TVehiculo)
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub TxtPlaca_LostFocus(sender As Object, e As EventArgs) Handles TxtPlaca.LostFocus
Vehiculoexiste()
End Sub
Private Sub TxtTipoVehiculo_LostFocus(sender As Object, e As EventArgs) Handles TxtTipoVehiculo.LostFocus
Enlace()
Comando = New SqlCommand(V & TxtTipoVehiculo.Text & "'", Conexion)
respuesta = Comando.ExecuteReader
While respuesta.Read
IDTVEHICULO = respuesta.Item("Id_tVehiculo")
End While
Conexion.Close()
Estado = "Desconectado"
respuesta.Close()
DGVPrecios.DataSource = Llenardgv()
End Sub
Sub Botonservicio()
'If Val(TxtAuto.Text) = 0 And Val(TxtMCarro.Text) = 0 And Val(TxtMoto.Text) = 0 And Val(TxtCami.Text) = 0 Then
If EstadoServicioVehiculo = "" Then
BtnModificar.Enabled = False
BtnCancelar.Enabled = False
BtnFinalizar.Enabled = False
ElseIf EstadoServicioVehiculo = "Finalizado" Then
BtnModificar.Enabled = False
BtnCancelar.Enabled = False
BtnFinalizar.Enabled = False
ElseIf EstadoServicioVehiculo = "Pendiente" Then
BtnModificar.Enabled = True
BtnCancelar.Enabled = True
BtnFinalizar.Enabled = True
ElseIf DGVVehiculos.Rows.Count = 0 Then
BtnModificar.Enabled = False
BtnCancelar.Enabled = False
BtnFinalizar.Enabled = False
End If
End Sub
Private Sub DGVVehiculos_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGVVehiculos.CellContentClick
temp = DGVVehiculos.CurrentRow.Cells.Item(3).Value
Turn = DGVVehiculos.CurrentRow.Cells.Item(0).Value
EstadoServicio()
Botonservicio()
DGVLavador.DataSource = LlenarDGVEmp()
DGVMecanico.DataSource = LlenarDGVEmpMec()
'If (DGVServicios.Row.Cells["Lavada"].Value Is DbNull.Value)
DGVServicios.DataSource = LlenarDGVServicios()
DGVSAceite.DataSource = LlenarDGVServiciosAceite()
'End If
DGVServicios.Columns("Grafitado").DefaultCellStyle.Format = "C2"
DGVServicios.Columns("Lavada").DefaultCellStyle.Format = "C2"
DGVServicios.Columns("Brillado").DefaultCellStyle.Format = "C2"
DGVSAceite.Columns("Costo").DefaultCellStyle.Format = "C2"
'DGVServicios.Columns("Grafidato").DefaultCellStyle.Format = "C2"
DGVServicios.Columns("Motor").DefaultCellStyle.Format = "C2"
DGVServicios.Columns("Full").DefaultCellStyle.Format = "C2"
End Sub
Private Sub CBLavada_CheckedChanged(sender As Object, e As EventArgs) Handles CBLavada.CheckedChanged
CBLavada.Checked = True
End Sub
Private Sub CBBrillada_CheckedChanged(sender As Object, e As EventArgs) Handles CBBrillada.CheckedChanged
Bloquear()
End Sub
Private Sub CBGrafitada_CheckedChanged(sender As Object, e As EventArgs) Handles CBGrafitada.CheckedChanged
Bloquear()
End Sub
Private Sub CBMotor_CheckedChanged(sender As Object, e As EventArgs) Handles CBMotor.CheckedChanged
Bloquear()
End Sub
Private Sub CBFull_CheckedChanged(sender As Object, e As EventArgs) Handles CBFull.CheckedChanged
Bloquear()
End Sub
Private Sub CBCambioAceite_CheckedChanged(sender As Object, e As EventArgs) Handles CBCambioAceite.CheckedChanged
Bloquear()
End Sub
Private Sub TxtPlaca_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtPlaca.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
Private Sub TxtMarca_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtMarca.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
Private Sub TxtObservación_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtObservación.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
Private Sub TxtPropietario_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtPropietario.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
Private Sub TxtDetallelavada_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TxtDetallelavada.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub
Sub Pruebatext()
Enlace()
Try
Dim Sql, Sql2, Sql3, Sql4, Sql5 As String
Sql = "select count(id_tturno) as N_Polizas from turnovehiculo TV
inner join turno T
on t.id_turno= tv.id_tturno
inner join vehiculo V
on v.id_vehiculo=tv.id_vehiculo
where cast(t.fecha as date)='" & Fechacorta2 & "' and v.id_tipo_vehiculo=1 and t.estado='Finalizado'"
Dim consulta As New SqlDataAdapter(Sql, Conexion)
consulta.SelectCommand.CommandType = CommandType.Text
Dim tabla As New DataTable ' Creamos una tabla en memoria ram
consulta.Fill(tabla) 'èl resultado del Select lo llenamos en la tabla
TxtMoto.Text = tabla.Rows(0).Item(0)
Sql2 = "select count(id_tturno) as N_Polizas from turnovehiculo TV
inner join turno T
on t.id_turno= tv.id_tturno
inner join vehiculo V
on v.id_vehiculo=tv.id_vehiculo
where cast(t.fecha as date)='" & Fechacorta2 & "' and v.id_tipo_vehiculo=2 and t.estado='Finalizado'"
Dim consulta2 As New SqlDataAdapter(Sql2, Conexion)
consulta2.SelectCommand.CommandType = CommandType.Text
Dim tabla2 As New DataTable ' Creamos una tabla en memoria ram
consulta2.Fill(tabla2) 'èl resultado del Select lo llenamos en la tabla
TxtMCarro.Text = tabla2.Rows(0).Item(0)
Sql3 = "select count(id_tturno) as N_Polizas from turnovehiculo TV
inner join turno T
on t.id_turno= tv.id_tturno
inner join vehiculo V
on v.id_vehiculo=tv.id_vehiculo
where cast(t.fecha as date)='" & Fechacorta2 & "' and v.id_tipo_vehiculo=3 and t.estado='Finalizado'"
Dim consulta3 As New SqlDataAdapter(Sql3, Conexion)
consulta3.SelectCommand.CommandType = CommandType.Text
Dim tabla3 As New DataTable ' Creamos una tabla en memoria ram
consulta3.Fill(tabla3) 'èl resultado del Select lo llenamos en la tabla
TxtAuto.Text = tabla3.Rows(0).Item(0)
Sql4 = "select count(id_tturno) as N_Polizas from turnovehiculo TV
inner join turno T
on t.id_turno= tv.id_tturno
inner join vehiculo V
on v.id_vehiculo=tv.id_vehiculo
where cast(t.fecha as date)='" & Fechacorta2 & "' and v.id_tipo_vehiculo=4 and t.estado='Finalizado'"
Dim consulta4 As New SqlDataAdapter(Sql4, Conexion)
consulta4.SelectCommand.CommandType = CommandType.Text
Dim tabla4 As New DataTable ' Creamos una tabla en memoria ram
consulta4.Fill(tabla4) 'èl resultado del Select lo llenamos en la tabla
TxtCami.Text = tabla4.Rows(0).Item(0)
Sql5 = "select count(id_tturno) as N_Polizas from turnovehiculo TV
inner join turno T
on t.id_turno= tv.id_tturno
inner join vehiculo V
on v.id_vehiculo=tv.id_vehiculo
where cast(t.fecha as date)='" & Fechacorta2 & "' and t.estado='Finalizado' "
Dim consulta5 As New SqlDataAdapter(Sql5, Conexion)
consulta5.SelectCommand.CommandType = CommandType.Text
Dim tabla5 As New DataTable
consulta5.Fill(tabla5)
TxtTotalVehiculos.Text = tabla5.Rows(0).Item(0)
'---------------------------------------------------------------------------------
TxtEstado.Enabled = False
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Sub EstadoServicio()
Enlace()
Try
Dim Sql6 As String
Sql6 = "select estado from TURNO T
inner join TURNOVEHICULO tv
on tv.Id_TTurno=t.Id_Turno
inner join VEHICULO v
on v.Id_Vehiculo=tv.Id_Vehiculo
where v.Placa='" & temp & "' and cast(t.fecha as date) ='" & Fechacorta2 & "' and T.Id_Turno='" & Turn & "' "
Dim consulta6 As New SqlDataAdapter(Sql6, Conexion)
consulta6.SelectCommand.CommandType = CommandType.Text
Dim tabla6 As New DataTable
consulta6.Fill(tabla6)
TxtEstado.Text = tabla6.Rows(0).Item(0)
EstadoServicioVehiculo = TxtEstado.Text
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub TxtLavada_Load(sender As Object, e As EventArgs)
End Sub
Private Sub TabLavador_Click(sender As Object, e As EventArgs) Handles TabLavador.Click
CBEmplAce.Text = ""
End Sub
Private Sub VentasDia()
Enlace()
Try
If Val(TxtMoto.Text) > 0 Or Val(TxtMCarro.Text) > 0 Or Val(TxtAuto.Text) > 0 Or Val(TxtCami.Text) > 0 Then
Dim Sql As String
Sql = "select Sum(total) from(
select sum(coalesce(costo,0)) as total from DETALLESERVICIOACE dsa
inner join EmpleadoAceite ea
on ea.Id_ServicioAce=dsa.Id_Servicio
inner join VEHICULO v
on v.Id_Vehiculo=ea.Id_Vehiculo
where cast(dsa.fecha as date)='" & Fechacorta2 & "' and dsa.estado='Finalizado'
union
select sum(coalesce(lavada,0)+coalesce(brillado,0)+coalesce(Grafitado,0)+coalesce(Motor,0)+coalesce([full],0)) as total from DETALLESERVICIOLAV DS
INNER JOIN TURNOVEHICULO TV
ON TV.Id_ServicioLav=DS.Id_Servicio
INNER JOIN TURNO T
ON T.Id_Turno=TV.Id_TTurno
inner join VEHICULO v
on v.Id_Vehiculo=tv.Id_Vehiculo
where CAST(T.Fecha AS DATE)='" & Fechacorta2 & "' and t.estado='Finalizado')total"
Dim Consulta As New SqlDataAdapter(Sql, Conexion)
Consulta.SelectCommand.CommandType = CommandType.Text
Dim Tabla As New DataTable
Consulta.Fill(Tabla)
TxtVentaDia.Text = Tabla.Rows(0).Item(0)
'Dim Num As Double = Val(TxtVentaDia.Text)
TxtVentaDia.Text = FormatCurrency(TxtVentaDia.Text)
'TxtTotalVehiculos.Text = Val(TxtMoto.Text) + Val(TxtMCarro.Text) + Val(TxtAuto.Text) + Val(TxtCami.Text)
Else
TxtVentaDia.Text = 0
TxtVentaDia.Text = FormatCurrency(TxtVentaDia.Text)
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
Conexion.Close()
Estado = "Desconectado"
End Try
End Sub
Private Sub CbEmpleLav_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CbEmpleLav.SelectedIndexChanged
Try
Id_Empleadolav = CInt(CbEmpleLav.SelectedValue)
DGVVehiculoslav.DataSource = LlenarDGVvehiculoslav()
Catch ex As Exception
End Try
End Sub
Private Sub TabMecanico_Click(sender As Object, e As EventArgs) Handles TabMecanico.Click
CbEmpleLav.Text = ""
End Sub
Private Sub CBEmplAce_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBEmplAce.SelectedIndexChanged
Try
Id_Empleadolav = CInt(CBEmplAce.SelectedValue)
DGvVeCA.DataSource = LlenarDGVvehiculosace()
Catch ex As Exception
End Try
End Sub
Private Sub BtnFinalizar_Click(sender As Object, e As EventArgs) Handles BtnFinalizar.Click
Dim Resp = MsgBox("Seguro que desea finalizar este servicio", vbYesNo, "Finalizar turno")
If Resp = vbYes Then
Try
#Disable Warning IDE0068 ' Usar el patrón de Dispose recomendado
Dim Fun As New Procedimientos
#Enable Warning IDE0068 ' Usar el patrón de Dispose recomendado
EstadoSer = "Finalizado"
Reg.Estado = EstadoSer
Reg.Placa = temp
Reg.Fecha = Fechacorta2
Reg.Turno = Turn
If Fun.ActualizarEstado(Reg) Then
MsgBox("Servicio Finalizado correctamente", vbInformation)
MostrarVehiculos()
EstadoServicio()
Pruebatext()
VentasDia()
Botonservicio()
End If
Catch ex As Exception
Finally
End Try
Else
EstadoSer = "Pendiente"
End If
End Sub
Private Sub BtnModificar_Click(sender As Object, e As EventArgs) Handles BtnModificar.Click
ActualizarServicio.Show()
End Sub
Private Sub TCEmpleados_Click(sender As Object, e As EventArgs) Handles TCEmpleados.Click
If TCEmpleados.SelectedTab Is TabLavador Then
CBEmplAce.Text = ""
DGvVeCA.DataSource = ""
Id_Empleadolav = 0
Try
DGVVehiculoslav.DataSource = LlenarDGVvehiculoslav()
Catch ex As Exception
End Try
Else
CbEmpleLav.Text = ""
DGVVehiculoslav.DataSource = ""
Id_Empleadolav = 0
Try
DGvVeCA.DataSource = LlenarDGVvehiculosace()
Catch ex As Exception
End Try
End If
End Sub
Private Sub TxtTipoVehiculo_TextChanged(sender As Object, e As EventArgs) Handles TxtTipoVehiculo.TextChanged
End Sub
Private Sub TxtLavada_Load_1(sender As Object, e As EventArgs) Handles TxtLavada.Load
End Sub
End Class