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

.net编程

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. //using System.Collections;
  5. namespace qminoa.DA
  6. {
  7. /// <summary>
  8. /// notebind 的摘要说明。
  9. /// </summary>
  10. /// 
  11. public class notebind
  12. {   
  13. private String conn=System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString");
  14. private SqlDataAdapter objadapter = new SqlDataAdapter();
  15. private DataSet objdataset = new DataSet();
  16. public notebind()
  17. {
  18.   
  19. }
  20.     
  21. //读取指定EmpID号的所有note
  22. public DataSet noteread(int EmpID)
  23. {
  24. return note("cpNoteBind","@EmpID",EmpID);
  25. }
  26. public DataSet note(string commandText, string paramName, int paramValue)
  27. {
  28. if (objadapter == null)//异常处理
  29. {
  30. throw new System.ObjectDisposedException( GetType().FullName );
  31. }
  32. SqlCommand objcommand = new SqlCommand();
  33. objadapter.SelectCommand = new SqlCommand(); 
  34. objadapter.SelectCommand.Connection = new SqlConnection(conn);
  35. objcommand = objadapter.SelectCommand;
  36.             objcommand.CommandText = commandText;
  37. objcommand.CommandType = CommandType.StoredProcedure;
  38. SqlParameter param = new SqlParameter(paramName, SqlDbType.Int);
  39. param.Value = paramValue;
  40.   objcommand.Parameters.Add(param); 
  41. objadapter.Fill(objdataset,"note5");
  42. return objdataset;
  43. }
  44.         //读取指定ID号的note
  45. public SqlCommand notefill(int NoteID)
  46. {
  47. return read("cpNoteRead","@NoteID",NoteID);
  48. }
  49. public SqlCommand read(string commandText, string paramName, int paramValue)
  50. {
  51. SqlCommand objcommand = new SqlCommand();
  52. objadapter.SelectCommand = new SqlCommand(); 
  53. objadapter.SelectCommand.Connection = new SqlConnection(conn);
  54. objcommand = objadapter.SelectCommand;
  55. objcommand.CommandText = commandText;
  56. objcommand.CommandType = CommandType.StoredProcedure; 
  57. objcommand.Parameters.Add(new SqlParameter(paramName, SqlDbType.Int));
  58. objcommand.Parameters[paramName].Value=paramValue;
  59. return objcommand;
  60. }
  61.         
  62. public void notedelete(int NoteID)
  63. {
  64. notedel("cpNoteDel","@NoteID",NoteID);
  65. }
  66. public void notedel(string commandText,string paramName,int paramValue)
  67. {
  68. SqlCommand objcommand = new SqlCommand();
  69. objcommand.Connection =new SqlConnection(conn);  
  70. objcommand.CommandText = commandText;
  71. objcommand.CommandType = CommandType.StoredProcedure; 
  72. objcommand.Parameters.Add(new SqlParameter(paramName,SqlDbType.Int));
  73. objcommand.Parameters[paramName].Value=paramValue;
  74. objcommand.Connection.Open();
  75. objcommand.ExecuteNonQuery();
  76. objcommand.Connection.Close();
  77. }
  78. public void noteaddup(int NoteID,int EmpID,string Content,DateTime CDate)
  79. {
  80.             noteadd("cpNoteAddUp","@NoteID",NoteID,"@EmpID",EmpID,"@Content",Content,"@CDate",CDate);
  81. }
  82. public void noteadd(string commandText,string paramName1,int paramValue1,string paramName2,int paramValue2,string paramName3,string  paramValue3,string paramName4,DateTime paramValue4)
  83. {
  84. SqlCommand objcommand = new SqlCommand();
  85. objcommand.Connection =new SqlConnection(conn);  
  86. objcommand.CommandText = commandText;
  87. objcommand.CommandType = CommandType.StoredProcedure; 
  88. objcommand.Parameters.Add(new SqlParameter(paramName1,SqlDbType.Int));
  89. objcommand.Parameters[paramName1].Value=paramValue1;
  90. objcommand.Parameters.Add(new SqlParameter(paramName2,SqlDbType.Int));
  91. objcommand.Parameters[paramName2].Value=paramValue2;
  92. objcommand.Parameters.Add(new SqlParameter(paramName3,SqlDbType.NVarChar,100));
  93. objcommand.Parameters[paramName3].Value=paramValue3;
  94. objcommand.Parameters.Add(new SqlParameter(paramName4,SqlDbType.DateTime));
  95. objcommand.Parameters[paramName4].Value=paramValue4;
  96. objcommand.Connection.Open();
  97. objcommand.ExecuteNonQuery();
  98. objcommand.Connection.Close();
  99. }
  100. }
  101. }