新闻视频 17 编写BLL层

BLL层 

image image

image

业务逻辑层 引用  DAL 层  和 MODEL  层

image

然后 把新闻类别表的操作类 全部复制到  CategoryManager.cs 里面

image

image

然后

image

因为我们会用到  CategoryDAO  这个类  那么我们实例化一个  然后开始改造BLL里面的代码

image

image   

/*
 *创建人:李鹏
 *创建时间:2011-10-26 10:06:29
 *说明:新闻类别表的业务类
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using DAL;
using Model;
using System.Data;
using System.Data.SqlClient;


namespace BLL
{
    public class CategoryManager
    {
        private CategoryDAO cdao = null;

        public CategoryManager()
        {
            cdao = new CategoryDAO();
        }

        #region 取出所有的新闻分类


        public DataTable SelectAll()
        {
            return cdao.SelectAll();
        }
        #endregion

        #region 增加类别


        public bool Insert(string caName)
        {
            return cdao.Insert(caName);
        }
        #endregion

        #region 修改类别


        public bool Update(Category ca)
        {
            return cdao.Update(ca);
        }
        #endregion

        #region 删除类别


        public bool Delete(Category ca)
        {
            return cdao.Delete(ca);
        }
        #endregion

        #region 判断类别名称是否已经存在


        public bool IsExists(string caName)
        {
            return cdao.IsExists(caName);
        }
        #endregion
    }
}
如下图所示

image

这样  新闻类别的逻辑类 已经做好了

接着是  新闻的逻辑类

image

image

image

image

下面是 评论  CommentManager.cs

image

image

对BLL 层 生成一次  看看有无报错

image

实际上  WEB层   不是引用DAL层  而是应该引用 BLL  层(和Model层)

image

image

image

注意一个问题 。耗费了我十分钟,先来看看

image

那么到这里  整个后台的三层代码 就完毕了

image

原文地址:https://www.cnblogs.com/iceicebaby/p/2224961.html