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