Professional Documents
Culture Documents
Form 4
Form 4
IO
Imports System.Data.SqlClient
Public Class Form4
Dim sqlcon As New SqlConnection("Data Source=(localdb)\MSSQLLocalDB;Initial
Catalog=houcem;Integrated Security=True")
Dim ofd As New OpenFileDialog
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Catch ex As Exception
MsgBox("error")
Finally
conn.Close()
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ofd.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg;
*.jpeg; *.jpe; *.jfif; *.png|PDF files (*.pdf)|*.pdf ;"
If ofd.ShowDialog = DialogResult.OK Then
Dim klo2 As String = ""
Dim klo1 As String
Dim pos2 As Integer
Dim pos As Integer
pos = InStr(ofd.FileName, Path.GetExtension(ofd.FileName))
klo1 = Microsoft.VisualBasic.Left(ofd.FileName, pos - 1)
pos2 = InStr(ofd.FileName, "\")
While pos2 <> 0
klo2 = Microsoft.VisualBasic.Mid(klo1, pos2 + 1, pos - 1)
klo1 = klo2
pos2 = InStr(klo2, "\")
End While
TextBox1.Text = klo2 & Path.GetExtension(ofd.FileName)
textbox2.text = klo2
End If
Dim fs As New FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fs)
Dim file() As Byte = br.ReadBytes(br.BaseStream.Length)
Try
sqlcon.Open()
cmd.ExecuteNonQuery()
ds.Clear()
Me.UploadTableAdapter1.Fill(Me.HoucemDataSet1.upload)
'dgvupload.
'Me.UploadTableAdapter.Fill(Me.HoucemDataSet.upload)
End Sub
End Sub
End Sub
Me.Dispose()
End Sub
End Sub
Private Sub dgvupload_KeyDown(sender As Object, e As KeyEventArgs) Handles
dgvupload.KeyDown
If e.KeyCode = Keys.Delete Then
Try
If TextBox2.Text = "" Then
Exit Sub
End If
Dim strinsert As String = "delete from upload where ID = " &
CInt(TextBox2.Text) & ""
'If Then
If dgvupload.RowCount > 0 Then
If CInt(TextBox3.Text) <= dgvupload.RowCount - 1 Then
dgvupload.Rows(CInt(TextBox3.Text)).Selected = True
Else
dgvupload.Rows(CInt(TextBox3.Text) - 1).Selected = True
TextBox2.Text = dgvupload(0, CInt(TextBox3.Text) - 1).Value
TextBox3.Text = (CInt(TextBox3.Text) - 1).ToString()
End If
End If
' End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
sqlcon.Close()
End Try
End If
End Sub
End Sub
End Sub
Private Sub Form4_Activated(sender As Object, e As EventArgs) Handles
Me.Activated
Me.WindowState = FormWindowState.Maximized
Me.FormBorderStyle = FormBorderStyle.None
TopMost = True
End Sub
End Class