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

.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. /// <summary>
  10. /// AdressList 的摘要说明。
  11. /// </summary>
  12. public class AdList:IDisposable
  13. {
  14. private SqlDataAdapter dsCommand;
  15. private SqlConnection mySqlConnection;
  16. public  string CONN=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
  17. public AdList()
  18. {
  19. mySqlConnection = new SqlConnection(CONN.ToString());
  20. }
  21. public void Dispose()
  22. {
  23. Dispose(true);
  24. GC.SuppressFinalize(true); // as a service to those who might inherit from us
  25. }
  26. protected virtual void Dispose(bool disposing)
  27. {
  28. if (! disposing)
  29. return; 
  30. if (dsCommand != null)
  31. {
  32. if(dsCommand.SelectCommand != null)
  33. {    
  34. if( dsCommand.SelectCommand.Connection != null )
  35. dsCommand.SelectCommand.Connection.Dispose();
  36. dsCommand.SelectCommand.Dispose();
  37. }    
  38. dsCommand.Dispose();
  39. dsCommand = null;
  40. }
  41. }
  42. public DataTable GetEmpAddress(int opt)
  43. {
  44. mySqlConnection.Open();
  45. dsCommand = new SqlDataAdapter();
  46. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  47. dsCommand.SelectCommand.CommandText="fmGetMrBaseInfo";  
  48.            
  49. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  50. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  51. sqlParams.Add(new SqlParameter("@opt", SqlDbType.Int)); 
  52. sqlParams["@opt"].Value=opt;
  53. DataTable data = new DataTable();
  54. dsCommand.Fill(data);
  55. return data;
  56. }
  57. public DataTable GetDepInfo()
  58. {
  59. dsCommand = new SqlDataAdapter("fmGetmrDepartment",CONN);
  60. //判断空则抛出异常
  61. if ( dsCommand == null )
  62. {
  63. throw new System.ObjectDisposedException( GetType().FullName );
  64. }            
  65. //公共层对象
  66.            
  67. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  68.           
  69. DataTable data = new DataTable();
  70. dsCommand.Fill(data);
  71. return data;
  72.   
  73. }
  74. public DataTable GetCompanyAddress()
  75. {
  76. dsCommand = new SqlDataAdapter("AdGetCompanyInfo",CONN);
  77. //判断空则抛出异常
  78. if ( dsCommand == null )
  79. {
  80. throw new System.ObjectDisposedException( GetType().FullName );
  81. }            
  82. //公共层对象
  83.            
  84. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure;   
  85.           
  86. DataTable data = new DataTable();
  87. dsCommand.Fill(data);
  88. return data;
  89. }
  90. public DataTable GetPersonalAddress(int empid,int opt)
  91. {  
  92. mySqlConnection.Open();
  93. dsCommand = new SqlDataAdapter();
  94. dsCommand.SelectCommand =  mySqlConnection.CreateCommand();
  95. dsCommand.SelectCommand.CommandText="AdGetPersonalList";  
  96. dsCommand.SelectCommand.CommandType=CommandType.StoredProcedure; 
  97. SqlParameterCollection sqlParams = dsCommand.SelectCommand.Parameters;
  98. sqlParams.Add(new SqlParameter("@empid", SqlDbType.Int)); 
  99. sqlParams["@empid"].Value=empid ;
  100. sqlParams.Add(new SqlParameter("@opt", SqlDbType.Int)); 
  101. sqlParams["@opt"].Value=opt;
  102. dsCommand.SelectCommand.ExecuteNonQuery();
  103. DataTable data = new DataTable(); 
  104. //填充data
  105. dsCommand.Fill(data);
  106. mySqlConnection.Close(); 
  107. return data;
  108.           
  109.   }
  110. public void SavePersonal(int pkid,string name,string job,string email,string company,string officetel,string mobile,string address,string postcode,string note,string relationdetiel,bool relationship,int empid,int opt)
  111. {
  112. mySqlConnection.Open();
  113. SqlCommand command = mySqlConnection.CreateCommand();
  114. command.CommandText ="AdSavePersonalList";// 
  115. command.CommandType =CommandType.StoredProcedure; 
  116. SqlParameterCollection sqlParams = command.Parameters;
  117. sqlParams.Add(new SqlParameter("@personid",SqlDbType.Int)); 
  118. sqlParams.Add(new SqlParameter("@name",SqlDbType.VarChar)); 
  119. sqlParams.Add(new SqlParameter("@job",SqlDbType.VarChar));
  120. sqlParams.Add(new SqlParameter("@email",SqlDbType.VarChar));
  121. sqlParams.Add(new SqlParameter("@company",SqlDbType.VarChar));
  122. sqlParams.Add(new SqlParameter("@officetel",SqlDbType.VarChar));
  123. sqlParams.Add(new SqlParameter("@mobile",SqlDbType.VarChar));
  124. sqlParams.Add(new SqlParameter("@address",SqlDbType.VarChar));
  125. sqlParams.Add(new SqlParameter("@postcode",SqlDbType.VarChar));
  126. sqlParams.Add(new SqlParameter("@note",SqlDbType.VarChar));
  127. sqlParams.Add(new SqlParameter("@relationdetiel",SqlDbType.VarChar));
  128.             sqlParams.Add(new SqlParameter("@relationship",SqlDbType.Bit));
  129. sqlParams.Add(new SqlParameter("@empid",SqlDbType.Int));
  130. sqlParams.Add(new SqlParameter("@opt",SqlDbType.Int));
  131. sqlParams["@personid"].Value=pkid;
  132. sqlParams["@name"].Value=name;
  133. sqlParams["@job"].Value=job;
  134. sqlParams["@email"].Value=email;
  135. sqlParams["@company"].Value=company;
  136. sqlParams["@officetel"].Value=officetel;
  137. sqlParams["@mobile"].Value=mobile;
  138. sqlParams["@address"].Value=address;
  139. sqlParams["@postcode"].Value=postcode;
  140. sqlParams["@note"].Value=note;
  141. sqlParams["@relationdetiel"].Value=relationdetiel;
  142. sqlParams["@relationship"].Value=relationship;
  143. sqlParams["@empid"].Value=empid;
  144. sqlParams["@opt"].Value=opt;
  145. command.ExecuteNonQuery(); 
  146. mySqlConnection.Close();  
  147. }
  148. }
  149. }