DocumentSave.aspx.cs
上传用户:hbbfjy2008
上传日期:2015-02-05
资源大小:5616k
文件大小:4k
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Data.SqlTypes;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace iWebOffice.ocx.c.net
- {
- /// <summary>
- /// DocumentSave 的摘要说明。
- /// </summary>
- public class DocumentSave : System.Web.UI.Page
- {
- string mRecordID="";
- string mTemplate="";
- string mSubject="";
- string mAuthor="";
- string mFileDate="";
- string mFileType="";
- string mHTMLPath="";
- string mStatus="";
- string mError="";
- private iDBManage2000 DBAobj;
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- SqlCommand nCommand;
- string strSelectCmd;
- string strUpdateCmd;
- string strInsertCmd;
- DBAobj=(iDBManage2000)Session["DBDemo"];
- mRecordID=Request.Form["RecordID"] ;
- mTemplate=Request.Form["Template"] ;
- mSubject=Request.Form["Subject"] ;
- mAuthor=Request.Form["Author"] ;
- mFileDate=Request.Form["FileDate"] ;
- mFileType=Request.Form["FileType"] ;
- mHTMLPath=Request.Form["HTMLPath"] ;
- mStatus="READ";
- //保存表单基本信息
- strSelectCmd= "SELECT RecordID from Document Where RecordID='" + mRecordID + "'";
- SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
- SqlDataReader mReader = mCommand.ExecuteReader();
- if (mReader.Read())
- {
- strUpdateCmd="update Document set RecordID=@RecordID,Template=@Template,Subject=@Subject,Author=@Author,FileDate=@FileDate,FileType=@FileType,HtmlPath=@HtmlPath,Status=@Status where RecordID='"+mRecordID+"'";
- nCommand = new SqlCommand(strUpdateCmd, DBAobj.Connection);
- }
- else
- {
- strInsertCmd="insert into Document (RecordID,Template,Subject,Author,FileDate,FileType,HtmlPath,Status) values (@RecordID,@Template,@Subject,@Author,@FileDate,@FileType,@HtmlPath,@Status)";
- nCommand = new SqlCommand(strInsertCmd, DBAobj.Connection);
- }
- mReader.Close();
- try
- {
- nCommand.Parameters.Add(new SqlParameter("@RecordID", SqlDbType.VarChar,16));
- nCommand.Parameters["@RecordID"].Value = mRecordID;
-
- nCommand.Parameters.Add(new SqlParameter("@Template",SqlDbType.VarChar,16));
- nCommand.Parameters["@Template"].Value = mTemplate;
-
- nCommand.Parameters.Add(new SqlParameter("@Subject",SqlDbType.VarChar,32));
- nCommand.Parameters["@Subject"].Value = mSubject;
-
-
- nCommand.Parameters.Add(new SqlParameter("@Author",SqlDbType.VarChar,32));
- nCommand.Parameters["@Author"].Value = mAuthor;
-
- nCommand.Parameters.Add(new SqlParameter("@FileDate",SqlDbType.DateTime));
- nCommand.Parameters["@FileDate"].Value = mFileDate;
-
- nCommand.Parameters.Add(new SqlParameter("@FileType",SqlDbType.VarChar,4));
- nCommand.Parameters["@FileType"].Value = mFileType;
-
- nCommand.Parameters.Add(new SqlParameter("@HtmlPath",SqlDbType.VarChar,64));
- nCommand.Parameters["@HtmlPath"].Value = mHTMLPath;
- nCommand.Parameters.Add(new SqlParameter("@Status",SqlDbType.VarChar,64));
- nCommand.Parameters["@Status"].Value = mStatus;
-
- nCommand.ExecuteNonQuery();
- Response.Redirect ("DocumentList.aspx");
- }
- catch(SqlException ex)
- {
- mError=ex.ToString();
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }