📄 depsch.cs
字号:
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;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -