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

📄 filea.cs

📁 专业的办公oa代码下载 c#语言编写 三层结构
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Data;
using System.Collections; 
using System.Data.SqlClient;


using qminoa.Common;
using qminoa.DA;    
namespace qminoa.DA
{
	public class FileA:IDisposable
	{
		private SqlDataAdapter dsCommand;
		private SqlConnection mySqlConnection;

		private const string DOCID_PARM = "@DocID"; 
		private const string FOLDERID_PARM     = "@FolderID";
		private const string HIFOLDERID_PARM    = "@HiFolderID";
		private const string FOLDERNAME_PARM     = "@FolderName";
		private const string FNAME_PARM ="@FName";
		private const string NOTE_PARM     = "@Note";
		private const string IHERCTR_PARM  = "@IherCtr";
		private const string CDATE_PARM  = "@CDate";
		private const string UDATE_PARM = "@UDate";
		private const string EMPID_PARM    = "@EmpID";
		private const string DDATE_PARM = "@DDate";
		private const string STATUS_PARM = "@Status";
		private const string DEMPID_PARM = "@dempid";
		private const string KEYWORD_PARM ="@keyword";
		private const string TYPEID_PARM ="@typeid";
		private const string LAYER_PARM = "@layer";//处理文档时用
		private const string FSIZE_PARM="@fsize";
		private const string FTYPE_PARM="@ftype";
		private const string FPATH_PARM="@fpath";
		private const string CONT_PARM="@Cont";
		private const string OPT_PARM="@opt";
		private const string FIlECONTID_PARM ="@filecontid";
		private const string SEARCHTEXT_PARM="@searchtext";
		private const string DOCTYPE_PARM="@doctype";
		public ArrayList arrlist;
		public ArrayList arrlistDoc;
		public Stack pathstack;
		public  string CONN=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
		
		public FileA()
		{
			mySqlConnection = new SqlConnection(CONN.ToString());
		}
		public void Dispose()
		{
			Dispose(true);
			GC.SuppressFinalize(true);
		}
		
		protected virtual void Dispose(bool disposing)
		{
			if (! disposing)
				return; 

			if (dsCommand != null)
			{
				if(dsCommand.SelectCommand != null)
				{    
					if( dsCommand.SelectCommand.Connection != null )
						dsCommand.SelectCommand.Connection.Dispose();
					dsCommand.SelectCommand.Dispose();
				}    
				dsCommand.Dispose();
				dsCommand = null;
			}
		}

		public FileData GetFolderTree()
		{
			dsCommand = new SqlDataAdapter("fmLoadFolderTree",CONN);
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}            
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
			return data;
		}

		public FileData LoadFile()
		{
			dsCommand = new SqlDataAdapter("fmLoadFileInfo",CONN);
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}            
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
			return data;
		}

		public FileData LoadSubFolder(int folderid)
		{
			mySqlConnection.Open();
			dsCommand = new SqlDataAdapter();
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.CommandText="fmloadsubfolder";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
			sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int)); 
			sqlParams[FOLDERID_PARM].Value=folderid; 
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
			mySqlConnection.Close(); 
			return data;
		}

		public FileData LoadhiFolder(int folderid)
		{
			mySqlConnection.Open();
			dsCommand = new SqlDataAdapter();
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.CommandText="fmloadhifolderid";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
			sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int)); 
			sqlParams[FOLDERID_PARM].Value=folderid; 
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
			mySqlConnection.Close(); 
			return data;
		}

		public  void ChangFolderInfo(int folderid,int hifolderid,string name,string note,DateTime Cdate,bool iherctr,int empid,int TypeId)
		{
			mySqlConnection.Open(); 
			SqlCommand command = mySqlConnection.CreateCommand();
			command.CommandText ="fmSaveFolder"; 
			command.CommandType =CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = command.Parameters;
			sqlParams.Add(new SqlParameter(FOLDERNAME_PARM, SqlDbType.NVarChar,64 ));
			sqlParams.Add(new SqlParameter(NOTE_PARM, SqlDbType.NVarChar,128 ));
			sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(HIFOLDERID_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(CDATE_PARM, SqlDbType.DateTime));
			sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(IHERCTR_PARM, SqlDbType.Bit));
			sqlParams.Add(new SqlParameter(STATUS_PARM,SqlDbType.Bit));  
			sqlParams.Add(new SqlParameter(TYPEID_PARM,SqlDbType.Int));  
			sqlParams[FOLDERNAME_PARM].Value = name;
			sqlParams[NOTE_PARM].Value =note;
			sqlParams[FOLDERID_PARM].Value =folderid;
			sqlParams[HIFOLDERID_PARM].Value =hifolderid;
			sqlParams[CDATE_PARM].Value=Cdate;  
			sqlParams[IHERCTR_PARM].Value =iherctr;
			sqlParams[EMPID_PARM].Value =empid;
			sqlParams[STATUS_PARM].Value =0;
			sqlParams[TYPEID_PARM].Value =TypeId;
			command.ExecuteNonQuery(); 
			mySqlConnection.Close();    
		}
		
		public  void ChangDocInfo(int folderid,string name,string note,DateTime Cdate,string keyword,int empid,int TypeId,int layer)
		{
			mySqlConnection.Open(); 
			SqlCommand command = mySqlConnection.CreateCommand();
			command.CommandText ="fmSaveDoc"; 
			command.CommandType =CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = command.Parameters;
			sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));  
			sqlParams.Add(new SqlParameter(FNAME_PARM, SqlDbType.NVarChar,64 ));
			sqlParams.Add(new SqlParameter(NOTE_PARM, SqlDbType.NVarChar,128 ));
			sqlParams.Add(new SqlParameter(CDATE_PARM, SqlDbType.DateTime));
			sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(LAYER_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(TYPEID_PARM,SqlDbType.Int));
			sqlParams.Add(new SqlParameter(KEYWORD_PARM,SqlDbType.NVarChar,128)); 
			sqlParams.Add(new SqlParameter(STATUS_PARM,SqlDbType.Bit));
			sqlParams[FNAME_PARM].Value = name;
			sqlParams[NOTE_PARM].Value =note;
			sqlParams[FOLDERID_PARM].Value =folderid;
			sqlParams[CDATE_PARM].Value=Cdate;  
			sqlParams[EMPID_PARM].Value =empid;
			sqlParams[TYPEID_PARM].Value =TypeId;
			sqlParams[KEYWORD_PARM].Value =keyword;
			sqlParams[LAYER_PARM].Value =layer;
			sqlParams[STATUS_PARM].Value =0;
			command.ExecuteNonQuery(); 
			mySqlConnection.Close();    
		}
		
		public FileData LoadDocFolder(int FolderID)
		{
			mySqlConnection.Open(); 
			dsCommand = new SqlDataAdapter();
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}            
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.Parameters.Add(FOLDERID_PARM,SqlDbType.Int);
			dsCommand.SelectCommand.Parameters[FOLDERID_PARM].Value=FolderID;  
			dsCommand.SelectCommand.CommandText="fmLoadDoc";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			dsCommand.SelectCommand.ExecuteNonQuery();
  			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
			mySqlConnection.Close(); 
			return data;
		}
		
		public FileData GetAllTypes()
		{
			mySqlConnection.Open(); 
			dsCommand = new SqlDataAdapter();
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.CommandText="fmGetAllTypes";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMFILEATT_TABLE);
			mySqlConnection.Close(); 
			return data;
		}

		public FileData SeachAllDocs(int flag)
		{
			mySqlConnection.Open(); 
			dsCommand = new SqlDataAdapter();
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException(GetType().FullName );
			}
			SqlCommand command = mySqlConnection.CreateCommand();
			command.CommandText ="fmSeachAllDocs"; 
			command.CommandType =CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = command.Parameters;
			sqlParams.Add(new SqlParameter("@flag", SqlDbType.Int));
			sqlParams["@flag"].Value = flag;
			dsCommand.SelectCommand= command;
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FMDOC_TABLE );
			mySqlConnection.Close(); 
			return data;
		}

		public FileData ShowAllFileCont()
		{
			mySqlConnection.Open();
			dsCommand = new SqlDataAdapter();
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.CommandText="fmGetAllFileCont";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FILECONT_TABLE);
			mySqlConnection.Close(); 
			return data;
		}

		public FileData GetNullFileCont()
		{
			mySqlConnection.Open();
			dsCommand = new SqlDataAdapter();
			if ( dsCommand == null )
			{
				throw new System.ObjectDisposedException( GetType().FullName );
			}
			dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
			dsCommand.SelectCommand.CommandText="fmGetNullFileCont";  
			dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
			dsCommand.SelectCommand.ExecuteNonQuery();
			FileData data = new FileData();
			dsCommand.Fill(data,FileData.FILECONT_TABLE);
			mySqlConnection.Close(); 
			return data;
		}

		public void InsertFileCont(int docid,string fname,string fpath,int size,string ftype,byte[] filecont,string dtype)
		{
			mySqlConnection.Open();
			SqlCommand command = mySqlConnection.CreateCommand();
			command.CommandText ="fmInsertFileCont"; 
			command.CommandType =CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = command.Parameters;
			sqlParams.Add(new SqlParameter(DOCID_PARM, SqlDbType.Int)); 
			sqlParams.Add(new SqlParameter(FNAME_PARM, SqlDbType.NVarChar,64 ));
			sqlParams.Add(new SqlParameter(FSIZE_PARM, SqlDbType.Int));
			sqlParams.Add(new SqlParameter(FTYPE_PARM, SqlDbType.NVarChar,128));
			sqlParams.Add(new SqlParameter(FPATH_PARM, SqlDbType.NVarChar,128));
			sqlParams.Add(new SqlParameter(CONT_PARM, SqlDbType.Image));
			sqlParams.Add(new SqlParameter(DOCTYPE_PARM,SqlDbType.NVarChar,10));
			sqlParams[DOCID_PARM].Value = docid;
			sqlParams[FNAME_PARM].Value = fname;
			sqlParams[FSIZE_PARM].Value = size;
			sqlParams[FPATH_PARM].Value = fpath;
			sqlParams[FTYPE_PARM].Value = ftype;
			sqlParams[CONT_PARM].Value = filecont;
			sqlParams[DOCTYPE_PARM].Value = dtype;
			command.ExecuteNonQuery(); 
			mySqlConnection.Close();     
		}
		
		public void DeleteFolder(int folderid,int empid,int flag)
		{
			mySqlConnection.Open();
			SqlCommand command = mySqlConnection.CreateCommand();
			command.CommandText ="fmFolderDelFlag"; 
			command.CommandType =CommandType.StoredProcedure; 
			SqlParameterCollection sqlParams = command.Parameters;
			sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int)); 
			sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));   
			sqlParams.Add(new SqlParameter("@flag", SqlDbType.Int)); 
			sqlParams[EMPID_PARM].Value=empid;
			sqlParams[FOLDERID_PARM].Value=folderid;

⌨️ 快捷键说明

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