📄 news_upt.aspx
字号:
<!-- #include virtual="/include/PageDirective.inc" -->
<!-- #include virtual="/include/imports.inc" -->
<!-- #include virtual="/include/common_function.inc" -->
<html>
<head>
<link REL="StyleSheet" HREF="/css/standard.css" >
<script language="C#" runat="server">
/*************************************************
* 模块: news_upt.aspx
* 作者: miles
* 修改: 1/30/2001
* 目的: news table maintain
* 参数: none
* 数据: sel: news
* ins: news
* del: news
* upt: none
***************************************************/
private void Page_Load(Object sender, EventArgs E) {
try{
if (IsPostBack)
return;
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);
//SqlCommand myCommand = new SqlCommand("select * from news where news_id='"+Request["news_id"]+"'", myConnection);
//SqlCommand myCommand = new SqlCommand("select * from news where news_id='"+Request.QueryString["news_id"]+"'", myConnection);
SqlCommand myCommand = new SqlCommand("select * from news where news_id='"+Request.Params["news_id"]+"'", myConnection);
SqlDataReader MyReader;
myConnection.Open();
MyReader=myCommand.ExecuteReader();
while (MyReader.Read()){
news_id.Text=MyReader["news_id"].ToString();
news_head.Text=MyReader["news_head"].ToString();
news_body.Text=MyReader["news_body"].ToString();
is_on.Text=MyReader["is_on"].ToString();
post_date.Text=MyReader["post_date"].ToString();
}
if (is_on.Text=="Y")
is_on_list.Items[0].Selected=true;
else
is_on_list.Items[1].Selected=true;
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void BackBtn_Click(Object Sender, EventArgs E) {
try{
Response.Redirect("news.aspx");
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
private void SubmitBtn_Click(Object Sender, EventArgs E) {
try{
if (Page.IsValid){
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["edu"]);;
String updateCmd = "update news set news_head= @news_head"
+", news_body=@news_body"
+", is_on=@is_on"
+", post_date=@post_date"
+" where news_id =@news_id";
SqlCommand myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@news_id", SqlDbType.VarChar, 50));
myCommand.Parameters["@news_id"].Value = news_id.Text;
myCommand.Parameters.Add(new SqlParameter("@news_head", SqlDbType.VarChar, 200));
myCommand.Parameters["@news_head"].Value = news_head.Text;
myCommand.Parameters.Add(new SqlParameter("@news_body", SqlDbType.VarChar,1600));
myCommand.Parameters["@news_body"].Value = news_body.Text;
myCommand.Parameters.Add(new SqlParameter("@is_on", SqlDbType.Char,1));
myCommand.Parameters["@is_on"].Value = is_on_list.SelectedItem.Value;
myCommand.Parameters.Add(new SqlParameter("@post_date", SqlDbType.DateTime));
myCommand.Parameters["@post_date"].Value = post_date.Text;
myConnection.Open();
try {
myCommand.ExecuteNonQuery();
Message.Style["color"] = "black";
Message.InnerHtml = "<b>数据修改:</b><br>数据已成功的在数据库中修改";
}
catch (System.Data.SqlClient.SqlException e) {
SQLErrorHandler(e);
if (e.Number == 2627)
Message.InnerHtml = "ERROR: 代码重复, 请重新输入";
else
Message.InnerHtml = "ERROR: "+e.ToString();
}
myConnection.Close();
}
}
catch (System.Exception e){
ErrorHandler(e.ToString());
}
}
</script>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function pick_date() {
ret=window.open("/qs/calendar.asp?field_name=post_date","QSWindow","toolbar=no,menubar=no,resizable=no,width=320,height=320",false);
return true;
}
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<!-- #include virtual="/include/header.inc" -->
<table width=100% cellspacing=0 cellpadding=0>
<tr>
<td align="center" class="CONTENTTITLE" width="100%" bgcolor="D3C9C7">
最新消息基本数据
</td>
</tr>
<tr>
<td>
<span id="Message" EnableViewState="false" class="MESSAGE" runat="server"/>
</td>
</tr>
</table>
<form runat="server" ACTION="news_upt.aspx" NAME="news_upt" METHOD="post">
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR>
<p>
<div style="padding:15,15,15,15;font-size:10pt;font-family:Verdana">
<TD VALIGN="top" ALIGN="left"><span class="REQUIREDFIELD">最新消息代码:</span>
<TD VALIGN="top" ALIGN="left">
<asp:label id="news_id" runat="server"/></b>
<TR style="background-color:#E7E7E7;">
<TD VALIGN="center" ALIGN="left"><span class="FIELD">最新消息名称: </span><TD VALIGN="top" ALIGN="left"></b><asp:textbox type="text" id="news_head" Width="400px" runat="server"/>
<TR>
<TD VALIGN="center" ALIGN="left"><span class="FIELD">发布日期:</span><TD VALIGN="top" ALIGN="left"><asp:textbox id="post_date" Width="400px" runat="server"/> <a href="#" onclick="javascript:pick_date();return false;">日历</a>
<TR style="background-color:#E7E7E7;">
<TD VALIGN="center" ALIGN="left"><span class="FIELD">上线:</span><TD VALIGN="top" ALIGN="left"><asp:textbox id="is_on" Visible="False" Width="400px" runat="server"/>
<asp:DropDownList id="is_on_list" runat="server">
<asp:ListItem Value="Y">是</asp:ListItem>
<asp:ListItem Value="N">否</asp:ListItem>
</asp:DropDownList>
<TR>
<TD VALIGN="center" ALIGN="left"><span class="FIELD">最新消息描述: </span><TD VALIGN="top" ALIGN="left"><asp:textbox id="news_body" Width="400px" Height="100px" TextMode="Multiline" runat="server"/>
<TR>
<TD VALIGN="center" ALIGN="left"> <asp:Button OnClick="SubmitBtn_Click" Text="储存修改" Runat="server"/>
<TD VALIGN="center" ALIGN="left"> <asp:Button OnClick="BackBtn_Click" Text="回最新消息基本数据维护" Runat="server"/>
</div>
</TABLE>
</form>
<!-- #include virtual="/include/footer.inc" -->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -