منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[VB.NET] اضافة الملفات - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [VB.NET] اضافة الملفات (/showthread.php?tid=22526)



اضافة الملفات - محمد اسماعيل - 13-11-17

السلام عليكم

اعمل علي داتا بيز اكسيس 2007 - وضع الاتصال المنفصل - فيجول بيسك دوت نت

عندي كود لاضافة ملفات مختلفة لقاعدة البيانات  الكود فية مشكلة في الاضافة رغم ان البيانات بتتنقل عادي باسمائها بحقل تيكست  وايضا حقل تحويل الملف الي بايت

  OLEObject

بقاعدة البيانات بس في مشكلة في الاضافة و عدم الحذف وعدم الاستعادة ورسالة خطاء عند الاضافة

[صورة مرفقة: Untitled-6.jpg?dl=0]

الاكواد كالاتي اضافة ملف -  حذف - استعادة

كود :
  Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addpdf.Click
       Try ' اضافة  add file to access 2007
           Using ofd As New OpenFileDialog
               ofd.Filter = "Pdf files (*.pdf)|*.pdf|All Files (*.*)|*.*"
               ofd.FilterIndex = 1
               If ofd.ShowDialog = DialogResult.OK Then
                   If BindingSource1.Find("type_prod", ofd.FileName) = -1 Then
                       Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
                       drv("type_prod") = ofd.FileName
                       drv("pic_prod") = IO.File.ReadAllBytes(ofd.FileName)
                       BindingSource1.EndEdit()
                       con.Open()
                       DataAdapter1.Update(DataSet1.Tables("purch_tb"))
                       con.Close()
                   Else
                       MessageBox.Show("الملف موجود بالفعل.", "اضافة ملف...")
                   End If
               End If
           End Using
       Catch ex As Exception

           MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
       End Try

   End Sub

   
   Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delete.Click
       '  حذف delete file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim dr As DialogResult = MessageBox.Show("هل تريد حذف الملف?", "حذف الملف...", MessageBoxButtons.YesNo)
           If dr = DialogResult.Yes Then
               BindingSource1.RemoveCurrent()

               con.Open()
               DataAdapter1.Update(DataSet1.Tables("purch_tb"))
               con.Close()
           End If
       End If
   End Sub

   Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles restore.Click
       ' استعادة restore file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
           Dim filename As String = drv("type_prod").ToString
           If IO.File.Exists(filename) Then
               Dim dr As DialogResult = MessageBox.Show("الملف المختار موجود ?", "استعادةالملف...", MessageBoxButtons.YesNo)
               If dr = DialogResult.No Then Exit Sub
           End If
           IO.File.WriteAllBytes(filename, CType(drv("pic_prod"), Byte()))
           Process.Start(filename)
           MessageBox.Show("تم استعادة الملف..." & vbNewLine & filename, "Restore File...")
       End If
   End Sub



RE: اضافة الملفات - محمد اسماعيل - 13-11-17

مجهود رائع

ممكن طلب ان تضع كود الحذف وفقا لطريقتك
وان يتم وضع الملف في الصف المحدد وليس اضافة صف جديد
وهل يوجد طريقة لوضع فولدر كامل داخل خلية بية مجموعة ملفات واعادتها بنفس طرييقتك


RE: اضافة الملفات - السندبااد - 13-11-17

(13-11-17, 06:44 AM)khodor1985 كتب : السلام عليكم أخي العزيز ورحمة الله وبركاته
لقد قمت بإنشاء مشروع يحاكي ما طلبت أتمنى أن تتقبله مني
المشروع :

وهذا فيديو يشرح فكرة البرنامج :




أتمنى لك التوفيق

شكراً لك، ولكن بعد التحميل الأرشيف يظهر لي وكأنه معطوب لا يمكن فكه
[attachment=16106]
أرجو أن تتكرم بضغطه من جديد ورفعه لنا



RE: اضافة الملفات - ابو روضة - 14-11-17

(13-11-17, 02:00 PM)السندبااد كتب :
(13-11-17, 06:44 AM)khodor1985 كتب : السلام عليكم أخي العزيز ورحمة الله وبركاته
لقد قمت بإنشاء مشروع يحاكي ما طلبت أتمنى أن تتقبله مني
المشروع :

وهذا فيديو يشرح فكرة البرنامج :




أتمنى لك التوفيق

شكراً لك، ولكن بعد التحميل الأرشيف يظهر لي وكأنه معطوب لا يمكن فكه

أرجو أن تتكرم بضغطه من جديد ورفعه لنا

يبدو ان برنامج الوين رار تبعك يحتاج الى نسخة أحدث الى سندباد



RE: اضافة الملفات - السندبااد - 14-11-17

كلامك في محله أخي العزيز (أبو روضة)
إن كان بالإمكان أرجو ضغطه بالوينزب الخاص بنظام ويندوز فهذا أضمن لفتح الملف



RE: اضافة الملفات - karimx - 14-11-17

السلام عليكم ورحمة الله وبركاته
هذه نسخة أخرى : [attachment=16111]


RE: اضافة الملفات - ilyeso2 - 17-05-18

أخي هل من الممكن ان تضع الكود ...إصدار البرنامج مختلف عن إصداري


RE: اضافة الملفات - elgokr - 17-05-18

(17-05-18, 05:16 AM)ilyeso2 كتب : أخي هل من الممكن ان تضع الكود ...إصدار البرنامج مختلف عن إصداري


