⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personalsign.cs

📁 很不错的公文流转系统
💻 CS
字号:
using System;
using System.Data .SqlClient ;
using System.Data ;
using System.Text ;
namespace OI.cs
{
	/// <summary>
	/// personalSign 的摘要说明。
	/// </summary>
	
	public class personalSign
	{   
		private string Userid;
		private OI.DatabaseOper .DatabaseConnect Dbc=new OI.DatabaseOper.DatabaseConnect ();
		private DataRow dr;
		public int UserID
		{
			set 
			{
               Userid=value.ToString ();
			}
		}
		public string PassWord
		{
			get 
			{
				if (dr==null)
				{
					CreateDataSource();
				}
				
				string s= System.Text.UTF8Encoding .UTF8.GetString ((byte[])dr["password"]) ;
				return s;

			}
		}
		public string LastTimeChange
		{
			get 
			{
				
				CreateDataSource();
				return dr["lastTimeChange"].ToString ();
				
			}
		}
		public string UserName
		{
			get 
			{
				try
				{
					string str=" select username from accounts_users where userid="+Userid;
					object o=Dbc.GetObjectBySql(str);  
					return o.ToString ();
				}
				catch
				{
				}
				return "";
			}
		}
		public personalSign()
		{

		}
		public personalSign(int userid)
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			if (userid.ToString ()==null || userid.ToString ()=="")
				return;
			else
				Userid=userid.ToString ();
			
		}
		private void CreateDataSource()
		{
			if (Userid ==null || Userid =="")
			{
				throw new ApplicationException ("请输入一个用户");
			}
			string str="select * from personalSign where userid="+Userid;
			DataTable dt ;
			try
			{
				dt=Dbc.getBinding (str,"t").Tables[0];
			}
			catch(Exception er)
			{
				throw new AppException (er.Message );
			}
			if (dt.Rows .Count <1)
			{
				throw new ApplicationException ("此用户还没有私章");
			}
			dr=dt.Rows[0];
		}
		/// <summary>
		/// 改变个人私章数据.
		/// </summary>
		/// <param name="Bpassword">密码,byte[]型.</param>
		/// <param name="Bsign">私章,byte[]型</param>
		public void ChangeData(byte[]Bpassword,byte[]Bsign)
		{
			string str ="select count(*) from personalSign where userid="+Userid;
			try
			{
				int i=int.Parse (Dbc.GetValueBySql (str));
				if (i <1)
				{
					AddDate(Bpassword,Bsign);
				}
				else
				{
					UpData(Bpassword,Bsign);
				}
			}
			catch(Exception er)
			{
				throw new ApplicationException (er.Message );
			}
		}
		/// <summary>
		/// 更改个人私章
		/// </summary>
		/// <param name="Bpassword"></param>
		/// <param name="Bsign"></param>
		private void UpData(byte[]Bpassword,byte[]Bsign)
		{
			try
			{
				SqlCommand command =new SqlCommand(); 
				SqlConnection conn=Dbc.GetConn(); 
				command.Connection =conn;
				//			SqlTransaction  transact =conn.BeginTransaction ();
				//			command.Transaction =transact;
				command.CommandText ="update personalSign set password=@password ,lastTimeChange=@lastTimeChange where userID="+Userid;
			
				command.Parameters.Add (new SqlParameter("@password",SqlDbType.VarBinary  ,Bpassword.Length ,"password"));
				command.Parameters["@password"].Value =Bpassword;
            
				command.Parameters .Add (new SqlParameter ("@lastTimeChange",SqlDbType.SmallDateTime  ,8,"lastTimeChange"));
				command.Parameters["@lastTimeChange"].Value =System.DateTime .Now;
				command.ExecuteNonQuery ();
				if (Bsign != null)
				{
					int upfileLength =Bsign.Length ;
					if (upfileLength >0)
					{
					   
						command.CommandText ="update personalSign set personalSign=@sign where userID="+Userid;
						command.Parameters.Add (new SqlParameter("@sign",SqlDbType.Image ,upfileLength,"personalSign"));
						command.Parameters["@sign"].Value =Bsign;
						command.ExecuteNonQuery ();
					}
				}
				//				transact.Commit ();
			}
			catch (Exception er)
			{
				throw new  ApplicationException (er.Message );
			}

		}
		/// <summary>
		/// 增加个人私章
		/// </summary>
		/// <param name="Bpassword"></param>
		/// <param name="Bsign"></param>
		private void AddDate(byte[]Bpassword,byte[]Bsign)
		{
			SqlCommand command =new SqlCommand(); 
			SqlConnection conn=Dbc.GetConn(); 
			command.Connection =conn;
			SqlTransaction  transact =conn.BeginTransaction ();
			command.Transaction =transact;
			command.CommandText ="insert into personalSign (userid,password,lastTimeChange) values (@userid,@password ,@lastTimeChange) ";
			
			command.Parameters.Add (new SqlParameter("@password",SqlDbType.VarBinary  ,Bpassword.Length ,"password"));
			command.Parameters["@password"].Value =Bpassword;
            
			command.Parameters .Add (new SqlParameter ("@lastTimeChange",SqlDbType.SmallDateTime  ,8,"lastTimeChange"));
			command.Parameters["@lastTimeChange"].Value =System.DateTime .Now ;
			
              
			command.Parameters .Add (new SqlParameter ("@userid",SqlDbType.Int ,4,"userid"));
			command.Parameters["@userid"].Value =Userid;
            command.ExecuteNonQuery ();

			int upfileLength =Bsign.Length ;
			if (upfileLength >0)
			{
					   
				command.CommandText ="update personalSign set personalSign=@sign where userID="+Userid;
				command.Parameters.Add (new SqlParameter("@sign",SqlDbType.Image ,upfileLength,"personalSign"));
				command.Parameters["@sign"].Value =Bsign;
				command.ExecuteNonQuery ();
			}
			try
			{
				transact.Commit ();
			}
			catch (Exception er)
			{
				throw new  ApplicationException (er.Message );
			}

		}
		/// <summary>
		/// 显示个人印章
		/// </summary>
		public string  Displayimg()
		{
			string displaySign;
			string sql="select personalSign from personalSign where UserID="+Userid;
			object o=Dbc.GetObjectBySql(sql);
			if (o==null || o.ToString ()=="")
			{
				displaySign="";

			}
			else
			{
				displaySign="<img  border=0 id=persionSign src=displayimg.aspx?id="+Userid +">";
			}
			return displaySign;
		}
		/// <summary>
		/// 显示个人印章,在校核的地方调用
		/// </summary>
		public string  Displayimg(bool isCheck) {
			string displaySign;
			string sql="select personalSign from personalSign where UserID="+Userid;
			object o=Dbc.GetObjectBySql(sql);
			if (o==null || o.ToString ()=="") {
				displaySign="";

			}
			else {
				displaySign="<img  border=0 id=persionSign src=../manage/displayimg.aspx?id="+Userid +">";
			}
			return displaySign;
		}


		/// <summary>
		/// 将该用户的私章密码设为初始值。
		/// </summary>
		/// <returns></returns>
		public void recoveryPassword()
		{
			byte [] bpassword =System.Text .Encoding .UTF8 .GetBytes("1111");
			byte [] Bsign=null;
		
			try
			{
				UpData(bpassword,Bsign);

			}
			catch(Exception er)
			{
				throw new ApplicationException (er.Message);
			}
			
			
		}
		public byte[] TransactPassword(string password)
		{
			
			return null;
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -