ACTUALIZAR CONTADOR EN BASE DE DATOS!
Publicado por Juan Antonio (36 intervenciones) el 13/02/2020 13:31:15
Hola amigos, tengo la siguiente codificacion:
QUISIERA SABER COMO PUEDO HACER QUE EL CONTADOR EN LA CAJA DE TEXTO ACEPTADOS SE ACTUALIZE CADA VEZ QUE SE INSERTE UN REGISTRO....
PARA QUE QUEDE MAS O MENOS ASI....
TENGO UN FORMULARIO QUE SOLO MANEJA ESTAS CAJAS DE TEXTO:
CODIGO, STATUS, NIVEL, ACEPTADOS Y RECHAZADOS!
ADJUNTO MI PROYECTO AQUI
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
Imports System.Data.OleDb
Public Class Form1
Sub limpiar()
txtCodigo.Clear()
txtCodigo.Focus()
txtstatus.SelectedIndex = -1
txtNIvel.Text = ""
End Sub
Sub llenar_datagrid()
Dim adaptador As New OleDbDataAdapter
Dim registros As New DataSet
Dim consulta As String
consulta = "Select * From AQL"
adaptador = New OleDbDataAdapter(consulta, conexion)
registros.Tables.Add("AQL")
adaptador.Fill(registros.Tables("AQL"))
DataGridView1.DataSource = registros.Tables("AQL")
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
End Sub
Private Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
conectarBD()
conexion.Open()
Try
Module1.consulta = New OleDb.OleDbCommand("insert into AQL (codigo, nivel, status, aceptados, rechazados)" &
"values(txtcodigo, txtnivel, txtstatus, txtaceptados, txtrechazados)", conexion)
Module1.consulta.Parameters.AddWithValue("@codigo", txtCodigo.Text)
Module1.consulta.Parameters.AddWithValue("@nivel", txtNIvel.Text)
Module1.consulta.Parameters.AddWithValue("@status", txtstatus.Text)
Module1.consulta.Parameters.AddWithValue("@aceptados", txtaceptados.Text)
Module1.consulta.Parameters.AddWithValue("@rechazados", txtrechazados.Text)
Module1.consulta.ExecuteNonQuery()
limpiar()
llenar_datagrid()
conexion.Close()
Catch ex As Exception
MessageBox.Show("Error : " + ex.Message + "", "Mensaje...", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
conectarBD()
llenar_datagrid()
End Sub
Private Sub txtstatus_TextChanged(sender As Object, e As EventArgs) Handles txtstatus.TextChanged
Dim CounterAcepted As Integer = 0
Dim CounterRechaced As Integer = 0
If txtstatus.Text = "Aceptado" Then
CounterAcepted += 1
txtaceptados.Text = CounterAcepted
CounterRechaced = 0
txtrechazados.Text = CounterRechaced
If CounterAcepted = 10 Then
txtNIvel.Text = "Reducido"
ElseIf CounterAcepted < 10 Then
txtNIvel.Text = "Normal"
End If
End If
End Sub
Sub existe_codigo()
Try
Using conn As New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;Data Source=BD.mdb")
Dim query As String = "select * from AQL where codigo = '" & txtCodigo.Text & "'"
Dim lector As OleDbDataReader
Dim cmd As New OleDbCommand(query, conn)
conn.Open()
lector = cmd.ExecuteReader()
If lector.Read() = False Then
txtInfoSys.Text = "Codigo no registrado, AQL Normal..."
Else
txtInfoSys.Text = "El codigo ya cuenta con un nivel de inspeccion..."
End If
End Using
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub txtCodigo_TextChanged(sender As Object, e As EventArgs) Handles txtCodigo.TextChanged
existe_codigo()
If txtCodigo.Text = "" Then
txtInfoSys.Text = "\\\\\ ----- << Sistema de prueba >> ----- ////"
End If
End Sub
End Class
QUISIERA SABER COMO PUEDO HACER QUE EL CONTADOR EN LA CAJA DE TEXTO ACEPTADOS SE ACTUALIZE CADA VEZ QUE SE INSERTE UN REGISTRO....
PARA QUE QUEDE MAS O MENOS ASI....
1
2
3
4
5
6
7
8
CODIGO NIVEL STATUS ACEPTADOS RECHAZADOS
1 NORMAL ACEPTADO 1 0
1 NORMAL ACEPTADO 2 0
1 NORMAL RECHAZADO 0 1
1 NORMAL RECHAZADO 0 2
1 NORMAL ACEPTADO 1 0
1 NORMAL ACEPTADO 2 0
1 NORMAL ACEPTADO 3 0
TENGO UN FORMULARIO QUE SOLO MANEJA ESTAS CAJAS DE TEXTO:
CODIGO, STATUS, NIVEL, ACEPTADOS Y RECHAZADOS!
ADJUNTO MI PROYECTO AQUI
- PRUEBADOS.7z(156,9 KB)
Valora esta pregunta


0