controlbinding.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:2k
- using System;
- using System.Data ;
- using System.Data.SqlClient ;
- namespace qminoa.DA
- {
- /// <summary>
- /// bind 的摘要说明。
- /// </summary>
-
- public class controlbinding
- {
- private DataSet objdataset;
- private SqlDataAdapter objadapter=new SqlDataAdapter();
- private SqlCommand objcommand=new SqlCommand();
- private String conn=System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString");
-
- public controlbinding()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- public DataSet dropPlacebind()
- {
- return controlbind("cpDropPlaceBind");
- }
- public DataSet dropTypebind()
- {
- return controlbind("cpDropTypeBind");
- }
- //绑定所有机构
- public DataSet dropBranchbind()
- {
- return controlbind("cpDropBranchBind");
- }
- //绑定指定机构下属所有部门
- public DataSet dropDepbind(string strtxt)
- {
- return controlbind("cpDropDepBind","@txtdropBranch",strtxt);
- }
- //绑定制定部门下属所有人员
- public DataSet droplstEmpbind(string strtxt)
- {
- return controlbind("cpLstEmpBind","@txtdropDep",strtxt);
- }
- public DataSet controlbind(string strsql)
- {
- objdataset=new DataSet ();
- objadapter=new SqlDataAdapter(strsql,conn);
- objadapter.Fill(objdataset, "tablename");
-
- return objdataset;
- }
- public DataSet controlbind(string strsql ,string paramName,int paramValue)
- {
- objadapter.SelectCommand = new SqlCommand();
- objadapter.SelectCommand.Connection = new SqlConnection(conn);
- objdataset=new DataSet ();
- objcommand = objadapter.SelectCommand;
- objcommand.CommandText = strsql;
- objcommand.CommandType = CommandType.StoredProcedure;
- SqlParameter param = new SqlParameter(paramName, SqlDbType.Int);
- param.Value = paramValue ;
- objcommand.Parameters.Add(param);
- objadapter.Fill(objdataset);
-
- return objdataset;
- }
- public DataSet controlbind(string strsql ,string paramName,string paramValue)
- {
- objadapter.SelectCommand = new SqlCommand();
- objadapter.SelectCommand.Connection = new SqlConnection(conn);
- objdataset=new DataSet ();
- objcommand = objadapter.SelectCommand;
- objcommand.CommandText = strsql;
- objcommand.CommandType = CommandType.StoredProcedure;
- SqlParameter param = new SqlParameter(paramName, SqlDbType.NVarChar, 255);
- param.Value = paramValue ;
- objcommand.Parameters.Add(param);
- objadapter.Fill(objdataset);
- return objdataset;
- }
- }
- }