If (Request("searchdata") = "ค้นหา") then
sql = ""
sql = "Select * From DLR_ORD_BKG,DLR_SLSM_MST,DSP_SRS_MST,DSP_MOD_MST,DSP_CLR_MST,DLR_SLSM_TEAM_MST,VSC_INV_INFO "
sql = sql & " Where DLR_ORD_BKG.DOB_SLSM_CD = DLR_SLSM_MST.SLM_SLSM_CD "
sql = sql & " and DLR_ORD_BKG.DOB_SRS_CD = DSP_SRS_MST.SMT_SRS_CD "
sql = sql & " and DLR_ORD_BKG.DOB_SRS_CD = DSP_MOD_MST.MMT_SRS_CD "
sql = sql & " and DLR_ORD_BKG.DOB_MOD_CD = DSP_MOD_MST.MMT_MOD_CD "
sql = sql & " and DLR_ORD_BKG.DOB_MOD_SFX = DSP_MOD_MST.MMT_MOD_SFX "
sql = sql & " and DLR_ORD_BKG.DOB_CLR_CD = DSP_CLR_MST.CMT_CLR_CD"
sql = sql & " and DLR_SLSM_MST.SLM_TEAM_CD = DLR_SLSM_TEAM_MST.STM_TEAM_CD "
sql = sql & " and DLR_ORD_BKG.DOB_VIN_NO = VSC_INV_INFO.IVI_VIN_NO "
End if
If ( codedata2 <> "") then
If (len(codedata2) >= 20) then
codedata2_srs = Left(codedata2,instr(codedata2,"#")-1)
codedata2_Md = mid(codedata2,instr(codedata2,"#")+1,18)
codedata2_model = mid(codedata2_Md,1,instr(codedata2_Md,"|")-1)
codedata2_sfx = mid(codedata2_Md,instr(codedata2_Md,"|")+1,2)
End If
If ( codedata2_srs <> "") then
sql = sql & " and DOB_SRS_CD = '" &codedata2_srs& "' "
End If
If ( codedata2_model <> "") then
sql = sql & " and DOB_MOD_CD = '" &codedata2_model& "' "
End If
If ( codedata2_sfx <> "") then
sql = sql & " and DOB_MOD_SFX = '" &codedata2_sfx& "' "
End If
End if
If ( codedata3<> "") then
sql = sql & " and DOB_CLR_CD = '" & codedata3& "' "
End if
If ( codedata4<> "") then
sql = sql & " and STM_TEAM_CD = '" & codedata4& "' "
End if
If ( codedata5<> "") then
sql = sql & " and DOB_SLSM_CD = '" & codedata5& "' "
End if
sql = sql & " Order by DOB_SRS_CD,DOB_MOD_CD,DOB_MOD_SFX,DOB_CLR_CD"
set rs = conn.execute(sql)
do while not rs.eof
Countstdata = Countstdata + 1
Session("txtdatast3") = rs("SMT_SRS_NM")
If (rs("DOB_SRE_TY") = "1") then
txtdatast1 = "Ordinary"
ElseIF (rs("DOB_SRE_TY") = "2") then
txtdatast1 = "Fleet"
End If
Response.Write "<td bgcolor=""#EFEFEF""><div align=""center"">"&txtdatast1&"</div></td>"
If (rs("DOB_BKG_STS_CD") = "W") Or (rs("DOB_BKG_STS_CD") = "w") then
txtdatast2 = "รอการอนุมัติ"
ElseIF (rs("DOB_BKG_STS_CD") = "A") Or (rs("DOB_BKG_STS_CD") = "a") then
txtdatast2 = "อนุมัติ"
ElseIF (rs("DOB_BKG_STS_CD") = "F") Or (rs("DOB_BKG_STS_CD") = "f") then
txtdatast2 = "จัดไฟแนนซ์ผ่าน"
ElseIF (rs("DOB_BKG_STS_CD") = "M") Or (rs("DOB_BKG_STS_CD") = "m") then
txtdatast2 = "จัดสรรรถยนต์"
ElseIF (rs("DOB_BKG_STS_CD") = "S") Or (rs("DOB_BKG_STS_CD") = "s") then
txtdatast2 = "มีกำหนดวันที่ออกรถ"
ElseIF (rs("DOB_BKG_STS_CD") = "R") Or (rs("DOB_BKG_STS_CD") = "r") then
txtdatast2 = "ส่งมอบรถ"
ElseIF (rs("DOB_BKG_STS_CD") = "G") Or (rs("DOB_BKG_STS_CD") = "g") then
txtdatast2 = "ยกเลิกใบจอง"
ElseIF (rs("DOB_BKG_STS_CD") = "D") Or (rs("DOB_BKG_STS_CD") = "d") then
txtdatast2 = "ไ่ม่ดำเนินการใดๆ"
End If
Response.Write "<td bgcolor=""#EFEFEF""><div align=""center"">"&txtdatast2&"</div></td>"
Response.Write "<td bgcolor=""#EFEFEF""><div align=""center"">"&rs("DOB_VIN_NO")&"</div></td>"
Response.Write "<td bgcolor=""#EFEFEF""><div align=""center"">"&rs("IVI_INV_DT")&"</div></td>"
Response.Write "</tr>"
rs.movenext
loop
set rs = nothing
End IF
%>
' check ว่าเขาได้ใส่เงืื่อนไขในการค้นหาข้อมูลของเงื่อนไขที่ 2 หรือเปล่า ถ้าใช่ต้องเอามาใส่ในเงื่อนไข where
If ( codedata2 <> "") Then
If (len(codedata2) >= 20) then
codedata2_srs = Left(codedata2,instr(codedata2,"#")-1)
codedata2_Md = mid(codedata2,instr(codedata2,"#")+1,18)
codedata2_model = mid(codedata2_Md,1,instr(codedata2_Md,"|")-1)
codedata2_sfx = mid(codedata2_Md,instr(codedata2_Md,"|")+1,2)
End If
If ( codedata2_srs <> "") then
sql = sql & " and DOB_SRS_CD = '" &codedata2_srs& "' "
End If
If ( codedata2_model <> "") then
sql = sql & " and DOB_MOD_CD = '" &codedata2_model& "' "
End If
If ( codedata2_sfx <> "") then
sql = sql & " and DOB_MOD_SFX = '" &codedata2_sfx& "' "
End If
End if
If ( codedata3<> "") then
sql = sql & " and DOB_CLR_CD = '" & codedata3& "' "
End if
If ( codedata4<> "") then
sql = sql & " and STM_TEAM_CD = '" & codedata4& "' "
End if
If ( codedata5<> "") then
sql = sql & " and DOB_SLSM_CD = '" & codedata5& "' "
End if
sql = sql & " Order by DOB_SRS_CD,DOB_MOD_CD,DOB_MOD_SFX,DOB_CLR_CD"
' ทำการ connect กับ database
set rs = conn.execute(sql)
' check เงื่อนไขของ loop ในกรณีที่ข้อมูลที่เรา select ออกมามีหลายเรคคอร์ด
'ในขณะที่ยังไม่หมดเรคคอร์ด
do while not rs.eof