Ejemplo n.º 1
0
        /// <summary>
        /// 禁用和启用
        /// </summary>
        /// <param name="channelId">栏目编号</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public bool Operate(int channelId, string status)
        {
            Tdms_Channel daChannel = new Tdms_Channel();

            if (!daChannel.SelectByPK(channelId))
            {
                Alert("查询失败" + daChannel.PromptInfo.MessageStack);
                return(false);
            }
            if (status == "Open")
            {
                if (daChannel.Status == ChannelStatus.禁用)
                {
                    daChannel.Status = ChannelStatus.启用;
                    if (!daChannel.Update())
                    {
                        Alert("启用失败" + daChannel.PromptInfo.MessageStack);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            if (status == "Close")
            {
                if (daChannel.Status == ChannelStatus.启用)
                {
                    daChannel.Status = ChannelStatus.禁用;
                    if (!daChannel.Update())
                    {
                        Alert("禁用失败" + daChannel.PromptInfo.MessageStack);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }