<% option explicit Response.Buffer = true if session("company_id") <> "" then dim conn dim rs dim ssql dim objUpload dim sImages dim sId dim sCode dim sCategory dim sSub_category dim sModel dim sMemberPrice dim sRetailPrice dim sDetails dim sStatus dim sShow_As_Latest_Product dim FileControler dim myfile dim fsize dim return_page dim item dim value dim file dim Form_Completed dim return_msg %> <% set FileControler = server.CreateObject("Scripting.FileSystemObject") Set objUpload = Server.CreateObject("aspSmartUpload.SmartUpload") objUpload.Upload For each file In objUpload.Files sImages = file.FileName Next 'Select each item in form '************************ For each item In objUpload.Form 'Select each value of the current item '************************************* For each value In objUpload.Form(item) 'get information if item = "product_code" then sCode = value end if if item = "product_category" then sCategory = value end if if item = "product_sub_category" then sSub_category = value end if if item = "product_model" then sModel = value end if if item = "product_member_price" then sMemberPrice = value end if if item = "product_retail_price" then sRetailPrice = value end if if item = "product_details" then sDetails = value end if if item = "product_status" then sStatus = value end if if item = "show_as_latest_product" then sShow_As_Latest_Product = value end if Next Next Form_Completed = true if len(sCategory) = 0 then return_msg = "You should add the category before add a new product" Form_Completed = false end if if len(sSub_category) = 0 then return_msg = "You should add the sub category before add a new product" Form_Completed = false end if if len(sCode) = 0 then return_msg = "Please enter the product code" Form_Completed = false end if if len(sModel) = 0 then return_msg = "Please enter the product name" Form_Completed = false end if if len(sMemberPrice) = 0 then return_msg = "Please enter the product member price" Form_Completed = false else if not isnumeric(sMemberPrice) then return_msg = "Product member price should be numeric only" Form_Completed = false end if end if if len(sRetailPrice) = 0 then return_msg = "Please enter the product retail price" Form_Completed = false if not isnumeric(sRetailPrice) then return_msg = "Product retail price should be numeric only" Form_Completed = false end if end if if len(sImages) > 0 then dim fext fext = lcase(right(sImages,3)) if fext = "jpg" or fext = "gif" or fext = "png" then 'images format correct else return_msg = "Image only support JPG, GIF, PNG format" Form_Completed = false end if end if if Form_Completed = true then sId = day(now) & month(now) & year(now) & hour(now) & minute(now) & second(now) If Len(sImages) > 0 Then sImages = lcase(sImages) objUpload.Save server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") set myfile = FileControler.GetFile(server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sImages) fsize = myfile.size else fsize = 1 End If if fsize >= session("product_image_file_size") then FileControler.DeleteFile server.MapPath("../../../../../member/" & Request.Cookies("storename") & "/images/") & "/" & sImages Response.Write "
" Response.Write "Product not save, image not uploaded!
" Response.Write "Sorry, images size are limited to " & session("display_product_image_file_size") Response.Write "
click here to upload again...
" else if len(sDetails) > 0 then sDetails = replace(sDetails, vbcrlf, "
", 1, -1, 1) end if ssql = "select * from tbl_product where product_code = '" & sCode & "'" set rs = server.CreateObject("adodb.recordset") rs.Open ssql,conn,3,3 if rs.EOF then 'add new data rs.AddNew rs.Fields("product_id") = sId rs.Fields("product_code") = sCode rs.Fields("product_category_id") = sCategory rs.Fields("product_sub_category_id") = sSub_category rs.Fields("product_model") = sModel rs.Fields("product_member_price") = sMemberPrice rs.Fields("product_retail_price") = sRetailPrice rs.Fields("product_details") = sDetails rs.Fields("product_images") = sImages rs.Fields("product_status") = sStatus rs.Fields("show_as_latest_product") = sShow_As_Latest_Product rs.Update rs.Close set rs = nothing return_page = "" Response.Write return_page else Response.Write "
" Response.Write "sorry, duplicate product code found." Response.Write "
click here to modify...
" end if conn.Close set conn = nothing end if set FileControler = nothing else Response.Write "
" Response.Write return_msg Response.Write "
click here to modify...
" end if else Response.Redirect "../../index.asp" end if %>