عفواً اخى الموضوع قديم

تحياتى لك



RE: اضافة الملفات - tuscake - 10-12-18

(13-11-17, 03:40 AM)Mohammed Ismail كتب : Heart Thank you so much, this will help my project in thesis

السلام عليكم

ادعم على Data بيز اكسيس 2007 - Separate connection mode - فيجول بيسك DotNet I

have a code to add different files to the database code is a problem in the add-in, although the data is moving in plain names in the field of texast and also the file conversion field to bytes

  OLEObject

in the database b. A problem with the addition and non - deletion and non - restoration and error message when

[صورة مرفقة: Untitled-6.jpg?dl=0]

adding codes, such as add file - delete - restore

كود :
  Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addpdf.Click
       Try ' اضافة  add file to access 2007
           Using ofd As New OpenFileDialog
               ofd.Filter = "Pdf files (*.pdf)|*.pdf|All Files (*.*)|*.*"
               ofd.FilterIndex = 1
               If ofd.ShowDialog = DialogResult.OK Then
                   If BindingSource1.Find("type_prod", ofd.FileName) = -1 Then
                       Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
                       drv("type_prod") = ofd.FileName
                       drv("pic_prod") = IO.File.ReadAllBytes(ofd.FileName)
                       BindingSource1.EndEdit()
                       con.Open()
                       DataAdapter1.Update(DataSet1.Tables("purch_tb"))
                       con.Close()
                   Else
                       MessageBox.Show("الملف موجود بالفعل.", "اضافة ملف...")
                   End If
               End If
           End Using
       Catch ex As Exception

           MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
       End Try

   End Sub

   
   Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delete.Click
       '  حذف delete file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim dr As DialogResult = MessageBox.Show("هل تريد حذف الملف?", "حذف الملف...", MessageBoxButtons.YesNo)
           If dr = DialogResult.Yes Then
               BindingSource1.RemoveCurrent()

               con.Open()
               DataAdapter1.Update(DataSet1.Tables("purch_tb"))
               con.Close()
           End If
       End If
   End Sub

   Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles restore.Click
       ' استعادة restore file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
           Dim filename As String = drv("type_prod").ToString
           If IO.File.Exists(filename) Then
               Dim dr As DialogResult = MessageBox.Show("الملف المختار موجود ?", "استعادةالملف...", MessageBoxButtons.YesNo)
               If dr = DialogResult.No Then Exit Sub
           End If
           IO.File.WriteAllBytes(filename, CType(drv("pic_prod"), Byte()))
           Process.Start(filename)
           MessageBox.Show("تم استعادة الملف..." & vbNewLine & filename, "Restore File...")
       End If
   End Sub

(13-11-17, 03:40 AM)Mohammed Ismail كتب : Heart Thank you so much, this will help my project in thesis

السلام عليكم

ادعم على Data بيز اكسيس 2007 - Separate connection mode - فيجول بيسك DotNet I

have a code to add different files to the database code is a problem in the add-in, although the data is moving in plain names in the field of texast and also the file conversion field to bytes

  OLEObject

in the database b. A problem with the addition and non - deletion and non - restoration and error message when

[صورة مرفقة: Untitled-6.jpg?dl=0]

adding codes, such as add file - delete - restore

كود :
  Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addpdf.Click
       Try ' اضافة  add file to access 2007
           Using ofd As New OpenFileDialog
               ofd.Filter = "Pdf files (*.pdf)|*.pdf|All Files (*.*)|*.*"
               ofd.FilterIndex = 1
               If ofd.ShowDialog = DialogResult.OK Then
                   If BindingSource1.Find("type_prod", ofd.FileName) = -1 Then
                       Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
                       drv("type_prod") = ofd.FileName
                       drv("pic_prod") = IO.File.ReadAllBytes(ofd.FileName)
                       BindingSource1.EndEdit()
                       con.Open()
                       DataAdapter1.Update(DataSet1.Tables("purch_tb"))
                       con.Close()
                   Else
                       MessageBox.Show("الملف موجود بالفعل.", "اضافة ملف...")
                   End If
               End If
           End Using
       Catch ex As Exception

           MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
       End Try

   End Sub

   
   Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delete.Click
       '  حذف delete file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim dr As DialogResult = MessageBox.Show("هل تريد حذف الملف?", "حذف الملف...", MessageBoxButtons.YesNo)
           If dr = DialogResult.Yes Then
               BindingSource1.RemoveCurrent()

               con.Open()
               DataAdapter1.Update(DataSet1.Tables("purch_tb"))
               con.Close()
           End If
       End If
   End Sub

   Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles restore.Click
       ' استعادة restore file to access 2007
       If DataGridView1.SelectedRows.Count > 0 Then
           Dim drv As DataRowView = CType(BindingSource1.Current, DataRowView)
           Dim filename As String = drv("type_prod").ToString
           If IO.File.Exists(filename) Then
               Dim dr As DialogResult = MessageBox.Show("الملف المختار موجود ?", "استعادةالملف...", MessageBoxButtons.YesNo)
               If dr = DialogResult.No Then Exit Sub
           End If
           IO.File.WriteAllBytes(filename, CType(drv("pic_prod"), Byte()))
           Process.Start(filename)
           MessageBox.Show("تم استعادة الملف..." & vbNewLine & filename, "Restore File...")
       End If
   End Sub