<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!--#include file="Connections/conn_news.asp" -->
<!--#include file="yns_config.asp" -->
<!--#include file="yns_chklogin.asp" -->
<% chk_user_login(2) %>
<!--#include file="yns_chkerror.asp" -->
<%
Dim rsn__MMColParam
rsn__MMColParam = "1"
If (Request.QueryString("n_id") <> "") Then
  rsn__MMColParam = Request.QueryString("n_id")
  else
response.Write yns_err_null
response.End()
End If
%>
<%
Dim rsn
Dim rsn_numRows

Set rsn = Server.CreateObject("ADODB.Recordset")
rsn.ActiveConnection = MM_conn_news_STRING
rsn.Source = "SELECT * FROM t_news WHERE n_id = " + Replace(rsn__MMColParam, "'", "''") + ""
rsn.CursorType = 0
rsn.CursorLocation = 2
rsn.LockType = 1
rsn.Open()

rsn_numRows = 0
%>
<%
if rsn.eof and rsn.bof then
response.Write yns_err_rseof
response.End()
End If
%>
<%
Dim rst
Dim rst_numRows

Set rst = Server.CreateObject("ADODB.Recordset")
rst.ActiveConnection = MM_conn_news_STRING
rst.Source = "SELECT * FROM t_type"
rst.CursorType = 0
rst.CursorLocation = 2
rst.LockType = 1
rst.Open()

rst_numRows = 0
%>
<%
Dim rss
Dim rss_numRows

Set rss = Server.CreateObject("ADODB.Recordset")
rss.ActiveConnection = MM_conn_news_STRING
rss.Source = "SELECT * FROM t_stype"
rss.CursorType = 0
rss.CursorLocation = 2
rss.LockType = 1
rss.Open()

rss_numRows = 0
%>

<%
Dim rsts
Dim rsts_numRows

Set rsts = Server.CreateObject("ADODB.Recordset")
rsts.ActiveConnection = MM_conn_news_STRING
rsts.Source = "SELECT *  FROM t_type_son inner join t_type on t_type_son.ts_pid=t_type.t_id  ORDER BY ts_pid"
rsts.CursorType = 0
rsts.CursorLocation = 2
rsts.LockType = 1
rsts.Open()

rsts_numRows = 0
%>
<%
Dim rsts1
Dim rsts1_numRows

Set rsts1 = Server.CreateObject("ADODB.Recordset")
rsts1.ActiveConnection = MM_conn_news_STRING
rsts1.Source = "SELECT *  FROM t_type_son inner join t_type on t_type_son.ts_pid=t_type.t_id  ORDER BY ts_pid"
rsts1.CursorType = 0
rsts1.CursorLocation = 2
rsts1.LockType = 1
rsts1.Open()

rsts1_numRows = 0
%>
<%
dim mm_ntid
dim mm_ntsid
mm_ntid = (rsn.Fields.Item("n_tid").Value)
mm_ntsid = (rsn.Fields.Item("n_tsid").Value)
'response.Write mm_ntid&"<br>"
'response.Write mm_ntsid
%>
<%
Dim rst1__mmid
rst1__mmid = "0"
If (mm_ntid <> "") Then
  rst1__mmid = mm_ntid
End If
%>
<%
Dim rst1
Dim rst1_numRows

Set rst1 = Server.CreateObject("ADODB.Recordset")
rst1.ActiveConnection = MM_conn_news_STRING
rst1.Source = "SELECT *  FROM t_type  WHERE t_id = " + Replace(rst1__mmid, "'", "''") + ""
rst1.CursorType = 0
rst1.CursorLocation = 2
rst1.LockType = 1
rst1.Open()

rst1_numRows = 0
%>
<%
Dim rsts2__mmid
rsts2__mmid = "0"
If (mm_ntsid <> "") Then
  rsts2__mmid = mm_ntsid
End If
%>
<%
Dim rsts2
Dim rsts2_numRows

Set rsts2 = Server.CreateObject("ADODB.Recordset")
rsts2.ActiveConnection = MM_conn_news_STRING
rsts2.Source = "SELECT *  FROM t_type_son  WHERE ts_id = " + Replace(rsts2__mmid, "'", "''") + ""
rsts2.CursorType = 0
rsts2.CursorLocation = 2
rsts2.LockType = 1
rsts2.Open()

