108 lines
5.3 KiB
VB.net
Executable File
108 lines
5.3 KiB
VB.net
Executable File
Imports DocumentFormat.OpenXml.Wordprocessing
|
|
Imports Microsoft.Data.SqlClient
|
|
Imports System.Data.DataTable
|
|
Imports System.Timers
|
|
|
|
Public Class Form9
|
|
'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
|
|
Dim rowData As String
|
|
Dim rowOra As String
|
|
Dim rowZona As String
|
|
Dim rowmasina As String
|
|
Dim rowdefect As String
|
|
Dim rowstatus As String
|
|
Dim Timer1 As System.Timers.Timer
|
|
|
|
|
|
|
|
|
|
Private Sub Form9_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
'updateTable()
|
|
Dim items As String() = New String() {"", "In Lucru", "Inchis"}
|
|
ComboBox1.DataSource = items
|
|
updateTable()
|
|
|
|
|
|
End Sub
|
|
|
|
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.mentenanta order by id desc", con)
|
|
Dim sda As New SqlDataAdapter(command)
|
|
Dim dt As New DataTable
|
|
sda.Fill(dt)
|
|
DataGridView1.DataSource = dt
|
|
con.Close()
|
|
Dim LTime As String 'string pentru SQL time
|
|
LTime = Date.Now.ToString("hh:mm") 'Format time
|
|
Label20.Text = LTime
|
|
|
|
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
|
|
Dim selectedCellValue1 As String = DataGridView1.Rows(selectRow).Cells("Data").Value.ToString()
|
|
rowData = selectedCellValue1 ' devinirea valorii lui rowData pe baza selectarii din datagrid
|
|
Dim selectedCellValue2 As String = DataGridView1.Rows(selectRow).Cells("Ora").Value.ToString()
|
|
rowOra = selectedCellValue2 ' devinirea valorii lui rowOra pe baza selectarii din datagrid
|
|
Dim selectedCellValue3 As String = DataGridView1.Rows(selectRow).Cells("zona").Value.ToString()
|
|
rowZona = selectedCellValue3 ' devinirea valorii lui rowzona pe baza selectarii din datagrid
|
|
Dim selectedCellValue4 As String = DataGridView1.Rows(selectRow).Cells("masina").Value.ToString()
|
|
rowmasina = selectedCellValue4 ' devinirea valorii lui rowzona pe baza selectarii din datagrid
|
|
Dim selectedCellValue5 As String = DataGridView1.Rows(selectRow).Cells("defect").Value.ToString()
|
|
rowdefect = selectedCellValue5 ' devinirea valorii lui rowzona pe baza selectarii din datagrid
|
|
Dim selectedCellValue6 As String = DataGridView1.Rows(selectRow).Cells("status").Value.ToString()
|
|
rowstatus = selectedCellValue6 ' devinirea valorii lui rowzona pe baza selectarii din datagrid
|
|
Label8.Text = rowIdval
|
|
Label9.Text = rowData
|
|
Label10.Text = rowOra
|
|
Label11.Text = rowZona
|
|
Label12.Text = rowmasina
|
|
Label13.Text = rowdefect
|
|
Label15.Text = rowstatus
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
Form1.Show() 'inchiderea formularului
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
' incarcare informatii noi in tabelul pentru mentenanta
|
|
Dim dta As String 'string pentru SQL data
|
|
dta = Date.Now.ToString("yyyy.MM.dd") ' format string
|
|
Dim dTime As String 'string pentru SQL time
|
|
dTime = Date.Now.ToString("hh:mm") 'Format time
|
|
|
|
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("update calitate.dbo.mentenanta set status = '" & ComboBox1.Text & "', datastart = '" & dta & "', Orastart = '" & dTime & "', constatare = '" & TextConst.Text & "', operator = '" & TextUser.Text & "' where id ='" & rowIdval & "' ", con)
|
|
command.ExecuteNonQuery()
|
|
con.Close()
|
|
updateTable()
|
|
End Sub
|
|
End Class
|