Visual Basic.NET - Ejecutar un procedimiento desde visual

 
Vista:
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 13/04/2020 18:48:38
buenos dias, estoy teniendo un inconveniente con un programa que estoy haciendo en visual studio, cuando ejecuto el formulario por primera vez registra los datos correctamente en la base de datos a traves de un procedimiento, pero al darle ingresar otro registro hace el procedimiento mas no lo ingresa en la base de datos si alguien me puede colaborar gracias, utilizo dos claces una con las funciones de llamado del procedimiento y otra de propiedades
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 13/04/2020 21:03:42
Hola,
Envias el codigo (el procedimiento completo) que registra los datos.
:)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 13/04/2020 21:10:29
Este es el codigo del formulario
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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

y este es donde llamo el procedimiento

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Public Function CrearTurnoTU(ByVal data As Propiedad) As Boolean
    Try
 
        Cn1.Open()
        Cmd = New SqlCommand("SP_IngresarTurnoServicioTU", Cn1) With {
            .CommandType = CommandType.StoredProcedure
        }
 
 
        With Cmd.Parameters
            .AddWithValue("@Fecha", data.FechaT)
            .AddWithValue("@Idmpleado", data.Idmpleado)
            .AddWithValue("@IdVehiculo", data.IdVehiculo)
            .AddWithValue("@Descripcion", data.Descripcion)
            .AddWithValue("@Frecuencia", data.Frecuencia)
            .AddWithValue("@IdEmpleadoAce", data.IdEmpleadoAce)
            .AddWithValue("@PCambio", data.Pcambio)
            .AddWithValue("@Costo", data.Costo)
            .AddWithValue("@Lavada", data.Lavada)
            .AddWithValue("@Brillada", data.Brillada)
            .AddWithValue("@Grafitada", data.Grafitada)
            .AddWithValue("@Motor", data.Motor)
            .AddWithValue("@Full", data.Full)
            .AddWithValue("@Observacion", data.Descripcion)
        End With
        If Cmd.ExecuteNonQuery() Then
            Return True
        Else
            Return False
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
        Cn1.Dispose()
        Cmd.Dispose()
        Return False
    Finally
        Cmd.Dispose()
        Cn1.Close()
 
    End Try
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 13/04/2020 22:31:57
Comprendo mal tu código, quizá demasió complexo ...

Veo más veces Dim Fun As New Procedimientos, pero veo un solo Fun.Dispose. Es nórmale ?
Quiza que este unico Fun.Dispose es ejecutado al primera vez y hace el error para la secunda vez ...
Además, Procedimientos es una palabra del programador, no una palabra reservada. Que es la definición de la clase Procedimientos ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 00:38:13
si tengo la clase Procedimientos donde implemento las funciones que llaman a los procedimientos realizados en la base de datos si quieres te anexo los tres archivo a ver que estoy haciendo mal, gracias por tu ayuda:
Clase Procedimientos:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
Imports System.Data
Imports System.Data.SqlClient
 
Public Class Procedimientos
    Implements IDisposable
 
#Region "IDisposable Support"
    Private disposedValue As Boolean ' Para detectar llamadas redundantes
 
    ' IDisposable
    Protected Overridable Sub Dispose(disposing As Boolean)
        If Not disposedValue Then
            If disposing Then
                ' TODO: elimine el estado administrado (objetos administrados).
            End If
 
            ' TODO: libere los recursos no administrados (objetos no administrados) y reemplace Finalize() a continuación.
            ' TODO: configure los campos grandes en nulos.
        End If
        disposedValue = True
    End Sub
 
    ' TODO: reemplace Finalize() solo si el anterior Dispose(disposing As Boolean) tiene código para liberar recursos no administrados.
    'Protected Overrides Sub Finalize()
    '    ' No cambie este código. Coloque el código de limpieza en el anterior Dispose(disposing As Boolean).
    '    Dispose(False)
    '    MyBase.Finalize()
    'End Sub
 
    ' Visual Basic agrega este código para implementar correctamente el patrón descartable.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' No cambie este código. Coloque el código de limpieza en el anterior Dispose(disposing As Boolean).
        Dispose(True)
        ' TODO: quite la marca de comentario de la siguiente línea si Finalize() se ha reemplazado antes.
        ' GC.SuppressFinalize(Me)
    End Sub
