الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

اخذ الصورة ووعها في السيرفر

بدأه thepast في 10 أبريل 2012 · 3 رد · 361 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

انا عندي صفحة ادخال بيانات الموظفين اريد وضع fileupload لوضع ملف pdf يحتوي على اوراق هذا الموظف كأتاتش

تمام وعندما اقوم بحفظ البيانات ياخذ الملف ويضعه في السيرفر تمام

وعندما اعمل بحث لهذا الشخص يقوم بجلب بياناته مع ملف الpdf

ارجوووووووووووووووووووووووووو كم المساعدة في اتمام هذا لاني سألت من قبل ولكن بلا فائده

ارجوكم مساعدتي جزاكم الله خير

#2

سؤالك يتكون من جزأين :

1- دالة لحفظ بيانات الموظف ومن ضمنها ملف السيرة الذاتية للموظف

2- دالة للبحث عن الموظف وليكن برقم الموظف .

عوما لو استخدمت خاصية (البحث) في المنتدى لوجدت عشراااااااااااات الحلول لأسئلتك .

اللهم أطل عمري وأحسن عملي واختم بالشهادة أجلي

#3

السلام عليكم ورحمة الله وبركاته

ان ما عندي مشكلة في fileupload

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

 If FileUpload1.HasFile Then
            Try
                Dim filename As String = Path.GetFileName(FileUpload1.FileName)

                FileUpload1.SaveAs(Server.MapPath("~\fas\") & filename)

                Label1.Text = "Upload status: File uploaded!"
            Catch ex As Exception
                Label1.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message
            End Try
        End If

بس مشكلتي في هذا الكود كيف اربط مسار الملف برقم الموظف

المشكلة الثانية ما هو كود جلب هذا الملف عند البحث عن موظف ما

ارجوووووووووووووووكم المساعدة جزاكم الله الجزاء

#4

كيف تنشأ رقم الموظف هل هو آلي AutoNumber أم لديك دالة لتنشأه ؟

عموما لدي كود لتحميل ملفات صور وكل صورة ينشأ لها تحت مجلد الصور images اسم فريد لا يتكرر يستخدم فكرة GUID

كود Button_Click

 Dim strGuid As String = ""
        Dim strPicExtension As String = ""
        Dim strFileName As String = ""
        Dim DateAdd As String = DateTime.Now

        '   Firstly upload the picture associated with the news
        If PhotoUpload.HasFile Then
            '   Constructs the picture extension
            strGuid = fnGuid()
            strPicExtension = fnGetPictureExtension(PhotoUpload.FileName)
            strFileName = strGuid & strPicExtension

            '   Add picture to folder
            subAddNewPicture(PhotoUpload, strFileName, "Images")

            '   Add the record to the database
            UpdateGallery(txtTitle.Text, strFileName, txtMemo.Text.Trim(), DateAdd)

            lblUploadMessage.Text = "تم تحميل  الصورةبنجاح .."

        Else
            lblUploadMessage.Text = "اختار الصورة .."
        End If

أكواد الدوال المستخدمة سابقا

Private Sub UpdateGallery(ByVal txtTitle As String, ByVal strFileName As String, ByVal strMemo As String, ByVal DateAdd As String)
        '   Variables declaration
        Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("myConnectionString").ToString()
        Dim sqlConn As New SqlConnection(strConnString)
        Dim sqlcmd As New SqlCommand()

        '   Building the query
        '        Dim sqlQuery_Photo As String = "INSERT INTO [Images] VALUES ('" & txtTitle & "', '~/Images/' +'" & strFileName & "', '" & strMemo & "','" & DateAdd & "')"

        Dim sqlQuery_Photo As String = "INSERT INTO Images(Title,path,Description,DateAdd) VALUES ('{0}', '~/Images/' +'{1}', '{2}','{3}')"

        sqlQuery_Photo = sqlQuery_Photo.Replace("{0}", txtTitle)
        sqlQuery_Photo = sqlQuery_Photo.Replace("{1}", strFileName)
        sqlQuery_Photo = sqlQuery_Photo.Replace("{2}", strMemo)
        sqlQuery_Photo = sqlQuery_Photo.Replace("{3}", DateAdd)


        '   Retrieving search result
        sqlConn.Open()
        sqlcmd.Connection = sqlConn

        '   Adding records to table
        sqlcmd.CommandText = sqlQuery_Photo
        sqlcmd.ExecuteNonQuery()

        sqlConn.Close()
    End Sub

Private Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName As String, ByVal strImgFolder As String)
        Dim strImageFolderPath As String
        Dim strImagePath As String

        Try
            '   Construct saving path
            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)
            strImagePath = Path.Combine(strImageFolderPath, strPictureName)

            '   Upload image
            FileUploader.SaveAs(strImagePath)
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

Private Function fnGuid() As String
        Dim strGuid As String = ""

        Try
            With Today
                strGuid = .Year & .Month & .Day & Now.Hour & Now.Minute & Now.Second
            End With
        Catch ex As Exception
            Throw ex
        End Try

        '   returning the guid generated
        Return strGuid
    End Function

 Private Function fnGetPictureExtension(ByVal strPictureName As String) As String
        Try
            With strPictureName.ToUpper
                If .EndsWith(".JPG") Then
                    Return ".JPG"
                ElseIf .EndsWith(".GIF") Then
                    Return ".GIF"
                ElseIf .EndsWith(".JPEG") Then
                    Return ".JPEG"
                End If
            End With
        Catch ex As Exception
            Throw ex
        End Try

        ' Else if has no extension so it returns ""
        Return ""
    End Function

تم تعديل هذه المشاركة بواسطة AboMoayad في 13 أبريل 2012 في 18:27

اللهم أطل عمري وأحسن عملي واختم بالشهادة أجلي

مواضيع مشابهة