27-01-23, 08:22 PM
السلام عليكم ورحمة الله وبركاته
لدي كود حفظ تالي يحفظ البيانات لكن في حالة عدم اختيار صورة من اداة pictures box يظهر خطا
اريد حتا في حالة عدم اختيار صورة يحفظ بيانات
لاريد فكره وهيا جعل صورة افتراضيه في اداة pictures box
هل من طريقه
لدي كود حفظ تالي يحفظ البيانات لكن في حالة عدم اختيار صورة من اداة pictures box يظهر خطا
اريد حتا في حالة عدم اختيار صورة يحفظ بيانات
لاريد فكره وهيا جعل صورة افتراضيه في اداة pictures box
هل من طريقه
كود :
If fullname.Text = "" Then
MessageBox.Show("الرجاء ادخال اسم العميل")
Exit Sub
End If
Dim sql = "select *from tbl_customers where cus_id=N'" & Val(customer_code.Text) & "'"
Dim adp As New SqlDataAdapter(sql, Module1.con)
Dim ds As New DataSet
adp.Fill(ds)
Dim dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
MessageBox.Show("اسم عميل موجود مسبقا")
Else
Dim DR = dt.NewRow
DR!CUS_ID = customer_code.Text
DR!FullName = fullname.Text
DR!TEL = tel.Text
DR!Email = email.Text
DR!country = ComboBox1.Text
DR!city = ComboBox2.Text
DR!status = True
If ofd.FileName <> "" Then
Dim imgbytearray() As Byte
Dim stream As New MemoryStream
PictureBox1.Image.Save(stream, ImageFormat.Jpeg)
imgbytearray = stream.ToArray()
stream.Close()
DR!picture = imgbytearray
End If
dt.Rows.Add(DR)
Dim cmd As New SqlCommandBuilder(adp)
adp.Update(dt)
MessageBox.Show("تم حفظ بنجاح")
btn_close_Click(sender, e)
End If