%
option explicit
Response.Buffer = true
if session("company_id") <> "" then
dim conn
dim rs
dim ssql
dim sSub_Category_Id
dim sSub_Category_Name
dim sSub_Category_Description
dim sShow_All
dim return_page
%>
<%
sSub_Category_Id = day(now) & month(now) & year(now) & hour(now) & minute(now) & second(now)
sSub_Category_Name = trim(Request.Form("sub_category_name"))
sSub_Category_Description = trim(Request.Form("sub_category_description"))
sShow_All = trim(Request.Form("show_all_item"))
'replace vbCrLf to
if len(sSub_Category_Description) > 0 then
sSub_Category_Description = replace(sSub_Category_Description, vbcrlf, "
", 1, -1, 1)
end if
set rs = server.CreateObject("adodb.recordset")
rs.Open "tbl_sub_category",conn,3,3
'add new data
rs.AddNew
rs.Fields("sub_category_id") = sSub_Category_Id
rs.Fields("sub_category_name") = sSub_Category_Name
rs.Fields("sub_category_description") = sSub_Category_Description
rs.Update
rs.Close
dim SubCatID
ssql = "select * from tbl_sub_category where sub_category_name = '" & sSub_Category_Name & "'"
rs.Open ssql,conn,3,3
sSub_Category_Id = rs("sub_category_id")
rs.Close
set rs = nothing
conn.close
set conn = nothing
dim file
dim objfs
dim objfile
'update data
set objfs = server.CreateObject("scripting.FileSystemObject")
if objfs.FileExists(server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/cat" & sSub_Category_Id & ".txt")) = true then
objfs.DeleteFile server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/cat" & sSub_Category_Id & ".txt"),0
end if
set objfile = objfs.CreateTextFile(server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/cat" & sSub_Category_Id & ".txt"))
objfile.WriteLine sShow_All
objfile.close
set objfile = nothing
return_page = ""
Response.Write return_page
else
Response.Redirect "../../index.asp"
end if
%>