#End Region
    Public Cn1 As New SqlConnection("Data Source=torvicasus-pc;Initial Catalog=Lavadero;User ID=sa;Password=Yacona6315**")
    Public Cmd As New SqlCommand
    Public Function IngresarVehiculo(ByVal data As Propiedad) As Boolean
        Try
 
            Cn1.Open()
            Cmd = New SqlCommand("IngresarVehiculo", Cn1) With {
                .CommandType = CommandType.StoredProcedure
            }
 
 
            With Cmd.Parameters
                .AddWithValue("@Placa", data.Placa)
                .AddWithValue("@Marca", data.Marca)
                .AddWithValue("@Propietario", data.Propietario)
                .AddWithValue("@IdTVehiculo", data.IdTipoVehiculo)
                .AddWithValue("@Fecha", data.Fecha)
                .AddWithValue("@Observacion", data.Descripcion)
 
            End With
            If Cmd.ExecuteNonQuery() Then
                Return True
 
            Else
                Return False
 
            End If
 
        Catch ex As Exception
            MsgBox(ex.Message)
            Cn1.Dispose()
            Cmd.Dispose()
            Return False
        Finally
            Cmd.Dispose()
            Cn1.Close()
 
        End Try
 
    End Function
    Public Function ActualizarEstado(ByVal data As Propiedad) As Boolean
        Try
 
            Cn1.Open()
            Cmd = New SqlCommand("ActualizarEstado", Cn1) With {
                .CommandType = CommandType.StoredProcedure
            }
 
 
            With Cmd.Parameters
                .AddWithValue("@Placa", data.Placa)
                .AddWithValue("@Fecha", data.Fecha)
                .AddWithValue("@Estado", data.Estado)
                .AddWithValue("@Turn", data.Turno)
            End With
            If Cmd.ExecuteNonQuery() Then
                Return True
            Else
                Return False
            End If
 
        Catch ex As Exception
            MsgBox(ex.Message)
            Cn1.Dispose()
            Cmd.Dispose()
            Return False
        Finally
            Cmd.Dispose()
            Cn1.Close()
        End Try
 
    End Function
    Public Function CrearTurno(ByVal data As Propiedad) As Boolean
        Try
 
            Cn1.Open()
            Cmd = New SqlCommand("SP_IngresarTurno", Cn1) With {
                .CommandType = CommandType.StoredProcedure
            }
 
 
            With Cmd.Parameters
                .AddWithValue("@Fecha", data.FechaT)
                .AddWithValue("@Idmpleado", data.Idmpleado)
                .AddWithValue("@IdVehiculo", data.IdVehiculo)
                .AddWithValue("@Descripcion", data.Descripcion)
                .AddWithValue("@Lavada", data.Lavada)
                .AddWithValue("@Brillada", data.Brillada)
                .AddWithValue("@Grafitada", data.Grafitada)
                .AddWithValue("@Motor", data.Motor)
                .AddWithValue("@Full", data.Full)
                .AddWithValue("@Observacion", data.Descripcion)
            End With
            If Cmd.ExecuteNonQuery() Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            Cn1.Dispose()
            Cmd.Dispose()
            Return False
        Finally
            Cmd.Dispose()
            Cn1.Close()
 
        End Try
    End Function
 
    Public Function CrearTurnoAceite(ByVal data As Propiedad) As Boolean
        Try
 
            Cn1.Open()
            Cmd = New SqlCommand("SP_IngresarTurnoServicio", Cn1) With {
                .CommandType = CommandType.StoredProcedure
            }
 
 
            With Cmd.Parameters
                .AddWithValue("@Fecha", data.FechaT)
                .AddWithValue("@Idmpleado", data.Idmpleado)
                .AddWithValue("@IdVehiculo", data.IdVehiculo)
                .AddWithValue("@Descripcion", data.Descripcion)
                .AddWithValue("@Frecuencia", data.Frecuencia)
                .AddWithValue("@IdEmpleadoAce", data.IdEmpleadoAce)
                .AddWithValue("@PCambio", data.Pcambio)
                .AddWithValue("@Costo", data.Costo)
                .AddWithValue("@Lavada", data.Lavada)
                .AddWithValue("@Brillada", data.Brillada)
                .AddWithValue("@Grafitada", data.Grafitada)
                .AddWithValue("@Motor", data.Motor)
                .AddWithValue("@Full", data.Full)
                .AddWithValue("@Observacion", data.Descripcion)
            End With
            If Cmd.ExecuteNonQuery() Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            Cn1.Dispose()
            Cmd.Dispose()
            Return False
        Finally
            Cmd.Dispose()
            Cn1.Close()
 
        End Try
    End Function
    Public Function CrearTurnoTU(ByVal data As Propiedad) As Boolean
        Try
 
            Cn1.Open()
            Cmd = New SqlCommand("SP_IngresarTurnoServicioTU", Cn1) With {
                .CommandType = CommandType.StoredProcedure
            }
 
 
            With Cmd.Parameters
                .AddWithValue("@Fecha", data.FechaT)
                .AddWithValue("@Idmpleado", data.Idmpleado)
                .AddWithValue("@IdVehiculo", data.IdVehiculo)
                .AddWithValue("@Descripcion", data.Descripcion)
                .AddWithValue("@Frecuencia", data.Frecuencia)
                .AddWithValue("@IdEmpleadoAce", data.IdEmpleadoAce)
                .AddWithValue("@PCambio", data.Pcambio)
                .AddWithValue("@Costo", data.Costo)
                .AddWithValue("@Lavada", data.Lavada)
                .AddWithValue("@Brillada", data.Brillada)
                .AddWithValue("@Grafitada", data.Grafitada)
                .AddWithValue("@Motor", data.Motor)
                .AddWithValue("@Full", data.Full)
                .AddWithValue("@Observacion", data.Descripcion)
            End With
            If Cmd.ExecuteNonQuery() Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            Cn1.Dispose()
            Cmd.Dispose()
            Return False
        Finally
            Cmd.Dispose()
            Cn1.Close()
 
        End Try
    End Function
 
 
