Código de Visual Basic.NET - Monitoreo de Impresiones

sin imagen de perfil
Val: 85
Ha disminuido su posición en 4 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Monitoreo de Impresionesgráfica de visualizaciones


Visual Basic.NET

Publicado el 9 de Junio del 2016 por Jose (2 códigos)
11.051 visualizaciones desde el 9 de Junio del 2016
Caratula
2
3


Este código permite monitorear una o varias impresoras conectadas en red, pausa, reanuda, cancela los trabajos de impresión enviados por los clientes.

Lleva un registro detallado de las impresiones enviadas e impresas por pc cliente y por impresora.

Registra el total de paginas enviadas, el total de paginas impresas y el numero de copias de cada pagina.

Requerimientos

PrinterQueueWatch.dll
Base de datos Access

1.0
estrellaestrellaestrellaestrellaestrella(7)

Publicado el 9 de Junio del 2016gráfica de visualizaciones de la versión: 1.0
11.052 visualizaciones desde el 9 de Junio del 2016
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
' Codigo para el FORM1 es el codigo para el monitoreo y configuracion
Imports System.Windows.Forms
Imports System.Printing
Imports System.Drawing.Printing
Imports PrinterQueueWatch
Imports System.Text
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim ruta As String = My.Application.Info.DirectoryPath
    'Dim PCNo As String = ""
    Public conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DatosImpresas.accdb;Persist Security Info=False")
    Public cmd As New OleDb.OleDbCommand
    Public sql As String = ""
    Private WithEvents pmon As New PrinterMonitorComponent
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        pmon.MonitorPrinterChangeEvent = False
        pmon.MonitorJobAddedEvent = True
        pmon.MonitorJobDeletedEvent = True
        pmon.MonitorJobSetEvent = False
        pmon.MonitorJobWrittenEvent = True
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn.Open()
        llenaimpresorasColBN()
        llenapausar()
        llenamonitorear()
        If MonitorearSiNo.CheckState = "0" Then
            pmon.Dispose()
        Else
            For Each p As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
                If (p) = nomonitorear1.Text Or (p) = nomonitorear2.Text Or (p) = nomonitorear3.Text Or (p) = nomonitorear4.Text Or (p) = nomonitorear5.Text Then
                    ImpresorasInstaladas.Items.Add(p).ToString()
                Else
                    pmon.AddPrinter(p)
                    Impresoras.Items.Add(p).ToString()
                End If
                ImpresorasInstaladas.Items.Add(p).ToString()
            Next p
        End If
    End Sub
    Private Sub cofigurar_monitor()
        llenapausar()
        llenamonitorear()
        ImpresorasInstaladas.Items.Clear()
        Impresoras.Items.Clear()
        If MonitorearSiNo.CheckState = "0" Then
            pmon.Dispose()
        Else
            For Each p As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
                If (p) = nomonitorear1.Text Or (p) = nomonitorear2.Text Or (p) = nomonitorear3.Text Or (p) = nomonitorear4.Text Or (p) = nomonitorear5.Text Then
                    ImpresorasInstaladas.Items.Add(p).ToString()
                Else
                    pmon.AddPrinter(p)
                    If pausarsino1.CheckState = "1" Then pmon.PrinterInformation(p).PauseAllNewJobs = True
                    If pausarsino1.CheckState = "0" Then pmon.PrinterInformation(p).PauseAllNewJobs = False
                    Impresoras.Items.Add(p).ToString()
                End If
                ImpresorasInstaladas.Items.Add(p).ToString()
            Next p
        End If
    End Sub
    Private Sub llenapausar()
        Dim dsp As New DataSet
        Dim dtp As New DataTable
        Try
            Dim strsqlp As String = "SELECT pausarimpresiones, nopausar1, nopausar2, nopausar3, nopausar4, nopausar5 FROM NOPAUSAR"
            Dim ADP As New OleDb.OleDbDataAdapter(strsqlp, conn)
            dsp.Tables.Add("TABLAPAUSAR")
            ADP.Fill(dsp.Tables("TABLAPAUSAR"))
            pausarsino1.CheckState = dsp.Tables(0).Rows(0)("pausarimpresiones").ToString()
            nopausar1.Text = dsp.Tables(0).Rows(0)("nopausar1").ToString()
            nopausar2.Text = dsp.Tables(0).Rows(0)("nopausar2").ToString()
            nopausar3.Text = dsp.Tables(0).Rows(0)("nopausar3").ToString()
            nopausar4.Text = dsp.Tables(0).Rows(0)("nopausar4").ToString()
            nopausar5.Text = dsp.Tables(0).Rows(0)("nopausar5").ToString()
        Catch ex As Exception
        End Try
    End Sub
    Private Sub llenamonitorear()
        Dim dsp As New DataSet
        Dim dtp As New DataTable
        Try
            Dim strsqlp As String = "SELECT monitorearimpresiones, nomonitorear1, nomonitorear2, nomonitorear3, nomonitorear4, nomonitorear5 FROM NOMONITOREAR"
            Dim ADP As New OleDb.OleDbDataAdapter(strsqlp, conn)
            dsp.Tables.Add("TABLAMONITOREAR")
            ADP.Fill(dsp.Tables("TABLAMONITOREAR"))
            MonitorearSiNo.CheckState = dsp.Tables(0).Rows(0)("monitorearimpresiones").ToString()
            nomonitorear1.Text = dsp.Tables(0).Rows(0)("nomonitorear1").ToString()
            nomonitorear2.Text = dsp.Tables(0).Rows(0)("nomonitorear2").ToString()
            nomonitorear3.Text = dsp.Tables(0).Rows(0)("nomonitorear3").ToString()
            nomonitorear4.Text = dsp.Tables(0).Rows(0)("nomonitorear4").ToString()
            nomonitorear5.Text = dsp.Tables(0).Rows(0)("nomonitorear5").ToString()
        Catch ex As Exception
        End Try
    End Sub
    Private Sub llenaimpresorasColBN()
        Dim dsp As New DataSet
        Dim dtp As New DataTable
        Try
            Dim strsqlp As String = "SELECT * from impresoras"
            Dim ADP As New OleDb.OleDbDataAdapter(strsqlp, conn)
            dsp.Tables.Add("tablaimpresoras")
            ADP.Fill(dsp.Tables("tablaimpresoras"))
            Teximpcol1.Text = dsp.Tables(0).Rows(0)("Color1").ToString()
            Teximpcol2.Text = dsp.Tables(0).Rows(0)("Color2").ToString()
            Teximpcol3.Text = dsp.Tables(0).Rows(0)("Color3").ToString()
            Teximpbn1.Text = dsp.Tables(0).Rows(0)("BN1").ToString()
            Teximpbn2.Text = dsp.Tables(0).Rows(0)("BN2").ToString()
            Teximpbn3.Text = dsp.Tables(0).Rows(0)("BN3").ToString()
        Catch ex As Exception
        End Try
    End Sub
    Private Sub pmon_JobAdded(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobAdded
        Dim posicion As Integer
        CheckForIllegalCrossThreadCalls = False
        Try
            With (CType(e, PrintJobEventArgs))
                posicion = joblist.Rows.Count
                With .PrintJob
                    If pausarsino1.CheckState = "1" Then
                        If (.MachineName).ToString = nopausar1.Text Or (.MachineName).ToString = nopausar2.Text Or (.MachineName).ToString = nopausar3.Text Or (.MachineName).ToString = nopausar4.Text Or (.MachineName).ToString = nopausar5.Text Then
                            'Shell("wmic printjob where jobid=" & .JobId & " resume")
                        Else
                            .Paused = True
                            Dim musica As System.Media.SoundPlayer
                            musica = New System.Media.SoundPlayer(ruta + "\Woop.wav")
                            musica.Play()
                        End If
                    End If
                    joblist.Rows.Add()
                    joblist.Rows(posicion).Cells("JobId").Value = (.JobId).ToString
                    joblist.Rows(posicion).Cells("Equipo").Value = (.MachineName.Replace("\\", "")).ToString
                    joblist.Rows(posicion).Cells("Impresora").Value = (.PrinterName).ToString
                    joblist.Rows(posicion).Cells("Estado").Value = (.StatusDescription).ToString
                    joblist.Rows(posicion).Cells("Documento").Value = (.Document).ToString
                    joblist.Rows(posicion).Cells("Fecha").Value = Now.Day.ToString.PadLeft(2, "0") & "/" & Now.Month.ToString.PadLeft(2, "0") & "/" & Now.Year.ToString.PadLeft(4, "0")
                    joblist.Rows(posicion).Cells("Hora").Value = Now.Hour.ToString.PadLeft(2, "0") & ":" & Now.Minute.ToString.PadLeft(2, "0") & ":" & Now.Second.ToString.PadLeft(2, "0")
                    joblist.Rows(posicion).Cells("TotalPaginas").Value = (.TotalPages).ToString
                    joblist.Rows(posicion).Cells("PaginasImpresas").Value = (.PagesPrinted).ToString
                    joblist.Rows(posicion).Cells("Copias").Value = (.Copies).ToString
                    If .PaperKind = PaperKind.Legal Then
                        joblist.Rows(posicion).Cells("Tamaño").Value = "Oficio"
                    Else
                        joblist.Rows(posicion).Cells("Tamaño").Value = "Carta"
                    End If
                End With
            End With
        Catch ex As Exception
        End Try
    End Sub
    Private Sub pmon_JobDeleted(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobDeleted
        Dim numfilas As Integer
        Dim fechai As String
        Dim horai As String
        Dim posicion As Integer = 0
        Dim total As Double = 0
        Dim agregado As Integer = 0
        Dim atexbox As String = ""
        Dim maqno As Integer = 0
        Dim dgvI As DataGridView
        CheckForIllegalCrossThreadCalls = False
        Try
            numfilas = joblist.RowCount 'cuenta las filas del DataGrid
            With CType(e, PrintJobEventArgs)
                With .PrintJob
                    For i = 0 To (numfilas - 1) 'recorre las filas del DataGrid
                        If .JobId = joblist.Rows(i).Cells("JobId").Value Then
                            joblist.Rows(i).Cells("Estado").Value = .StatusDescription.ToString
                            joblist.Rows(i).Cells("TotalPaginas").Value = .TotalPages.ToString
                            joblist.Rows(i).Cells("PaginasImpresas").Value = .PagesPrinted.ToString
                            fechai = Now.Day.ToString.PadLeft(2, "0") & "/" & Now.Month.ToString.PadLeft(2, "0") & "/" & Now.Year.ToString.PadLeft(4, "0")
                            horai = Now.Hour.ToString.PadLeft(2, "0") & ":" & Now.Minute.ToString.PadLeft(2, "0") & ":" & Now.Second.ToString.PadLeft(2, "0")
                            cmd.CommandType = CommandType.Text
                            cmd.Connection = conn
                            'PCNo = (.MachineName.Replace("\\", "")).ToString
                            sql = "INSERT INTO Impresiones (JobId, Equipo, Impresora, Estado, Documento, Fecha, Hora, Paginas, Impresas, Copias)"
                            sql += "VALUES ('" & .JobId & "','" & .MachineName.Replace("\\", "") & "','" & .PrinterName & "','" & .StatusDescription & "','" & .Document & "','" & fechai & "','" & horai & "','" & .TotalPages & "','" & .PagesPrinted & "','" & .Copies & "')"
                            cmd.CommandText = sql
                            cmd.ExecuteNonQuery()
                        End If
                    Next
                End With
            End With
        Catch ex As Exception
        End Try
    End Sub
    Private Sub pmon_JobWritten(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobWritten
        Dim numfilas As Integer
        CheckForIllegalCrossThreadCalls = False
        Try
            numfilas = joblist.RowCount 'cuenta las filas del DataGrid
            With CType(e, PrintJobEventArgs)
                With .PrintJob
                    For i = 0 To (numfilas - 1) 'recorre las filas del DataGrid
                        If .JobId = joblist.Rows(i).Cells("JobId").Value Then
                            joblist.Rows(i).Cells("Estado").Value = .StatusDescription.ToString
                            joblist.Rows(i).Cells("TotalPaginas").Value = .TotalPages.ToString
                            joblist.Rows(i).Cells("PaginasImpresas").Value = .PagesPrinted.ToString
                            joblist.Rows(i).Cells("Copias").Value = .Copies.ToString
                        End If
 
                    Next
                End With
            End With
        Catch ex As Exception
        End Try
    End Sub
    Private Sub btnreanudar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreanudar.Click
        Dim SERVIDOR As New System.Printing.PrintServer() 'SUPERIOR DEL SISTEMA DE IMPRESION (EL ORDENADOR)
        Dim IMPRESORAS As PrintQueueCollection = SERVIDOR.GetPrintQueues() 'IMPRESORAS DISPONIBLES
        For Each IMPRESORA As PrintQueue In IMPRESORAS 'RECORRE TODAS LAS IMPRESORAS
            Try
                If IMPRESORA.NumberOfJobs > 0 Then 'SI LA IMPRESORA TIENE ALGUNA IMPRESION EN MARCHA......
                    IMPRESORA.Refresh()
                    Dim IMPRESIONES As PrintJobInfoCollection = IMPRESORA.GetPrintJobInfoCollection() 'CREA UNA COLECCION DE IMPRESIONES EN MARCHA
                    For Each IMPRESION In IMPRESIONES ' POR CADA IMPRESION......
                        If IMPRESION.JobIdentifier = joblist.CurrentRow.Cells("JobId").Value Then
                            IMPRESION.Resume()
                            Exit Sub
                        End If
                    Next
                End If
            Catch ex As Exception
            End Try
        Next
    End Sub
    Private Sub btncancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancelar.Click
        Try
            Dim Respuesta As String = MsgBox("Desea cancelar La mpresion?, No podra recuperarla, Desea continuar?", vbYesNo + vbCritical, "Manager Printer")
            If Respuesta = vbYes Then   ' El usuario eligió el botón Sí.
                If joblist.CurrentRow.Cells("JobId").Value = "" Then
                    Exit Sub
                End If
                Dim SERVIDOR As New System.Printing.PrintServer() 'SUPERIOR DEL SISTEMA DE IMPRESION (EL ORDENADOR)
                Dim IMPRESORAS As PrintQueueCollection = SERVIDOR.GetPrintQueues() 'IMPRESORAS DISPONIBLES
                For Each IMPRESORA As PrintQueue In IMPRESORAS 'RECORRE TODAS LAS IMPRESORAS
                    If IMPRESORA.NumberOfJobs > 0 Then 'SI LA IMPRESORA TIENE ALGUNA IMPRESION EN MARCHA......
                        IMPRESORA.Refresh()
                        Dim IMPRESIONES As PrintJobInfoCollection = IMPRESORA.GetPrintJobInfoCollection() 'CREA UNA COLECCION DE IMPRESIONES EN MARCHA
                        For Each IMPRESION In IMPRESIONES ' POR CADA IMPRESION......
                            If IMPRESION.JobIdentifier = joblist.CurrentRow.Cells("JobId").Value Then
                                IMPRESION.Cancel()
                                joblist.Rows.RemoveAt(joblist.CurrentRow.Index)
                                Exit Sub
                            End If
                        Next
                    End If
                Next
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub joblist_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles joblist.CellFormatting
        Dim numfilas As Integer
        numfilas = joblist.RowCount
        For i = 0 To (numfilas - 1)
            If joblist.Item("Estado", joblist.Rows(i).Index).Value = "Paused" Then
                joblist.Rows(i).DefaultCellStyle.BackColor = Color.Red
                joblist.Rows(i).DefaultCellStyle.ForeColor = Color.White
            End If
            If joblist.Item("Estado", joblist.Rows(i).Index).Value = "Printed" Then
                joblist.Rows(i).DefaultCellStyle.BackColor = Color.ForestGreen
                joblist.Rows(i).DefaultCellStyle.ForeColor = Color.White
            End If
            If joblist.Item("Estado", joblist.Rows(i).Index).Value = "Printing" Then
                joblist.Rows(i).DefaultCellStyle.BackColor = Color.Yellow
                joblist.Rows(i).DefaultCellStyle.ForeColor = Color.Navy
            End If
        Next
    End Sub
    Private Sub BorrarImpresos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BorrarImpresos.Click
        Try
            If joblist.CurrentRow.Cells("Estado").Value = "Paused" Then
                'no hace nada
            Else
                joblist.Rows.RemoveAt(joblist.CurrentRow.Index)
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub ReanudarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReanudarToolStripMenuItem.Click
        Dim SERVIDOR As New System.Printing.PrintServer() 'SUPERIOR DEL SISTEMA DE IMPRESION (EL ORDENADOR)
        Dim IMPRESORAS As PrintQueueCollection = SERVIDOR.GetPrintQueues() 'IMPRESORAS DISPONIBLES
        For Each IMPRESORA As PrintQueue In IMPRESORAS 'RECORRE TODAS LAS IMPRESORAS
            Try
                If IMPRESORA.NumberOfJobs > 0 Then 'SI LA IMPRESORA TIENE ALGUNA IMPRESION EN MARCHA......
                    IMPRESORA.Refresh()
                    Dim IMPRESIONES As PrintJobInfoCollection = IMPRESORA.GetPrintJobInfoCollection() 'CREA UNA COLECCION DE IMPRESIONES EN MARCHA
                    For Each IMPRESION In IMPRESIONES ' POR CADA IMPRESION......
                        If IMPRESION.JobIdentifier = joblist.CurrentRow.Cells("JobId").Value Then
                            IMPRESION.Resume()
                            Exit Sub
                        End If
                    Next
                End If
            Catch ex As Exception
            End Try
        Next
    End Sub
    Private Sub CancelarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelarToolStripMenuItem.Click
        Try
            Dim Respuesta As String = MsgBox("Desea cancelar La mpresion?, No podra recuperarla, Desea continuar?", vbYesNo + vbCritical, "Manager Printer")
            If Respuesta = vbYes Then   ' El usuario eligió el botón Sí.
                If joblist.CurrentRow.Cells("JobId").Value = "" Then
                    Exit Sub
                End If
                Dim SERVIDOR As New System.Printing.PrintServer() 'SUPERIOR DEL SISTEMA DE IMPRESION (EL ORDENADOR)
                Dim IMPRESORAS As PrintQueueCollection = SERVIDOR.GetPrintQueues() 'IMPRESORAS DISPONIBLES
                For Each IMPRESORA As PrintQueue In IMPRESORAS 'RECORRE TODAS LAS IMPRESORAS
                    If IMPRESORA.NumberOfJobs > 0 Then 'SI LA IMPRESORA TIENE ALGUNA IMPRESION EN MARCHA......
                        IMPRESORA.Refresh()
                        Dim IMPRESIONES As PrintJobInfoCollection = IMPRESORA.GetPrintJobInfoCollection() 'CREA UNA COLECCION DE IMPRESIONES EN MARCHA
                        For Each IMPRESION In IMPRESIONES ' POR CADA IMPRESION......
                            If IMPRESION.JobIdentifier = joblist.CurrentRow.Cells("JobId").Value Then
                                IMPRESION.Cancel()
                                joblist.Rows.RemoveAt(joblist.CurrentRow.Index)
                                Exit Sub
                            End If
                        Next
                    End If
                Next
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub BorrarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BorrarToolStripMenuItem.Click
        Try
            If joblist.CurrentRow.Cells("Estado").Value = "Paused" Then
                'no hace nada
            Else
                joblist.Rows.RemoveAt(joblist.CurrentRow.Index)
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub ImpresionesToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Impresiones.Show()
    End Sub
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Impresiones.Show()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Try
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim idreg As Integer = 1
            sql = " UPDATE nopausar SET "
            sql += "pausarimpresiones = '" & pausarsino1.CheckState & "', "
            sql += "nopausar1 = '" & nopausar1.Text & "', "
            sql += "nopausar2 = '" & nopausar2.Text & "', "
            sql += "nopausar3 = '" & nopausar3.Text & "', "
            sql += "nopausar4 = '" & nopausar4.Text & "', "
            sql += "nopausar5 = '" & nopausar5.Text & "' "
            sql += "WHERE ID =" & idreg & " "
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            MsgBox("Datos actualizados correctamente")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Try
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim idreg As Integer = 1
            sql = " UPDATE nomonitorear SET "
            sql += "monitorearimpresiones = '" & MonitorearSiNo.CheckState & "', "
            sql += "nomonitorear1 = '" & nomonitorear1.Text & "', "
            sql += "nomonitorear2 = '" & nomonitorear2.Text & "', "
            sql += "nomonitorear3 = '" & nomonitorear3.Text & "', "
            sql += "nomonitorear4 = '" & nomonitorear4.Text & "', "
            sql += "nomonitorear5 = '" & nomonitorear5.Text & "' "
            sql += "WHERE ID =" & idreg & " "
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            MsgBox("Datos actualizados correctamente")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        cofigurar_monitor()
    End Sub
    Private Sub Guardarnp_Click_1(sender As Object, e As EventArgs) Handles Guardarnp.Click
        Try
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim idreg As Integer = 1
            sql = " UPDATE nopausar SET "
            sql += "pausarimpresiones = '" & pausarsino1.CheckState & "', "
            sql += "nopausar1 = '" & nopausar1.Text & "', "
            sql += "nopausar2 = '" & nopausar2.Text & "', "
            sql += "nopausar3 = '" & nopausar3.Text & "', "
            sql += "nopausar4 = '" & nopausar4.Text & "', "
            sql += "nopausar5 = '" & nopausar5.Text & "' "
            sql += "WHERE ID =" & idreg & " "
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            MsgBox("Datos actualizados correctamente")
        Catch ex As Exception
        End Try
        cofigurar_monitor()
    End Sub
    Private Sub guardarinm_Click_1(sender As Object, e As EventArgs) Handles guardarinm.Click
        Try
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim idreg As Integer = 1
            sql = " UPDATE nomonitorear SET "
            sql += "nomonitorear1 = '" & nomonitorear1.Text & "', "
            sql += "nomonitorear2 = '" & nomonitorear2.Text & "', "
            sql += "nomonitorear3 = '" & nomonitorear3.Text & "', "
            sql += "nomonitorear4 = '" & nomonitorear4.Text & "', "
            sql += "nomonitorear5 = '" & nomonitorear5.Text & "' "
            sql += "WHERE ID =" & idreg & " "
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            MsgBox("Datos actualizados correctamente")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        cofigurar_monitor()
    End Sub
    Private Sub guardaimpresoras_Click_1(sender As Object, e As EventArgs) Handles guardaimpresoras.Click
        Try
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim idreg As Integer = 1
            sql = " UPDATE impresoras SET "
            sql += "Color1 = '" & Teximpcol1.Text & "', "
            sql += "Color2 = '" & Teximpcol2.Text & "', "
            sql += "Color3 = '" & Teximpcol3.Text & "', "
            sql += "BN1 = '" & Teximpbn1.Text & "', "
            sql += "BN2 = '" & Teximpbn2.Text & "', "
            sql += "BN3 = '" & Teximpbn3.Text & "' "
            sql += "WHERE ID =" & idreg & " "
            cmd.CommandText = sql
            cmd.ExecuteNonQuery()
            MsgBox("Datos actualizados correctamente")
        Catch ex As Exception
        End Try
        llenaimpresorasColBN()
    End Sub
    Private Sub ReporteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ReporteToolStripMenuItem.Click
        Impresiones.Show()
    End Sub
    Private Sub Salir_Click(sender As Object, e As EventArgs) Handles Salir.Click
        End
    End Sub
End Class
 
'Codigo para el FORM Impresiones (es la consulta de las impresiones realizadas)
Public Class Impresiones
    Public conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DatosImpresas.accdb;Persist Security Info=False")
    Public cmd As New OleDb.OleDbCommand
    Public sql As String = ""
    Private Sub Impresiones_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FIR.Value = Now
        FFR.Value = Now
 
        llenagridi()
    End Sub
    Private Sub llenagridi()
        Dim ds As New DataSet
        Dim dt As New DataTable
        Dim posicion As Integer = 0
 
        Dim strsql As String = "SELECT Reg, Equipo, Impresora, Estado, Documento, Fecha, Hora, Paginas, Impresas, Copias FROM Impresiones WHERE Fecha >= #" & FIR.Value.Month & "/" & FIR.Value.Day & "/" & FIR.Value.Year & "# and Fecha <= #" & FFR.Value.Month & "/" & FFR.Value.Day & "/" & FFR.Value.Year & "#"
        Dim ADP As New OleDb.OleDbDataAdapter(strsql, conn)
        ds.Tables.Add("TABLAIMPRESIONES")
        ADP.Fill(ds.Tables("TABLAIMPRESIONES"))
        Me.FIR1.DataSource = ds.Tables("TABLAIMPRESIONES")
        'Sumar una Columna
        Dim Totali As Integer = 0
        Dim Col As Integer
        Col = 9
        For Each row As DataGridViewRow In Me.FIR1.Rows
            Totali = Totali + Val(row.Cells(Col).Value)
        Next
        Col = 8
        Dim totalp As Integer = 0
        For Each row As DataGridViewRow In Me.FIR1.Rows
            totalp = totalp + Val(row.Cells(Col).Value)
        Next
        Me.lbltotali.Text = Totali.ToString
        Me.lbtotalp.Text = totalp.ToString
        FIR1.Columns(0).Width = 3
        FIR1.Columns(1).Width = 98
        FIR1.Columns(2).Width = 78
        FIR1.Columns(3).Width = 78
        FIR1.Columns(4).Width = 350
        FIR1.Columns(5).Width = 68
        FIR1.Columns(6).Width = 68
        FIR1.Columns(7).Width = 63
        FIR1.Columns(8).Width = 63
        FIR1.Columns(9).Width = 63
        Col = 0
        FIR1.Sort(FIR1.Columns(0), System.ComponentModel.ListSortDirection.Descending)
    End Sub
 
    Private Sub btnactualizahisi_Click(sender As Object, e As EventArgs) Handles btnactualizahisi.Click
        llenagridi()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Me.Close()
    End Sub
 
    Private Sub btncancelar_Click(sender As Object, e As EventArgs) Handles btncancelar.Click
        Dim Mensaje As String = "Desea cancelar La mpresion?"   ' cuerpo del mensaje.
        Dim Estilo As String = vbYesNo + vbCritical   ' Define el estilo, los botones, lo que está después del mas es el circulo rojo con la cruz.
        Dim Título As String = "Manager Printer"   ' es el título.
        Dim Respuesta As String = MsgBox(Mensaje, Estilo, Título) 'el paréntesis se pone también
        If Respuesta = vbYes Then   ' El usuario eligió el botón Sí.
            cmd.CommandType = CommandType.Text
            cmd.Connection = conn
            Dim strsql As String = "delete * from Impresiones WHERE Fecha >= #" & FIR.Value.Month & "/" & FIR.Value.Day & "/" & FIR.Value.Year & "# and Fecha <= #" & FFR.Value.Month & "/" & FFR.Value.Day & "/" & FFR.Value.Year & "#"
            cmd.CommandText = strsql
            cmd.ExecuteNonQuery()
            lbtotalp.Text = "0"
            lbltotali.Text = "0"
            llenagridi()
        End If
    End Sub
End Class



Comentarios sobre la versión: 1.0 (7)

Imágen de perfil
10 de Junio del 2016
estrellaestrellaestrellaestrellaestrella
hola jose me parece interesante lo que hace el programa, pero no seria bueno que subas el sistema con tu base de datos para poder hacerle mejoras y resubirlo. gracias
Responder
13 de Junio del 2016
estrellaestrellaestrellaestrellaestrella
Ya subí todos los fuentes, incluyendo la base de datos y la dll, cualquier cambio o mejora que le hagas al sistema por favor lo subes y me avisas.

Este sistema es parte de un control de cyber que tengo completo.
Responder
13 de Junio del 2016
estrellaestrellaestrellaestrellaestrella
Este es el enlace.
http://www.lawebdelprogramador.com/codigo/Visual-Basic.NET/3552-Monitor-de-Impresiones.html
Responder
Ponchito
1 de Marzo del 2018
estrellaestrellaestrellaestrellaestrella
Dos errores, el primero al compilar: El proveedor "Microsoft.ACE.OLEDB.12.0" no está registrado en el equipo local(System.Data)

El cualse solucionó utilizando el conectador de bases de datos:

https://www.microsoft.com/en-us/download/details.aspx?id=23734

Luego el siguiente error:

Unrecognized database format 'C:\Users\XXXXXX\Documents\Visual Studio 2017\Projects\MonitorPQW\bin\Debug\DatosImpresas.accdb'.'

El cual se solucionó volviendo a guardar la base de datos dentro de la carpeta bin/debug a formato access 2002-2003 y renombrado su extensión a accdb.
Responder
jony marin
15 de Marzo del 2019
estrellaestrellaestrellaestrellaestrella
controla las impresoras compartidas en la red ?
Responder
Javier Arandia Mendoza
23 de Marzo del 2019
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder
25 de Noviembre del 2019
estrellaestrellaestrellaestrellaestrella
Gracias, por este gran aporte, tengo un cyber y echare andar este código, tambien quiero aplicar el control de tinta en cada impresiones, asi como el programa control de cyber cyberplanet o cyberadmin.

saludos y felicidades
Responder

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3551