www.pudn.com > MyShop.rar > Config.cs


using System; 
using System.Collections.Generic; 
using System.Data; 
 
 
using MyShop.DALFactory; 
using MyShop.IDAL; 
using MyShop.Model; 
 
namespace MyShop.BLL 
{ 
    public class Config 
    { 
        private IConfig dal = DataAccess.CreateConfig();  
 
        private ConfigInfo configInfo = new ConfigInfo(); 
        private string tableName = "Ljh_Config"; 
 
        public Config() 
        { 
 
            if (!string.IsNullOrEmpty(configInfo.TablePrefix.Trim())) 
                tableName = configInfo.TablePrefix + "Config"; 
 
        } 
 
        #region IConfig 
 
        public int Add(ConfigInfo model) 
        { 
            if (model == null) 
            { 
                return 0; 
            } 
            return dal.Add(model); 
        } 
 
        public 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 ConfigInfo 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(ConfigInfo model, string filter) 
        { 
            if (model == null) 
                return 0; 
            filter = filter.Trim(); 
            return dal.Update(model, filter); 
        } 
 
        #endregion 
 
        #region common 
 
        public int Add(ConfigInfo 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; } public int Update(ConfigInfo model) { if (model == null) { return 0; } string filter; filter = ""; return Update(model, filter); } public ConfigInfo GetModel() { DataSet dataset = new DataSet(); dataset = GetDataSet(); if (dataset != null) return GetModel(dataset.Tables[0].Rows[0]); return null; } #endregion } }