End Class
 
Clase propiedades
 
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
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

Pantallazo-formulario
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 03:38:18
si tengo la clase Procedimientos donde implemento las funciones que llaman a los procedimientos realizados en la base de datos si quieres te anexo los tres archivo a ver que estoy haciendo mal, gracias por tu ayuda:
Clase Procedimientos:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
Imports System.Data
Imports System.Data.SqlClient
 
Public Class Procedimientos
Implements IDisposable
 
#Region "IDisposable Support"
Private disposedValue As Boolean ' Para detectar llamadas redundantes
 
' IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not disposedValue Then
If disposing Then
' TODO: elimine el estado administrado (objetos administrados).
End If
 
' TODO: libere los recursos no administrados (objetos no administrados) y reemplace Finalize() a continuación.
' TODO: configure los campos grandes en nulos.
End If
disposedValue = True
End Sub
 
' TODO: reemplace Finalize() solo si el anterior Dispose(disposing As Boolean) tiene código para liberar recursos no administrados.
'Protected Overrides Sub Finalize()
' ' No cambie este código. Coloque el código de limpieza en el anterior Dispose(disposing As Boolean).
' Dispose(False)
' MyBase.Finalize()
'End Sub
 
' Visual Basic agrega este código para implementar correctamente el patrón descartable.
Public Sub Dispose() Implements IDisposable.Dispose
' No cambie este código. Coloque el código de limpieza en el anterior Dispose(disposing As Boolean).
Dispose(True)
' TODO: quite la marca de comentario de la siguiente línea si Finalize() se ha reemplazado antes.
' GC.SuppressFinalize(Me)
End Sub
#End Region
Public Cn1 As New SqlConnection("Data Source=torvicasus-pc;Initial Catalog=Lavadero;User ID=sa;Password=Yacona6315**")
Public Cmd As New SqlCommand
Public Function IngresarVehiculo(ByVal data As Propiedad) As Boolean
Try
 
Cn1.Open()
Cmd = New SqlCommand("IngresarVehiculo", Cn1) With {
.CommandType = CommandType.StoredProcedure
}
 
 
With Cmd.Parameters
.AddWithValue("@Placa", data.Placa)
.AddWithValue("@Marca", data.Marca)
.AddWithValue("@Propietario", data.Propietario)
.AddWithValue("@IdTVehiculo", data.IdTipoVehiculo)
.AddWithValue("@Fecha", data.Fecha)
.AddWithValue("@Observacion", data.Descripcion)
 
End With
If Cmd.ExecuteNonQuery() Then
Return True
 
Else
Return False
 
End If
 
Catch ex As Exception
MsgBox(ex.Message)
Cn1.Dispose()
Cmd.Dispose()
Return False
Finally
Cmd.Dispose()
Cn1.Close()
 
End Try
 
End Function
Public Function ActualizarEstado(ByVal data As Propiedad) As Boolean
Try
 
