1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| 'Check Name
MysqlConn.Open()
COMMAND.CommandText = "select * from product where name = '" & TextBox2.Text & "' and id = '" & TextBox1.Text & "'"
READER = COMMAND.ExecuteReader
If READER.HasRows = True Then
'Check Name
Try
Dim mstream As New System.IO.MemoryStream()
PictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
mstream.Close()
MysqlConn.Close()
MysqlConn.Open()
COMMAND.Connection = MysqlConn
COMMAND.CommandText = "update product set
id_maker=@Value1,
id_types=@Value2,
name=@Value3,
foto=@foto
where id = '" & TextBox1.Text & "' and name = '" & TextBox2.Text & "'"
COMMAND.Parameters.AddWithValue("@Value1", If(String.IsNullOrEmpty(ComboBox1.Text), DBNull.Value, ComboBox1.Text))
COMMAND.Parameters.AddWithValue("@Value2", If(String.IsNullOrEmpty(ComboBox2.Text), DBNull.Value, ComboBox2.Text))
COMMAND.Parameters.AddWithValue("@Value3", If(String.IsNullOrEmpty(TextBox2.Text), DBNull.Value, TextBox2.Text))
COMMAND.Parameters.AddWithValue("@foto", arrImage)
READER = COMMAND.ExecuteReader
MessageBox.Show("Datos Guardados")
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
MysqlConn.Close()
MysqlConn.Open()
ElseIf TextBox15.Text <> TextBox2.Text = True Then
'Check Name
'MysqlConn.Open()
MysqlConn.Close()
MysqlConn.Open()
COMMAND.CommandText = "select * from product where name = '" & TextBox2.Text & "' and id = '" & TextBox1.Text & "'"
READER = COMMAND.ExecuteReader
If READER.HasRows Then
MsgBox("Product Duplicated !", MsgBoxStyle.Critical)
Me.Show()
MysqlConn.Close()
Else
Try
Dim mstream As New System.IO.MemoryStream()
PictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
mstream.Close()
MysqlConn.Close()
MysqlConn.Open()
COMMAND.Connection = MysqlConn
COMMAND.CommandText = "update product set
id_maker=@Value1,
id_types=@Value2,
name=@Value3,
foto=@foto
where id = '" & TextBox1.Text & "'"
COMMAND.Parameters.AddWithValue("@Value1", If(String.IsNullOrEmpty(ComboBox1.Text), DBNull.Value, ComboBox1.Text))
COMMAND.Parameters.AddWithValue("@Value2", If(String.IsNullOrEmpty(ComboBox2.Text), DBNull.Value, ComboBox2.Text))
COMMAND.Parameters.AddWithValue("@Value3", If(String.IsNullOrEmpty(TextBox2.Text), DBNull.Value, TextBox2.Text))
COMMAND.Parameters.AddWithValue("@foto", arrImage)
READER = COMMAND.ExecuteReader
MessageBox.Show("Datos Guardados")
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
MysqlConn.Close()
MysqlConn.Open()
End If
End If
End If |
Partager