ช่วยอธิบายโค้ดการบันทึกให้หน่อยไก้ไหมคะ
จะขอบคุณมากค่ะ
If (Request("savecardnew") = "บันทึก" ) and ( Session("RidNew_card") <> "") and (Session("RMaxidNew_card") <> "") and (Request("nmcardnew22") <> "") and (Request("nmcardnew23") <> "") and (Request("nmcardnew27") <> "") and (Request("codecardnew42") <> "") then
If (len(Request("nmcardnew27")) >= 13) then
If ( Request("codecardnew42") <> "") then
If (len(Request("codecardnew42")) >= 20) then
codecardnew2_srs = Left(Request("codecardnew42"),instr(Request("codecardnew42"),"#")-1)
codecardnew2_Md = mid(Request("codecardnew42"),instr(Request("codecardnew42"),"#")+1,18)
codecardnew2_model = mid(codecardnew2_Md,1,instr(codecardnew2_Md,"|")-1)
codecardnew2_sfx = mid(codecardnew2_Md,instr(codecardnew2_Md,"|")+1,2)
End If
End if
If (Request("card_fr_date") <> "") and (Request("card_fr_month") <> "") then
card_fr_dt_new = mid(Request("card_fr_month"),3,4)&"/"&Left(Request("card_fr_month"),2)&"/"&Request("card_fr_date")
End if
Chk_card_cd = ""
sql = ""
sql = "Select * From DLR_ACRD"
sql = sql & " Where ACD_FST_NM like '" &Request("nmcardnew22")& "'"
sql = sql & " and ACD_FMLY_NM like '" &Request("nmcardnew23")& "'"
sql = sql & " and ACD_CST_ID = '" &Request("nmcardnew27")& "'"
sql = sql & " and ACD_SRS_CD = '" &codecardnew2_srs& "'"
sql = sql & " and ACD_MOD_CD = '" &codecardnew2_model& "'"
sql = sql & " and ACD_MOD_SFX = '" &codecardnew2_sfx& "'"
sql = sql & " and ACD_CLR_CD = '" &Request("codecardnew43")& "'"
sql = sql & " and ACD_ACRD_DT = '" &card_fr_dt_new& "'"
set rs = conn.execute(sql)
do while not rs.eof
loop
If (Chk_card_cd = "") then
If (Request("card_to_date") <> "") and (Request("card_to_month") <> "") then
card_to_dt_new = mid(Request("card_to_month"),3,4)&"/"&Left(Request("card_to_month"),2)&"/"&Request("card_to_date")
End if
If (Request("card_apmt_date") <> "") and (Request("card_apmt_month") <> "") then
card_apmt_dt_new = mid(Request("card_apmt_month"),3,4)&"/"&Left(Request("card_apmt_month"),2)&"/"&Request("card_apmt_date")
End if
If (Request("nmcardnew26") = "") OR (Request("nmcardnew25") = "") OR (Request("nmcardnew24") = "") then
card_bd_dt_new = NwYear&"/"&NwMonth&"/"&NwDate
Else
card_bd_dt_new = Cstr(Cint("25"&Request("nmcardnew26"))-543)&"/"&Request("nmcardnew25")&"/"&Request("nmcardnew24")
End If
Slsty_card = ""
Slsno_card = ""
If (Request("radiocardnew") <> "") then
Slsty_card = Request("radiocardnew")
If (Slsty_card = "1") then
Slsno_card = "0"
ElseIf (Slsty_card = "2") then
Slsno_card = Request("nmcardnew2")
If (Slsno_card = "") Or (Slsno_card = "0") then
Slsno_card = "0"
End If
End If
End If
If (codecardnew2_srs <> "") and (codecardnew2_model <> "") and (codecardnew2_sfx <> "") then
If (Request("codecardnew4") = "P") and (Request("nmcardnew27") <> "") then
Chk_card_cst_cd = ""
sql = ""
sql = "Select * From DLR_CST_MST"
sql = sql & " Where DCM_CST_ID = '" &Request("nmcardnew27")& "'"
sql = sql & " and DCM_CST_TY_CD = '" &Request("codecardnew21")& "'"
sql = sql & " and DCM_FST_NM = '" &Request("nmcardnew22")& "'"
sql = sql & " and DCM_FMLY_NM = '" &Request("nmcardnew23")& "'"
sql = sql & " and DCM_CST_GRP = 'A' "
set rs = conn.execute(sql)
loop
If (Chk_card_cst_cd = "") then
sql = ""
sql = "Select Max(DCM_CST_MAX) From DLR_CST_MST"
sql = sql & " Where DCM_CST_GRP = 'A' "
set rs = conn.execute(sql)
If (rs("Max(DCM_CST_MAX)") <> "") then
Maxidcard_cst_max = rs("Max(DCM_CST_MAX)")
Else
Maxidcard_cst_max = 0
End If
Maxidcard_cst_max_st = mid(CStr(10000000 + (Cint(Maxidcard_cst_max) +1)),2,7)
Maxidcard_cst_no_st = "A"&mid(CStr(CInt(Request("codecardnew21")) + 100),2,2)&Maxidcard_cst_max_st
If (rs("Max(ACD_ACRD_MAX)") <> "") then
Maxidcard_newst = rs("Max(ACD_ACRD_MAX)")
Else
Maxidcard_newst = 0
End If
Maxidcard_new = mid(CStr(100000 + (Cint(Maxidcard_newst) +1)),2,5)