/// <summary> /// 获取所有客户等级 /// </summary> /// <param name="companyId">公司编号</param> /// <returns>客户等级集合</returns> public IList <MComLev> GetList(string companyId) { string sql = "SELECT Id,CompanyId,[Name],OperatorId,IsSystem,LevType FROM tbl_ComLev WHERE IsDelete = '0' AND CompanyId = @CompanyId"; DbCommand comm = this._db.GetSqlStringCommand(sql); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, companyId); IList <MComLev> list = new List <MComLev>(); MComLev item = null; using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db)) { while (reader.Read()) { list.Add(item = new MComLev() { Id = (int)reader["Id"], CompanyId = reader["CompanyId"].ToString(), Name = reader["Name"].ToString(), OperatorId = reader["OperatorId"].ToString(), IsSystem = GetBoolean(reader["IsSystem"].ToString()), LevType = (EyouSoft.Model.EnumType.ComStructure.LevType) Enum.Parse(typeof(EyouSoft.Model.EnumType.ComStructure.LevType), reader["LevType"].ToString()) }); } } return(list); }
/// <summary> /// 修改客户等级 /// </summary> /// <param name="item">客户等级实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComLev item) { string sql = "UPDATE tbl_ComLev SET [Name] = @Name,OperatorId = @OperatorId WHERE Id = @Id AND CompanyId = @CompanyId and IsSystem='0'"; DbCommand comm = this._db.GetSqlStringCommand(sql); this._db.AddInParameter(comm, "@Name", DbType.String, item.Name); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@Id", DbType.Int32, item.Id); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 添加客户等级 /// </summary> /// <param name="item">客户等级实体</param> /// <returns>true:成功 false:失败</returns> public bool Add(MComLev item) { string sql = "INSERT INTO tbl_ComLev(CompanyId,[Name],OperatorId,LevType) VALUES(@CompanyId,@Name,@OperatorId,@LevType)"; DbCommand comm = this._db.GetSqlStringCommand(sql); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); this._db.AddInParameter(comm, "@Name", DbType.String, item.Name); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@LevType", DbType.Byte, (int)item.LevType); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 修改客户等级 /// </summary> /// <param name="item">客户等级实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComLev item) { if (item == null || item.Id < 1) { return(false); } bool result = dal.Update(item); if (result) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("修改客户等级,编号为:{0}", item.Id)); EyouSoft.Cache.Facade.EyouSoftCache.Remove(string.Format(TagName.BaoJiaBiaoZhun, item.CompanyId)); } return(result); }
/// <summary> /// 添加客户等级 /// </summary> /// <param name="item">客户等级实体</param> /// <returns>true:成功 false:失败</returns> public bool Add(MComLev item) { if (item == null) { return(false); } bool result = dal.Add(item); if (result) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("添加客户等级,名称为:{0}", item.Name)); EyouSoft.Cache.Facade.EyouSoftCache.Remove(string.Format(TagName.BaoJiaBiaoZhun, item.CompanyId)); } return(result); }
/// <summary> /// 获取客户等级信息业务实体 /// </summary> /// <param name="dengJiId">客户等级编号</param> /// <param name="companyId">公司编号</param> /// <returns></returns> public MComLev GetInfo(int dengJiId, string companyId) { var items = GetList(companyId); if (items == null || items.Count == 0) { return(null); } MComLev info = null; foreach (var item in items) { if (item.Id == dengJiId) { info = item; break; } } return(info); }