类库中的DataBaseHelper类
重新包装了SQLHelper类的功能,因为并不是所有SQLHelper类功能我们都会用到,我们只应用到了一小部分
以下为引用的内容: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using Microsoft.ApplicationBlocks.Data; using System.Data;
namespace Shop.DataAccess { public class DataBaseHelper:DataAccessBase { public SqlParameter[] Parameters { get; set; }
/// <summary> /// 构造函数 /// </summary> /// <param name="storedproceducename">赋值存储过程</param> public DataBaseHelper(string storedproceducename) { this.StoredprocedureName = storedproceducename; }
/// <summary> /// 无数据返回 /// </summary> /// <param name="transaction"></param> public void Run(SqlTransaction transaction) { SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, this.StoredprocedureName, this.Parameters); }
/// <summary> /// 无数据返回,自己提供参数 /// </summary> /// <param name="transaction"></param> /// <param name="Parameters">参数</param> public void Run(SqlTransaction transaction, SqlParameter[] Parameters) { SqlHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, this.StoredprocedureName, Parameters); }
/// <summary> /// 有参数返回(DataSet) /// </summary> /// <param name="connectionstring"></param> /// <param name="parameters"></param> /// <returns></returns> public DataSet Run(string connectionstring, SqlParameter[] parameters) { DataSet ds; ds = SqlHelper.ExecuteDataset(connectionstring, this.StoredprocedureName, parameters); return ds; }
/// <summary> /// 返回第一行第一列的值 /// </summary> /// <param name="connectionstring"></param> /// <param name="parameters"></param> /// <returns></returns> public object RunScalar(string connectionstring, SqlParameter[] parameters) { object obj; obj = SqlHelper.ExecuteScalar(connectionstring, this.StoredprocedureName, parameters); return obj; }
/// <summary> /// 返回第一行第一列的值 /// </summary> /// <param name="transaction"></param> /// <param name="parameters"></param> /// <returns></returns> public object RunScalar(SqlTransaction transaction, SqlParameter[] parameters) { object obj; obj = SqlHelper.ExecuteScalar(transaction, this.StoredprocedureName, parameters); return obj; }
/// <summary> /// 无参数返回(DataSet) /// </summary> /// <param name="connectionstring"></param> /// <returns></returns> public DataSet Run(string connectionstring) { DataSet ds; ds = SqlHelper.ExecuteDataset(connectionstring, CommandType.StoredProcedure, this.StoredprocedureName); return ds; }
/// <summary> /// 无返回值 /// </summary> public void Run() { SqlHelper.ExecuteNonQuery(base.ConnectionString, CommandType.StoredProcedure, this.StoredprocedureName, this.Parameters); }
/// <summary> /// 返回是SqlDataReader /// </summary> /// <param name="parameters"></param> /// <returns></returns> public SqlDataReader Run(SqlParameter[] parameters) { SqlDataReader dr; dr = SqlHelper.ExecuteReader(base.ConnectionString, CommandType.StoredProcedure, this.StoredprocedureName, parameters); return dr; } } } |
业务逻辑层
Shop.BusinessLogic
这里涉及到要编写接口
首先了解下什么是接口,接口就是只包含抽象成员的应用类型,接口中的成员可以是方法,索引器,属性和事件,而不可以是包含任何常量,构造函数,静态成员或数据字段。接口只包含这些成员的声明。而具体的实现必须从实现该接口的任何类中进行初始化。
这里编辑一个接口是因为所有该类库的类都会调用一个函数来实现获得数据
以下为引用的内容: using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Shop.BusinessLogic { interface IBusinessLogic { void Invoke(); } } |
Shop.Common类库是编写一个公共类
Shop.Operational自定义一些类
具体的一些内容留在下面文章分析 |