SignatureAddFrm.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.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.Signature
- {
- /// <summary>
- /// SignatureAddFrm 的摘要说明。
- /// </summary>
- public class SignatureAddFrm : System.Web.UI.Page
- {
-
- string mUserName;
- string mPassWord;
- string mMarkName;
- byte[] mMarkBody;
- int mMarkSize;
- string mMarkType;
- DateTime mMarkDate;
- protected System.Web.UI.HtmlControls.HtmlInputFile MarkFile;
- protected System.Web.UI.HtmlControls.HtmlInputText UserName;
- protected System.Web.UI.HtmlControls.HtmlInputText PassWord;
- protected System.Web.UI.HtmlControls.HtmlInputText MarkName;
- private iDBManage2000 DBAobj;
- private string ExtName(string FileName)
- {
- string mFileName;
- string mExtName;
- int mLastIndex,mExtLength;
-
- mExtName="";
- mFileName=FileName;
- if (mFileName!="")
- {
- mLastIndex=mFileName.LastIndexOf(".");
- mExtLength=mFileName.Length - mLastIndex;
- mExtName= mFileName.Substring(mLastIndex,mExtLength);
- }
- return (mExtName);
- }
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- DBAobj=(iDBManage2000)Session["DBDemo"];
- // 在此处放置用户代码以初始化页面
- if (this.IsPostBack)
- {
- mUserName=UserName.Value;
- mPassWord=PassWord.Value;
- mMarkName=MarkName.Value;
- mMarkBody=new Byte[MarkFile.PostedFile.ContentLength];
- MarkFile.PostedFile.InputStream.Read(mMarkBody,0,MarkFile.PostedFile.ContentLength);
- mMarkSize=MarkFile.PostedFile.ContentLength;
- mMarkType=ExtName(MarkFile.PostedFile.FileName);
- mMarkDate=System.DateTime.Now;
-
- bool mResult=false;
- SqlCommand nCommand;
- string strInsertCmd;
- string strSelectCmd= "select MarkName from Signature where MarkName='" + mMarkName + "'";
- SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
- SqlDataReader mReader = mCommand.ExecuteReader();
- if (mReader.Read())
- {
- mResult=false;
- }
- else
- {
- mResult=true;
- }
- mReader.Close();
- if (mResult)
- {
- strInsertCmd="insert into Signature (UserName,PassWord,MarkName,MarkType,MarkBody,MarkSize,MarkDate) values (@UserName,@PassWord,@MarkName,@MarkType,@MarkBody,@MarkSize,@MarkDate)";
- nCommand = new SqlCommand(strInsertCmd, DBAobj.Connection);
- nCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar,16));
- nCommand.Parameters["@UserName"].Value = mUserName;
-
- nCommand.Parameters.Add(new SqlParameter("@PassWord",SqlDbType.VarChar,32));
- nCommand.Parameters["@PassWord"].Value = mPassWord;
-
- nCommand.Parameters.Add(new SqlParameter("@MarkName",SqlDbType.VarChar,64));
- nCommand.Parameters["@MarkName"].Value = mMarkName;
-
-
- nCommand.Parameters.Add(new SqlParameter("@MarkBody",SqlDbType.Image));
- nCommand.Parameters["@MarkBody"].Value = mMarkBody;
-
-
- nCommand.Parameters.Add(new SqlParameter("@MarkSize",SqlDbType.Int));
- nCommand.Parameters["@MarkSize"].Value = mMarkSize;
- nCommand.Parameters.Add(new SqlParameter("@MarkType",SqlDbType.VarChar,4 ));
- nCommand.Parameters["@MarkType"].Value = mMarkType;
-
- nCommand.Parameters.Add(new SqlParameter("@MarkDate",SqlDbType.DateTime));
- nCommand.Parameters["@MarkDate"].Value = mMarkDate;
- nCommand.ExecuteNonQuery();
-
- Response.Redirect("SignatureList.aspx");
- }
- }
- }
- #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
- }
- }