created new structure

This commit is contained in:
2025-04-16 13:31:51 +03:00
parent 82d5746b71
commit 4e43c17242
243 changed files with 0 additions and 10859 deletions

704
VS code/Form11.vb Normal file
View File

@@ -0,0 +1,704 @@
Imports System.Linq
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Imports System.IO
Imports System.Xml.XPath
Imports System.Data
Imports System.Xml
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports System.Security.Cryptography
Public Class Form11
'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 surceW As String = My.Settings.ServerNameW
Dim catalogW As String = My.Settings.ServerDatabaseW
Dim userW As String = My.Settings.ServerUserW
Dim passW As String = My.Settings.ServerUserPasW
Dim subnetW As String = My.Settings.SubnetW
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 rowindex As Int16
Dim cpSerial As String
Private Sub rowIndexv() ' command to give the row index of tha SQL table With info about labels,
'this row indezx help us manipulate the sql table and if a comand to update table is not succesfuly we myust delete the rows addet incorrect
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 & "") ' conection to data string from settings
Dim Cmd2 As SqlCommand ' sql command
Dim rowindex1 As Int32
Dim query As String = "select max(id_eti) from Info_etichete"
con.Open()
Cmd2 = New SqlCommand(query, con)
rowindex1 = Cmd2.ExecuteScalar()
con.Close()
Label3.Text = rowindex1
rowindex = rowindex1 ' rowindez is declarated as a variable in the his form and will be avalabele in other subrutines
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' cod for uploading data from excel files
Dim conn As OleDbConnection ' we use oldb conection
'Dim dtr As OleDbDataReader
Dim dta As OleDbDataAdapter
'Dim cmd As OleDbCommand
Dim dts As DataSet
Dim excel As String
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog1.FileName = ""
OpenFileDialog1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
OpenFileDialog1.Filter = "All Files (*.*)|*.*|Excel files (*.xlsx)|*.xlsx|CSV Files (*.csv)|*.csv|XLS Files (*.xls)|*xls" ' types of file avalable to be uploadet
If (OpenFileDialog1.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
DataGridView1.Columns.Clear() ' clear first tha data grid view
Dim fi As New FileInfo(OpenFileDialog1.FileName) ' name of the file
Dim FileName As String = OpenFileDialog1.FileName
excel = fi.FullName
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties=Excel 12.0") ' conection to transfor file from data file tu be updated in data grid
dta = New OleDbDataAdapter("Select * From [Sheet1$]", conn) ' select from Sheet 1
dts = New DataSet
dta.Fill(dts, "[Sheet1$]")
DataGridView1.DataSource = dts
DataGridView1.DataMember = "[Sheet1$]"
conn.Close()
Label2.Text = FileName ' the name of the file will apear in Label 12 that is on top of data grid view
rowIndexv() ' update of the row index to prepare for loading them on SQL server
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ' comand that will upload info in SQL server from files that contain series labels for Hulshot
Dim Msg, Style, Title, Response
Msg = " Esti sigur ca vrei sa incarci etichetele de Hulshot Serii?" ' msg box for confirmation
Style = vbYesNo
Title = "Interogare de siguranta"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then ' if response is no , the program will delete the information from datagrid and wil put the program in whaiting state for new file upload
MsgBox("Se va goli Informatia din Datagrid")
DataGridView1.DataSource = Nothing
Else
' the program will start uploading informations in SQL server according to the transformation required for correct labbel.
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 & "") ' conection for SQL
rowIndexv() ' get row index for the case we can not update the file
Dim nrLinii As Integer = DataGridView1.Rows.Count - 1 ' get thr number of rows in Datagrid to prepare for Uploading in SQL
Try
For i As Integer = 0 To DataGridView1.Rows.Count - 2 ' for each row we perform upload comand in SQL
' next rows will perform file transformation to be able to upload to SQL
Dim codfirma As String = "007" ' romanian code for uploading from Hulshot companu code 007
Dim comanda As String ' info for order number taked from Cell 2 of each row
If DataGridView1.Rows(i).Cells(2).Value IsNot DBNull.Value Then ' if cell has no info result will be -
comanda = DataGridView1.Rows(i).Cells(2).Value
Else
comanda = "-"
End If
Dim linia As String
' info for line of the order number taked from Cell 3 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(3).Value IsNot DBNull.Value Then
linia = DataGridView1.Rows(i).Cells(3).Value
Else
linia = "-"
End If
Dim cant As String
' info for the quantity of the order taked from Cell 12 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(12).Value IsNot DBNull.Value Then
cant = DataGridView1.Rows(i).Cells(12).Value
Else
cant = "-"
End If
Dim onsordercode As String
' info for ons ordercode of the order number taked from Cell 13 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(13).Value IsNot DBNull.Value Then
onsordercode = DataGridView1.Rows(i).Cells(13).Value
Else
onsordercode = "-"
End If
Dim descriere As String
' info for the description of the order number taked from Cell 7 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(7).Value IsNot DBNull.Value Then
descriere = DataGridView1.Rows(i).Cells(7).Value
Else
descriere = "-"
End If
' info for dimensions of the order number taked from Cell 9 / 10/ 11 of each row
Dim Dimensiune1 As String = DataGridView1.Rows(i).Cells(9).Value
Dim Dimensiune2 As String = DataGridView1.Rows(i).Cells(10).Value
Dim Dimensiune3 As String = DataGridView1.Rows(i).Cells(11).Value
Dim Client As String
' info for name of the customer for the order number taked from Cell 6 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(6).Value IsNot DBNull.Value Then
Client = DataGridView1.Rows(i).Cells(6).Value
Else
Client = "-"
End If
Dim Strada As String
' info for strate addres of the order number taked from Cell 4 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(4).Value IsNot DBNull.Value Then
Strada = DataGridView1.Rows(i).Cells(4).Value
Else
Strada = "-"
End If
' post code we have no postcode on the files for series
Dim postcode As String = "-"
' we have no information customer town that is definde in sql as orasclient
Dim orasclient As String = "-"
Dim pf As String
' info for miercurea article code of the order number taked from Cell 8 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(8).Value IsNot DBNull.Value Then
pf = DataGridView1.Rows(i).Cells(8).Value
Else
pf = "-"
End If
Dim marcaj As String
' info for marking of the order number taked from Cell 14 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(14).Value IsNot DBNull.Value Then
marcaj = DataGridView1.Rows(i).Cells(14).Value
Else
marcaj = "-"
End If
Dim data_livrare As String
' info for delivery date of the order number taked from Cell 15 of each row
' for mts orders some time delivery date is not avalable
' if cell has no info result will be --/--/--
If DataGridView1.Rows(i).Cells(15).Value IsNot DBNull.Value Then
Me.DataGridView1.Columns("hpp-dat").DefaultCellStyle.Format = "dd.MM.yyyy" ' formating cel in an accepted date format for SQL
data_livrare = DataGridView1.Rows(i).Cells(15).Value
Else
data_livrare = "--/--/--"
End If
Dim volum As String
' info for volume of the covers from the order number taked from Cell 3 of each row
' if cell has no info result will be -
If DataGridView1.Rows(i).Cells(16).Value IsNot DBNull.Value Then
volum = DataGridView1.Rows(i).Cells(16).Value
Else
volum = "-"
End If
Dim barcode As String = DataGridView1.Rows(i).Cells(0).Value ' information for the barcode
Dim NumeCli As String = "Hushout" ' customer name for internal task
Dim comLinia As String = comanda & "-" & linia ' gruping the order to be able to recover from SQL after CP import
Dim comLinia1 As String = codfirma & "-" & comLinia ' gruping info for label with cod firma, an order and line
Dim dimens As String = Dimensiune1 & "X" & Dimensiune2 & "X" & Dimensiune3 ' gruping dimensions in one cell
Dim cmd As New SqlCommand("Insert into Info_etichete values ('" & comLinia & "','" & cant & "','" & comLinia1 & "','" & onsordercode & "',
'" & descriere & "','" & dimens & "','" & Client & "','" & Strada & "','" & postcode & "','" & orasclient & "',
'" & pf & "','" & marcaj & "','" & data_livrare & "','" & volum & "','" & barcode & "','" & NumeCli & "') ", con) ' the sql command for inserting defined values
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Next ' continuing the loop for each i equal with data grid views rows number
MsgBox("Au fost Incarcate un numar de - " & nrLinii & " linii cu succes") ' when the loop is done with no error we receve this message
Catch ex As Exception
MsgBox("Incercarea de a incarca un nr de : " & nrLinii & " linii nu a reusit, este posibil ca informatia pentru aceste etichete sa fie deja incarcata")
' this is the message in case the loop has an error an not all the information was inserted.
Dim CmdDel As New SqlCommand("DELETE from Info_etichete where id_eti >" & rowindex & "", con) ' if we have an error and som rows wher not corectly updated in SQL we delet the rows using the index number
CmdDel.ExecuteNonQuery() ' execute the delet command
con.Close() ' close the query
End Try
' when all the data was uploadet or it has an eror, next command will delet the info from data grid
DataGridView1.DataSource = Nothing
End If
rowIndexv() ' get the new index row number
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Form15.Show() ' button for close the form and send to label upload
Me.Close()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' this button handles the transformation for single cover, all tha transformations ar in the same method mades as for the Series covers only the colums ar a litle different
' the information coms in different flavor in excel and for that we ned different transformations from the data grid to SQL
Dim Msg, Style, Title, Response
Msg = " esti sigur ca vrei sa incarci etichetele de Hulshot Single Covers?"
Style = vbYesNo
Title = "Interogare de siguranta"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
MsgBox("Se va goli Informatia din Datagrid")
DataGridView1.DataSource = Nothing
Else
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 & "")
rowIndexv()
Dim nrLinii As Integer = DataGridView1.Rows.Count - 1
Try
For i As Integer = 0 To DataGridView1.Rows.Count - 2
Dim codfirma As String = "007"
Dim comanda As String
If DataGridView1.Rows(i).Cells(2).Value IsNot DBNull.Value Then
comanda = DataGridView1.Rows(i).Cells(2).Value
Else
comanda = "-"
End If
Dim linia As String
If DataGridView1.Rows(i).Cells(3).Value IsNot DBNull.Value Then
linia = DataGridView1.Rows(i).Cells(3).Value
Else
linia = "-"
End If
Dim cant As String = "1" 'DataGridView1.Rows(i).Cells(12).Value
Dim onsordercode As String
If DataGridView1.Rows(i).Cells(10).Value IsNot DBNull.Value Then
onsordercode = DataGridView1.Rows(i).Cells(10).Value
Else
onsordercode = "-"
End If
Dim descriere As String
If DataGridView1.Rows(i).Cells(6).Value IsNot DBNull.Value Then
descriere = DataGridView1.Rows(i).Cells(6).Value
Else
descriere = "-"
End If
Dim Dimensiune1 As String
If DataGridView1.Rows(i).Cells(7).Value IsNot DBNull.Value Then
Dimensiune1 = DataGridView1.Rows(i).Cells(7).Value
Else
Dimensiune1 = "-"
End If
Dim Dimensiune2 As String
If DataGridView1.Rows(i).Cells(8).Value IsNot DBNull.Value Then
Dimensiune2 = DataGridView1.Rows(i).Cells(8).Value
Else
Dimensiune2 = "-"
End If
Dim Dimensiune3 As String
If DataGridView1.Rows(i).Cells(9).Value IsNot DBNull.Value Then
Dimensiune3 = DataGridView1.Rows(i).Cells(9).Value
Else
Dimensiune3 = "-"
End If
Dim Client As String
If DataGridView1.Rows(i).Cells(11).Value IsNot DBNull.Value Then
Client = DataGridView1.Rows(i).Cells(11).Value
Else
Client = "-"
End If
Dim Strada As String
If DataGridView1.Rows(i).Cells(12).Value IsNot DBNull.Value Then
Strada = DataGridView1.Rows(i).Cells(12).Value
Else
Strada = "-"
End If
Dim postcode As String
If DataGridView1.Rows(i).Cells(13).Value IsNot DBNull.Value Then
postcode = DataGridView1.Rows(i).Cells(13).Value
Else
postcode = "-"
End If
Dim orasclient As String
If DataGridView1.Rows(i).Cells(14).Value IsNot DBNull.Value Then
orasclient = DataGridView1.Rows(i).Cells(14).Value
Else
orasclient = "-"
End If
Dim pf As String = "-"
Dim dateN As Date = Today()
Dim duedate As Date = dateN.AddDays(9)
Dim marcaj As String
If DataGridView1.Rows(i).Cells(15).Value IsNot DBNull.Value Then
marcaj = DataGridView1.Rows(i).Cells(15).Value
Else
marcaj = "-"
End If
Dim data_livrare As String
If DataGridView1.Rows(i).Cells(16).Value IsNot DBNull.Value Then
Me.DataGridView1.Columns("hpp-dat").DefaultCellStyle.Format = "dd.MM.yyyy"
data_livrare = DataGridView1.Rows(i).Cells(16).Value
Else
data_livrare = "--/--/--"
End If
Dim volum As String
If DataGridView1.Rows(i).Cells(17).Value IsNot DBNull.Value Then
volum = DataGridView1.Rows(i).Cells(17).Value
Else
volum = "-"
End If
Dim barcode As String = DataGridView1.Rows(i).Cells(0).Value
Dim NumeCli As String = "Hushout"
Dim comLinia As String = comanda & "-" & linia
Dim comLinia1 As String = DataGridView1.Rows(i).Cells(18).Value
Dim dimens As String = Dimensiune1 & "X" & Dimensiune2 & "X" & Dimensiune3
Dim cmd As New SqlCommand("Insert into Info_etichete values ('" & comLinia & "','" & cant & "','" & comLinia1 & "','" & onsordercode & "',
'" & descriere & "','" & dimens & "','" & Client & "','" & Strada & "','" & postcode & "','" & orasclient & "',
'" & pf & "','" & marcaj & "','" & data_livrare & "','" & volum & "','" & barcode & "','" & NumeCli & "') ", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Next
MsgBox("Au fost Incarcate un numar de - " & nrLinii & " linii cu succes")
Catch ex As Exception
MsgBox("Incercarea de a incarca un nr de : " & nrLinii & " linii nu a reusit, este posibil ca informatia pentru aceste etichete sa fie deja incarcata")
Dim CmdDel As New SqlCommand("DELETE from dbo.Info_etichete where id_eti >" & rowindex & "", con)
con.Open()
CmdDel.ExecuteNonQuery()
con.Close()
End Try
DataGridView1.DataSource = Nothing
End If
rowIndexv()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
' this button handles the transformation for Kesteren cover, all tha transformations ar in the same method mades as for the Series covers only the colums ar a litle different
' the information coms in different flavor in excel and for that we ned different transformations from the data grid to SQL
Dim Msg, Style, Title, Response
Msg = " esti sigur ca vrei sa incarci etichetele de Kesteren?"
Style = vbYesNo
Title = "Interogare de siguranta"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
MsgBox("Se va goli Informatia din Datagrid")
DataGridView1.DataSource = Nothing
Else
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 & "")
rowIndexv()
Dim nrLinii As Integer = DataGridView1.Rows.Count - 1
Try
For i As Integer = 0 To DataGridView1.Rows.Count - 2
Dim codfirma As String = "7345"
Dim comanda As String
If DataGridView1.Rows(i).Cells(5).Value IsNot DBNull.Value Then
comanda = DataGridView1.Rows(i).Cells(5).Value
Else
comanda = "-"
End If
Dim linia As String
If DataGridView1.Rows(i).Cells(6).Value IsNot DBNull.Value Then
linia = DataGridView1.Rows(i).Cells(6).Value
Else
linia = "-"
End If
Dim cant As String
If DataGridView1.Rows(i).Cells(10).Value IsNot DBNull.Value Then
cant = DataGridView1.Rows(i).Cells(10).Value
Else
cant = "-"
End If
Dim onsordercode As String
If DataGridView1.Rows(i).Cells(3).Value IsNot DBNull.Value Then
onsordercode = "created on:" & DataGridView1.Rows(i).Cells(3).Value
Else
onsordercode = "-"
End If
Dim descriere As String
If DataGridView1.Rows(i).Cells(8).Value IsNot DBNull.Value Then
descriere = DataGridView1.Rows(i).Cells(8).Value
Else
descriere = "-"
End If
Dim Dimensiune1 As String = DataGridView1.Rows(i).Cells(7).Value
Dim Dimensiune2 As String = DataGridView1.Rows(i).Cells(8).Value
Dim Dimensiune3 As String = DataGridView1.Rows(i).Cells(9).Value
Dim Client As String = "Aquinos Bedding Romania"
'If DataGridView1.Rows(i).Cells(11).Value IsNot DBNull.Value Then
'Client = DataGridView1.Rows(i).Cells(11).Value
' Else
'Client = "-"
'End If
Dim Strada As String
If DataGridView1.Rows(i).Cells(7).Value IsNot DBNull.Value Then
Strada = DataGridView1.Rows(i).Cells(7).Value
Else
Strada = "-"
End If
Dim postcode As String
If DataGridView1.Rows(i).Cells(5).Value IsNot DBNull.Value Then
postcode = DataGridView1.Rows(i).Cells(5).Value
Else
postcode = "-"
End If
Dim orasclient As String
If DataGridView1.Rows(i).Cells(6).Value IsNot DBNull.Value Then
orasclient = DataGridView1.Rows(i).Cells(6).Value
Else
orasclient = "-"
End If
Dim pf As String
If DataGridView1.Rows(i).Cells(9).Value IsNot DBNull.Value Then
pf = DataGridView1.Rows(i).Cells(9).Value
Else
pf = "-"
End If
Dim dateN As Date = Today()
Dim duedate As Date = dateN.AddDays(9)
Dim marcaj As String
If DataGridView1.Rows(i).Cells(11).Value IsNot DBNull.Value Then
marcaj = DataGridView1.Rows(i).Cells(11).Value
Else
marcaj = "-"
End If
Dim data_livrare As String
If DataGridView1.Rows(i).Cells(5).Value IsNot DBNull.Value Then
Me.DataGridView1.Columns("Delivery date").DefaultCellStyle.Format = "dd.MM.yyyy"
data_livrare = DataGridView1.Rows(i).Cells(4).Value
Else
data_livrare = "--/--/--"
End If
Dim volum As String
If DataGridView1.Rows(i).Cells(12).Value IsNot DBNull.Value Then
volum = DataGridView1.Rows(i).Cells(12).Value
Else
volum = "-"
End If
Dim barcode As String = comanda & "-" & linia
Dim NumeCli As String = "Kesteren"
Dim comLinia As String = comanda & "-" & linia
Dim comLinia1 As String = comLinia
Dim dimens As String = descriere.Substring(descriere.Length - 7)
Dim cmd As New SqlCommand("insert into Info_etichete values ('" & comLinia & "','" & cant & "','" & comLinia1 & "','" & onsordercode & "',
'" & descriere & "','" & dimens & "','" & Client & "','" & Strada & "','" & postcode & "','" & orasclient & "',
'" & pf & "','" & marcaj & "','" & data_livrare & "','" & volum & "','" & barcode & "','" & NumeCli & "') ", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Next
MsgBox("Au fost Incarcate un numar de - " & nrLinii & " linii cu succes")
Catch ex As Exception
MsgBox("Incercarea de a incarca un nr de : " & nrLinii & " linii nu a reusit, este posibil ca informatia pentru aceste etichete sa fie deja incarcata")
Dim CmdDel As New SqlCommand("DELETE from Info_etichete where id_eti >" & rowindex & "", con)
CmdDel.ExecuteNonQuery()
con.Close()
End Try
DataGridView1.DataSource = Nothing
End If
rowIndexv()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
' this button handles the transformation for single cover, all tha transformations ar in the same method mades as for the Series covers only the colums ar a litle different
' the information coms in different flavor in excel and for that we ned different transformations from the data grid to SQL
Dim Msg, Style, Title, Response
Msg = " esti sigur ca vrei sa incarci etichetele de Bochum?"
Style = vbYesNo
Title = "Interogare de siguranta"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
MsgBox("Se va goli Informatia din Datagrid")
DataGridView1.DataSource = Nothing
Else
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 & "")
rowIndexv()
Dim nrLinii As Integer = DataGridView1.Rows.Count - 1
Try
For i As Integer = 1 To DataGridView1.Rows.Count - 2
Dim comanda As String
If DataGridView1.Rows(i).Cells(3).Value IsNot DBNull.Value Then
comanda = DataGridView1.Rows(i).Cells(3).Value
Else
comanda = "-"
End If
Dim linia As String
If DataGridView1.Rows(i).Cells(4).Value IsNot DBNull.Value Then
linia = DataGridView1.Rows(i).Cells(4).Value
Else
linia = "-"
End If
Dim cant As String
If DataGridView1.Rows(i).Cells(9).Value IsNot DBNull.Value Then
cant = DataGridView1.Rows(i).Cells(9).Value
Else
cant = "-"
End If
Dim onsordercode As String
If DataGridView1.Rows(i).Cells(18).Value IsNot DBNull.Value Then
onsordercode = DataGridView1.Rows(i).Cells(18).Value
Else
onsordercode = "-"
End If
Dim descriere As String
If DataGridView1.Rows(i).Cells(19).Value IsNot DBNull.Value Then
descriere = DataGridView1.Rows(i).Cells(19).Value
Else
descriere = "-"
End If
Dim Dimensiune1 As String = DataGridView1.Rows(i).Cells(7).Value
Dim Dimensiune2 As String = DataGridView1.Rows(i).Cells(8).Value
'Dim Dimensiune3 As String = DataGridView1.Rows(i).Cells(9).Value
Dim Client As String = "Aguinos Bedding Romania" ' "Aquinos Bedding Romania"
'If DataGridView1.Rows(i).Cells(11).Value IsNot DBNull.Value Then
'Client = DataGridView1.Rows(i).Cells(11).Value
'Else
'Client = "-"
'End If
Dim Strada As String ' data comenzii catre client
If DataGridView1.Rows(i).Cells(20).Value IsNot DBNull.Value Then
Strada = DataGridView1.Rows(i).Cells(20).Value
Else
Strada = "-"
End If
Dim postcode As String
If DataGridView1.Rows(i).Cells(13).Value IsNot DBNull.Value Then
postcode = DataGridView1.Rows(i).Cells(13).Value
Else
postcode = "-"
End If
Dim orasclient As String
If DataGridView1.Rows(i).Cells(12).Value IsNot DBNull.Value Then
orasclient = DataGridView1.Rows(i).Cells(12).Value
Else
orasclient = "-"
End If
Dim pf As String
If DataGridView1.Rows(i).Cells(21).Value IsNot DBNull.Value Then
pf = DataGridView1.Rows(i).Cells(21).Value
Else
pf = "-"
End If
Dim dateN As Date = Today()
Dim duedate As Date = dateN.AddDays(9)
Dim marcaj As String = "-"
Dim data_livrare As String
If DataGridView1.Rows(i).Cells(10).Value IsNot DBNull.Value Then
Me.DataGridView1.Columns(10).DefaultCellStyle.Format = "dd.MM.yyyy"
data_livrare = DataGridView1.Rows(i).Cells(10).Value
Else
data_livrare = "--/--/--"
End If
Dim volum As String = "-"
' If DataGridView1.Rows(i).Cells(12).Value IsNot DBNull.Value Then
'volum = DataGridView1.Rows(i).Cells(12).Value
' Else
'volum = "-"
'End If
Dim barcode As String = comanda & "-" & linia
Dim NumeCli As String = "Bochum"
Dim comLinia As String = comanda & "-" & linia
Dim comLinia1 As String = comanda & "-" & linia
Dim dimens As String = Dimensiune1 & "x" & Dimensiune2 & "x"
Dim cmd As New SqlCommand("insert into Info_etichete values ('" & comLinia & "','" & cant & "','" & comLinia1 & "','" & onsordercode & "',
'" & descriere & "','" & dimens & "','" & Client & "','" & Strada & "','" & postcode & "','" & orasclient & "',
'" & pf & "','" & marcaj & "','" & data_livrare & "','" & volum & "','" & barcode & "','" & NumeCli & "') ", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Next
MsgBox("Au fost Incarcate un numar de - " & nrLinii & " linii cu succes")
Catch ex As Exception
MsgBox("Incercarea de a incarca un nr de : " & nrLinii & " linii nu a reusit, este posibil ca informatia pentru aceste etichete sa fie deja incarcata")
Dim CmdDel As New SqlCommand("DELETE from Info_etichete where id_eti >" & rowindex & "", con)
con.Open()
CmdDel.ExecuteNonQuery()
con.Close()
End Try
DataGridView1.DataSource = Nothing
End If
rowIndexv()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs)
' 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 1 * from dbo.SERIAL order by SERIAL 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
Label5.Text = DataGridView1.Rows(0).Cells(0).Value.ToString()
cpSerial = DataGridView1.Rows(0).Cells(0).Value.ToString()
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs)
Dim con1 As New SqlConnection("Data Source=" & surceW & "; Initial Catalog=" & catalogW & "; User ID=" & userW &
"; Password=" & passW & "; Connect Timeout=" & timeout & "; Encrypt=" & encrypt &
"; TrustServerCertificate=" & trust & "; ApplicationIntent=" & reason & "; MultiSubnetFailover=" & subnet & "")
con1.Open() ' deschiderea conexiuni cu serverul
Dim command As New SqlCommand("select * from dbo.SERIAL where serial > " & cpSerial & " ", con1)
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
con1.Close() ' inchiderea conexiuneii cu serverul
End Sub
End Class