FileA.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:22k
源码类别:

.net编程

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Collections; 
  4. using System.Data.SqlClient;
  5. using qminoa.Common;
  6. using qminoa.DA;    
  7. namespace qminoa.DA
  8. {
  9. public class FileA:IDisposable
  10. {
  11. private SqlDataAdapter dsCommand;
  12. private SqlConnection mySqlConnection;
  13. private const string DOCID_PARM = "@DocID"; 
  14. private const string FOLDERID_PARM     = "@FolderID";
  15. private const string HIFOLDERID_PARM    = "@HiFolderID";
  16. private const string FOLDERNAME_PARM     = "@FolderName";
  17. private const string FNAME_PARM ="@FName";
  18. private const string NOTE_PARM     = "@Note";
  19. private const string IHERCTR_PARM  = "@IherCtr";
  20. private const string CDATE_PARM  = "@CDate";
  21. private const string UDATE_PARM = "@UDate";
  22. private const string EMPID_PARM    = "@EmpID";
  23. private const string DDATE_PARM = "@DDate";
  24. private const string STATUS_PARM = "@Status";
  25. private const string DEMPID_PARM = "@dempid";
  26. private const string KEYWORD_PARM ="@keyword";
  27. private const string TYPEID_PARM ="@typeid";
  28. private const string LAYER_PARM = "@layer";//处理文档时用
  29. private const string FSIZE_PARM="@fsize";
  30. private const string FTYPE_PARM="@ftype";
  31. private const string FPATH_PARM="@fpath";
  32. private const string CONT_PARM="@Cont";
  33. private const string OPT_PARM="@opt";
  34. private const string FIlECONTID_PARM ="@filecontid";
  35. private const string SEARCHTEXT_PARM="@searchtext";
  36. private const string DOCTYPE_PARM="@doctype";
  37. public ArrayList arrlist;
  38. public ArrayList arrlistDoc;
  39. public Stack pathstack;
  40. public  string CONN=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
  41. public FileA()
  42. {
  43. mySqlConnection = new SqlConnection(CONN.ToString());
  44. }
  45. public void Dispose()
  46. {
  47. Dispose(true);
  48. GC.SuppressFinalize(true);
  49. }
  50. protected virtual void Dispose(bool disposing)
  51. {
  52. if (! disposing)
  53. return; 
  54. if (dsCommand != null)
  55. {
  56. if(dsCommand.SelectCommand != null)
  57. {    
  58. if( dsCommand.SelectCommand.Connection != null )
  59. dsCommand.SelectCommand.Connection.Dispose();
  60. dsCommand.SelectCommand.Dispose();
  61. }    
  62. dsCommand.Dispose();
  63. dsCommand = null;
  64. }
  65. }
  66. public FileData GetFolderTree()
  67. {
  68. dsCommand = new SqlDataAdapter("fmLoadFolderTree",CONN);
  69. if ( dsCommand == null )
  70. {
  71. throw new System.ObjectDisposedException( GetType().FullName );
  72. }            
  73. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  74. FileData data = new FileData();
  75. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  76. return data;
  77. }
  78. public FileData LoadFile()
  79. {
  80. dsCommand = new SqlDataAdapter("fmLoadFileInfo",CONN);
  81. if ( dsCommand == null )
  82. {
  83. throw new System.ObjectDisposedException( GetType().FullName );
  84. }            
  85. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  86. FileData data = new FileData();
  87. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  88. return data;
  89. }
  90. public FileData LoadSubFolder(int folderid)
  91. {
  92. mySqlConnection.Open();
  93. dsCommand = new SqlDataAdapter();
  94. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  95. dsCommand.SelectCommand.CommandText="fmloadsubfolder";  
  96. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
  97. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  98. sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int)); 
  99. sqlParams[FOLDERID_PARM].Value=folderid; 
  100. dsCommand.SelectCommand.ExecuteNonQuery();
  101. FileData data = new FileData();
  102. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  103. mySqlConnection.Close(); 
  104. return data;
  105. }
  106. public FileData LoadhiFolder(int folderid)
  107. {
  108. mySqlConnection.Open();
  109. dsCommand = new SqlDataAdapter();
  110. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  111. dsCommand.SelectCommand.CommandText="fmloadhifolderid";  
  112. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
  113. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  114. sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int)); 
  115. sqlParams[FOLDERID_PARM].Value=folderid; 
  116. dsCommand.SelectCommand.ExecuteNonQuery();
  117. FileData data = new FileData();
  118. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  119. mySqlConnection.Close(); 
  120. return data;
  121. }
  122. public  void ChangFolderInfo(int folderid,int hifolderid,string name,string note,DateTime Cdate,bool iherctr,int empid,int TypeId)
  123. {
  124. mySqlConnection.Open(); 
  125. SqlCommand command = mySqlConnection.CreateCommand();
  126. command.CommandText ="fmSaveFolder"; 
  127. command.CommandType =CommandType.StoredProcedure; 
  128. SqlParameterCollection sqlParams = command.Parameters;
  129. sqlParams.Add(new SqlParameter(FOLDERNAME_PARM, SqlDbType.NVarChar,64 ));
  130. sqlParams.Add(new SqlParameter(NOTE_PARM, SqlDbType.NVarChar,128 ));
  131. sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));
  132. sqlParams.Add(new SqlParameter(HIFOLDERID_PARM, SqlDbType.Int));
  133. sqlParams.Add(new SqlParameter(CDATE_PARM, SqlDbType.DateTime));
  134. sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int));
  135. sqlParams.Add(new SqlParameter(IHERCTR_PARM, SqlDbType.Bit));
  136. sqlParams.Add(new SqlParameter(STATUS_PARM,SqlDbType.Bit));  
  137. sqlParams.Add(new SqlParameter(TYPEID_PARM,SqlDbType.Int));  
  138. sqlParams[FOLDERNAME_PARM].Value = name;
  139. sqlParams[NOTE_PARM].Value =note;
  140. sqlParams[FOLDERID_PARM].Value =folderid;
  141. sqlParams[HIFOLDERID_PARM].Value =hifolderid;
  142. sqlParams[CDATE_PARM].Value=Cdate;  
  143. sqlParams[IHERCTR_PARM].Value =iherctr;
  144. sqlParams[EMPID_PARM].Value =empid;
  145. sqlParams[STATUS_PARM].Value =0;
  146. sqlParams[TYPEID_PARM].Value =TypeId;
  147. command.ExecuteNonQuery(); 
  148. mySqlConnection.Close();    
  149. }
  150. public  void ChangDocInfo(int folderid,string name,string note,DateTime Cdate,string keyword,int empid,int TypeId,int layer)
  151. {
  152. mySqlConnection.Open(); 
  153. SqlCommand command = mySqlConnection.CreateCommand();
  154. command.CommandText ="fmSaveDoc"; 
  155. command.CommandType =CommandType.StoredProcedure; 
  156. SqlParameterCollection sqlParams = command.Parameters;
  157. sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));  
  158. sqlParams.Add(new SqlParameter(FNAME_PARM, SqlDbType.NVarChar,64 ));
  159. sqlParams.Add(new SqlParameter(NOTE_PARM, SqlDbType.NVarChar,128 ));
  160. sqlParams.Add(new SqlParameter(CDATE_PARM, SqlDbType.DateTime));
  161. sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int));
  162. sqlParams.Add(new SqlParameter(LAYER_PARM, SqlDbType.Int));
  163. sqlParams.Add(new SqlParameter(TYPEID_PARM,SqlDbType.Int));
  164. sqlParams.Add(new SqlParameter(KEYWORD_PARM,SqlDbType.NVarChar,128)); 
  165. sqlParams.Add(new SqlParameter(STATUS_PARM,SqlDbType.Bit));
  166. sqlParams[FNAME_PARM].Value = name;
  167. sqlParams[NOTE_PARM].Value =note;
  168. sqlParams[FOLDERID_PARM].Value =folderid;
  169. sqlParams[CDATE_PARM].Value=Cdate;  
  170. sqlParams[EMPID_PARM].Value =empid;
  171. sqlParams[TYPEID_PARM].Value =TypeId;
  172. sqlParams[KEYWORD_PARM].Value =keyword;
  173. sqlParams[LAYER_PARM].Value =layer;
  174. sqlParams[STATUS_PARM].Value =0;
  175. command.ExecuteNonQuery(); 
  176. mySqlConnection.Close();    
  177. }
  178. public FileData LoadDocFolder(int FolderID)
  179. {
  180. mySqlConnection.Open(); 
  181. dsCommand = new SqlDataAdapter();
  182. if ( dsCommand == null )
  183. {
  184. throw new System.ObjectDisposedException( GetType().FullName );
  185. }            
  186. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  187. dsCommand.SelectCommand.Parameters.Add(FOLDERID_PARM,SqlDbType.Int);
  188. dsCommand.SelectCommand.Parameters[FOLDERID_PARM].Value=FolderID;  
  189. dsCommand.SelectCommand.CommandText="fmLoadDoc";  
  190. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  191. dsCommand.SelectCommand.ExecuteNonQuery();
  192.    FileData data = new FileData();
  193. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  194. mySqlConnection.Close(); 
  195. return data;
  196. }
  197. public FileData GetAllTypes()
  198. {
  199. mySqlConnection.Open(); 
  200. dsCommand = new SqlDataAdapter();
  201. if ( dsCommand == null )
  202. {
  203. throw new System.ObjectDisposedException( GetType().FullName );
  204. }
  205. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  206. dsCommand.SelectCommand.CommandText="fmGetAllTypes";  
  207. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  208. dsCommand.SelectCommand.ExecuteNonQuery();
  209. FileData data = new FileData();
  210. dsCommand.Fill(data,FileData.FMFILEATT_TABLE);
  211. mySqlConnection.Close(); 
  212. return data;
  213. }
  214. public FileData SeachAllDocs(int flag)
  215. {
  216. mySqlConnection.Open(); 
  217. dsCommand = new SqlDataAdapter();
  218. if ( dsCommand == null )
  219. {
  220. throw new System.ObjectDisposedException(GetType().FullName );
  221. }
  222. SqlCommand command = mySqlConnection.CreateCommand();
  223. command.CommandText ="fmSeachAllDocs"; 
  224. command.CommandType =CommandType.StoredProcedure; 
  225. SqlParameterCollection sqlParams = command.Parameters;
  226. sqlParams.Add(new SqlParameter("@flag", SqlDbType.Int));
  227. sqlParams["@flag"].Value = flag;
  228. dsCommand.SelectCommand= command;
  229. dsCommand.SelectCommand.ExecuteNonQuery();
  230. FileData data = new FileData();
  231. dsCommand.Fill(data,FileData.FMDOC_TABLE );
  232. mySqlConnection.Close(); 
  233. return data;
  234. }
  235. public FileData ShowAllFileCont()
  236. {
  237. mySqlConnection.Open();
  238. dsCommand = new SqlDataAdapter();
  239. if ( dsCommand == null )
  240. {
  241. throw new System.ObjectDisposedException( GetType().FullName );
  242. }
  243. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  244. dsCommand.SelectCommand.CommandText="fmGetAllFileCont";  
  245. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  246. dsCommand.SelectCommand.ExecuteNonQuery();
  247. FileData data = new FileData();
  248. dsCommand.Fill(data,FileData.FILECONT_TABLE);
  249. mySqlConnection.Close(); 
  250. return data;
  251. }
  252. public FileData GetNullFileCont()
  253. {
  254. mySqlConnection.Open();
  255. dsCommand = new SqlDataAdapter();
  256. if ( dsCommand == null )
  257. {
  258. throw new System.ObjectDisposedException( GetType().FullName );
  259. }
  260. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  261. dsCommand.SelectCommand.CommandText="fmGetNullFileCont";  
  262. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  263. dsCommand.SelectCommand.ExecuteNonQuery();
  264. FileData data = new FileData();
  265. dsCommand.Fill(data,FileData.FILECONT_TABLE);
  266. mySqlConnection.Close(); 
  267. return data;
  268. }
  269. public void InsertFileCont(int docid,string fname,string fpath,int size,string ftype,byte[] filecont,string dtype)
  270. {
  271. mySqlConnection.Open();
  272. SqlCommand command = mySqlConnection.CreateCommand();
  273. command.CommandText ="fmInsertFileCont"; 
  274. command.CommandType =CommandType.StoredProcedure; 
  275. SqlParameterCollection sqlParams = command.Parameters;
  276. sqlParams.Add(new SqlParameter(DOCID_PARM, SqlDbType.Int)); 
  277. sqlParams.Add(new SqlParameter(FNAME_PARM, SqlDbType.NVarChar,64 ));
  278. sqlParams.Add(new SqlParameter(FSIZE_PARM, SqlDbType.Int));
  279. sqlParams.Add(new SqlParameter(FTYPE_PARM, SqlDbType.NVarChar,128));
  280. sqlParams.Add(new SqlParameter(FPATH_PARM, SqlDbType.NVarChar,128));
  281. sqlParams.Add(new SqlParameter(CONT_PARM, SqlDbType.Image));
  282. sqlParams.Add(new SqlParameter(DOCTYPE_PARM,SqlDbType.NVarChar,10));
  283. sqlParams[DOCID_PARM].Value = docid;
  284. sqlParams[FNAME_PARM].Value = fname;
  285. sqlParams[FSIZE_PARM].Value = size;
  286. sqlParams[FPATH_PARM].Value = fpath;
  287. sqlParams[FTYPE_PARM].Value = ftype;
  288. sqlParams[CONT_PARM].Value = filecont;
  289. sqlParams[DOCTYPE_PARM].Value = dtype;
  290. command.ExecuteNonQuery(); 
  291. mySqlConnection.Close();     
  292. }
  293. public void DeleteFolder(int folderid,int empid,int flag)
  294. {
  295. mySqlConnection.Open();
  296. SqlCommand command = mySqlConnection.CreateCommand();
  297. command.CommandText ="fmFolderDelFlag"; 
  298. command.CommandType =CommandType.StoredProcedure; 
  299. SqlParameterCollection sqlParams = command.Parameters;
  300. sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int)); 
  301. sqlParams.Add(new SqlParameter(FOLDERID_PARM, SqlDbType.Int));   
  302. sqlParams.Add(new SqlParameter("@flag", SqlDbType.Int)); 
  303. sqlParams[EMPID_PARM].Value=empid;
  304. sqlParams[FOLDERID_PARM].Value=folderid;
  305. sqlParams["@flag"].Value=flag; 
  306. command.ExecuteNonQuery(); 
  307. mySqlConnection.Close();  
  308. }
  309. public void DeleteDoc(int Docid,int empid)
  310. {
  311. mySqlConnection.Open();
  312. SqlCommand command = mySqlConnection.CreateCommand();
  313. command.CommandText ="fmDocDelFlag"; 
  314. command.CommandType =CommandType.StoredProcedure; 
  315. SqlParameterCollection sqlParams = command.Parameters;
  316. sqlParams.Add(new SqlParameter(EMPID_PARM, SqlDbType.Int)); 
  317. sqlParams.Add(new SqlParameter(DOCID_PARM, SqlDbType.Int));   
  318. sqlParams[EMPID_PARM].Value=empid;
  319. sqlParams[DOCID_PARM].Value=Docid;
  320. command.ExecuteNonQuery(); 
  321. mySqlConnection.Close();  
  322. }
  323. public ArrayList GetDelFolderId(int folderid)
  324. {
  325. arrlist =new ArrayList();
  326. arrlist.Add(folderid);
  327. DataView dvdata = SubFolderView(folderid);
  328. AddToArrlist(arrlist,dvdata);
  329. return arrlist;
  330. }
  331. public static DataView SubFolderView(int folderid)
  332. {
  333. FileData filedata =(new FileA()).LoadhiFolder(folderid); 
  334. DataView dvdata =filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;  
  335. return dvdata;
  336. }
  337. private  static void  AddToArrlist(ArrayList arrlist,DataView dvdata)
  338. {
  339. int recordId; 
  340. int recordcount;
  341. int i;
  342. recordcount=dvdata.Count;
  343. if(recordcount!=0)
  344. {
  345. for(i=0;i<recordcount ;i++)
  346. {
  347. recordId = Convert.ToInt32(dvdata[i].Row[0].ToString()); 
  348. arrlist.Add(recordId);
  349. DataView dv = SubFolderView(recordId);
  350. AddToArrlist(arrlist,dv);
  351. }
  352. }
  353. }
  354. public ArrayList GetDelDocId(ArrayList arrlist)
  355. {
  356. int i;
  357. int j;
  358. FileData filedata;
  359. arrlistDoc=new ArrayList();          
  360. for(i=0;i<arrlist.Count;i++)
  361. {
  362. int fid=Convert.ToInt32(arrlist[i].ToString(),10) ;
  363. filedata=SeachAllDocs(0);
  364. DataView dvdata = filedata.Tables[FileData.FMDOC_TABLE].DefaultView;  
  365. if(dvdata.Count!=0)
  366. {
  367. dvdata.RowFilter= "FolderId="+fid;
  368. int recordcount =dvdata.Count;
  369. for(j=0;j<recordcount;j++)
  370. {
  371. int recordid=Convert.ToInt32(dvdata[j].Row[0].ToString(),10);  
  372. arrlistDoc.Add(recordid); 
  373. }
  374. }
  375. }
  376. return arrlistDoc;
  377. }
  378. public ArrayList GetDelDocIdForReuse(ArrayList arrlist)
  379. {
  380. int i;
  381. int j;
  382. FileData filedata;
  383. arrlistDoc=new ArrayList();          
  384. for(i=0;i<arrlist.Count;i++)
  385. {
  386. int fid=Convert.ToInt32(arrlist[i].ToString(),10) ;
  387. filedata=SeachAllDocs(1);
  388. DataView dvdata = filedata.Tables[FileData.FMDOC_TABLE].DefaultView;  
  389. if(dvdata.Count!=0)
  390. {
  391. dvdata.RowFilter= "FolderId="+fid;
  392. int recordcount =dvdata.Count;
  393. for(j=0;j<recordcount;j++)
  394. {
  395. int recordid=Convert.ToInt32(dvdata[j].Row[0].ToString(),10);  
  396. arrlistDoc.Add(recordid); 
  397. }
  398. }
  399. }
  400. return arrlistDoc;
  401. }
  402. public FileData LoadRecycleFile()
  403. {
  404. dsCommand = new SqlDataAdapter("fmLoadRecycleFileInfo",CONN);
  405. if ( dsCommand == null )
  406. {
  407. throw new System.ObjectDisposedException( GetType().FullName );
  408. }            
  409. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  410. FileData data = new FileData();
  411. dsCommand.Fill(data,FileData.FMDOC_TABLE);
  412. return data;
  413. }
  414. public void DoRecycle(int opt,int docid)
  415. {
  416. mySqlConnection.Open();
  417. SqlCommand command = mySqlConnection.CreateCommand();
  418. command.CommandText ="fmDoRecycle";
  419. command.CommandType =CommandType.StoredProcedure; 
  420. SqlParameterCollection sqlParams = command.Parameters;
  421. sqlParams.Add(new SqlParameter(OPT_PARM, SqlDbType.Int)); 
  422. sqlParams.Add(new SqlParameter(DOCID_PARM, SqlDbType.Int));   
  423. sqlParams[OPT_PARM].Value=opt;
  424. sqlParams[DOCID_PARM].Value=docid;
  425. command.ExecuteNonQuery(); 
  426. mySqlConnection.Close();  
  427. }
  428. public string GetDocPath(int folderid)
  429. {
  430. int id=folderid;
  431. string path="C:";
  432. pathstack=new Stack();
  433. if(id==0)
  434. {
  435. return path+"\";
  436. }
  437. else
  438. {
  439. pathstack.Push(id);
  440. int fid=gethifolderid(id);
  441. if(fid==0)
  442. {
  443. path=path+"\"+FileA.getfoldername(id);
  444. }
  445. else
  446. {
  447. pathstack.Push(fid);
  448.  
  449. id=fid;
  450. while(fid!=0)
  451. {   
  452. fid=gethifolderid(id);
  453. pathstack.Push(fid);
  454. id=fid;
  455. }
  456. pathstack.Pop();
  457. int recordcount=pathstack.Count;
  458. for(int j=0;j<recordcount;j++)
  459. {
  460. int foldid=Convert.ToInt32(pathstack.Pop()); 
  461. if(foldid!=0)
  462. {
  463. path=path+"\"+FileA.getfoldername(foldid);
  464. }
  465. }
  466. }
  467. return path;
  468. }
  469. }
  470. public static int gethifolderid(int folderid)
  471. {
  472. FileData filedata = (new FileA()).LoadSubFolder(folderid); 
  473. DataView dv=filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
  474. int hifolder=Convert.ToInt32(dv[0].Row[2].ToString(),10);
  475. return hifolder;
  476. }
  477. public static string getfoldername(int folderid)
  478. {  
  479. FileData filedata = (new FileA()).LoadSubFolder(folderid); 
  480. DataView dv=filedata.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView;
  481. string name=dv[0].Row[15].ToString();  
  482. return name;
  483. }
  484. public void DeleteFileCont(int filecontId)
  485. {
  486. mySqlConnection.Open();
  487. SqlCommand command = mySqlConnection.CreateCommand();
  488. command.CommandText ="fmDeleteFileCont";// 
  489. command.CommandType =CommandType.StoredProcedure; 
  490. SqlParameterCollection sqlParams = command.Parameters;
  491. sqlParams.Add(new SqlParameter(FIlECONTID_PARM, SqlDbType.Int)); 
  492. sqlParams[FIlECONTID_PARM].Value=filecontId;
  493. command.ExecuteNonQuery(); 
  494. mySqlConnection.Close();  
  495. }
  496. public void MoveFolder(int folderform,int folderto)
  497. {
  498. mySqlConnection.Open();
  499. SqlCommand command = mySqlConnection.CreateCommand();
  500. command.CommandText ="fmMoveFolder";// 
  501. command.CommandType =CommandType.StoredProcedure; 
  502. SqlParameterCollection sqlParams = command.Parameters;
  503. sqlParams.Add(new SqlParameter("@folderfrom", SqlDbType.Int)); 
  504. sqlParams.Add(new SqlParameter("@folderto", SqlDbType.Int)); 
  505. sqlParams["@folderfrom"].Value=folderform;
  506. sqlParams["@folderto"].Value=folderto;
  507. command.ExecuteNonQuery(); 
  508. mySqlConnection.Close();  
  509. }
  510. public void UpdateFileCont()
  511. {
  512. mySqlConnection.Open();
  513. SqlCommand command = mySqlConnection.CreateCommand();
  514. command.CommandText ="fmUpdateFileCont";// 
  515. command.CommandType =CommandType.StoredProcedure; 
  516. SqlParameterCollection sqlParams = command.Parameters;
  517. sqlParams.Add(new SqlParameter(DOCID_PARM, SqlDbType.Int)); 
  518. sqlParams.Add(new SqlParameter(OPT_PARM, SqlDbType.Int)); 
  519. sqlParams[DOCID_PARM].Value=0;
  520. sqlParams[OPT_PARM].Value=1;
  521. command.ExecuteNonQuery(); 
  522. mySqlConnection.Close();  
  523. }
  524. public void MoveDoc(int docid,int folderid)
  525. {
  526. mySqlConnection.Open();
  527. SqlCommand command = mySqlConnection.CreateCommand();
  528. command.CommandText ="fmMoveDoc";// 
  529. command.CommandType =CommandType.StoredProcedure; 
  530. SqlParameterCollection sqlParams = command.Parameters;
  531. sqlParams.Add(new SqlParameter(DOCID_PARM,SqlDbType.Int)); 
  532. sqlParams.Add(new SqlParameter(FOLDERID_PARM,SqlDbType.Int)); 
  533. sqlParams[DOCID_PARM].Value=docid;
  534. sqlParams[FOLDERID_PARM].Value=folderid;
  535. command.ExecuteNonQuery(); 
  536. mySqlConnection.Close();  
  537. }
  538. public void DeleteRight(int conid,int opt)
  539. {
  540. mySqlConnection.Open();
  541. SqlCommand command = mySqlConnection.CreateCommand();
  542. command.CommandText ="fmDeleteFolderRight";
  543. command.CommandType =CommandType.StoredProcedure; 
  544. SqlParameterCollection sqlParams = command.Parameters;
  545. sqlParams.Add(new SqlParameter("@ConId", SqlDbType.Int)); 
  546. sqlParams["@ConId"].Value=conid;
  547. sqlParams.Add(new SqlParameter("@opt", SqlDbType.Int)); 
  548. sqlParams["@opt"].Value=opt;
  549. command.ExecuteNonQuery(); 
  550. mySqlConnection.Close();  
  551. }
  552. public FileData SearchForDoc(string name,string keyword,string content,string empname)
  553. {
  554. mySqlConnection.Open();
  555. dsCommand = new SqlDataAdapter();
  556. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  557. dsCommand.SelectCommand.CommandText="fmSearchDoc";  
  558. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
  559. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  560. sqlParams.Add(new SqlParameter("@docname", SqlDbType.NVarChar,50)); 
  561. sqlParams["@docname"].Value="%"+name+"%";
  562. sqlParams.Add(new SqlParameter("@keyword", SqlDbType.NVarChar,50)); 
  563. sqlParams["@keyword"].Value="%"+keyword+"%";
  564. sqlParams.Add(new SqlParameter("@content", SqlDbType.NVarChar,50)); 
  565. sqlParams["@content"].Value=content;
  566. sqlParams.Add(new SqlParameter("@empname", SqlDbType.NVarChar,50)); 
  567. sqlParams["@empname"].Value="%"+empname+"%";
  568. dsCommand.SelectCommand.ExecuteNonQuery();
  569. FileData data = new FileData();
  570. dsCommand.Fill(data,FileData.FMDOCFOLDER_TABLE);
  571. int count=data.Tables[FileData.FMDOCFOLDER_TABLE].DefaultView.Count;   
  572. mySqlConnection.Close(); 
  573. return data;
  574. }
  575. public string GetEmpName(int empid)
  576. {
  577. mySqlConnection.Open();
  578. dsCommand = new SqlDataAdapter();
  579. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  580. dsCommand.SelectCommand.CommandText="fmGetMrBaseInfo";  
  581. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  582. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  583. sqlParams.Add(new SqlParameter("@opt", SqlDbType.Int)); 
  584. sqlParams["@opt"].Value=2;
  585. DataTable data = new DataTable();
  586. dsCommand.Fill(data);
  587. string empname;
  588. DataView dv=data.DefaultView;
  589. dv.RowFilter="Empid="+empid; 
  590. if(dv.Count!=0)
  591. {
  592. empname=dv[0].Row[1].ToString();   
  593. }
  594. else
  595. {
  596. empname="";
  597. }
  598. return empname;
  599. }
  600. }
  601. }