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 SiteInfoEdit : BasePage
|
{
|
Info_SortBLL bll_Info_SortBLL = null;
|
Info_ContentBLL bll_Info_ContentBLL = null;
|
Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
|
|
//初始化
|
public SiteInfoEdit()
|
{
|
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()
|
{
|
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(5, "网站资讯类型").ToString2()));
|
if (ds != null && ds.Rows.Count > 0)
|
{
|
GetDataByLevel(this.selSortId, ds, bll_Sys_DictionaryBLL.GetKeyIdByKeyid(5, "网站资讯类型"), 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.selSortId.Value = m_Info_Content.SortID.ToString2();
|
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 = false;
|
m_Info_Content.Title_Color = "";
|
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 = "";
|
m_Info_Content.Author = "";
|
m_Info_Content.WebLink = "";
|
m_Info_Content.IsRecommendation = false;
|
m_Info_Content.IsTop = false;
|
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 = CurrentUser.MemberId;
|
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(5, "网站资讯类型").ToInt32();
|
|
if (bll_Info_ContentBLL.InsertModel(m_Info_Content))
|
JavaScript.MessageBox("发布成功", this,true,true);
|
else
|
JavaScript.MessageBox("发布失败", this);
|
}
|
}
|
|
|
}
|
}
|