internal static NewsInfo ToNewsInfo(TradeNews news)
        {
            NewsInfo tInfo = new NewsInfo();

            tInfo.ID          = news.ID;
            tInfo.NewsContent = news.NewsContent;
            tInfo.NewsTitle   = news.NewsTitle;
            //Todo:查看枚举是否可以如此转换
            tInfo.NType     = (NewsTypeEnum)news.NType;
            tInfo.PubPerson = news.PubPerson;
            tInfo.PubTime   = news.PubTime;
            tInfo.Status    = (NewsStatusEnum)news.Status;
            return(tInfo);
        }
Example #2
0
        private void Save()
        {
            TradeNews news = new TradeNews();

            news.NewsTitle   = txtTitle.Text;
            news.OverView    = txtOverView.Text;
            news.NewsContent = NewsContent.InnerText;
            if (string.IsNullOrEmpty(news.NewsContent))
            {
                MessageBox("请填写内容!");
                return;
            }
            if (string.IsNullOrEmpty(news.NewsTitle))
            {
                MessageBox("请填写标题!");
                return;
            }
            if (string.IsNullOrEmpty(news.OverView))
            {
                MessageBox("请填写摘要!");
                return;
            }
            if (news.NewsContent.Length > 4000)
            {
                MessageBox("内容不能超过4000字符!");
                return;
            }
            if (news.NewsTitle.Length > 200)
            {
                MessageBox("标题不能超过200字符!");
                return;
            }
            if (news.OverView.Length > 2000)
            {
                MessageBox("摘要不能超过2000字符!");
                return;
            }
            int type;

            if (!string.IsNullOrEmpty(ddlType.SelectedItem.Value))
            {
                type = int.Parse(ddlType.SelectedItem.Value);
            }
            else
            {
                MessageBox("请选择类型!");
                return;
            }
            news.NType     = (NewsType)type;
            news.PubPerson = Account;
            int status = 1;

            status      = rbEnable.Checked ? 1 : 0;
            news.Status = (NewsStatus)status;

            ResultDesc result = new ResultDesc();

            if (string.IsNullOrEmpty(ID))
            {
                news.ID = Guid.NewGuid().ToString("n");
                result  = GetManager.AddTradeNews(news, LoginId);
            }
            else
            {
                news.ID = ID;
                result  = GetManager.ModifyTradeNews(news, LoginId);
            }
            MessageBox(result.Desc);
        }
 internal static TradeNews ToTradeNews(NewsInfo tInfo)
 {
     TradeNews news = new TradeNews();
     news.ID = tInfo.ID;
     news.NewsContent = tInfo.NewsContent;
     news.NewsTitle = tInfo.NewsTitle;
     news.NType = (NewsType)tInfo.NType;
     news.PubPerson = tInfo.PubPerson;
     news.PubTime = tInfo.PubTime;
     news.Status = (NewsStatus)tInfo.Status;
     return news;
 }
 internal static NewsInfo ToNewsInfo(TradeNews news)
 {
     NewsInfo tInfo = new NewsInfo();
     tInfo.ID = news.ID;
     tInfo.NewsContent = news.NewsContent;
     tInfo.NewsTitle = news.NewsTitle;
     //Todo:查看枚举是否可以如此转换
     tInfo.NType = (NewsTypeEnum)news.NType;
     tInfo.PubPerson = news.PubPerson;
     tInfo.PubTime = news.PubTime;
     tInfo.Status = (NewsStatusEnum)news.Status;
     return tInfo;
 }