Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnInsert.Click
If txtName.Text = "" Then
lblStatus.Text = "กรุณาใส่รายละเอียดให้ครบ"
Else
Dim strConnection As SqlConnection = New SqlConnection("Data Source=WDB-PR0168\SQLEXPRESS;Initial Catalog=ESD_001;Integrated Security=True")
strConnection.Open()
Dim _Update As String = DateTime.Now
Dim Data_insert As String = "INSERT INTO Data_Mini_QST (Fixture_Name,Type,Lacation,Image1,Image2,Image3,Image4,File_Data,Status,Update_) VALUES ('" & txtName.Text & "','" & DropDownList_Type.SelectedItem.Text & "','" & DropDownList_Location.SelectedItem.Text & "','" & "~/Pic_Mini_QST/" + FileUpload1.FileName.ToString & "','" & "~/Pic_Mini_QST/" + FileUpload2.FileName.ToString & "','" & "~/Pic_Mini_QST/" + FileUpload3.FileName.ToString & "','" & "~/Pic_Mini_QST/" + FileUpload4.FileName.ToString & "','" & FileUpload_File.FileName.ToString & "','" & "0" & "','" & _Update & "')"
Dim Query_ As New SqlCommand(Data_insert)
Query_.Connection = strConnection
Query_.ExecuteNonQuery()
Query_.Connection.Close()
copyimage1()
copyimage2()
copyimage3()
copyimage4()
Response.Redirect("Frm_Mini_QST.aspx")
End If
End Sub
Sub copyimage1()
Dim imagefolder As String = "Pic_Mini_QST"
Dim savepath As String
Dim savefile As String
savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder)
savefile = Path.Combine(savepath, FileUpload1.FileName)
FileUpload1.SaveAs(savefile)
End Sub
Sub copyimage2()
Dim imagefolder As String = "Pic_Mini_QST"
Dim savepath As String
Dim savefile As String
savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder)
savefile = Path.Combine(savepath, FileUpload2.FileName)
FileUpload2.SaveAs(savefile)
End Sub
Sub copyimage3()
Dim imagefolder As String = "Pic_Mini_QST"
Dim savepath As String
Dim savefile As String
savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder)
savefile = Path.Combine(savepath, FileUpload3.FileName)
FileUpload3.SaveAs(savefile)
End Sub
Sub copyimage4()
Dim imagefolder As String = "Pic_Mini_QST"
Dim savepath As String
Dim savefile As String
savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder)
savefile = Path.Combine(savepath, FileUpload4.FileName)
FileUpload4.SaveAs(savefile)
End Sub