<%
'-----------------------------
    function getIdParent(con,id)
	dim rez,rs
	rez=""
	set rs=server.createObject("adodb.recordset")
	rs.open "select cat_id from items where id=" & id,con
	while not rs.eof
	    if rs.bof then break
	    rez=rs("cat_id").value
	    rs.moveNext
	wend
	rs.close
	set rs=nothing
	if rez="" then rez=0
	getIdParent=rez
    end function
'--------------------------------
    set con=server.createObject("adodb.connection")
    con.open Application("Product")
    
%>
<html>
<body>
<%
    
    '---------------------------
    'afiseaza pagina de 
    id=request("id")
    if id="" then id=0
%>
<h1 align=center>Modify Product</h1>
<form action="updateProduct.asp?id=<%=id%>" method=post>
<table align=center>
<%
	on error resume next
	set rs=server.createObject("adodb.recordset")
	rs.open "select * from items  where id=" & id,con
	rs.moveFirst
%>
<tr>
<td>Name</td>
<td><input type=text name="txtName" value="<%=rs("Name")%>"></td>
</tr>

<tr>
<td>Description</td>
<td><input type=text  name="txtDescription" value="<%=rs("Description")%>"></td>
</tr>

<tr>
<td>Image</td>
<td><a href="chooseImage.asp?id=<%=id%>">
<% 
    if rs("image")<>"" then
%>
<img src="../../productImages/<%=rs("Image")%>" border=0>
<%
    else    
%>
<font size=2>Choose</font>
<%
    end if
%>
</a></td>
</tr>

<tr>
<td>Remark</td>
<td><input type=text  name="txtRemark" value="<%=rs("remark")%>"></td>
</tr>


<tr>
<td>Price</td>
<td><input type=text  name="txtPrice" value="<%=rs("price")%>"></td>
</tr>

<tr>
<td colspan=2>
    <input type=submit value="Save">
</td>
</tr>
</table>
<%
    parent=getIdParent(con,id)
%>
<input type=hidden name=id value="<%=id%>">
<input type=hidden name=parent value="<%=parent%>">
</form>
<br>
<hr>
<a href="admin.asp?id=<%=parent%>">Back</a>
</body>
</html>
<%
    rs.close
    con.close
    set rs= nothing
    set con=nothing
%>

