Initial commit
This commit is contained in:
210
Form2.vb
Normal file
210
Form2.vb
Normal file
@@ -0,0 +1,210 @@
|
||||
|
||||
Imports System.Security.Cryptography
|
||||
Imports Microsoft.Data.SqlClient
|
||||
Imports System.Data.DataTable
|
||||
|
||||
|
||||
Public Class Form2
|
||||
'setari pentru server
|
||||
Dim DataString As String = My.Settings.subnet ' informatii cu privire la subnet
|
||||
Dim surce As String = My.Settings.serverName ' informatii preluate din system settings numele servarului
|
||||
Dim catalog As String = My.Settings.serverdatabase ' informatii din system setings cu privire la numele bazei de date
|
||||
Dim user As String = My.Settings.serverUser ' informatii din system setings cu privire la userul de introducere a datelor in baza de date
|
||||
Dim pass As String = My.Settings.serverUserpass ' informatii din system setings cu privire la parola userului
|
||||
Dim timeout As String = My.Settings.timeout ' informatii din system setings cu privire la server time out
|
||||
Dim encrypt As String = My.Settings.encrypt ' ' informatii din system setings cu privire la encriptie
|
||||
Dim trust As String = My.Settings.cert ' informatii din system setings cu privire la certificate
|
||||
Dim reason As String = My.Settings.reason
|
||||
Dim subnet As String = My.Settings.subnet
|
||||
Dim rowIdval As String ' gasirea randului din datagrid
|
||||
|
||||
Private Sub updateTable()
|
||||
' updateul tabelului din datagrid care se face dupa fiecare conexiune la server
|
||||
Dim con As New SqlConnection("Data Source=" & surce & "; Initial Catalog=" & catalog & "; User ID=" & user &
|
||||
"; Password=" & pass & "; Connect Timeout=" & timeout & "; Encrypt=" & encrypt &
|
||||
"; TrustServerCertificate=" & trust & "; ApplicationIntent=" & reason & "; MultiSubnetFailover=" & subnet & "")
|
||||
con.Open() ' deschiderea conexiuni cu serverul
|
||||
Dim command As New SqlCommand("select top 14 * from dbo.scanare order by id desc", con)
|
||||
Dim sda As New SqlDataAdapter(command) ' adaptorul pentru data grig view
|
||||
Dim dt As New DataTable ' pregatirea datelor pentru data grid view
|
||||
sda.Fill(dt) ' actualizarea data grid view
|
||||
DataGridView1.DataSource = dt
|
||||
con.Close() ' inchiderea conexiuneii cu serverul
|
||||
End Sub
|
||||
Private Sub UserForm2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
' text box1 incarcare valoare, set text box 2 pentru scan
|
||||
updateTable()
|
||||
TextBox1.Focus() ' setarea textbox 1 a defaul entry la deschiderea formei, se introduce cotul operatoruului de calitate
|
||||
End Sub
|
||||
Private Sub TextBox1_TextChangeed(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
|
||||
' validare text box 1 cu OQ
|
||||
' acest text box are o lungime a stringului de 4 caractere
|
||||
If TextBox1.Text.Length < 4 Then
|
||||
' caod de validare a criteriilor de Operator calitate OQ01 OQ02 OQ03 OQ04....
|
||||
ElseIf TextBox1.Text.Length = 4 Then
|
||||
Dim val As String
|
||||
val = TextBox1.Text
|
||||
If InStr(1, val, "OQ") > 0 Then
|
||||
TextBox2.Focus() ' schimbarea focusului pe textbox 2 daca este valida informatia din cod operator
|
||||
|
||||
Else
|
||||
MsgBox("Introdu cod Operator") ' cod de eroare in cazul introducerii codului gresit
|
||||
TextBox1.Focus() 'focus pe textbox 1
|
||||
End If
|
||||
Else
|
||||
|
||||
End If
|
||||
End Sub
|
||||
Private Sub TextBox2_TextChangeed(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
|
||||
' validare CP text box 2
|
||||
' acest text box are o lungime a stringului de 14 caractere
|
||||
If TextBox2.Text.Length < 14 Then
|
||||
' cod ce valideaza lungimea de 14 caractere a scanarii codului de bare
|
||||
' codul de bare are structura CP00000000-000
|
||||
ElseIf TextBox2.Text.Length = 14 Then
|
||||
Dim val As String
|
||||
val = TextBox2.Text
|
||||
If InStr(1, val, "CP") > 0 Then ' confirmare ca stringul contine CP focus pe textbox 3
|
||||
TextBox3.Focus()
|
||||
|
||||
Else
|
||||
MsgBox("Introdu CP Corect") ' rescanare articol
|
||||
TextBox2.Clear()
|
||||
TextBox2.Focus()
|
||||
End If
|
||||
Else
|
||||
End If
|
||||
End Sub
|
||||
Private Sub TextBox3_TextChangeed(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
|
||||
' validare oc text box 3
|
||||
' acest text box are o lungime a stringului de 4 caractere
|
||||
If TextBox3.Text.Length < 4 Then
|
||||
ElseIf TextBox3.Text.Length = 4 Then ' veificare a valorii OC pentru operator cusut
|
||||
Dim val As String
|
||||
val = TextBox3.Text
|
||||
If InStr(1, val, "OC") > 0 Then ' confirmare oc si mutare la text box 4
|
||||
TextBox4.Focus()
|
||||
|
||||
ElseIf InStr(1, val, "sp") > 0 Then
|
||||
TextBox4.Focus()
|
||||
ElseIf InStr(1, val, "SP") > 0 Then
|
||||
TextBox4.Focus()
|
||||
ElseIf InStr(1, val, "sn") > 0 Then
|
||||
TextBox4.Focus()
|
||||
ElseIf InStr(1, val, "SN") > 0 Then
|
||||
TextBox4.Focus()
|
||||
Else
|
||||
MsgBox("Introdu cod Operator")
|
||||
TextBox3.Clear()
|
||||
TextBox3.Focus()
|
||||
End If
|
||||
Else
|
||||
End If
|
||||
End Sub
|
||||
Private Sub TextBox4_TextChangeed(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
|
||||
' validare oc text box 4
|
||||
' acest text box are o lungime a stringului de 4 caractere
|
||||
If TextBox4.Text.Length < 4 Then
|
||||
ElseIf TextBox4.Text.Length = 4 Then
|
||||
Dim val As String
|
||||
val = TextBox4.Text
|
||||
If InStr(1, val, "OC") > 0 Then ' verificar oc 2
|
||||
TextBox5.Focus()
|
||||
Else
|
||||
MsgBox("Introdu cod Cusatoare Corect")
|
||||
TextBox4.Clear()
|
||||
TextBox4.Focus()
|
||||
End If
|
||||
Else
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Private Sub TextBox5_TextChangeed(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
|
||||
' validare Calitate text box5
|
||||
' acest text box are o lungime a stringului de 4 caractere
|
||||
If TextBox5.Text.Length < 4 Then
|
||||
ElseIf TextBox5.Text.Length = 4 Then ' verificare string ca e corect codul de defect
|
||||
Dim val As String
|
||||
val = TextBox5.Text
|
||||
If InStr(1, val, "Q") > 0 Then ' daca codul de defect e corect urmeaza incarcarea in baza de date
|
||||
Dim oq As String = TextBox1.Text 'string pentru SQL oq
|
||||
Dim cp As String = TextBox2.Text 'string pentru SQL cp
|
||||
Dim oc1 As String = TextBox3.Text 'string pentru SQL oc1
|
||||
Dim oc2 As String = TextBox4.Text 'string pentru SQL oc2
|
||||
Dim quality As String = TextBox4.Text 'string pentru SQL calitate
|
||||
Dim dta As String 'string pentru SQL data
|
||||
dta = Date.Now.ToString("yyyy.MM.dd") ' format string
|
||||
Label6.Text = dta 'Update in Label
|
||||
Dim dTime As String 'string pentru SQL time
|
||||
dTime = Date.Now.ToString("hh: mm") 'Format time
|
||||
Label7.Text = dTime ' update in label
|
||||
Dim cant As Integer 'cantitate 1 intodeauna
|
||||
cant = 1
|
||||
Dim con As New SqlConnection("Data Source=" & surce & "; Initial Catalog=" & catalog & "; User ID=" & user &
|
||||
"; Password=" & pass & "; Connect Timeout=" & timeout & "; Encrypt=" & encrypt &
|
||||
"; TrustServerCertificate=" & trust & "; ApplicationIntent=" & reason & "; MultiSubnetFailover=" & subnet & "")
|
||||
con.Open()
|
||||
Dim command As New SqlCommand("Insert into calitate.dbo.scanare values('" & TextBox2.Text & "','" & TextBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & dta & "','" & dTime & "','" & cant & "')", con)
|
||||
command.ExecuteNonQuery()
|
||||
con.Close()
|
||||
updateTable() ' update tabel in data grid view
|
||||
TextBox2.Clear() ' curatarea informatiilor scanate
|
||||
TextBox3.Clear()
|
||||
TextBox4.Clear()
|
||||
TextBox5.Clear()
|
||||
TextBox2.Focus()
|
||||
|
||||
Else
|
||||
MsgBox("Introdu cod Defect Corect") ' msg box in caz de croare la scanat textul din casuta cod defect
|
||||
TextBox5.Clear()
|
||||
TextBox5.Focus()
|
||||
End If
|
||||
Else
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' inchidere forma scanare articole
|
||||
' buton Inchide Formularul inchide forma de scanare relanseaza forma
|
||||
Form1.Show()
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
' stergere rand din datagrid
|
||||
|
||||
Dim result1 As DialogResult = MsgBox("Sigur Vrei sa strigi linia selectata ?", MsgBoxStyle.Information + MsgBoxStyle.YesNo,
|
||||
"Confirmare stergere Linie")
|
||||
' msg bog stergere
|
||||
If DialogResult.OK Then 'confirmare MsgBox
|
||||
' cod stergere din SQL
|
||||
If rowIdval >= 0 Then ' id row datagrid din sub datagrid
|
||||
Dim id As Integer = rowIdval
|
||||
Dim con As New SqlConnection("Data Source=" & surce & "; Initial Catalog=" & catalog & "; User ID=" & user &
|
||||
"; Password=" & pass & "; Connect Timeout=" & timeout & "; Encrypt=" & encrypt &
|
||||
"; TrustServerCertificate=" & trust & "; ApplicationIntent=" & reason & "; MultiSubnetFailover=" & subnet & "")
|
||||
con.Open()
|
||||
Dim command As New SqlCommand("Delete calitate.dbo.scanare where id = '" & id & "'", con)
|
||||
command.ExecuteNonQuery()
|
||||
con.Close()
|
||||
updateTable()
|
||||
MsgBox(" Linia a fost stearsa")
|
||||
TextBox2.Focus()
|
||||
End If
|
||||
Else
|
||||
MsgBox(" Ai anulat stergerea liniei")
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
|
||||
Dim selectRow As Integer = e.RowIndex ' gasirea indezului din datagrid
|
||||
If selectRow >= 0 Then 'gasirea id din randul selectat din datagrid
|
||||
Dim selectedCellValue As String = DataGridView1.Rows(selectRow).Cells("id").Value.ToString()
|
||||
rowIdval = selectedCellValue ' devinirea valorii lui rowIdVal pe baza selectarii din datagrid
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user