username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.BLL;
using CY.Infrastructure.Common;
using System.Data;
using CY.BLL.Sys;
 
namespace CY.WebForm.Pages.InfoManage
{
    //吴辉
    //添加/修改新闻信息
    public partial class NewsInfoEdit : BasePage
    {
        Info_SortBLL bll_Info_SortBLL = null;
        Info_ContentBLL bll_Info_ContentBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
 
        //初始化
        public NewsInfoEdit()
        {
            bll_Info_SortBLL = new Info_SortBLL();
            bll_Info_ContentBLL = new Info_ContentBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //页面加载
        public void InitData()
        {
            this.selTitle_Color.DataSource = bll_Sys_DictionaryBLL.GetDataByType("新闻信息标题颜色");
            this.selTitle_Color.DataValueField = "Remark";
            this.selTitle_Color.DataTextField = "Name";
            this.selTitle_Color.DataBind();
            this.selTitle_Color.Items.Insert(0, new ListItem("默认", ""));
 
 
            DataTable ds = bll_Info_SortBLL.SelectList("11111111-1111-1111-1111-111111111111".ToGuid2());
            this.selSortId.Items.Clear();
            this.selSortId.Items.Insert(0, new ListItem("请选择", bll_Sys_DictionaryBLL.GetKeyIdByKeyid(3, "网站资讯类型").ToString2()));
            if (ds != null && ds.Rows.Count > 0)
            {
                GetDataByLevel(this.selSortId, ds, bll_Sys_DictionaryBLL.GetKeyIdByKeyid(3, "网站资讯类型"), 1);
            }
 
            Info_Content m_Info_Content = new Info_Content();
            if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
                m_Info_Content = bll_Info_ContentBLL.SelectModelBySortId(Request["Keyid"].ToInt32());
 
            this.txtTitle.Value = m_Info_Content.Title.ToString2();
            this.selTitle_Bold.Value = m_Info_Content.Title_Bold ? "true" : "false";
            this.selTitle_Color.Value = m_Info_Content.Title_Color.ToString2();
            this.selSortId.Value = m_Info_Content.SortID.ToString2();
            this.txtFromSource.Value = m_Info_Content.FromSource.ToString2();
            this.txtAuthor.Value = m_Info_Content.Author.ToString2();
            this.selIsRecommendation.Value = m_Info_Content.IsRecommendation ? "true" : "false";
            this.selIsTop.Value = m_Info_Content.IsTop ? "true" : "false";
            this.txtInfoContent.Text =m_Info_Content.InfoContent.ToString2();
            this.txtOrderNum.Value = m_Info_Content.OrderNum.ToString2();
 
        }
 
        //遍历数据
        public static void GetDataByLevel(System.Web.UI.HtmlControls.HtmlSelect sel, DataTable data, int? parentId, int level)
        {
 
            DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
            int i = -1;
            while (++i < result.Length)
            {
                sel.Items.Add(new ListItem(GetSplitChar(level) + result[i]["Title"].ToString2(), result[i]["Keyid"].ToString2()));
                GetDataByLevel(sel, data, result[i]["Keyid"].ToInt32().Value, level + 1);
            }
        }
 
        //获取隔位符
        public static string GetSplitChar(int level)
        {
            string res = ""; //level.ToString2();
            for (int i = 0; i < level; i++)
            {
                res += "..";
            }
            return res;
        }
 
        //提交事件
        protected void btn_Submit_form(object sender, EventArgs e)
        {
            Info_Content m_Info_Content = new Info_Content();
            if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
                m_Info_Content = bll_Info_ContentBLL.SelectModelBySortId(Request["Keyid"].ToInt32());
 
            m_Info_Content.Title = this.txtTitle.Value.ToString2();
            m_Info_Content.Title_Bold = this.selTitle_Bold.Value.ToBoolean2();
            m_Info_Content.Title_Color = this.selTitle_Color.Value.ToString2();
            m_Info_Content.SortID = this.selSortId.Value.ToInt32();
            m_Info_Content.Keyword = this.txtTitle.Value.ToString2();
            m_Info_Content.MeteDesc = this.txtTitle.Value.ToString2();
            m_Info_Content.FromSource = this.txtFromSource.Value.ToString2();
            m_Info_Content.Author = this.txtAuthor.Value.ToString2();
            m_Info_Content.WebLink ="";
            m_Info_Content.IsRecommendation = this.selIsRecommendation.Value.ToBoolean2();
            m_Info_Content.IsTop = this.selIsTop.Value.ToBoolean2();
            m_Info_Content.InfoContent = this.txtInfoContent.Text.ToString2();
            m_Info_Content.OrderNum = this.txtOrderNum.Value.ToInt32();
            m_Info_Content.UpTime = DateTime.Now;
 
            if (Request["Keyid"] != null && Request["Keyid"].ToInt32() > 0)
            {
                if (bll_Info_ContentBLL.UpdateModel(m_Info_Content))
                    JavaScript.MessageBox("更新成功", this,true,true);
                else
                    JavaScript.MessageBox("更新失败", this);
            }
            else
            {
                m_Info_Content.MemberId = "11111111-1111-1111-1111-111111111111".ToGuid2();
                m_Info_Content.Star = 0;
                m_Info_Content.Hits = 0;
                m_Info_Content.GoodNum = 0;
                m_Info_Content.MediumNum = 0;
                m_Info_Content.BadNum = 0;
                m_Info_Content.CreatTime = DateTime.Now;
                m_Info_Content.TypeId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(3, "网站资讯类型").ToInt32();
 
                if (bll_Info_ContentBLL.InsertModel(m_Info_Content))
                    JavaScript.MessageBox("发布成功", this,true,true);
                else
                    JavaScript.MessageBox("发布失败", this);
            }
        }
 
 
    }
}