www.pudn.com > MyShop.rar > Help.cs, change:2007-12-17,size:4342b


using System; 
using System.Collections.Generic; 
using System.Data; 
 
using MyShop.DALFactory; 
using MyShop.IDAL; 
using MyShop.Model; 
 
namespace MyShop.BLL 
{ 
    public class Help 
    { 
        private IHelp dal = DataAccess.CreateHelp(); 
 
        #region  IHelp 
        protected int Add(HelpInfo model) 
        { 
            if (model == null) 
            { 
                return 0; 
            } 
            return dal.Add(model); 
        } 
 
        protected int Delete(string filter) 
        { 
            if (string.IsNullOrEmpty(filter)) 
                return 0; 
            return dal.Delete(filter); 
        } 
 
        public bool Exist(string filter) 
        { 
            filter = filter.Trim(); 
            if (string.IsNullOrEmpty(filter)) 
                return false; 
            return dal.Exist(filter); 
        } 
        public DataSet GetDataSet() 
        { 
            return dal.GetDataSet(); 
        } 
 
        public DataSet GetDataSet(string filter) 
        { 
            filter = filter.Trim(); 
            if (string.IsNullOrEmpty(filter)) 
                return null; 
            return dal.GetDataSet(filter); 
        } 
 
        public HelpInfo GetModel(DataRow dr) 
        { 
            if (dr == null) 
                return null; 
            return dal.GetModel(dr); 
        } 
 
        private DataSet Query(string sql) 
        { 
            sql = sql.Trim(); 
            if (string.IsNullOrEmpty(sql)) 
                return null; 
            return dal.Query(sql); 
        } 
 
        public int Update(HelpInfo model, string filter) 
        { 
            if (model == null) 
                return 0; 
            filter = filter.Trim(); 
            if (string.IsNullOrEmpty(filter)) 
                return 0; 
            return dal.Update(model, filter); 
        } 
 
        #endregion 
 
        #region common 
 
        ///  
        ///  
        ///  
        ///  
        ///  
        ///  
        public int Add(HelpInfo model, out string msg) 
        { 
            msg = ""; 
            if (model == null) 
            { 
                msg = msg + "
  • 数据不能为空
  • "; return 0; } bool isErr = false; if (isErr) return 0; int count = 0; count = Add(model); if (count == 0) msg = "
  • 系统发生错误,请重新添加!
  • "; if (count == 1) msg = "
  • 添加成功!
  • "; return count; } /// /// 删除Help /// /// /// public int Delete(int articleId) { HelpInfo model = new HelpInfo(); model = GetModel(articleId); if (model == null) return 0; string filer; filer = " articleId =" + articleId; return Delete(filer); } public int Update(HelpInfo model) { if (model == null) { return 0; } string filter; filter = " articleId=" + model.ArticleID; return Update(model, filter); } public HelpInfo GetModel(int articleId) { DataSet dataset = new DataSet(); dataset = GetDataSet(" articleId=" + articleId); if (dataset != null && dataset.Tables[0].Rows.Count > 0) return GetModel(dataset.Tables[0].Rows[0]); return null; } public HelpInfo GetModel(string title) { title = Utils.ReplaceBadSQL(title.Trim()); if (string.IsNullOrEmpty(title.ToString())) return null; DataSet dataset = new DataSet(); dataset = GetDataSet(" title='" + title + "'"); if (dataset != null && dataset.Tables[0].Rows.Count > 0) return GetModel(dataset.Tables[0].Rows[0]); return null; } #endregion #region 后台管理 #endregion } }