<!--#include virtual = "/common/lib/dbcon.asp" -->
<!--#include virtual = "/common/lib/func.asp" -->
<%
Dim bdm_idx, info_url, bdm_depth, bdm_code, bdm_ref, bdm_menuname, bdm_t_clr, bdm_ro_clr, bdm_chk, bdm_wdate
Dim prepage

prepage			= request.form("prepage")
bdm_idx			= inputValue( request.form("bdm_idx") )
bdm_ref			= inputValue( request.form("bdm_ref") )
bdm_menuname	= inputValue( request.form("bdm_menuname") )
bdm_chk			= inputValue( request.form("bdm_chk") )

If bdm_idx = "" Then		'저장

	'depth
	sql = "select top 1 bdm_depth from bd_menu_page where bdm_idx = '" & bdm_ref & "'"
	Set rs = dbcon.execute( sql )
	If rs.bof Or rs.eof Then
		bdm_depth = 1
	Else
		bdm_depth = rs(0) + 1
	End if
	Set rs = nothing

	'code
	sql = "select top 1 bdm_code from bd_menu_page order by bdm_code desc"
	Set rs = dbcon.execute( sql )
	If rs.bof Or rs.eof Then
		bdm_code = 1
	Else
		bdm_code = rs(0) + 1
	End If
	Set rs = nothing


	info_url		= ""
	bdm_t_clr		= "#ffffff"
	bdm_ro_clr		= "#f4f4f4"
	bdm_chk			= "Y"
	bdm_wdate		= Date() & " " &  Right("0" & hour(now), 2) & ":" & Right("0" & minute(now), 2)


	r_fields_s = "info_url, bdm_depth, bdm_code, bdm_ref, bdm_menuname, bdm_t_clr, bdm_ro_clr, bdm_chk, bdm_wdate"
	Call InsertQuery(r_fields_s, "bd_menu_page")

Else

	r_fields_u = "bdm_menuname, bdm_chk"
	Call UpdateQuery( r_fields_u, "bd_menu_page", "where bdm_idx = '" & bdm_idx & "'" )


End if

%>
<script type="text/javascript">
//<![CDATA[
parent.document.getElementById("tree").src = "tree.asp";
location.href= "<%=prepage%>";
//]]>
</script>