rsts2_numRows = 0
%>
<%
If (rst1.EOF And rst.BOF) or (rsts2.eof and rsts.bof) Then
response.Write yns_err_rseof
response.End()
End If
%>
<%
Dim fname
Dim filepath
dim mm_rnd
fname = rsn("n_fname")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>湖南百润医药有限公司-------康曼德www.hnicp.com</title>
<script language="javascript">
<!--
function mm_makefname(){
var cc;
var c1;
var c2;
var dd;
cc = document.form1.n_date.value;
cc = cc.split(" ");
c1 = cc[0];
c1 = c1.split("-");
c2 = cc[1];
c2 = c2.split(":");
dd = ""
dd +=c1[0];
dd +=c1[1];
dd +=c1[2];
dd +=c2[0];
dd +=c2[1];
dd +=c2[2];
dd += parseInt(Math.random()*8999+1000)
dd +=".htm"
document.form1.n_fname.value=(dd);
}
//-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function makefpath(){
var a;
var b;
var c;
a = document.form1.n_date.value;
b = a.split(" ");
document.form1.n_fpath.value = b[0];
}
//-->
</script>
<script language="javascript">
<!--
function checkdata(){

makefpath()
mm_makefname();

if (document.form1.n_tid.value=="") {
alert ("请选择新闻的大类 ！")
return false
}
if (document.form1.n_tsid.value=="") {
alert ("请选择新闻的小类 ！")
return false
}
if (document.form1.n_title.value=="") {
alert ("请输入新闻标题 ！")
return false
}
if (document.form1.n_author.value=="") {
alert ("请输入新闻作者 ！")
return false
}
return true
}
//-->
</script>
<script>
<!--
function showimg(){
if (document.form1.n_index.checked == true) {
	img.style.display = "";
	advance.innerText="取消首页新闻:"
}else{
	img.style.display = "none";
	advance.innerText="设为首页新闻:"
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<%
dim mm_jsmenu
dim i
i = -1
mm_jsmenu = "<script language="&chr(34)&"javascript"&chr(34)&">"&chr(13)
mm_jsmenu = mm_jsmenu&"<!--"&chr(13)
mm_jsmenu = mm_jsmenu&"var subcat = new Array();"&chr(13)
do while not rsts.eof
i = i + 1
mm_jsmenu = mm_jsmenu&"subcat["&i&"] = new Array('"&(rsts.Fields.Item("ts_pid").Value)&"','"&(rsts.Fields.Item("ts_name").Value)&"','"&(rsts.Fields.Item("ts_id").Value)&"')"&chr(13)
rsts.movenext
loop
mm_jsmenu = mm_jsmenu&chr(13)&"function changeselect1(locationid)"&chr(13)
mm_jsmenu = mm_jsmenu&"{"&chr(13)
mm_jsmenu = mm_jsmenu&"document.form1.n_tsid.length = 0; "&chr(13)
mm_jsmenu = mm_jsmenu&"document.form1.n_tsid.options[0] = new Option('请选择','');"&chr(13)
mm_jsmenu = mm_jsmenu&"for (i=0; i<subcat.length; i++) "&chr(13)
mm_jsmenu = mm_jsmenu&"{"&chr(13)
mm_jsmenu = mm_jsmenu&"if (subcat[i][0] == locationid) "&chr(13)
mm_jsmenu = mm_jsmenu&"{document.form1.n_tsid.options[document.form1.n_tsid.length] = new Option(subcat[i][1], subcat[i][2]);} "&chr(13)
mm_jsmenu = mm_jsmenu&"}"&chr(13)
mm_jsmenu = mm_jsmenu&"}"&chr(13)
mm_jsmenu = mm_jsmenu&"//-->"&chr(13)&"</script>"&chr(13)
response.Write mm_jsmenu
%>
<%
dim mm_ss
dim mm_ss1
mm_ss =(rsn.Fields.Item("n_tid").Value)
i = 0
do while not rsts1.eof
if (rsts1.Fields.Item("t_id").Value) = (rsn.Fields.Item("n_tid").Value) then
i = i + 1
 if (rsts1.Fields.Item("ts_id").Value) = (rsn.Fields.Item("n_tsid").Value) then
 mm_ss1 = i
 end if
end if
rsts1.movenext
loop
%>
<script>
<!--
function mm_select(){

changeselect1(<%=mm_ss%>)
document.form1.n_tsid.selectedIndex = <%=mm_ss1%>
<% if (rsn.Fields.Item("n_index").Value) = 1 then%>
document.form1.n_index.checked = true
showimg()
<% end if %>
}
//-->
</script>
<script>
<!--
function mm_time(){
document.form1.n_date.value ='<%=now()%>';
}
//-->
</script>

<link href="style/css.css" rel="stylesheet" type="text/css">
</head>

<body onLoad="mm_select()">

<form ACTION="yns_nupdata_save.asp" METHOD="POST"   name="form1" id="form1"  >
  <table width="94%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC" class="table-line">
    <tr class="td-title-color">
      <td height="27" colspan="3" nowrap >更新新闻</td>
    </tr>
    <tr class="td-body-color">
      <td width="18%" height="27" align="center" nowrap >类别:</td>
      <td height="27" colspan="2"> <select name="n_tid" class="px12"  onChange="changeselect1(this.value)">
          <option value="" <%If (Not isNull((rsn.Fields.Item("n_tid").Value))) Then If ("" = CStr((rsn.Fields.Item("n_tid").Value))) Then Response.Write("SELECTED") : Response.Write("")%>>请选择</option>
          <%
While (NOT rst.EOF)
%>
          <option value="<%=(rst.Fields.Item("t_id").Value)%>" <%If (Not isNull((rsn.Fields.Item("n_tid").Value))) Then If (CStr(rst.Fields.Item("t_id").Value) = CStr((rsn.Fields.Item("n_tid").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(rst.Fields.Item("t_name").Value)%></option>
          <%
  rst.MoveNext()
Wend
If (rst.CursorType > 0) Then
  rst.MoveFirst
Else
  rst.Requery
End If
%>
        </select> <select name="n_tsid" class="px12" id="n_tsid">
          <option>请选择</option>
        </select> </td>
    </tr>
    <tr class="td-body-color">
      <td width="18%" height="27" align="center" nowrap>标题:</td>
      <td height="27" colspan="2"> <input name="n_title" type="text" style="font-family: 宋体; font-size: 9pt" value="<%=replace(rsn.Fields.Item("n_title").Value,"""","'")%>" size="50">
      </td>
    </tr>
    <tr class="td-body-color">
      <td width="18%" height="27" align="center" nowrap >作者:</td>
      <td height="27" colspan="2"><font color="#F6F6F6">
        <input style="font-family: 宋体; font-size: 9pt" type="text" name="n_author" value="<%=(rsn.Fields.Item("n_author").Value)%>" size="15">
        </font> </td>
    </tr>
    <tr class="td-body-color">
      <td height="27" align="center" nowrap>时间:</td>
      <td height="27" colspan="2" ><input name="n_date" type="text" id="n_date" value="<%=(rsn.Fields.Item("n_date").Value)%>">
        <input type="button" value="取得当前时间" onClick="mm_time()"></td>
    </tr>
  </table>
  <table width="94%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#EFEFEF" class="table-line" id="img" style="display: none">
    <tr>
      <td width="18%" height="27" align="center" nowrap>缩略图:</td>
      <td width="50%" height="27"> <input style="font-family: 宋体; font-size: 9pt"  type="text" name="n_mpic" value="<%=(rsn.Fields.Item("n_mpic").Value)%>" size="32">
      </td>
      <td width="32%" height="27"> <a href="#" onClick="MM_openBrWindow('yns_upload.asp?m=1','上传图片','width=300,height=100')">上传缩略图</a></td>
    </tr>
    <tr>
      <td width="18%" height="27" align="center" nowrap>真实图:</td>
      <td width="50%" height="27"> <input style="font-family: 宋体; font-size: 9pt" type="text" name="n_rpic" value="<%=(rsn.Fields.Item("n_rpic").Value)%>" size="32">
      </td>
      <td width="32%" height="27"> <a href="#" onClick="MM_openBrWindow('yns_upload.asp?m=2','上传图片','width=300,height=100')">上传真实图</a></td>
    </tr>
  </table>
  <table width="94%" border="3" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" class="table-line">
    <tr>
      <td> <iframe ID="eWebEditor1" src="editor/ewebeditor.asp?id=n_content&style=standard" frameborder="0" scrolling="no" width="100%" HEIGHT="350"></iframe>
      </td>
    </tr>
  </table>
  <div align="center"><br>
    <input id=Submit1  type=submit name=Submit1 value="修改完毕,更新新闻" onClick="return checkdata()">
    <input name="n_fpath" type="hidden" id="n_fpath">
    <input name="n_fname" type="hidden" id="n_fname" value="<%=(rsn.Fields.Item("n_fname").Value)%>">
    <input name="n_content" type="hidden" id="n_content" value="<%=Server.HTMLEncode(rsn.Fields.Item("n_content").Value)%>">
    <input name="n_tdir" type="hidden" id="n_tdir" value="<%=(rst1.Fields.Item("t_dir").Value)%>">
    <input name="n_tsdir" type="hidden" id="n_tsdir" value="<%=(rsts2.Fields.Item("ts_dir").Value)%>">
    <input name="n_fpath1" type="hidden" id="n_fpath1" value="<%=(rsn.Fields.Item("n_fpath").Value)%>">
    <input name="n_fname1" type="hidden" id="n_fname1" value="<%=(rsn.Fields.Item("n_fname").Value)%>">
    <input name="n_id" type="hidden" id="n_id" value="<%=request("n_id")%>">
  </div>

  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= rsn.Fields.Item("n_id").Value %>">
</form>
</body>
</html>
<%
rst.Close()
Set rst = Nothing
%>
<%
rss.Close()
Set rss = Nothing
%>
<%
rsn.Close()
Set rsn = Nothing
%>
<%
rsts.Close()
Set rsts = Nothing
%>
<%
rsts1.Close()
Set rsts1 = Nothing
%>
<%
rst1.Close()
Set rst1 = Nothing
%>
<%
rsts2.Close()
Set rsts2 = Nothing
%>