123 lines
5.6 KiB
VB.net
Executable File
123 lines
5.6 KiB
VB.net
Executable File
|
|
Imports System.Security.Cryptography
|
|
Imports Microsoft.Data.SqlClient
|
|
Imports System.Data.DataTable
|
|
|
|
|
|
Public Class Form12
|
|
'setari pentru server
|
|
Dim DataString As String = My.Settings.subnet
|
|
Dim surce As String = My.Settings.serverName
|
|
Dim catalog As String = My.Settings.serverdatabase
|
|
Dim user As String = My.Settings.serverUser
|
|
Dim pass As String = My.Settings.serverUserpass
|
|
Dim timeout As String = My.Settings.timeout
|
|
Dim encrypt As String = My.Settings.encrypt
|
|
Dim trust As String = My.Settings.cert
|
|
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()
|
|
Dim command As New SqlCommand("select top 14 * from dbo.cusut order by id desc", con)
|
|
Dim sda As New SqlDataAdapter(command)
|
|
Dim dt As New DataTable
|
|
sda.Fill(dt)
|
|
DataGridView1.DataSource = dt
|
|
con.Close()
|
|
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()
|
|
TextBox5.Focus()
|
|
End Sub
|
|
|
|
Private Sub TextBox2_TextChangeed(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
|
|
' validare CP text box 2
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub TextBox5_TextChangeed(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
|
|
' validare Calitate text box5
|
|
If TextBox5.Text.Length < 10 Then
|
|
|
|
ElseIf TextBox5.Text.Length = 10 Then
|
|
Dim val As String
|
|
val = TextBox5.Text
|
|
If InStr(1, val, "CP") > 0 Then
|
|
Dim cp As String = TextBox2.Text 'string pentru SQL cp
|
|
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 String
|
|
cant = TextBox5.Text
|
|
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.cusut values('" & TextBox2.Text & "','" & cant & "','" & dta & "','" & dTime & "')", con)
|
|
command.ExecuteNonQuery()
|
|
con.Close()
|
|
updateTable()
|
|
|
|
TextBox5.Clear()
|
|
TextBox2.Clear()
|
|
TextBox5.Focus()
|
|
|
|
Else
|
|
MsgBox("Introdu CP Corect")
|
|
TextBox2.Clear()
|
|
TextBox2.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
|
|
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")
|
|
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.cusut 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
|