Cn1.Open()
Cmd = New SqlCommand("ActualizarEstado", Cn1) With {
.CommandType = CommandType.StoredProcedure
}
 
 
With Cmd.Parameters
.AddWithValue("@Placa", data.Placa)
.AddWithValue("@Fecha", data.Fecha)
.AddWithValue("@Estado", data.Estado)
.AddWithValue("@Turn", data.Turno)
End With
If Cmd.ExecuteNonQuery() Then
Return True
Else
Return False
End If
 
Catch ex As Exception
MsgBox(ex.Message)
Cn1.Dispose()
Cmd.Dispose()
Return False
Finally
Cmd.Dispose()
Cn1.Close()
End Try
 
End Function
Public Function CrearTurno(ByVal data As Propiedad) As Boolean
Try
 
Cn1.Open()
Cmd = New SqlCommand("SP_IngresarTurno", Cn1) With {
.CommandType = CommandType.StoredProcedure
}
 
 
With Cmd.Parameters
.AddWithValue("@Fecha", data.FechaT)
.AddWithValue("@Idmpleado", data.Idmpleado)
.AddWithValue("@IdVehiculo", data.IdVehiculo)
.AddWithValue("@Descripcion", data.Descripcion)
.AddWithValue("@Lavada", data.Lavada)
.AddWithValue("@Brillada", data.Brillada)
.AddWithValue("@Grafitada", data.Grafitada)
.AddWithValue("@Motor", data.Motor)
.AddWithValue("@Full", data.Full)
.AddWithValue("@Observacion", data.Descripcion)
End With
If Cmd.ExecuteNonQuery() Then
Return True
Else
Return False
End If
Catch ex As Exception
MsgBox(ex.Message)
Cn1.Dispose()
Cmd.Dispose()
Return False
Finally
Cmd.Dispose()
Cn1.Close()
 
End Try
End Function
 
Public Function CrearTurnoAceite(ByVal data As Propiedad) As Boolean
Try
 
Cn1.Open()
Cmd = New SqlCommand("SP_IngresarTurnoServicio", Cn1) With {
.CommandType = CommandType.StoredProcedure
}
 
 
With Cmd.Parameters
.AddWithValue("@Fecha", data.FechaT)
.AddWithValue("@Idmpleado", data.Idmpleado)
.AddWithValue("@IdVehiculo", data.IdVehiculo)
.AddWithValue("@Descripcion", data.Descripcion)
.AddWithValue("@Frecuencia", data.Frecuencia)
.AddWithValue("@IdEmpleadoAce", data.IdEmpleadoAce)
.AddWithValue("@PCambio", data.Pcambio)
.AddWithValue("@Costo", data.Costo)
.AddWithValue("@Lavada", data.Lavada)
.AddWithValue("@Brillada", data.Brillada)
.AddWithValue("@Grafitada", data.Grafitada)
.AddWithValue("@Motor", data.Motor)
.AddWithValue("@Full", data.Full)
.AddWithValue("@Observacion", data.Descripcion)
End With
If Cmd.ExecuteNonQuery() Then
Return True
Else
Return False
End If
Catch ex As Exception
MsgBox(ex.Message)
Cn1.Dispose()
Cmd.Dispose()
Return False
Finally
Cmd.Dispose()
Cn1.Close()
 
End Try
End Function
Public Function CrearTurnoTU(ByVal data As Propiedad) As Boolean
Try
 
Cn1.Open()
Cmd = New SqlCommand("SP_IngresarTurnoServicioTU", Cn1) With {
.CommandType = CommandType.StoredProcedure
}
 
 
With Cmd.Parameters
.AddWithValue("@Fecha", data.FechaT)
.AddWithValue("@Idmpleado", data.Idmpleado)
.AddWithValue("@IdVehiculo", data.IdVehiculo)
.AddWithValue("@Descripcion", data.Descripcion)
.AddWithValue("@Frecuencia", data.Frecuencia)
.AddWithValue("@IdEmpleadoAce", data.IdEmpleadoAce)
.AddWithValue("@PCambio", data.Pcambio)
.AddWithValue("@Costo", data.Costo)
.AddWithValue("@Lavada", data.Lavada)
.AddWithValue("@Brillada", data.Brillada)
.AddWithValue("@Grafitada", data.Grafitada)
.AddWithValue("@Motor", data.Motor)
.AddWithValue("@Full", data.Full)
.AddWithValue("@Observacion", data.Descripcion)
End With
If Cmd.ExecuteNonQuery() Then
Return True
Else
Return False
End If
Catch ex As Exception
MsgBox(ex.Message)
Cn1.Dispose()
Cmd.Dispose()
Return False
Finally
Cmd.Dispose()
Cn1.Close()
 
