Dim intWidth, intHeight As Integer
Dim objGraphic As Image
Dim objBitmap As Bitmap
intWidth = 120 '*** Fix Width ***'
'intHeight = 0 '*** If = 0 Auto Re-cal Size
intHeight = 120
Dim editFileName As String = storeID & ".jpg"
Dim UlFileName As String = "ImageStore/Update" & editFileName
'*** IMAGE RESIZED ***'
Dim NewFileName As String = "ImageStore/UpdateThumbnail" & editFileName
'Dim strUpdateFile = String.Empty
If fiUpload.HasFile Then
'UlFileName += fiUpload.FileName
fiUpload.SaveAs(Server.MapPath(UlFileName))
objGraphic = System.Drawing.Image.FromFile(Server.MapPath(UlFileName))
'strUpdateFile = "storePic='" & UlFileName & "' "
'*** CALCULATE HEIGHT ***'
If intHeight > 0 Then
objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
Else
If objGraphic.Width > intWidth Then
Dim ratio As Double = objGraphic.Height / objGraphic.Width
intHeight = ratio * intWidth
objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
Else
objBitmap = New Bitmap(objGraphic)
End If
End If
objBitmap.Save(Server.MapPath(NewFileName), objGraphic.RawFormat)
objGraphic.Dispose()
objBitmap = Nothing
objGraphic = Nothing
Else
Dim img As System.Web.UI.WebControls.Image = CType(gridStore.Rows(e.RowIndex).FindControl("imageUser"), System.Web.UI.WebControls.Image)
UlFileName = img.ImageUrl
End If
Dim SqlCon As New SqlConnection(con)
Dim cmd As New SqlCommand("UPDATE Store SET storeName='" & storeName.Text & "', active='" & active.SelectedValue & "', online='" & online.SelectedValue & "', storePic='" & NewFileName & "' WHERE storeID='" & storeID & "'", SqlCon)
SqlCon.Open()
cmd.ExecuteNonQuery()
SqlCon.Close()
gridStore.EditIndex = -1
loadStore()