depsch.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:3k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- namespace qminoa.DA
- {
- /// <summary>
- /// depsch 的摘要说明。
- /// </summary>
- public class depsch
- {
- private String conn=System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString");
- private SqlDataAdapter objadapter = new SqlDataAdapter();
- private SqlCommand objcommand;
- //不能定义为共有变量
- // private DataTable objdataset = new DataTable();
-
-
-
- public depsch()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- public DataTable cpdepempread(string Branch,string Dep,string EmpName)
- {
- return reading("cpDepEmpRead","@Branch",Branch,"@Dep",Dep,"@EmpName",EmpName);
- }
- public DataTable reading(string commandText, string paramName1, string paramValue1,string paramName2, string paramValue2,string paramName3,string paramValue3)
- {
- if (objadapter == null)//异常处理
- {
- throw new System.ObjectDisposedException( GetType().FullName );
- }
- //不能定义为共有变量
- DataTable objdataset = new DataTable();
- 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(paramName1, SqlDbType.VarChar));
- objcommand.Parameters[paramName1].Value=paramValue1;
- objcommand.Parameters.Add(new SqlParameter(paramName2, SqlDbType.VarChar));
- objcommand.Parameters[paramName2].Value=paramValue2;
- objcommand.Parameters.Add(new SqlParameter(paramName3, SqlDbType.VarChar));
- objcommand.Parameters[paramName3].Value=paramValue3;
- objadapter.Fill(objdataset);
- return objdataset;
- }
- public DataTable cpdepschread(DateTime paramValue1,int paramValue2)
- {
- return reading("cpDepSchRead","@Fdate",paramValue1,"@EmpID",paramValue2);
- }
- public DataTable reading(string commandText, string paramName1, DateTime paramValue1,string paramName2,int paramValue2)
- {
- if (objadapter == null)//异常处理
- {
- throw new System.ObjectDisposedException( GetType().FullName );
- }
- //不能定义为共有变量
-
- DataTable objdataset = new DataTable();
- 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(paramName1, SqlDbType.DateTime));
- objcommand.Parameters[paramName1].Value=paramValue1;
- objcommand.Parameters.Add(new SqlParameter(paramName2, SqlDbType.Int));
- objcommand.Parameters[paramName2].Value=paramValue2;
- objadapter.Fill(objdataset);
- return objdataset;
- }
- }
- }