📄 dictionarybll.cs
字号:
//------------------------------------*/
//版权所有:杭州商易信息技术有限公司
//功能描述:系统字典类
// 作者:沈伟
// 日期:2008/08/27
//------------------------------------*/
using System;
using System.Data;
using System.Text;
namespace Itsv.BLL.SystemManage
{
public class dictionaryBLL
{
private static readonly Itsv.DAL.SystemManage.dictionaryDAL dal = new Itsv.DAL.SystemManage.dictionaryDAL();
public dictionaryBLL()
{ }
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(int dict_id)
{
return dal.Exists(dict_id);
}
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(Itsv.Model.dictionary model, ref string msg)
{
try
{
//if (dal.Exists(model.dict_code))
//{
// msg = "字典编号已经存在" + model.dict_code;
// return false;
//}
msg = "字典项增加成功";
dal.Add(model);
return true;
}
catch (Exception ex)
{
msg = ex.Message.Replace("'", "");
return false;
}
}
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(Itsv.Model.dictionary model, ref string msg)
{
try
{
Itsv.Model.dictionary d = dal.GetModel(model.dict_code);
if (model != null)
{
if (d.dict_id != model.dict_id)
{
msg = "字典编号已经存在" + model.dict_code;
return false;
}
}
msg = "修改字典项成功";
dal.Update(model);
return true;
}
catch (Exception ex)
{
msg = ex.Message.Replace("'", "");
return false;
}
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(int dict_id, ref string msg)
{
try
{
//判断是否存在子项
DataSet ds = dal.GetList(" parent_id = " + dict_id);
if (ds.Tables[0].Rows.Count > 0)
{
msg = "存在子项目,请先删除子项目";
ds.Dispose();
ds = null;
return false;
}
msg = "删除成功";
dal.Delete(dict_id);
return true;
}
catch (Exception ex)
{
msg = ex.Message.Replace("'", "");
return false;
}
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Itsv.Model.dictionary GetModel(int dict_id, ref string msg)
{
try
{
msg = "操作成功";
return dal.GetModel(dict_id);
}
catch (Exception ex)
{
msg = ex.Message.Replace("'", "");
return null;
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -