CMS Traffic Systems Ltd. - Traffic Solutions
<%
if session("userid1")="" then
Response.Redirect "Login.asp?page=UploadProduct"
end if
Function ReplaceName(Name)
Dim LeftStr , RightStr
Dim SingleFound ,AtPlace
AtPlace = InStr(1, Name, "'")
If AtPlace > 0 Then
SingleFound = True
LeftStr = Left(Name, InStr(AtPlace, Name, "'") - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace, Name, "'"))
While SingleFound = True
If InStr(AtPlace + 1, Name, "'") > 0 Then
LeftStr = LeftStr & Mid(Name, AtPlace + 1, InStr(AtPlace + 1, Name, "'") - AtPlace - 1) & "''"
RightStr = Right(Name, Len(Name) - InStr(AtPlace + 1, Name, "'"))
AtPlace = InStr(AtPlace + 1, Name, "'")
SingleFound = True
Else
SingleFound = False
End If
Wend
ReplaceName = LeftStr & RightStr
Else
ReplaceName = Name
End If
End Function
%>
<%
set conn1 = Server.CreateObject("adodb.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("tsl.mdb")
conn1.open connstr
mode=Request.QueryString("mode")
if mode <>"" then
cat_id=Request.QueryString("cat_id")
prod_id=Request.QueryString("prod_id")
prod_name=Request.Form("prod_name")
prod_img=Request.Form("prod_img")
prod_introduction=Request.Form("prod_introduction")
prod_shortintro=Request.Form("prod_shortintro")
prod_feature=Request.Form("prod_feature")
prod_down=Request.Form("prod_down")
prod_display=Request.QueryString("disp")
end if
if mode="Add" then
if prod_display="Yes" then
flag="Y"
strsql="update product_mast set prod_homedisplay='No'"
conn1.Execute strsql
strsql="insert into product_mast(cat_id,prod_name,prod_img,prod_introduction,prod_shortintro,prod_feature,prod_downtech,prod_homedisplay"
strsql=strsql&") values "
strsql=strsql&"("&cat_id&","&"'"&ReplaceName(prod_name)&"','"&ReplaceName(prod_img)&"','"&ReplaceName(prod_introduction)&"','"&ReplaceName(prod_shortintro)&"','"&ReplaceName(prod_feature)&"','"&ReplaceName(prod_down)&"','"&ReplaceName(prod_display)&"')"
else
flag="Y"
strsql="insert into product_mast(cat_id,prod_name,prod_img,prod_introduction,prod_shortintro,prod_feature,prod_downtech,prod_homedisplay"
strsql=strsql&") values "
strsql=strsql&"("&cat_id&","&"'"&ReplaceName(prod_name)&"','"&ReplaceName(prod_img)&"','"&ReplaceName(prod_introduction)&"','"&ReplaceName(prod_shortintro)&"','"&ReplaceName(prod_feature)&"','"&ReplaceName(prod_down)&"','"&prod_display&"')"
end if
end if
if mode="Modify" then
if prod_display="Yes" then
flag="Y"
flag="Y"
strsql="update product_mast set prod_homedisplay='No'"
conn1.Execute strsql
strsql="update product_mast set prod_name='"&ReplaceName(prod_name)&"',prod_img='"&prod_img
strsql=strsql&"',prod_introduction='"&ReplaceName(prod_introduction)&"',prod_shortintro='"&ReplaceName(prod_shortintro)&"',prod_feature='"&ReplaceName(prod_feature)&"',prod_downtech='"&ReplaceName(prod_down)&"',prod_homedisplay='"&prod_display
strsql=strsql&"'"
strsql=strsql&" where prod_id="&prod_id
else
flag="Y"
strsql="update product_mast set prod_name='"&ReplaceName(prod_name)&"',prod_img='"&prod_img
strsql=strsql&"',prod_introduction='"&ReplaceName(prod_introduction)&"',prod_shortintro='"&ReplaceName(prod_shortintro)&"',prod_feature='"&ReplaceName(prod_feature)&"',prod_downtech='"&ReplaceName(prod_down)&"',prod_homedisplay='"&prod_display
strsql=strsql&"'"
strsql=strsql&" where prod_id="&prod_id
end if
end if
if mode="Delete" then
flag="Y"
strsql="Delete from product_mast where cat_id="&cat_id&" and prod_id="&prod_id
end if
if flag="Y" then
conn1.Execute strsql
end if
%>