?? updatedocument.aspx.cs
字號:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using OfficeAutomatization;
public partial class UpdateDocument : System.Web.UI.Page
{
int nDocumentID = -1;
protected void Page_Load(object sender, EventArgs e)
{
///獲取ID的值
if (Request.Params["DocumentID"] != null)
{
nDocumentID = Int32.Parse(Request.Params["DocumentID"].ToString());
}
if (!Page.IsPostBack)
{
///綁定控件的數(shù)據(jù)
if (nDocumentID > -1)
{
///綁定控件的數(shù)據(jù)
BindDocumentData(nDocumentID);
}
}
///設置更新按鈕的可用性
UpdateBtn.Enabled = nDocumentID <= -1 ? false : true;
}
private void BindDocumentData(int nDocumentID)
{
///獲取數(shù)據(jù)
Document document = new Document();
SqlDataReader recd = document.GetSingleDocument(nDocumentID);
///讀取數(shù)據(jù)
if (recd.Read())
{
///顯示數(shù)據(jù)
Desn.Text = recd["Desn"].ToString();
Body.Text = recd["Body"].ToString();
Author.Text = recd["Author"].ToString();
FromSource.Text = recd["FromSource"].ToString();
Remark.Text = recd["Remark"].ToString();
}
recd.Close(); ///關閉數(shù)據(jù)源
}
protected void UpdateBtn_Click(object sender, EventArgs e)
{
///如果頁面輸入內(nèi)容合法
if (Page.IsValid == true)
{
///定義類
OfficeAutomatization.Document document = new OfficeAutomatization.Document();
try
{
///修改數(shù)據(jù)
document.UpdateDocument(nDocumentID,Desn.Text.Trim(),Body.Text,
Author.Text.Trim(),FromSource.Text,Remark.Text);
///顯示操作結(jié)果信息
Response.Write("<script>window.alert('" + ASPNET2System.OPERATIONUPDATESUCCESSMESSAGE + "')</script>");
}
catch (Exception ex)
{
///顯示修改操作中的失敗、錯誤信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ ASPNET2System.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n", " "));
}
}
}
protected void ReturnBtn_Click(object sender, EventArgs e)
{
///返回管理頁面
Response.Redirect("~/DesktopModules/Document/DocumentManage.aspx");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -