using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL;
|
using CY.Model;
|
using CY.Infrastructure.Common;
|
using System.Data;
|
using CY.BLL.Sys;
|
|
namespace CY.WebForm.Pages.InfoManage
|
{
|
//吴辉
|
//网站信息分类
|
public partial class SiteInfoCate : BasePage
|
{
|
Info_SortBLL bll_Info_SortBLL = null;
|
Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
|
public static string treeHtml = ""; //树形参数
|
public static string selHtml = ""; //下拉框内容
|
|
//实例化
|
public SiteInfoCate()
|
{
|
bll_Info_SortBLL = new Info_SortBLL();
|
bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
}
|
|
//页面加载
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
if (Request["deleteid"] != null)
|
{
|
Info_Sort m_Info_Sort = bll_Info_SortBLL.SelectModelByKeyId(Request["deleteid"].ToInt32());
|
if (m_Info_Sort != null)
|
{
|
if (bll_Info_SortBLL.DeleteModelAll(m_Info_Sort.Keyid))
|
Response.Write("1");
|
else
|
Response.Write("2");
|
}
|
Response.End();
|
}
|
|
if (!IsPostBack)
|
{
|
InitialData();
|
}
|
}
|
|
//提交修改 hideKeyId
|
protected void btn_Submit_Config(object sender, EventArgs e)
|
{
|
Info_Sort m_Info_Sort = new Info_Sort();
|
if (this.hideKeyId.Value.ToInt32() > 0)
|
m_Info_Sort = bll_Info_SortBLL.SelectModelByKeyId(this.hideKeyId.Value.ToInt32());
|
|
m_Info_Sort.CateTypeId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(5, "网站资讯类型");
|
m_Info_Sort.Leavel = 0;
|
m_Info_Sort.ParentId = this.selParentId.Value.ToInt32();
|
m_Info_Sort.Title = this.txtTitle.Value.ToString2();
|
m_Info_Sort.Status = this.selStatus.Value.ToString2();
|
m_Info_Sort.OrderNum = this.txtOrderNum.Value.ToInt32();
|
m_Info_Sort.IsHomeShow = false;
|
|
m_Info_Sort.IsOtherPage = false;// this.selIsOtherPage.Value.ToBoolean2();
|
m_Info_Sort.Herf = ""; //this.txtHerf.Value.ToString2();
|
|
m_Info_Sort.Operator = CurrentUser.ShortName;
|
m_Info_Sort.LastUpdateTime = DateTime.Now;
|
m_Info_Sort.Remarks = "";
|
|
|
//图片上传
|
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.Upload("fileIcon", m_Info_Sort.Icon);
|
m_Info_Sort.Icon = m_Info_Sort.Icon ?? "";
|
if (_UpFileResult2.returnerror.Count == 0)
|
{
|
if (_UpFileResult2.returnfilename.Count > 0)
|
m_Info_Sort.Icon = _UpFileResult2.returnfilename[0].ToString2();
|
}
|
else
|
{
|
JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this);
|
return;
|
}
|
|
|
if (this.hideKeyId.Value.ToInt32() > 0)
|
{
|
if (bll_Info_SortBLL.UpdateModel(m_Info_Sort))
|
JavaScript.MessageBox("更新成功", this);
|
else
|
JavaScript.MessageBox("更新失败", this);
|
}
|
else
|
{
|
m_Info_Sort.AdminId = CurrentUser.MemberId;
|
if (bll_Info_SortBLL.InsertModel(m_Info_Sort))
|
JavaScript.MessageBox("添加成功", this);
|
else
|
JavaScript.MessageBox("添加失败", this);
|
}
|
InitialData();
|
}
|
|
//获取遍历结果
|
public void InitialData()
|
{
|
DataTable ds = bll_Info_SortBLL.SelectList("11111111-1111-1111-1111-111111111111".ToGuid2());
|
selParentId.Items.Clear();
|
treeHtml = "{ id: " + bll_Sys_DictionaryBLL.GetKeyIdByKeyid(5, "网站资讯类型") + ", parentId: -1, name: '网站信息分类', open: true },";
|
selParentId.Items.Insert(0, new ListItem("网站信息分类", bll_Sys_DictionaryBLL.GetKeyIdByKeyid(5, "网站资讯类型").ToString2()));
|
if (ds != null && ds.Rows.Count > 0)
|
{
|
GetDataByLevel(ref treeHtml, selParentId, ds, bll_Sys_DictionaryBLL.GetKeyIdByKeyid(5, "网站资讯类型"), 1);
|
}
|
treeHtml = treeHtml.Trim(',');
|
}
|
|
//遍历数据
|
public static void GetDataByLevel(ref string treeHtmlo, 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)
|
{
|
treeHtmlo = treeHtmlo + "{ id: " + result[i]["Keyid"].ToString2() + ", parentId: " + result[i]["ParentId"].ToString2() + ", name: '" + result[i]["Title"].ToString2() + "[" + result[i]["OrderNum"].ToString2() + "]" + "'" + (level < 2 ? ", open: true" : "") + " },";
|
GetDataByLevel(ref treeHtmlo, 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;
|
}
|
|
}
|
}
|