End Try
End Function
 
 
End Class

Clase propiedades

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
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
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 14/04/2020 08:52:56
Hola,

Comprendo mejor la organización de tu código.

Pero no puedo buscar problemas en 2000 líneas de código. Puedes me decir como este funciona bien al primera ejecución y que es el problema al segunda ejecución ? Que están los mensajes de los errores ?

Has verificar esta pregunta : " ... Veo más veces Dim Fun As New Procedimientos, pero veo un solo Fun.Dispose. Es nórmale ?
Quiza que este único Fun.Dispose es ejecutado al primera vez y hace el error para la segunda vez
... " ?

Puedes ejecutar paso a pasa (menú DEPURAR y <F10> o <F11>) para saber dónde viene la error ?

Que tenga un buen dia ...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 08:56:47
lo he hecho y de hecho ejecuta el procedimieto correctamente sin nigun error solo que mi datagrid ni la base de datos registran los datosme parece muy extraño porque he hecho el paso a paso y todo va bien a execto de que cundo es el segundo registro no lo hace de hecho diseñe otro aplicacion de cero y me pasa igual pero bueno mil gracias por tu ayuda voy a seguir mirando que puede ser
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 14/04/2020 09:15:58
Ahora, comprendo que no es la segunda ejecución que no funciona pero el INSERT en la DB del segundo registro que no funciona.

En este caso, puedes dar solamente los codigos que ejecuten la frase SQL "INSERT INTO ... " ?

Debo partir y vuelvo en 2 horas ...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 17:58:24
este es el procedimiento almacenado para registrar un nuevo servicio:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
ALTER proc [dbo].[SP_IngresarTurnoServicioTU](
	@Fecha datetime,
	@Idmpleado int ,
	@IdVehiculo int,
	@Descripcion varchar(1000)='',
	@Frecuencia char(3),
	@IdEmpleadoAce int,
	@PCambio datetime,
	@Costo money,
	@Lavada money,
	@Brillada money,
	@Grafitada money,
	@Motor money,
	@Full money,
	@Observacion varchar(1000)=''
	--@IdTServicio int
	)
as
set nocount on
	if not exists(select top 1 Id_Turno from TURNO where Fecha= @Fecha)
		begin
			insert into TURNO(Fecha,Estado,Descripcion)
			values(@Fecha,'Pendiente',@Descripcion)
 
			declare @auxIdTurno int
			set @auxIdTurno= @@IDENTITY
 
			if @IdEmpleadoAce>0
			begin
				insert into DETALLESERVICIOACE(Frecuencia,ProximoCambio,Costo,Fecha,Estado)
				values(@Frecuencia,@PCambio,@Costo,@Fecha,'Pendiente')
				declare @AuxAce int
				set @AuxAce=@@IDENTITY
 
				insert into EmpleadoAceite(id_ServicioAce,Id_Empleado, id_vehiculo,id_turno)
				values(@AuxAce,@IdEmpleadoAce,@IdVehiculo,@auxIdTurno)
			end
			insert into DETALLESERVICIOLAV(Lavada,Brillado,Grafitado,Motor,[Full],Observacion)
			values(@Lavada,@Brillada,@Grafitada,@Motor,@Full,@Observacion)
			declare @AuxLav int
			set @AuxLav=@@IDENTITY
 
 
			insert into TURNOVEHICULO (Id_TTurno,Id_Empleado,Id_Vehiculo,Id_ServicioLav)
			values(@auxIdTurno,@Idmpleado,@IdVehiculo,@AuxLav)
 
			print 'El Turno se creo correctamente'
			return
		end
	else
		begin
			print 'Ya existe este turno'
 
		end
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 14/04/2020 18:31:29
Hola,

Este muy difficile para mi de estimar tu código ...

Quiza puedes testar esta : Agregar código print 'Insert Nombre de la tabla' después cada Insert para verificar el detalle de la ejecución.

Me pregunto sobre el codigo if not exists(select top 1 Id_Turno from TURNO where Fecha= @Fecha), es que este significa que no existe dos registros con la misma fecha ? En este caso, no possible registrar segundo registro si misma fecha.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 18:34:14
te puedo enviar el escrip de la base de datos

