تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] حذف مرفقات من مجلد المرفقات
#11
(12-06-19, 01:08 PM)asemshahen5 كتب :
PHP كود :
Private Sub ClearPictureBox(pb As PictureBox)
 
   pb.Image Nothing
    pb
.BackColor Color.Empty
 
   pb.Invalidate()
End Sub 
أو :
PHP كود :
       If Not PictureBox1.Image Is Nothing Then
            PictureBox1
.Image.Dispose()
 
           PictureBox1.Image Nothing
        End 
If 



تمااااااااامممممم
شكرا جزيل لحضرك
ولصبرك معى زادك الله علماً
وشكرا للاستاذ سعود

جزاكم الله خيراً
الرد }}}
تم الشكر بواسطة: ابراهيم ايبو , asemshahen5 , elgokr
#12
بالإضافة لمجهود الاخوه الكرام


الاكواد 
1- المكتبات
كود :
Imports System.Data.OleDb
Imports System.IO
2- المتغيرات
كود :
   Dim con As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\dbo.mdb;Jet OLEDB:Database Password=")
   Dim imgName As String
   Dim sourceDirectoryName As String
   Dim filyname As String
3- جلب صوره(Button)
كود :
Try
           Dim dlgImage As FileDialog = New OpenFileDialog()

           dlgImage.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif"

           If dlgImage.ShowDialog() = DialogResult.OK Then
               imgName = dlgImage.FileName

               Dim newimg As New Bitmap(imgName)

               PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
               PictureBox1.Image = DirectCast(newimg, Image)

               'دالة  تخزن مسار الملف
               sourceDirectoryName = dlgImage.FileName
               'داله تقوم بتخزين اسم الملف فقط بها
               filyname = My.Computer.FileSystem.GetDirectoryInfo(sourceDirectoryName).Name
               t1.Text = filyname


           End If

           dlgImage = Nothing

       Catch ae As System.ArgumentException
           imgName = " "

           MessageBox.Show(ae.Message.ToString())
       Catch ex As Exception
           MessageBox.Show(ex.Message.ToString())
       End Try
4-الحفظ (Button)
كود :
Dim str50 As String
       If con.State = ConnectionState.Closed Then
           con.Open()
       End If

       Dim cmd As New OleDb.OleDbCommand
       cmd.Connection = con
       str50 = "insert into tppicture(masar,wasf,[pic])" &
            "values (@1,@2,@3)"
       cmd.CommandText = str50


       Dim imgParam2 As New OleDbParameter()
       Dim fs2 As FileStream

       fs2 = New FileStream(imgName, FileMode.Open, FileAccess.Read)

       Dim picByte2 As Byte() = New Byte(fs2.Length - 1) {}

       fs2.Read(picByte2, 0, System.Convert.ToInt32(fs2.Length))

       fs2.Close()

       imgParam2.OleDbType = OleDbType.Binary
       imgParam2.ParameterName = "pic"
       imgParam2.Value = picByte2


       cmd.Parameters.AddWithValue("@1", t1.Text.Trim)
       cmd.Parameters.AddWithValue("@2", t2.Text.Trim)

       cmd.Parameters.AddWithValue("@3", picByte2)
       cmd.ExecuteScalar()
       If cmd.CommandTimeout Then
           con.Close()
       End If
       My.Computer.FileSystem.CopyFile(sourceDirectoryName, Application.StartupPath & "\picturey\" + filyname)
       MsgBox("تم إضافة الصورة بنجاح")
       PictureBox1.Image = Nothing
5-البحث (Button)
كود :
If con.State = ConnectionState.Closed Then
           con.Open()
       End If
       Dim adapter As New OleDbDataAdapter("select * from tppicture where masar like '" & t1.Text.Trim & "' ", con)
       Dim dt As New DataTable
       dt.Clear()
       adapter.Fill(dt)
       picid.Text = dt.Rows(0).Item(0).ToString
       t1.Text = dt.Rows(0).Item(1).ToString
       t2.Text = dt.Rows(0).Item(2).ToString

       Dim bytBLOBData() As Byte = dt.Rows(0).Item(3)
       Dim stmBLOBData As New MemoryStream(bytBLOBData)
       PictureBox1.Image = Image.FromStream(stmBLOBData)
6-الحذف (Button)
كود :
If MsgBox("تاكد قبل الحذف؟", MsgBoxStyle.OkCancel, "تأكيد") = MsgBoxResult.Cancel Then
           Exit Sub
       End If


       'Dim IDM As Integer = Val(t6.Text.Trim)
       If con.State = ConnectionState.Closed Then
           con.Open()
       End If
       Dim cmd2 As New OleDb.OleDbCommand
       cmd2.Connection = con
       cmd2.CommandType = CommandType.Text
       cmd2.CommandText = "DELETE FROM tppicture WHERE id = " & picid.Text & ""
       cmd2.ExecuteScalar()
       con.Close()
       My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\picturey\" & t1.Text)

       MsgBox("تم حذف  المحدد بنجاح  ")

       PictureBox1.Image = Nothing


الملفات المرفقة
.rar   صورةحذف-اضافه-نسخ.rar (الحجم : 2.05 م ب / التحميلات : 9)
اللهم صلي علي نبي (الرحمه) محمد رسول الله وبارك علي اله وصحابته والتابعين  واحقن دماء امتنا واجعل بأسنا علي اعدائنا يا ارحم الراحمين
[b]امين [/b]



الرد }}}
تم الشكر بواسطة: ابراهيم ايبو , asemshahen5 , elgokr , mr_hso



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم