219 lines
11 KiB
VB.net
Executable File
219 lines
11 KiB
VB.net
Executable File
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
|
|
Imports System.Security.Cryptography
|
|
Imports Microsoft.Data.SqlClient
|
|
Imports System.Data.DataTable
|
|
Imports DocumentFormat.OpenXml.VariantTypes
|
|
Imports System.Drawing.Printing
|
|
Imports System.Reflection
|
|
Imports DocumentFormat.OpenXml.Bibliography
|
|
Imports System.Reflection.Emit
|
|
|
|
Public Class Form18
|
|
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
|
|
Dim comCli As String
|
|
Dim comCli2 As String
|
|
Dim plusCpSerie As String
|
|
Dim cpserie As String
|
|
Dim CP_Seriat As String
|
|
Dim row As Integer = 0
|
|
'Dim dataStringforE As String
|
|
|
|
Private Sub Form17_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
' Get available printers and add them to combo box
|
|
For Each printer As String In PrinterSettings.InstalledPrinters
|
|
ComboBox1.Items.Add(printer)
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Private Sub updateTable()
|
|
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 * from Info_etichete where Comanda_Linia = '" & comCli & "' ", 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 serverull
|
|
|
|
Dim clientDataGrid As String
|
|
clientDataGrid = DataGridView1.Rows(0).Cells(15).Value
|
|
Label7.Text = clientDataGrid
|
|
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
|
|
row = selectRow
|
|
If selectRow >= 0 Then 'gasirea id din randul selectat din datagrid
|
|
Dim selectedCellValue As String = DataGridView1.Rows(selectRow).Cells("CP_Seriat").Value.ToString()
|
|
CP_Seriat = selectedCellValue ' devinirea valorii lui rowIdVal pe baza selectarii din datagrid
|
|
End If
|
|
End Sub
|
|
Private Sub ScanCP_TextChangeed(sender As Object, e As EventArgs) Handles ScanCP.TextChanged
|
|
' validare text box 1 cu OQ
|
|
' acest text box are o lungime a stringului de 4 caractere
|
|
If ScanCP.Text.Length < 10 Then
|
|
' caod de validare a criteriilor de Operator calitate OQ01 OQ02 OQ03 OQ04....
|
|
ElseIf ScanCP.Text.Length = 10 Then
|
|
Dim val As String
|
|
val = ScanCP.Text
|
|
If InStr(1, val, ) > 0 Then
|
|
comCli = val
|
|
updateTable()
|
|
|
|
Else
|
|
MsgBox("Scaneaza codul corect") ' cod de eroare in cazul introducerii codului gresit
|
|
ScanCP.Focus() 'focus pe textbox 1
|
|
End If
|
|
|
|
|
|
Else
|
|
MsgBox("Scaneaza codul CP corect") ' cod de eroare in cazul introducerii codului gresit
|
|
ScanCP.Focus() 'focus pe textbox 1
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Dim WithEvents PD As New PrintDocument
|
|
|
|
Dim PPD As New PrintPreviewDialog
|
|
|
|
Private Sub BTPRINT_Click(sender As Object, e As EventArgs) Handles BTPRINT.Click
|
|
PPD.Document = PD
|
|
PPD.ShowDialog()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub PD_BeginPrint(sender As Object, e As PrintEventArgs) Handles PD.BeginPrint
|
|
Dim pagesetup As New PageSettings
|
|
pagesetup.PaperSize = New PaperSize("Custom", 300, 500)
|
|
PD.DefaultPageSettings = pagesetup
|
|
If ComboBox1.Text = "" Then
|
|
MsgBox("Selecteaza un printer")
|
|
Else
|
|
PD.PrinterSettings.PrinterName = ComboBox1.SelectedItem.ToString()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub PD_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PD.PrintPage
|
|
|
|
|
|
|
|
Dim f8 As New Font("Calibri", 8, FontStyle.Regular)
|
|
Dim f10 As New Font("Calibri", 10, FontStyle.Regular)
|
|
Dim f10b As New Font("Calibri", 10, FontStyle.Bold)
|
|
Dim f14 As New Font("Calibri", 12, FontStyle.Bold)
|
|
|
|
Dim leftmargin As Integer = PD.DefaultPageSettings.Margins.Left
|
|
Dim centermargin As Integer = PD.DefaultPageSettings.PaperSize.Width / 2
|
|
Dim rightmargin As Integer = PD.DefaultPageSettings.PaperSize.Width
|
|
|
|
'font alignment
|
|
Dim right As New StringFormat
|
|
Dim center As New StringFormat
|
|
|
|
right.Alignment = StringAlignment.Far
|
|
center.Alignment = StringAlignment.Center
|
|
|
|
Dim line As String
|
|
line = "----------------------------------------------"
|
|
Dim bara As String
|
|
|
|
bara = "|"
|
|
'Dim row As Integer = 0
|
|
DataGridView1.AllowUserToAddRows = False
|
|
|
|
e.Graphics.DrawString("Quantity:", f14, Brushes.Black, 5, 40) 'first line
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(1).Value.ToString, f14, Brushes.Black, 90, 40) 'first line
|
|
e.Graphics.DrawString("To Pallet", f14, Brushes.Black, 110, 40) 'First line
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 55) ' linia nr 2
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(2).Value.ToString, f14, Brushes.Black, 5, 65) ' linia nr 3
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 80) 'linia nr 4
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(3).Value.ToString, f14, Brushes.Black, 5, 90) 'inia nr 5
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 100) 'linia 6
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(4).Value.ToString, f14, Brushes.Black, 5, 110) 'linia 7
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 125) 'linia 8
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(5).Value.ToString, f14, Brushes.Black, 5, 135) 'linia 9
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 147) 'linia 10
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(6).Value.ToString, f14, Brushes.Black, 5, 155) 'linia 11
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 167) 'linia 12
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(7).Value.ToString, f14, Brushes.Black, 5, 175) ' 'linia 13
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 187) 'linia 14
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(8).Value.ToString, f14, Brushes.Black, 5, 195) 'linia 15
|
|
e.Graphics.DrawString(bara, f14, Brushes.Black, 100, 195) 'linia 15
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(9).Value.ToString, f14, Brushes.Black, 110, 195) 'linia 15
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 205) 'linia 16
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(10).Value.ToString, f14, Brushes.Black, 5, 215) 'linia 17
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 225) 'linia 18
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(11).Value.ToString, f14, Brushes.Black, 5, 235) 'linia 19
|
|
e.Graphics.DrawString(bara, f14, Brushes.Black, 50, 235) 'linia 19
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(12).Value, f14, Brushes.Black, 65, 235) 'linia 19
|
|
e.Graphics.DrawString(bara, f14, Brushes.Black, 160, 235) 'linia 19
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(13).Value.ToString, f14, Brushes.Black, 170, 235) 'linia 19
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 250) 'linia 20
|
|
e.Graphics.DrawString("Barcode Number =>", f14, Brushes.Black, 5, 260) 'linia 21
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 275) 'linia 22
|
|
e.Graphics.DrawString(DataGridView1.Rows(row).Cells(14).Value.ToString, f14, Brushes.Black, 10, 285) 'linia 23
|
|
Dim barcodeData As String = DataGridView1.Rows(row).Cells(14).Value.ToString
|
|
Dim gbarcode As New MessagingToolkit.Barcode.BarcodeEncoder
|
|
Dim barcodeimage As Image
|
|
Dim w As Integer = 100
|
|
Dim h As Integer = 300
|
|
barcodeimage = New Bitmap(gbarcode.Encode(MessagingToolkit.Barcode.BarcodeFormat.Code128, barcodeData))
|
|
PictureBox1.Image = barcodeimage
|
|
Me.PictureBox1.Height = h
|
|
Me.PictureBox1.Width = w
|
|
Me.PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 300) 'linia 24
|
|
e.Graphics.DrawImage(PictureBox1.Image, 205, 60, 90, 300) ''Print lateral code de bare
|
|
e.Graphics.DrawString("Production Number & Series ", f14, Brushes.Black, 5, 310)
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 320)
|
|
cpserie = DataGridView1.Rows(row).Cells(0).Value.ToString
|
|
e.Graphics.DrawString(cpserie, f14, Brushes.Black, 5, 330)
|
|
e.Graphics.DrawString(line, f10b, Brushes.Black, 0, 345)
|
|
Dim cpBarcode As New MessagingToolkit.Barcode.BarcodeEncoder
|
|
Dim cpbarcodeimage As Image
|
|
cpbarcodeimage = New Bitmap(cpBarcode.Encode(MessagingToolkit.Barcode.BarcodeFormat.Code128, cpserie))
|
|
PictureBox2.Image = cpbarcodeimage
|
|
PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
|
|
PictureBox2.Size = New Size(300, 200)
|
|
e.Graphics.DrawImage(PictureBox2.Image, -50, 353, 400, 100)
|
|
PictureBox1.Dispose()
|
|
PictureBox2.Dispose()
|
|
'InfoPrintEtichete()
|
|
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
Form15.Show()
|
|
Me.Close()
|
|
End Sub
|
|
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
comCli = ScanCP.Text
|
|
updateTable()
|
|
End Sub
|
|
|
|
|
|
End Class |