79 lines
2.3 KiB
VB.net
79 lines
2.3 KiB
VB.net
Imports System.IO
|
|
Imports MySql.Data.MySqlClient
|
|
|
|
Public Class frm_update_flag
|
|
|
|
Private Country As country
|
|
|
|
Private Sub btn_open_Click(sender As Object, e As EventArgs) Handles btn_open.Click
|
|
|
|
If IsNothing(pb_country_flag.Image) Then
|
|
|
|
' Open Picture File
|
|
ResizePicture(pb_country_flag, 236, 156)
|
|
|
|
' Making Sure The Isntance Is Ready
|
|
Country = New country(cbo_countries.SelectedValue)
|
|
|
|
' Store The Picture
|
|
Country.UpdateFlag(pb_country_flag)
|
|
|
|
ElseIf Not IsNothing(pb_country_flag.Image) Then
|
|
|
|
Dim iPictureUpdate As DialogResult = MessageBox.Show("Would You Like To Update The Country Flag ?", "Country Flag Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
|
If iPictureUpdate = DialogResult.Yes Then
|
|
|
|
' Open Picture File
|
|
ResizePicture(pb_country_flag, 236, 156)
|
|
|
|
' Making Sure The Isntance Is Ready
|
|
Country = New country(cbo_countries.SelectedValue)
|
|
|
|
' Store The Picture
|
|
Country.UpdateFlag(pb_country_flag)
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
Try
|
|
' Read All Countries To ComboBox
|
|
GetCountryList(cbo_countries)
|
|
Catch ex As Exception
|
|
cbo_countries.Items.Clear()
|
|
cbo_countries.DataSource = Nothing
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click
|
|
|
|
Try
|
|
' Read Created Function To Update Country Flag In Functions Module
|
|
Country = New country(cbo_countries.SelectedValue)
|
|
Country.UpdateFlag(pb_country_flag)
|
|
Catch ex As Exception
|
|
pb_country_flag.Image = Nothing
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub cbo_countries_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbo_countries.SelectedIndexChanged
|
|
|
|
Try
|
|
' Read Country Flag Image From Database To Picture Box
|
|
Country = New country(cbo_countries.SelectedValue)
|
|
pb_country_flag.Image = Image.FromStream(Country.Flag)
|
|
Catch ex As Exception
|
|
pb_country_flag.Image = Nothing
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
End Class
|