Foods.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

  1. //------------------------------------------------------------------------------
  2. // 创建标识: Copyright (C) 2009 Socansoft.com 版权所有
  3. // 创建描述: SocanCode代码生成器 V4.3.2.3 自动创建于 2009-12-7 19:55:38
  4. //
  5. // 功能描述: 
  6. //
  7. // 修改标识: 
  8. // 修改描述: 
  9. //------------------------------------------------------------------------------
  10. using System;
  11. using System.Data;
  12. using System.Collections.Generic;
  13. using System.Text;
  14. using System.Web;
  15. using System.Web.Caching;
  16. namespace BLL
  17. {
  18. /// <summary>
  19. /// 业务逻辑类 Foods
  20. /// </summary>
  21. public class Foods
  22. {
  23. private readonly SqlServerDAL.Foods dal = new SqlServerDAL.Foods();
  24. public Foods()
  25. { }
  26.         /// <summary>
  27. /// 增加一条数据
  28. /// </summary>
  29.         public void Add(Model.Foods model)
  30.         {
  31.             if(model == null)
  32.                 throw new Exception("实体参数不能为空。");
  33.             //请在此处添加更多与业务逻辑有关的验证,例如:
  34.             //if(string.IsNullOrEmpty(model.Name))
  35.             //    throw new Exception("名称不能为空。");
  36.             //if (!Regex.IsMatch(style, @"^[swu4e00-u9fa5]{1,20}$"))
  37.             //    throw new Exception("名称格式不正确。");
  38.             dal.Add(model);
  39.         }
  40.         /// <summary>
  41. /// 更新一条数据
  42. /// </summary>
  43.         public void Update(Model.Foods model)
  44.         {
  45.             if(model == null)
  46.                 throw new Exception("实体参数不能为空。");
  47.             //请在此处添加更多与业务逻辑有关的验证,例如:
  48.             //if(string.IsNullOrEmpty(model.Name))
  49.             //    throw new Exception("名称不能为空。");
  50.             //if (!Regex.IsMatch(style, @"^[swu4e00-u9fa5]{1,20}$"))
  51.             //    throw new Exception("名称格式不正确。");
  52.             dal.Update(model);
  53.         }
  54.         /// <summary>
  55. /// 删除一条数据
  56. /// </summary>
  57.         public void Delete(int ID)
  58.         {
  59.             if (ID <= 0)
  60.                 throw new Exception("参数不正确。");
  61.             dal.Delete(ID);
  62.         }
  63.         /// <summary>
  64. /// 是否存在该记录
  65. /// </summary>
  66.         public bool Exists(int ID)
  67.         {
  68.             if (ID <= 0)
  69.                 throw new Exception("参数不正确。");
  70.             return dal.Exists(ID);
  71.         }
  72.         /// <summary>
  73. /// 得到一个对象实体
  74. /// </summary>
  75.         public Model.Foods GetModel(int ID)
  76.         {
  77.             if (ID <= 0)
  78.                 throw new Exception("参数不正确。");
  79.             return dal.GetModel(ID);
  80.         }
  81.         /// <summary>
  82. /// 获得泛型数据列表
  83. /// </summary>
  84.         public List<Model.Foods> GetList()
  85.         {
  86.             return dal.GetList();
  87.         }
  88.         /// <summary>
  89. /// 取得数据行数,不建议直接使用此方法,请根据业务逻辑重写
  90. /// </summary>
  91.         public int GetCount(string condition)
  92.         {
  93.             return dal.GetCount(condition);
  94.         }
  95.         /// <summary>
  96. /// 分页获取泛型数据列表,不建议直接使用此方法,请根据业务逻辑重写
  97. /// </summary>
  98.         public List<Model.Foods> GetPageList(int pageSize, int pageIndex, string fldSort, bool fldDir, string condition)
  99.         {
  100.             if (pageSize <= 0)
  101.                 throw new Exception("每页数据条数必须大于0。");
  102.             if (pageIndex <= 0)
  103.                 throw new Exception("页索引必须大于0。");
  104.             if (string.IsNullOrEmpty(fldSort))
  105.                 throw new Exception("排序字段不能为空。如果是默认排序,可以填写主键字段。");
  106.             return dal.GetPageList(pageSize, pageIndex, fldSort, fldDir, condition);
  107.         }
  108. }
  109. }