si el "if no exists Es para validar que no haya otro turno con igual fecha
anexo una version en visual y el script de toda la base de datos

nuevamente gracias mi hermano por hacer todo lo posible para resolver esto
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 14/04/2020 19:15:47
Bien, miraré en la tarde o mañana ...
Tenemos 7 horas de distancia, este es la 7 de la tarde aquí
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Wilfredo Patricio Castillo
Val: 1.239
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Wilfredo Patricio Castillo (720 intervenciones) el 14/04/2020 19:47:04
Código demasiado sucio y muy malo, muchas líneas de código como para ponerse a buscar linea a linea y no teniendo el entorno difícilmente, se te podrá ayudar si no hay un problema en específico, o algún mensaje de error, esas mas de 2 mil líneas, tranquilamente se reducen a un 80% menos.

Saludos cordiales,
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
3
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 14/04/2020 19:51:05
Si gracias por tu aporte ahí anexé otro pos con la interfaz y el scrit de la base de datos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
-2
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 14/04/2020 12:30:37
Hola,

Veo tu código y comprendo que el INSERT es hecho por el "SP_IngresarTurnoServicioTU", procedimiento registrado en la DB.
No puedo depurar sin la DB ...

Pero, me pregunto si todos parámetros en Function CrearTurnoTU están correctos. Este es en este lugar que tienes que buscar la origine del error. Notamente el identificador del registro …

Siento, no poder te ayudar ...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 15/04/2020 12:54:03
Hola,

No puedo crear bien la DB con los archivos que has enviado.
Puedes envias la DB, el archivo .MDF ?

Tengo un poco tiempo en la tarde ...

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 15/04/2020 17:48:05
Gracias. Miro ...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 15/04/2020 19:27:32
Demasió problemas con la seguridad.
Puedes envias la cadena de conexión que es escrito dans MySetting (o Parametros del proyecto) ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 15/04/2020 19:30:56
no tengo muy claro si te refieres a esto:

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="Lavadero.My.MySettings.Conexiondb2" connectionString="Data Source=torvicasus-pc;Initial Catalog=Lavadero;User ID=sa;Password=Yacona6315**"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
    </startup>
</configuration>
este es mi whatsapp es mucho mas rapido por aqui:
+57 3113919830
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 15/04/2020 21:39:40
No puedo abrir la DB. Error : Use 'sa' not autorized.
Debo parar hasta mañana ...
Quizá tienes un DB sin user Id, ni Password ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Phil Rob
Val: 3.353
Oro
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Phil Rob (1549 intervenciones) el 16/04/2020 11:09:28
Hola Victor,

He abierto tu DB y ejecuto tu programa.

No parece existir datos en la DB. Normale ?

Puedes dar me 2 juegos de datos para testar los registros?
Puedes enviar 2 fotos de pantallas con los datos :

SQL01
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Javier
Val: 150
Ha disminuido 1 puesto en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Javier (77 intervenciones) el 16/04/2020 21:12:02
La verdad que esta muy confuso tu codigo, unas dudas.

Primero, tiene un TextBox llamado TxtTipoVehiculo, el cual pones su propiedad Visible en false al cargar la vista, después cuando capturas la placa haces una consulta a la BD y si no existe cambias la propiedad Visible a true, pero después tienes una condición

1
If AUX2 <> 1 Then

la cual se cumple y por consiguiente cambias de nuevo la propiedad Visible a false, con esto al momento de dar en el botón Registrar validas si la propiedad de TxtTipoVehiculo es true, entonces al no cumplirse no llevas en tu variable Reg.IdTipoVehiculo un dato correcto por que nunca haces la consulta, por lo que entra en conflicto con tu BD.

Segundo, por que haces consulta a la BD con el texto de TxtTipoVehiculo para obtener el ID de tipo vehículo? esto lo puedes obtener si llenas correctamente tu combo CmbTipoVehiculos con el ValueMember y DisplayMember
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Victor Alfonso
Val: 31
Ha disminuido su posición en 3 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Ejecutar un procedimiento desde visual

Publicado por Victor Alfonso (12 intervenciones) el 16/04/2020 21:19:28
Lo qué pasa es que al ingresar la placa si el vehículo ya está en la base de datos el muestra en el TextBox el tipo de vehiculo si no he viste le permite a través de un combobox elegir el tipo de vehículo pero voy hacer lo que me dices del valué member y Display menber ya que hago otro procedimiento para obtener el uf del vehículo y así poder mandar el id a la base de datos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar