이 프로그램은 좌석 예약 시스템이며 각 좌석의 가용성을 확인할 때 문제가 있습니다.배열 내의 객체 및 속성 변경
폼이로드되면 배열이 만들어져 시트 이름이 저장됩니다. 각 시트는 버튼으로 표시된 확인란입니다. SQL 문은 실행되고 null 고객 ID 필드, 해당 좌석의 좌석 ID 및 금요일의 표시 날짜가있는 레코드를 찾습니다. 반환되는 레코드 수 = 1이면 확인란의 뒷면 색이 녹색으로 바뀌고 그렇지 않으면 빨간색으로 바뀝니다.
가용성을 확인하는 코드는 완벽하게 작동합니다. 변경하려는 배열의 위치에있는 확인란의 뒤쪽 색상을 변경하는 방법을 모르겠습니다. 배열이 문자열이 아니라 객체를 보유하고 있기 때문이라고 생각합니다. 나는 이것에 대해 많은 연구를 해왔고 해결책을 찾을 수없는 것 같습니다.
필요한 것은 SQL 문에서 사용할 수 있도록 배열에 저장 될 시트 이름 (A1, A2 등)뿐 아니라 해당 시트의 뒤쪽 색상을 변경하는 방법입니다 . 총 197 석이 있기 때문에 배열로이 작업을 수행해야합니다.
나는이 문제에 대한 해결책을 매우 고맙게 생각하며 데이터베이스 테이블의 스크린 샷, 양식 디자인의 스크린 샷 및 코드를 포함하여 아래의 모든 정보를 제공 할 것입니다.
데이터베이스 테이블 : http://gyazo.com/0cf669a1c2144b7174066bdbbd29d3a3
양식 디자인 : http://gyazo.com/b9400018cccd61afb83518e3754df2d4
Private Sub frmSeatPlan_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim seat(11, 15) As String
Dim seatname As String
Dim sql As String
Dim da As OleDb.OleDbDataAdapter
seat(1, 1) = A1.Name
seat(1, 2) = A2.Name
seat(1, 3) = A3.Name
seat(1, 4) = A4.Name
seat(1, 5) = A5.Name
seat(1, 6) = A6.Name
seat(1, 7) = A7.Name
seat(1, 8) = A8.Name
seat(1, 9) = A9.Name
seat(1, 10) = A10.Name
seat(1, 11) = A11.Name
seat(1, 12) = A12.Name
seat(1, 13) = A13.Name
seat(1, 14) = A14.Name
Dim x As Integer
Dim y As Integer
For y = 1 To 1
For x = 1 To 14
seatname = seat(y, x)
con.ConnectionString = dbProvider & dbSource
con.Open() 'opens the connection to the database
sql = "SELECT * FROM Bookings where show_id = 'friday' AND customer_ID is null AND seat_id ='" & seatname & "'"
da = New OleDb.OleDbDataAdapter(sql, con) 'create a data adapter to store the filtered data using the SQL code
MsgBox(sql)
da.Fill(ds, seat(y, x))
'count the number of records with an empty customer id, the show ID of Friday and the seat ID of this seat.
Dim recordCount As Integer
recordCount = ds.Tables(seat(y, x)).Rows.Count
MsgBox(recordCount)
If recordCount = 1 Then
'change backcolor to green
Else
'change backcolor to red
End If
con.Close()
Next x
Next y
End Sub
편집 이전 질문 http://stackoverflow.com/questions/16342882/vb-2010-changing-object-properties-in-a-loop을하기보다는 새로 만들기 – user1937198
@ user1937198 죄송합니다. 이전 질문을 삭제했습니다. 희망이 문제를 해결. – darkjoe31
페이지로드가 페이지 당 197 개의 DB 쿼리로 인해 고가가 될 때까지이 사이트에서 예상하는로드 유형은 무엇입니까? – user1937198