实战剖析三层架构2:实例代码
前段时间写了《实战剖析三层架构》,看有些朋友希望提供一下代码。但近期博客园上关于三层架构的文章很多,而且写得都很好,所以就不准备被再写了。不过这几天又有朋友留言鼓励,而且编程中发现一段比较合适的,所以还是决定写出来共享给大家。
先简要介绍一下,这个模块是一个商品管理模块。程序中实现了商品的浏览、添加、修改等功能。
Model项目,商品品牌实体类,BrandInfo.cs:
Code
using System;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 品牌元数据
/// </summary>
[Serializable]
public class BrandInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//品牌Id
private int _Id;
//品牌名称
private string _Name;
//排序编号
private int _Number;
//是否为推荐品牌
private bool _IsVouch;
/**//***************************************************
* 属性列表
***************************************************/
/**//// <summary>
/// 品牌Id
/// </summary>
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 品牌名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 排序编号
/// </summary>
public int OrderNumber
{
get { return _Number; }
set { _Number = value; }
}
/**//// <summary>
/// 是否推荐品牌
/// </summary>
public bool IsVouch
{
get { return _IsVouch; }
set { _IsVouch = value; }
}
public string Vouch
{
get
{
if (_IsVouch)
{
return "推荐品牌";
}
else
{
return "普通品牌";
}
}
}
/**//***************************************************
* 构造函数
***************************************************/
public BrandInfo() { }
public BrandInfo(int id, string name)
{
_Id = id;
_Name = name;
}
public BrandInfo(int id, string name, int orderNumber, bool isVouch)
{
_Id = id;
_Name = name;
_Number = orderNumber;
_IsVouch = isVouch;
}
}
}
using System;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 品牌元数据
/// </summary>
[Serializable]
public class BrandInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//品牌Id
private int _Id;
//品牌名称
private string _Name;
//排序编号
private int _Number;
//是否为推荐品牌
private bool _IsVouch;
/**//***************************************************
* 属性列表
***************************************************/
/**//// <summary>
/// 品牌Id
/// </summary>
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 品牌名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 排序编号
/// </summary>
public int OrderNumber
{
get { return _Number; }
set { _Number = value; }
}
/**//// <summary>
/// 是否推荐品牌
/// </summary>
public bool IsVouch
{
get { return _IsVouch; }
set { _IsVouch = value; }
}
public string Vouch
{
get
{
if (_IsVouch)
{
return "推荐品牌";
}
else
{
return "普通品牌";
}
}
}
/**//***************************************************
* 构造函数
***************************************************/
public BrandInfo() { }
public BrandInfo(int id, string name)
{
_Id = id;
_Name = name;
}
public BrandInfo(int id, string name, int orderNumber, bool isVouch)
{
_Id = id;
_Name = name;
_Number = orderNumber;
_IsVouch = isVouch;
}
}
}
Model项目:GoodSortInfo.cs
Code
using System;
using System.Collections.Generic;
using System.Text;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 分类实体类
/// </summary>
[Serializable]
public class GoodSortInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//分类Id
private int _Id;
//分类名称
private string _Name;
//级别
private int _Layer;
//上级分类
private GoodSortInfo _ParentSort;
//下级分类数量
private int _ChildNumber;
//备注
private string _Remark;
/**//***************************************************
* 属性列表
***************************************************/
/**//// <summary>
/// 分类Id
/// </summary>
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 分类名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 分类等级
/// </summary>
public int Layer
{
get { return _Layer; }
set { _Layer = value; }
}
/**//// <summary>
/// 上级分类
/// </summary>
public GoodSortInfo ParentSort
{
get { return _ParentSort; }
set { _ParentSort = value; }
}
/**//// <summary>
/// 上级分类Id
/// </summary>
public int ParentId
{
get { return _ParentSort.Id; }
}
/**//// <summary>
/// 下级分类数量
/// </summary>
public int ChildSortCount
{
get { return _ChildNumber; }
set { _ChildNumber = value; }
}
/**//// <summary>
/// 备注
/// </summary>
public string Remark
{
get { return _Remark; }
set { _Remark = value; }
}
/**//***************************************************
* 构造函数
***************************************************/
public GoodSortInfo() { }
public GoodSortInfo(int id)
{
_Id = id;
}
public GoodSortInfo(int id, string name)
{
_Id = id;
_Name = name;
}
public GoodSortInfo(int id, string name, int depth, int childNumber)
{
_Id = id;
_Name = name;
_Layer = depth;
_ChildNumber = childNumber;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 分类实体类
/// </summary>
[Serializable]
public class GoodSortInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//分类Id
private int _Id;
//分类名称
private string _Name;
//级别
private int _Layer;
//上级分类
private GoodSortInfo _ParentSort;
//下级分类数量
private int _ChildNumber;
//备注
private string _Remark;
/**//***************************************************
* 属性列表
***************************************************/
/**//// <summary>
/// 分类Id
/// </summary>
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 分类名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 分类等级
/// </summary>
public int Layer
{
get { return _Layer; }
set { _Layer = value; }
}
/**//// <summary>
/// 上级分类
/// </summary>
public GoodSortInfo ParentSort
{
get { return _ParentSort; }
set { _ParentSort = value; }
}
/**//// <summary>
/// 上级分类Id
/// </summary>
public int ParentId
{
get { return _ParentSort.Id; }
}
/**//// <summary>
/// 下级分类数量
/// </summary>
public int ChildSortCount
{
get { return _ChildNumber; }
set { _ChildNumber = value; }
}
/**//// <summary>
/// 备注
/// </summary>
public string Remark
{
get { return _Remark; }
set { _Remark = value; }
}
/**//***************************************************
* 构造函数
***************************************************/
public GoodSortInfo() { }
public GoodSortInfo(int id)
{
_Id = id;
}
public GoodSortInfo(int id, string name)
{
_Id = id;
_Name = name;
}
public GoodSortInfo(int id, string name, int depth, int childNumber)
{
_Id = id;
_Name = name;
_Layer = depth;
_ChildNumber = childNumber;
}
}
}
Model项目,GoodInfo.cs:
Code
using System;
using System.Collections;
using System.Collections.Generic;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 商品元数据
/// </summary>
[Serializable]
public class GoodInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//商品Id
private int _Id;
//商品名称
private string _Name;
//品牌
private BrandInfo _BrandInfo;
//分类
private GoodSortInfo _SortInfo;
//商品编码
private string _Code;
//条形码
private string _Barcode;
//单位(个/盒/袋等)
private string _Unit;
//规格
private string _Standard;
//简介
private string _SimpleIntroduction;
//详细说明
private string _DetailIntroduction;
//图片路径
private string _PicturePath;
//发布日期
private DateTime _PublicTime;
//更新日期
private DateTime _UpdateTime;
//市场价
private decimal _MarketPrice;
//零售价
private decimal _SellPrice;
//赠送积分
private decimal _Score;
//浏览次数
private int _ClickCount;
//上一次浏览时间
private DateTime _ClickTime;
//商品种类
private string _KindName;
//库存数量
private int _Stock;
//是否显示
private bool _Visable = false;
关键字段枚举#region 关键字段枚举
private static Hashtable _KindList;
private static Hashtable _PopList;
#endregion
/**//***************************************************
* 属性列表
***************************************************/
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 商品编码
/// </summary>
public string Code
{
get { return _Code; }
set { _Code = value; }
}
/**//// <summary>
/// 条形码
/// </summary>
public string Barcode
{
get { return _Barcode; }
set { _Barcode = value; }
}
/**//// <summary>
/// 品牌
/// </summary>
public BrandInfo BrandInfo
{
get
{
if (_BrandInfo == null)
{
_BrandInfo = new BrandInfo();
}
return _BrandInfo;
}
set { _BrandInfo = value; }
}
/**//// <summary>
/// 品牌名称
/// </summary>
public string BrandName
{
get { return this.BrandInfo.Name; }
set { this.BrandInfo.Name = value; }
}
/**//// <summary>
/// 商品分类
/// </summary>
public GoodSortInfo Sort
{
get { return _SortInfo; }
set { _SortInfo = value; }
}
/**//// <summary>
/// 商品名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 单位(个/盒/袋等)
/// </summary>
public string Unit
{
get { return _Unit; }
set { _Unit = value; }
}
/**//// <summary>
/// 规格
/// </summary>
public string Standard
{
get { return _Standard; }
set { _Standard = value; }
}
/**//// <summary>
/// 简介
/// </summary>
public string SimpleIntroduction
{
get { return _SimpleIntroduction; }
set { _SimpleIntroduction = value; }
}
/**//// <summary>
/// 详细说明
/// </summary>
public string DetailIntroduction
{
get { return _DetailIntroduction; }
set { _DetailIntroduction = value; }
}
/**//// <summary>
/// 图片路径
/// </summary>
public string PicturePath
{
get { return _PicturePath; }
set { _PicturePath = value; }
}
/**//// <summary>
/// 发布日期
/// </summary>
public DateTime PublicTime
{
get { return _PublicTime; }
set { _PublicTime = value; }
}
/**//// <summary>
/// 更新日期
/// </summary>
public DateTime UpdateTime
{
get { return _UpdateTime; }
set { _UpdateTime = value; }
}
/**//// <summary>
/// 市场价
/// </summary>
public decimal MarketPrice
{
get { return _MarketPrice; }
set { _MarketPrice = value; }
}
/**//// <summary>
/// 零售价
/// </summary>
public decimal SellPrice
{
get { return _SellPrice; }
set { _SellPrice = value; }
}
/**//// <summary>
/// 赠送积分
/// </summary>
public decimal Score
{
get { return _Score; }
set { _Score = value; }
}
/**//// <summary>
/// 浏览次数
/// </summary>
public int ClickCount
{
get { return _ClickCount; }
set { _ClickCount = value; }
}
/**//// <summary>
/// 上次浏览时间
/// </summary>
public DateTime ClickTime
{
get { return _ClickTime; }
set { _ClickTime = value; }
}
public string KindName
{
get { return _KindName; }
set { _KindName = value; }
}
/**//// <summary>
/// 库存数量
/// </summary>
public int Stock
{
get { return _Stock; }
set { _Stock = value; }
}
/**//// <summary>
/// 是否显示
/// </summary>
public bool Visable
{
get { return _Visable; }
set { _Visable = value; }
}
/**//***************************************************
* 构造函数
***************************************************/
public GoodInfo() { }
public GoodInfo(int id, string code, string name, string picturePath, decimal marketPrice, decimal sellPrice, string unit, string standard, int stock)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
_MarketPrice = marketPrice;
_SellPrice = sellPrice;
_Unit = unit;
_Standard = standard;
_Stock = stock;
}
public GoodInfo(int id, string code, string name, string picturePath, string brandName, string kindName, string standard, string simpleIntroduction, DateTime publicTime, decimal marketPrice, decimal sellPrice, string unit, decimal score, int clickNumber)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
this.BrandName = brandName;
_KindName = kindName;
_Standard = standard;
_SimpleIntroduction = simpleIntroduction;
_PublicTime = publicTime;
_MarketPrice = marketPrice ;
_SellPrice = sellPrice;
_Unit = unit;
_Score = score;
_ClickCount = clickNumber;
_Stock = Stock;
}
public GoodInfo(int id, string code, string name, string picturePath, string brandName, string kindName, string standard, string simpleIntroduction, string detailIntroduction, decimal marketPrice, decimal sellPrice, string unit, decimal score, int clickNumber, DateTime publicTime, int stock)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
this.BrandName = brandName;
_KindName = kindName;
_Standard = standard;
_SimpleIntroduction = simpleIntroduction;
_DetailIntroduction = detailIntroduction;
_MarketPrice = marketPrice;
_SellPrice = sellPrice;
_Unit = unit;
_Score = score;
_ClickCount = clickNumber;
_PublicTime = publicTime;
_Stock = stock;
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
namespace JKL.eShop.Model
{
/**//// <summary>
/// 商品元数据
/// </summary>
[Serializable]
public class GoodInfo
{
/**//***************************************************
* 成员列表
***************************************************/
//商品Id
private int _Id;
//商品名称
private string _Name;
//品牌
private BrandInfo _BrandInfo;
//分类
private GoodSortInfo _SortInfo;
//商品编码
private string _Code;
//条形码
private string _Barcode;
//单位(个/盒/袋等)
private string _Unit;
//规格
private string _Standard;
//简介
private string _SimpleIntroduction;
//详细说明
private string _DetailIntroduction;
//图片路径
private string _PicturePath;
//发布日期
private DateTime _PublicTime;
//更新日期
private DateTime _UpdateTime;
//市场价
private decimal _MarketPrice;
//零售价
private decimal _SellPrice;
//赠送积分
private decimal _Score;
//浏览次数
private int _ClickCount;
//上一次浏览时间
private DateTime _ClickTime;
//商品种类
private string _KindName;
//库存数量
private int _Stock;
//是否显示
private bool _Visable = false;
关键字段枚举#region 关键字段枚举
private static Hashtable _KindList;
private static Hashtable _PopList;
#endregion
/**//***************************************************
* 属性列表
***************************************************/
public int Id
{
get { return _Id; }
set { _Id = value; }
}
/**//// <summary>
/// 商品编码
/// </summary>
public string Code
{
get { return _Code; }
set { _Code = value; }
}
/**//// <summary>
/// 条形码
/// </summary>
public string Barcode
{
get { return _Barcode; }
set { _Barcode = value; }
}
/**//// <summary>
/// 品牌
/// </summary>
public BrandInfo BrandInfo
{
get
{
if (_BrandInfo == null)
{
_BrandInfo = new BrandInfo();
}
return _BrandInfo;
}
set { _BrandInfo = value; }
}
/**//// <summary>
/// 品牌名称
/// </summary>
public string BrandName
{
get { return this.BrandInfo.Name; }
set { this.BrandInfo.Name = value; }
}
/**//// <summary>
/// 商品分类
/// </summary>
public GoodSortInfo Sort
{
get { return _SortInfo; }
set { _SortInfo = value; }
}
/**//// <summary>
/// 商品名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/**//// <summary>
/// 单位(个/盒/袋等)
/// </summary>
public string Unit
{
get { return _Unit; }
set { _Unit = value; }
}
/**//// <summary>
/// 规格
/// </summary>
public string Standard
{
get { return _Standard; }
set { _Standard = value; }
}
/**//// <summary>
/// 简介
/// </summary>
public string SimpleIntroduction
{
get { return _SimpleIntroduction; }
set { _SimpleIntroduction = value; }
}
/**//// <summary>
/// 详细说明
/// </summary>
public string DetailIntroduction
{
get { return _DetailIntroduction; }
set { _DetailIntroduction = value; }
}
/**//// <summary>
/// 图片路径
/// </summary>
public string PicturePath
{
get { return _PicturePath; }
set { _PicturePath = value; }
}
/**//// <summary>
/// 发布日期
/// </summary>
public DateTime PublicTime
{
get { return _PublicTime; }
set { _PublicTime = value; }
}
/**//// <summary>
/// 更新日期
/// </summary>
public DateTime UpdateTime
{
get { return _UpdateTime; }
set { _UpdateTime = value; }
}
/**//// <summary>
/// 市场价
/// </summary>
public decimal MarketPrice
{
get { return _MarketPrice; }
set { _MarketPrice = value; }
}
/**//// <summary>
/// 零售价
/// </summary>
public decimal SellPrice
{
get { return _SellPrice; }
set { _SellPrice = value; }
}
/**//// <summary>
/// 赠送积分
/// </summary>
public decimal Score
{
get { return _Score; }
set { _Score = value; }
}
/**//// <summary>
/// 浏览次数
/// </summary>
public int ClickCount
{
get { return _ClickCount; }
set { _ClickCount = value; }
}
/**//// <summary>
/// 上次浏览时间
/// </summary>
public DateTime ClickTime
{
get { return _ClickTime; }
set { _ClickTime = value; }
}
public string KindName
{
get { return _KindName; }
set { _KindName = value; }
}
/**//// <summary>
/// 库存数量
/// </summary>
public int Stock
{
get { return _Stock; }
set { _Stock = value; }
}
/**//// <summary>
/// 是否显示
/// </summary>
public bool Visable
{
get { return _Visable; }
set { _Visable = value; }
}
/**//***************************************************
* 构造函数
***************************************************/
public GoodInfo() { }
public GoodInfo(int id, string code, string name, string picturePath, decimal marketPrice, decimal sellPrice, string unit, string standard, int stock)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
_MarketPrice = marketPrice;
_SellPrice = sellPrice;
_Unit = unit;
_Standard = standard;
_Stock = stock;
}
public GoodInfo(int id, string code, string name, string picturePath, string brandName, string kindName, string standard, string simpleIntroduction, DateTime publicTime, decimal marketPrice, decimal sellPrice, string unit, decimal score, int clickNumber)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
this.BrandName = brandName;
_KindName = kindName;
_Standard = standard;
_SimpleIntroduction = simpleIntroduction;
_PublicTime = publicTime;
_MarketPrice = marketPrice ;
_SellPrice = sellPrice;
_Unit = unit;
_Score = score;
_ClickCount = clickNumber;
_Stock = Stock;
}
public GoodInfo(int id, string code, string name, string picturePath, string brandName, string kindName, string standard, string simpleIntroduction, string detailIntroduction, decimal marketPrice, decimal sellPrice, string unit, decimal score, int clickNumber, DateTime publicTime, int stock)
{
_Id = id;
_Code = code;
_Name = name;
_PicturePath = picturePath;
this.BrandName = brandName;
_KindName = kindName;
_Standard = standard;
_SimpleIntroduction = simpleIntroduction;
_DetailIntroduction = detailIntroduction;
_MarketPrice = marketPrice;
_SellPrice = sellPrice;
_Unit = unit;
_Score = score;
_ClickCount = clickNumber;
_PublicTime = publicTime;
_Stock = stock;
}
}
}
BLL项目:GoodBLL.cs
BLL
using System;
using System.Collections.Generic;
using JKL.eShop.DAL;
using JKL.eShop.Model;
namespace JKL.eShop.BLL
{
/**//// <summary>
///
/// </summary>
public class GoodBLL
{
/**//* **************************************************
* 成员列表
* *************************************************/
private GoodDAL _GoodDal = null;
/**//* **************************************************
* 属性列表
* *************************************************/
private GoodDAL GoodDal
{
get
{
if (_GoodDal == null)
{
_GoodDal = new GoodDAL();
}
return _GoodDal;
}
}
/**//* **************************************************
* 公共方法
* *************************************************/
/**//// <summary>
/// 更新商品信息
/// </summary>
/// <param name="goodInfo"></param>
/// <returns></returns>
public bool ChangeGood(GoodInfo goodInfo)
{
return false;
}
/**//// <summary>
/// 商品变价
/// </summary>
/// <param name="goodinfo"></param>
/// <returns></returns>
public bool ChangePrice(GoodInfo goodinfo)
{
return this.GoodDal.UpdateGoodsPrice(goodinfo);
}
/**//// <summary>
/// 根据ID返回商品的详细信息
/// </summary>
/// <param name="goodId"></param>
/// <returns></returns>
public GoodInfo GetGood(int goodId)
{
GoodInfo good = this.GoodDal.SelectGood(goodId);
good.ClickCount++;
this.GoodDal.UpdateGood(good);
return good;
}
返回商品信息列表#region 返回商品信息列表
/**//// <summary>
/// 返回所有商品的列表
/// </summary>
/// <returns></returns>
public IList<GoodInfo> GetGoodsList()
{
return this.GoodDal.SelectGoods();
}
/**//// <summary>
/// 返回指定分类的所属商品列表
/// </summary>
/// <param name="sortId">分类Id</param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListBySort(int sortId)
{
return this.GoodDal.SelectGoodsBySort(sortId);
}
/**//// <summary>
/// 根据热门程度的类型返回商品列表
/// </summary>
/// <param name="sortId"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListByPop(string popKind)
{
return this.GoodDal.SelectGoodsListByPop(1000, popKind);
}
/**//// <summary>
/// 返回指定品牌的所属商品列表
/// </summary>
/// <param name="brandName"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListByBrand(string brandName)
{
GoodDAL goodDal = new GoodDAL();
return goodDal.SelectGoodsListByBrand(brandName);
}
public IList<GoodInfo> GetGoodsBrief()
{
return this.GoodDal.SelectGoodsBrief();
}
/**//// <summary>
///
/// </summary>
/// <param name="topNumber"></param>
/// <param name="kindName"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsBriefByKind(int topNumber, string kindName)
{
return this.GoodDal.SelectGoodsBriefByKind(topNumber, kindName);
}
public IList<GoodInfo> GetGoodsListByKind(string kindName)
{
return this.GoodDal.SelectGoodsListByKind(kindName);
}
#endregion
商品查询部分#region 商品查询部分
public IList<GoodInfo> QueryGoodsList(string keyword)
{
GoodDAL goodDal = new GoodDAL();
return goodDal.SelectGoodsListByKeyword(keyword);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using JKL.eShop.DAL;
using JKL.eShop.Model;
namespace JKL.eShop.BLL
{
/**//// <summary>
///
/// </summary>
public class GoodBLL
{
/**//* **************************************************
* 成员列表
* *************************************************/
private GoodDAL _GoodDal = null;
/**//* **************************************************
* 属性列表
* *************************************************/
private GoodDAL GoodDal
{
get
{
if (_GoodDal == null)
{
_GoodDal = new GoodDAL();
}
return _GoodDal;
}
}
/**//* **************************************************
* 公共方法
* *************************************************/
/**//// <summary>
/// 更新商品信息
/// </summary>
/// <param name="goodInfo"></param>
/// <returns></returns>
public bool ChangeGood(GoodInfo goodInfo)
{
return false;
}
/**//// <summary>
/// 商品变价
/// </summary>
/// <param name="goodinfo"></param>
/// <returns></returns>
public bool ChangePrice(GoodInfo goodinfo)
{
return this.GoodDal.UpdateGoodsPrice(goodinfo);
}
/**//// <summary>
/// 根据ID返回商品的详细信息
/// </summary>
/// <param name="goodId"></param>
/// <returns></returns>
public GoodInfo GetGood(int goodId)
{
GoodInfo good = this.GoodDal.SelectGood(goodId);
good.ClickCount++;
this.GoodDal.UpdateGood(good);
return good;
}
返回商品信息列表#region 返回商品信息列表
/**//// <summary>
/// 返回所有商品的列表
/// </summary>
/// <returns></returns>
public IList<GoodInfo> GetGoodsList()
{
return this.GoodDal.SelectGoods();
}
/**//// <summary>
/// 返回指定分类的所属商品列表
/// </summary>
/// <param name="sortId">分类Id</param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListBySort(int sortId)
{
return this.GoodDal.SelectGoodsBySort(sortId);
}
/**//// <summary>
/// 根据热门程度的类型返回商品列表
/// </summary>
/// <param name="sortId"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListByPop(string popKind)
{
return this.GoodDal.SelectGoodsListByPop(1000, popKind);
}
/**//// <summary>
/// 返回指定品牌的所属商品列表
/// </summary>
/// <param name="brandName"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsListByBrand(string brandName)
{
GoodDAL goodDal = new GoodDAL();
return goodDal.SelectGoodsListByBrand(brandName);
}
public IList<GoodInfo> GetGoodsBrief()
{
return this.GoodDal.SelectGoodsBrief();
}
/**//// <summary>
///
/// </summary>
/// <param name="topNumber"></param>
/// <param name="kindName"></param>
/// <returns></returns>
public IList<GoodInfo> GetGoodsBriefByKind(int topNumber, string kindName)
{
return this.GoodDal.SelectGoodsBriefByKind(topNumber, kindName);
}
public IList<GoodInfo> GetGoodsListByKind(string kindName)
{
return this.GoodDal.SelectGoodsListByKind(kindName);
}
#endregion
商品查询部分#region 商品查询部分
public IList<GoodInfo> QueryGoodsList(string keyword)
{
GoodDAL goodDal = new GoodDAL();
return goodDal.SelectGoodsListByKeyword(keyword);
}
#endregion
}
}
DAL项目:GoodDAL.cs
Code
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using KoalaStudio.Data.SqlServer;
using JKL.eShop.Model;
namespace JKL.eShop.DAL
{
/**//// <summary>
///
/// </summary>
public class GoodDAL
{
/**//* **************************************************
* 成员列表
* **************************************************/
/**//* **************************************************
* 属性列表
* **************************************************/
/**//* **************************************************
* 构造函数
* **************************************************/
public GoodDAL() { }
/**//* **************************************************
* 私有和受保护方法
* **************************************************/
/**//// <summary>
///
/// </summary>
/// <param name="sqlText"></param>
/// <returns></returns>
private IList<GoodInfo> SelectGoodsBrief(string sqlText)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = sqlText;
SqlDataReader dr = cmd.ExecuteReader();
IList<GoodInfo> goods = new List<GoodInfo>();
SortDAL sortDal = new SortDAL();
if (dr.HasRows)
{
while (dr.Read())
{
GoodInfo good = new GoodInfo();
good.Id = Convert.ToInt32(dr["Id"]); ;
good.Code = dr["dianneima"].ToString();
good.Name = dr["Name"].ToString();
string picturePath = dr["Picture"].ToString();
good.PicturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good.MarketPrice = Convert.ToDecimal(dr["MarketPrice"]); ;
good.SellPrice = Convert.ToDecimal(dr["MemberPrice"]);
good.Unit = dr["DanWei"].ToString();
good.Standard = dr["GuiGe"].ToString();
goods.Add(good);
}
dr.Close();
cmd.Disconnection();
}
return goods;
}
/**//// <summary>
///
/// </summary>
/// <param name="sqlText"></param>
/// <returns></returns>
private IList<GoodInfo> SelectGoodsList(string sqlText)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = sqlText;
SqlDataReader dr = cmd.ExecuteReader();
IList<GoodInfo> goods = new List<GoodInfo>();
SortDAL sortDal = new SortDAL();
if (dr.HasRows)
{
while (dr.Read())
{
GoodInfo good = new GoodInfo();
good.Id = Convert.ToInt32(dr["Id"]);
good.Name = dr["Name"].ToString();
good.BrandInfo.Name = dr["Brand"].ToString();
good.Code = dr["dianneima"].ToString();
string picturePath = dr["Picture"].ToString();
good.PicturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good.KindName = dr["Kind"].ToString();
good.Standard = dr["GuiGe"].ToString();
good.SimpleIntroduction = dr["Introduce"].ToString();
good.PublicTime = Convert.ToDateTime(dr["JoinDate"]);
good.MarketPrice = Convert.ToDecimal(dr["MarketPrice"]); ;
good.SellPrice = Convert.ToDecimal(dr["MemberPrice"]);
good.Unit = dr["DanWei"].ToString();
good.Score = Convert.ToDecimal(dr["Score"]);
good.ClickCount = Convert.ToInt32(dr["TotalHits"]);
goods.Add(good);
}
dr.Close();
cmd.Disconnection();
}
return goods;
}
/**//* **************************************************
* 公共方法
* **************************************************/
/**//// <summary>
/// 更新商品的价格和库存信息
/// </summary>
/// <returns></returns>
public bool UpdateGoodsPrice(GoodInfo goodInfo)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "UPDATE SW_Product SET MarketPrice = " + goodInfo.MarketPrice + ", MemberPrice = " + goodInfo.SellPrice + ", Stock = " + goodInfo.Stock + ", ModiDate = '" + DateTime.Now + "' WHERE Id = " + goodInfo.Id;
cmd.ExecuteNonQuery();
return true;
}
/**//// <summary>
/// 更新商品信息
/// 当前仅支持更新点击率一项
/// </summary>
/// <param name="good"></param>
/// <returns></returns>
public bool UpdateGood(GoodInfo good)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "UPDATE eShop_Goods SET ClickCount = " + good.ClickCount + " WHERE GoodId = " + good.Id;
cmd.ExecuteNonQuery();
return true;
}
/**//// <summary>
/// 返回所有商品列表
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoods()
{
string sqlText = "SELECT * FROM eShop_Goods";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定分类的所属商品列表
/// </summary>
/// <param name="sortId"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBySort(int sortId)
{
string sqlText = "SELECT * FROM SW_Product WHERE Hide = 0 AND ClassId IN (SELECT ClassId FROM SW_Class WHERE Parentstr LIKE '%" + sortId + "%' OR ClassId = " + sortId + ")";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定排行类型的所属商品列表
/// </summary>
/// <param name="topNumber"></param>
/// <param name="popName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsByPop(int topNumber, string popName)
{
string sqlText = "SELECT TOP " + topNumber + " Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 ORDER BY " + GoodInfo.PopList[popName].ToString() + " DESC";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定品牌的所属商品列表
/// </summary>
/// <param name="brandName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsByBrand(string brandName)
{
string sqlText = "SELECT * FROM SW_Product WHERE Hide = 0 AND Brand = '" + brandName + "'";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回所有商品列表,按简要说明返回
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBrief()
{
string sqlText = "SELECT Id, dianneima, Name, Picture, MarketPrice, MemberPrice, DanWei, GuiGe, Stock FROM SW_Product";
return this.SelectGoodsBrief(sqlText);
}
/**//// <summary>
/// 返回指定分区的所属商品列表,按简要说明返回
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBriefByKind(int topNumber, string kindName)
{
string sqlText = "SELECT TOP " + topNumber + " Id, dianneima, Name, Picture, MarketPrice, MemberPrice, DanWei, GuiGe, Stock FROM SW_Product WHERE Hide = 0 AND Kind = " + GoodInfo.KindList[kindName].ToString() + " ORDER BY JoinDate DESC";
return this.SelectGoodsBrief(sqlText);
}
/**//// <summary>
/// 返回指定分区的所属商品列表
/// </summary>
/// <param name="kindName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsListByKind(string kindName)
{
string sqlText = "SELECT Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND (Kind = " + GoodInfo.KindList[kindName].ToString() + ") ORDER BY JoinDate DESC";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回商品的详细信息
/// </summary>
/// <param name="goodId"></param>
/// <returns></returns>
public GoodInfo SelectGood(int goodId)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "SELECT TOP 1 Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, Detail, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND Id = " + goodId;
SqlDataReader dr = cmd.ExecuteReader();
GoodInfo good;
if (dr.HasRows)
{
dr.Read();
string picturePath = dr["Picture"].ToString();
picturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good = new GoodInfo(Convert.ToInt32(dr["Id"]), dr["dianneima"].ToString(), dr["Name"].ToString(), picturePath, dr["Brand"].ToString(), dr["Kind"].ToString(), dr["GuiGe"].ToString(), dr["Introduce"].ToString(), dr["Detail"].ToString(), Convert.ToDecimal(dr["MarketPrice"]), Convert.ToDecimal(dr["MemberPrice"]), dr["DanWei"].ToString(), Convert.ToDecimal(dr["Score"]), Convert.ToInt32(dr["TotalHits"]), Convert.ToDateTime(dr["JoinDate"]), Convert.ToInt32(dr["Stock"]));
dr.Close();
cmd.Disconnection();
}
else
{
good = new GoodInfo();
}
return good;
}
/**//// <summary>
/// 根据关键字返回商品列表
/// </summary>
/// <param name="queryString"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsListByKeyword(string keyword)
{
string sqlText = "SELECT Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND Name like '%" + keyword + "%'";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 新增商品
/// </summary>
/// <param name="good"></param>
/// <returns></returns>
public bool InsertGood(GoodInfo good)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "INSERT INTO eShop_Goods (SortId, [Name], BrandId, Code, Barcode, Unit, [Standard], PicturePath, SimpleIntroduction, DetailIntroduction, MarketPrice, SellPrice, PublicTime, UpdateTime, ClickCount, ClickTime, Stock) VALUES (" + good.Sort.Id + ", '" + good.Name + "', " + good.BrandInfo.Id + ", '" + good.Code + "', '" + good.Barcode + "', '" + good.Unit + "', '" + good.Standard + "', '" + good.PicturePath + "', '" + good.SimpleIntroduction + "', '" + good.DetailIntroduction + "', " + good.MarketPrice + ", " + good.SellPrice + ", '" + good.PublicTime + "', '" + good.UpdateTime + "', " + good.ClickCount + ", '" + good.ClickTime + "', " + good.Stock + ")";
cmd.ExecuteNonQuery();
return true;
}
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using KoalaStudio.Data.SqlServer;
using JKL.eShop.Model;
namespace JKL.eShop.DAL
{
/**//// <summary>
///
/// </summary>
public class GoodDAL
{
/**//* **************************************************
* 成员列表
* **************************************************/
/**//* **************************************************
* 属性列表
* **************************************************/
/**//* **************************************************
* 构造函数
* **************************************************/
public GoodDAL() { }
/**//* **************************************************
* 私有和受保护方法
* **************************************************/
/**//// <summary>
///
/// </summary>
/// <param name="sqlText"></param>
/// <returns></returns>
private IList<GoodInfo> SelectGoodsBrief(string sqlText)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = sqlText;
SqlDataReader dr = cmd.ExecuteReader();
IList<GoodInfo> goods = new List<GoodInfo>();
SortDAL sortDal = new SortDAL();
if (dr.HasRows)
{
while (dr.Read())
{
GoodInfo good = new GoodInfo();
good.Id = Convert.ToInt32(dr["Id"]); ;
good.Code = dr["dianneima"].ToString();
good.Name = dr["Name"].ToString();
string picturePath = dr["Picture"].ToString();
good.PicturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good.MarketPrice = Convert.ToDecimal(dr["MarketPrice"]); ;
good.SellPrice = Convert.ToDecimal(dr["MemberPrice"]);
good.Unit = dr["DanWei"].ToString();
good.Standard = dr["GuiGe"].ToString();
goods.Add(good);
}
dr.Close();
cmd.Disconnection();
}
return goods;
}
/**//// <summary>
///
/// </summary>
/// <param name="sqlText"></param>
/// <returns></returns>
private IList<GoodInfo> SelectGoodsList(string sqlText)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = sqlText;
SqlDataReader dr = cmd.ExecuteReader();
IList<GoodInfo> goods = new List<GoodInfo>();
SortDAL sortDal = new SortDAL();
if (dr.HasRows)
{
while (dr.Read())
{
GoodInfo good = new GoodInfo();
good.Id = Convert.ToInt32(dr["Id"]);
good.Name = dr["Name"].ToString();
good.BrandInfo.Name = dr["Brand"].ToString();
good.Code = dr["dianneima"].ToString();
string picturePath = dr["Picture"].ToString();
good.PicturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good.KindName = dr["Kind"].ToString();
good.Standard = dr["GuiGe"].ToString();
good.SimpleIntroduction = dr["Introduce"].ToString();
good.PublicTime = Convert.ToDateTime(dr["JoinDate"]);
good.MarketPrice = Convert.ToDecimal(dr["MarketPrice"]); ;
good.SellPrice = Convert.ToDecimal(dr["MemberPrice"]);
good.Unit = dr["DanWei"].ToString();
good.Score = Convert.ToDecimal(dr["Score"]);
good.ClickCount = Convert.ToInt32(dr["TotalHits"]);
goods.Add(good);
}
dr.Close();
cmd.Disconnection();
}
return goods;
}
/**//* **************************************************
* 公共方法
* **************************************************/
/**//// <summary>
/// 更新商品的价格和库存信息
/// </summary>
/// <returns></returns>
public bool UpdateGoodsPrice(GoodInfo goodInfo)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "UPDATE SW_Product SET MarketPrice = " + goodInfo.MarketPrice + ", MemberPrice = " + goodInfo.SellPrice + ", Stock = " + goodInfo.Stock + ", ModiDate = '" + DateTime.Now + "' WHERE Id = " + goodInfo.Id;
cmd.ExecuteNonQuery();
return true;
}
/**//// <summary>
/// 更新商品信息
/// 当前仅支持更新点击率一项
/// </summary>
/// <param name="good"></param>
/// <returns></returns>
public bool UpdateGood(GoodInfo good)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "UPDATE eShop_Goods SET ClickCount = " + good.ClickCount + " WHERE GoodId = " + good.Id;
cmd.ExecuteNonQuery();
return true;
}
/**//// <summary>
/// 返回所有商品列表
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoods()
{
string sqlText = "SELECT * FROM eShop_Goods";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定分类的所属商品列表
/// </summary>
/// <param name="sortId"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBySort(int sortId)
{
string sqlText = "SELECT * FROM SW_Product WHERE Hide = 0 AND ClassId IN (SELECT ClassId FROM SW_Class WHERE Parentstr LIKE '%" + sortId + "%' OR ClassId = " + sortId + ")";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定排行类型的所属商品列表
/// </summary>
/// <param name="topNumber"></param>
/// <param name="popName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsByPop(int topNumber, string popName)
{
string sqlText = "SELECT TOP " + topNumber + " Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 ORDER BY " + GoodInfo.PopList[popName].ToString() + " DESC";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回指定品牌的所属商品列表
/// </summary>
/// <param name="brandName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsByBrand(string brandName)
{
string sqlText = "SELECT * FROM SW_Product WHERE Hide = 0 AND Brand = '" + brandName + "'";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回所有商品列表,按简要说明返回
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBrief()
{
string sqlText = "SELECT Id, dianneima, Name, Picture, MarketPrice, MemberPrice, DanWei, GuiGe, Stock FROM SW_Product";
return this.SelectGoodsBrief(sqlText);
}
/**//// <summary>
/// 返回指定分区的所属商品列表,按简要说明返回
/// </summary>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsBriefByKind(int topNumber, string kindName)
{
string sqlText = "SELECT TOP " + topNumber + " Id, dianneima, Name, Picture, MarketPrice, MemberPrice, DanWei, GuiGe, Stock FROM SW_Product WHERE Hide = 0 AND Kind = " + GoodInfo.KindList[kindName].ToString() + " ORDER BY JoinDate DESC";
return this.SelectGoodsBrief(sqlText);
}
/**//// <summary>
/// 返回指定分区的所属商品列表
/// </summary>
/// <param name="kindName"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsListByKind(string kindName)
{
string sqlText = "SELECT Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND (Kind = " + GoodInfo.KindList[kindName].ToString() + ") ORDER BY JoinDate DESC";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 返回商品的详细信息
/// </summary>
/// <param name="goodId"></param>
/// <returns></returns>
public GoodInfo SelectGood(int goodId)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "SELECT TOP 1 Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, Detail, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND Id = " + goodId;
SqlDataReader dr = cmd.ExecuteReader();
GoodInfo good;
if (dr.HasRows)
{
dr.Read();
string picturePath = dr["Picture"].ToString();
picturePath = picturePath.Substring(0, picturePath.IndexOf("|||"));
good = new GoodInfo(Convert.ToInt32(dr["Id"]), dr["dianneima"].ToString(), dr["Name"].ToString(), picturePath, dr["Brand"].ToString(), dr["Kind"].ToString(), dr["GuiGe"].ToString(), dr["Introduce"].ToString(), dr["Detail"].ToString(), Convert.ToDecimal(dr["MarketPrice"]), Convert.ToDecimal(dr["MemberPrice"]), dr["DanWei"].ToString(), Convert.ToDecimal(dr["Score"]), Convert.ToInt32(dr["TotalHits"]), Convert.ToDateTime(dr["JoinDate"]), Convert.ToInt32(dr["Stock"]));
dr.Close();
cmd.Disconnection();
}
else
{
good = new GoodInfo();
}
return good;
}
/**//// <summary>
/// 根据关键字返回商品列表
/// </summary>
/// <param name="queryString"></param>
/// <returns></returns>
public IList<GoodInfo> SelectGoodsListByKeyword(string keyword)
{
string sqlText = "SELECT Id, dianneima, Name, Picture, Brand, GuiGe, CASE Kind WHEN 0 THEN '最新上架' WHEN 1 THEN '推荐商品' WHEN 2 THEN '特价商品' END AS Kind, Introduce, JoinDate, MarketPrice, MemberPrice, DanWei, Score, TotalHits, Stock FROM SW_Product WHERE Hide = 0 AND Name like '%" + keyword + "%'";
return this.SelectGoodsList(sqlText);
}
/**//// <summary>
/// 新增商品
/// </summary>
/// <param name="good"></param>
/// <returns></returns>
public bool InsertGood(GoodInfo good)
{
CmdCommand cmd = new CmdCommand();
cmd.CommandText = "INSERT INTO eShop_Goods (SortId, [Name], BrandId, Code, Barcode, Unit, [Standard], PicturePath, SimpleIntroduction, DetailIntroduction, MarketPrice, SellPrice, PublicTime, UpdateTime, ClickCount, ClickTime, Stock) VALUES (" + good.Sort.Id + ", '" + good.Name + "', " + good.BrandInfo.Id + ", '" + good.Code + "', '" + good.Barcode + "', '" + good.Unit + "', '" + good.Standard + "', '" + good.PicturePath + "', '" + good.SimpleIntroduction + "', '" + good.DetailIntroduction + "', " + good.MarketPrice + ", " + good.SellPrice + ", '" + good.PublicTime + "', '" + good.UpdateTime + "', " + good.ClickCount + ", '" + good.ClickTime + "', " + good.Stock + ")";
cmd.ExecuteNonQuery();
return true;
}
}
}
作者:行一山人
出处:http://www.cnblogs.com/benbenkoala/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。