SignatureEditFrm.aspx.cs
上传用户:hbbfjy2008
上传日期:2015-02-05
资源大小:5616k
文件大小:6k
- 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>
- /// SignatureEditFrm 的摘要说明。
- /// </summary>
- public class SignatureEditFrm : System.Web.UI.Page
- {
- protected System.Web.UI.HtmlControls.HtmlInputButton Submit1;
- protected System.Web.UI.HtmlControls.HtmlInputHidden SignatureID;
- protected System.Web.UI.HtmlControls.HtmlInputText UserName;
- protected System.Web.UI.HtmlControls.HtmlInputText PassWord;
- protected System.Web.UI.HtmlControls.HtmlInputFile MarkFile;
- protected System.Web.UI.HtmlControls.HtmlInputText MarkName;
- protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
- string mSignatureID;
- protected System.Web.UI.WebControls.Label Status;
- private iDBManage2000 DBAobj;
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
-
- DBAobj=(iDBManage2000)Session["DBDemo"];
-
- if (this.IsPostBack)
- {
- mSignatureID=SignatureID.Value;
- }
- else
- {
- mSignatureID=Request["SignatureID"].ToString();
- string strSelectCmd="select SignatureID,UserName,PassWord,MarkName from Signature where SignatureID = " + mSignatureID;
- SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
- SqlDataReader mReader = mCommand.ExecuteReader();
- if (mReader.Read())
- {
- SignatureID.Value = mReader["SignatureID"].ToString() ;
- UserName.Value = mReader["UserName"].ToString() ;
- PassWord.Value = mReader["PassWord"].ToString() ;
- MarkName.Value = mReader["MarkName"].ToString() ;
- }
- mReader.Close();
- }
- }
- #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.Submit1.ServerClick += new System.EventHandler(this.Submit1_ServerClick);
- this.Button1.ServerClick += new System.EventHandler(this.Button1_ServerClick);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- 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 Submit1_ServerClick(object sender, System.EventArgs e)
- {
- string mUserName;
- string mPassWord;
- string mMarkName;
- byte[] mMarkBody;
- int mMarkSize;
- string mMarkType;
- DateTime mMarkDate;
- 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 strUpdateCmd;
- string strSelectCmd= "select MarkName from Signature where SignatureID<>" + mSignatureID + " and 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)
- {
- strUpdateCmd="update Signature set UserName=@UserName,PassWord=@PassWord,MarkName=@MarkName,MarkType=@MarkType,MarkBody=@MarkBody,MarkSize=@MarkSize,MarkDate=@MarkDate WHERE SignatureID=" + mSignatureID ;
- nCommand = new SqlCommand(strUpdateCmd, 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");
- }
- else
- {
- Status.Text = "标签名称重复!";
- }
- }
- private void Button1_ServerClick(object sender, System.EventArgs e)
- {
- string strDeleteCmd= "Delete from Signature where SignatureID=" + mSignatureID;
- SqlCommand mCommand = new SqlCommand(strDeleteCmd,DBAobj.Connection);
- mCommand.ExecuteNonQuery();
- Response.Redirect("SignatureList.aspx");
- }
- }
- }