notebind.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:4k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- //using System.Collections;
- namespace qminoa.DA
- {
- /// <summary>
- /// notebind 的摘要说明。
- /// </summary>
- ///
- public class notebind
- {
- private String conn=System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString");
- private SqlDataAdapter objadapter = new SqlDataAdapter();
- private DataSet objdataset = new DataSet();
- public notebind()
- {
-
- }
-
- //读取指定EmpID号的所有note
- public DataSet noteread(int EmpID)
- {
- return note("cpNoteBind","@EmpID",EmpID);
- }
- public DataSet note(string commandText, string paramName, int paramValue)
- {
- if (objadapter == null)//异常处理
- {
- throw new System.ObjectDisposedException( GetType().FullName );
- }
- SqlCommand objcommand = new SqlCommand();
- objadapter.SelectCommand = new SqlCommand();
- objadapter.SelectCommand.Connection = new SqlConnection(conn);
- objcommand = objadapter.SelectCommand;
- objcommand.CommandText = commandText;
- objcommand.CommandType = CommandType.StoredProcedure;
- SqlParameter param = new SqlParameter(paramName, SqlDbType.Int);
- param.Value = paramValue;
- objcommand.Parameters.Add(param);
- objadapter.Fill(objdataset,"note5");
- return objdataset;
- }
- //读取指定ID号的note
- public SqlCommand notefill(int NoteID)
- {
- return read("cpNoteRead","@NoteID",NoteID);
- }
- public SqlCommand read(string commandText, string paramName, int paramValue)
- {
- SqlCommand objcommand = new SqlCommand();
- objadapter.SelectCommand = new SqlCommand();
- objadapter.SelectCommand.Connection = new SqlConnection(conn);
- objcommand = objadapter.SelectCommand;
- objcommand.CommandText = commandText;
- objcommand.CommandType = CommandType.StoredProcedure;
- objcommand.Parameters.Add(new SqlParameter(paramName, SqlDbType.Int));
- objcommand.Parameters[paramName].Value=paramValue;
- return objcommand;
- }
-
- public void notedelete(int NoteID)
- {
- notedel("cpNoteDel","@NoteID",NoteID);
- }
- public void notedel(string commandText,string paramName,int paramValue)
- {
- SqlCommand objcommand = new SqlCommand();
- objcommand.Connection =new SqlConnection(conn);
- objcommand.CommandText = commandText;
- objcommand.CommandType = CommandType.StoredProcedure;
- objcommand.Parameters.Add(new SqlParameter(paramName,SqlDbType.Int));
- objcommand.Parameters[paramName].Value=paramValue;
- objcommand.Connection.Open();
- objcommand.ExecuteNonQuery();
- objcommand.Connection.Close();
- }
- public void noteaddup(int NoteID,int EmpID,string Content,DateTime CDate)
- {
- noteadd("cpNoteAddUp","@NoteID",NoteID,"@EmpID",EmpID,"@Content",Content,"@CDate",CDate);
- }
- public void noteadd(string commandText,string paramName1,int paramValue1,string paramName2,int paramValue2,string paramName3,string paramValue3,string paramName4,DateTime paramValue4)
- {
- SqlCommand objcommand = new SqlCommand();
- objcommand.Connection =new SqlConnection(conn);
- objcommand.CommandText = commandText;
- objcommand.CommandType = CommandType.StoredProcedure;
- objcommand.Parameters.Add(new SqlParameter(paramName1,SqlDbType.Int));
- objcommand.Parameters[paramName1].Value=paramValue1;
- objcommand.Parameters.Add(new SqlParameter(paramName2,SqlDbType.Int));
- objcommand.Parameters[paramName2].Value=paramValue2;
- objcommand.Parameters.Add(new SqlParameter(paramName3,SqlDbType.NVarChar,100));
- objcommand.Parameters[paramName3].Value=paramValue3;
- objcommand.Parameters.Add(new SqlParameter(paramName4,SqlDbType.DateTime));
- objcommand.Parameters[paramName4].Value=paramValue4;
- objcommand.Connection.Open();
- objcommand.ExecuteNonQuery();
- objcommand.Connection.Close();
- }
- }
- }