public string GetColumn(int Id) { StringBuilder sb = new StringBuilder(); int count = new BLL.contents.article().GetCount("category_id=" + Id + "") > 0 ? new BLL.contents.article().GetCount("category_id=" + Id + "") : 0; model = bll.GetModel(Id); switch (model.model_id) { case 1: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 2: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\">" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 3: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 4: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 0: sb.Append(model.title); break; } return(sb.ToString()); }
public string GetColumn(int Id) { StringBuilder sb = new StringBuilder(); int count = new BLL.contents.article().GetCount("category_id=" + Id + "") > 0 ? new BLL.contents.article().GetCount("category_id=" + Id + "") : 0; model = bll.GetModel(Id); switch (model.model_id) { case 1: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 2: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\">" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 3: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 4: sb.Append("<a href=\"article/article_list.aspx?category_id=" + Id + "\" target=\"mainFrame\" >" + model.title + "</a>" + "<span class=\"column\">(" + count + ")</span>"); break; case 0: sb.Append(model.title); break; } return sb.ToString(); }
private void edit_category(HttpContext context) { //取得管理员登录信息 Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo(); if (adminInfo == null) { context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}"); return; } int category1 = OSRequest.GetFormInt("Category1"); int category2 = OSRequest.GetFormInt("Category2"); if (category1 == category2) { context.Response.Write("{\"status\": 0, \"msg\": \"移动目录跟目的目录不能相同!\"}"); return; } BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(category2); if (model.class_list.IndexOf("," + category1 + ",") > 0) { context.Response.Write("{\"status\": 0, \"msg\": \"父级本不能向其子级转移!\"}"); return; } if (bll.GetModel(category1).parent_id == category2) { context.Response.Write("{\"status\": 0, \"msg\": \"移动目录已经在目的目录里!\"}"); return; } DataTable dt = bll.GetList(0, "class_list like '%," + category1 + ",%'", "class_layer asc").Tables[0]; if (dt.Rows != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { int id = Convert.ToInt32(dt.Rows[i]["id"]); string class_list = dt.Rows[i]["class_list"].ToString(); int new_channel_id = model.channel_id; string new_class_list = model.class_list + class_list.Substring(class_list.IndexOf("," + category1 + ",")).TrimStart(','); string new_class_layer = new_class_list.Trim(',').Split(',').Length.ToString(); if (i == 0) { bll.UpdateField(id, "channel_id=" + new_channel_id + ", parent_id=" + category2 + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer); } else { bll.UpdateField(id, "channel_id=" + new_channel_id + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer); } } } new BLL.managers.manager_log().Add(adminInfo.id, adminInfo.user_name, OSEnums.ActionEnum.Edit.ToString(), "移动栏目:" + bll.GetModel(category1).title); //记录日志 context.Response.Write("{\"status\": 1, \"msg\": \"栏目转移成功!\"}"); }
private void ShowInfo(int _id) { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(_id); ddlParentId.SelectedValue = model.parent_id.ToString(); txtCallIndex.Text = model.call_index; txtCallIndex.Attributes.Add("ajaxurl", "../../ashx/admin_ajax.ashx?action=navigation_validate&old_name=" + Utils.UrlEncode(model.call_index)); txtCallIndex.Focus(); //设置焦点,防止JS无法提交 txtTitle.Text = model.title; txtSortId.Text = model.sort_id.ToString(); txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; txtLinkUrl.Text = model.link_url; txtImgUrl.Text = model.img_url; txtContent.Value = model.content; rblStatus.SelectedValue = model.model_id.ToString(); if (model.is_add_category == 1) { cblItem.Items[0].Selected = true; } if (model.is_add_content == 1) { cblItem.Items[1].Selected = true; } if (model.is_show_top == 1) { cblItem.Items[2].Selected = true; } if (model.is_show_foot == 1) { cblItem.Items[3].Selected = true; } if (model.is_albums == 1) { cbIsAlbums.Checked = true; } if (model.is_attach == 1) { cbIsAttach.Checked = true; } txtPageSize.Text = model.page_size.ToString(); //赋值扩展字段 if (model.category_fields != null) { for (int i = 0; i < cblAttributeField.Items.Count; i++) { Model.contents.category_field modelt = model.category_fields.Find(p => p.field_id == int.Parse(cblAttributeField.Items[i].Value)); //查找对应的字段ID if (modelt != null) { cblAttributeField.Items[i].Selected = true; } } } }
public void ProcessRequest(HttpContext context) { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = new Model.contents.article_category(); int id = OSRequest.GetQueryInt("id", -2); int type = OSRequest.GetQueryInt("type", -2); //0上 ;1下 model = bll.GetModel(id); DataTable dt_sx = bll.GetList(0, "parent_id=" + model.parent_id, "sort_id asc,id desc").Tables[0]; if (dt_sx.Rows != null && dt_sx.Rows.Count > 0) { for (int i = 0; i < dt_sx.Rows.Count; i++) { if (Convert.ToInt32(dt_sx.Rows[i]["ID"]) == id) { if (type == 1) { if ((i + 1) < dt_sx.Rows.Count) { int newId = Convert.ToInt32(dt_sx.Rows[i + 1]["ID"]); //位置互换 bll.UpdateField(newId, "sort_id=" + model.sort_id + ""); bll.UpdateField(id, "sort_id=" + (bll.GetModel(newId).sort_id + 1) + ""); context.Response.Write("OK"); } else { context.Response.Write("down"); } } else if (type == 0) { if ((i - 1) >= 0) { int newId = Convert.ToInt32(dt_sx.Rows[i - 1]["ID"]); //位置互换 bll.UpdateField(newId, "sort_id=" + model.sort_id + ""); bll.UpdateField(id, "sort_id=" + (bll.GetModel(newId).sort_id - 1) + ""); context.Response.Write("OK"); } else { context.Response.Write("up"); } } else { context.Response.Write("参数错误"); } } } } }
/// <summary> /// 加载栏目简介 /// </summary> /// <param name="id"></param> /// <returns></returns> public static string GetCategoryZhaiYao(int id) { string rStr = string.Empty; BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(id); if (model != null) { rStr = model.content; } return(rStr); }
/// <summary> /// 加载名称+Url /// </summary> /// <param name="id"></param> /// <returns></returns> public static string GetPageNameUrl(int id) { string rStr = string.Empty; BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(id); if (model != null) { rStr = "<a href=\"" + model.link_url + "\">" + model.title + "</a>"; } return(rStr); }
public void ProcessRequest(HttpContext context) { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = new Model.contents.article_category(); int id = OSRequest.GetQueryInt("id", -2); int type = OSRequest.GetQueryInt("type", -2); //0上 ;1下 model = bll.GetModel(id); DataTable dt_sx = bll.GetList(0, "parent_id=" + model.parent_id, "sort_id asc,id desc").Tables[0]; if (dt_sx.Rows != null && dt_sx.Rows.Count > 0) { for (int i = 0; i < dt_sx.Rows.Count; i++) { if (Convert.ToInt32(dt_sx.Rows[i]["ID"]) == id) { if (type == 1) { if ((i + 1) < dt_sx.Rows.Count) { int newId = Convert.ToInt32(dt_sx.Rows[i + 1]["ID"]); //位置互换 bll.UpdateField(newId, "sort_id=" + model.sort_id + ""); bll.UpdateField(id, "sort_id=" + (bll.GetModel(newId).sort_id + 1) + ""); context.Response.Write("OK"); } else { context.Response.Write("down"); } } else if (type == 0) { if ((i - 1) >= 0) { int newId = Convert.ToInt32(dt_sx.Rows[i - 1]["ID"]); //位置互换 bll.UpdateField(newId, "sort_id=" + model.sort_id + ""); bll.UpdateField(id, "sort_id=" + (bll.GetModel(newId).sort_id - 1) + ""); context.Response.Write("OK"); } else { context.Response.Write("up"); } } else { context.Response.Write("参数错误"); } } } } }
public string Column_Access(int Id) { if (Id != -1) { model = bll.GetModel(Id); //允许添加子类 string is_zilei = model.is_add_category == 1 ? " <a style=\"padding-left:30px;\" href=\"category_edit.aspx?action=" + OSEnums.ActionEnum.Add + "&channel_id=" + model.channel_id + "&id=" + Id + "\"/>添加子类</a>" : ""; //默认最多只能添加三级("model.class_layer == 3"深度) string is_zilei_there = model.class_layer == 4 ? "" : is_zilei; string style = is_zilei_there == "" ? "style=\"padding-left:20px;\"" : "style=\"padding-left:10px;\""; return is_zilei_there + "<a " + style + " href=\"category_edit.aspx?action=" + OSEnums.ActionEnum.Edit + "&channel_id=" + model.channel_id + "&id=" + Id + "\"/>编辑</a> <a style=\"padding-left:10px;\" href=\"javascript:del(" + Id + ")\" class=\"del\">删除</a> <a style=\"padding-left:10px;\" href=\"javascript:categoey(" + Id + ")\" >移动</a>"; } return ""; }
public string Column_Access(int Id) { if (Id != -1) { model = bll.GetModel(Id); //允许添加子类 string is_zilei = model.is_add_category == 1 ? " <a style=\"padding-left:30px;\" href=\"category_edit.aspx?action=" + OSEnums.ActionEnum.Add + "&channel_id=" + model.channel_id + "&id=" + Id + "\"/>添加子类</a>" : ""; //默认最多只能添加三级("model.class_layer == 3"深度) string is_zilei_there = model.class_layer == 4 ? "" : is_zilei; string style = is_zilei_there == "" ? "style=\"padding-left:20px;\"" : "style=\"padding-left:10px;\""; return(is_zilei_there + "<a " + style + " href=\"category_edit.aspx?action=" + OSEnums.ActionEnum.Edit + "&channel_id=" + model.channel_id + "&id=" + Id + "\"/>编辑</a> <a style=\"padding-left:10px;\" href=\"javascript:del(" + Id + ")\" class=\"del\">删除</a> <a style=\"padding-left:10px;\" href=\"javascript:categoey(" + Id + ")\" >移动</a>"); } return(""); }
private bool DoEdit(int _id) { try { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = 0; model.call_index = txtName.Text.Trim(); if (cbIsLock.Checked == true) { model.is_lock = 1; } if (model.is_sys == 0) { int parentId = int.Parse(ddlParentId.SelectedValue); //如果选择的父ID不是自己,则更改 if (parentId != model.id) { model.parent_id = parentId; } } model.link_url = txtLinkUrl.Text.Trim(); model.content = txtRemark.Text; //添加操作权限类型 string action_type_str = string.Empty; for (int i = 0; i < cblActionType.Items.Count; i++) { if (cblActionType.Items[i].Selected && Utils.ActionType().ContainsKey(cblActionType.Items[i].Value)) { action_type_str += cblActionType.Items[i].Value + ","; } } model.action_type = Utils.DelLastComma(action_type_str); if (bll.Update(model)) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "修改导航信息:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
private bool DoAdd() { try { Model.contents.article_category model = new Model.contents.article_category(); BLL.contents.article_category bll = new BLL.contents.article_category(); model.nav_type = OSEnums.NavigationEnum.System.ToString().Trim();; model.title = txtTitle.Text.Trim(); model.channel_id = -1; model.call_index = txtName.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtRemark.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = 0; if (cbIsLock.Checked == true) { model.is_lock = 1; } model.parent_id = int.Parse(ddlParentId.SelectedValue); //添加操作权限类型 string action_type_str = string.Empty; for (int i = 0; i < cblActionType.Items.Count; i++) { if (cblActionType.Items[i].Selected && Utils.ActionType().ContainsKey(cblActionType.Items[i].Value)) { action_type_str += cblActionType.Items[i].Value + ","; } } model.action_type = Utils.DelLastComma(action_type_str); if (bll.Add(model) > 0) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "添加导航信息:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
private void ShowInfo(int _id) { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(_id); ddlParentId.SelectedValue = model.parent_id.ToString(); txtSortId.Text = model.sort_id.ToString(); if (model.is_lock == 1) { cbIsLock.Checked = true; } ddlParentId.Enabled = false; if (model.nav_type.Trim() == "WebSite") { txtTitle.Enabled = false; style = " style=\"display:none\""; } txtTitle.Text = model.title; txtName.Text = model.call_index; txtName.Attributes.Add("ajaxurl", "../../ashx/admin_ajax.ashx?action=navigation_validate&old_name=" + Utils.UrlEncode(model.call_index)); txtName.Focus(); //设置焦点,防止JS无法提交 txtLinkUrl.Text = model.link_url; txtRemark.Text = model.content; //赋值操作权限类型 string[] actionTypeArr = model.action_type.Split(','); for (int i = 0; i < cblActionType.Items.Count; i++) { for (int n = 0; n < actionTypeArr.Length; n++) { if (actionTypeArr[n].ToLower() == cblActionType.Items[i].Value.ToLower()) { cblActionType.Items[i].Selected = true; } } } }
private bool DoEdit(int _id) { try { BLL.contents.article_category bll = new BLL.contents.article_category(); Model.contents.article_category model = bll.GetModel(_id); int parentId = int.Parse(ddlParentId.SelectedValue); model.channel_id = this.channel_id; model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); //如果选择的父ID不是自己,则更改 //if (parentId != model.id) //{ // model.parent_id = parentId; //} model.sort_id = int.Parse(txtSortId.Text.Trim()); model.seo_title = txtSeoTitle.Text; model.seo_keywords = txtSeoKeywords.Text; model.seo_description = txtSeoDescription.Text; model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.content = txtContent.Value; model.model_id = int.Parse(rblStatus.SelectedValue); model.is_add_category = 0; model.is_add_content = 0; model.is_show_top = 0; model.is_show_foot = 0; if (cblItem.Items[0].Selected == true) { model.is_add_category = 1; } if (cblItem.Items[1].Selected == true) { model.is_add_content = 1; } if (cblItem.Items[2].Selected == true) { model.is_show_top = 1; } if (cblItem.Items[3].Selected == true) { model.is_show_foot = 1; } if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10); //添加频道扩展字段 List <Model.contents.category_field> ls = new List <Model.contents.category_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { ls.Add(new Model.contents.category_field { category_id = model.id, field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0) }); } } model.category_fields = ls; if (bll.Update(model)) { AddAdminLog(OSEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道栏目分类:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.contents.article_category model) { return(dal.Update(model)); }
private bool DoAdd() { try { Model.contents.article_category model = new Model.contents.article_category(); BLL.contents.article_category bll = new BLL.contents.article_category(); model.channel_id = this.channel_id; model.nav_type = OSEnums.NavigationEnum.WebSite.ToString().Trim(); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); // model.parent_id = int.Parse(ddlParentId.SelectedValue); model.parent_id = this.id; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.seo_title = txtSeoTitle.Text; model.seo_keywords = txtSeoKeywords.Text; model.seo_description = txtSeoDescription.Text; model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.content = txtContent.Value; model.model_id = int.Parse(rblStatus.SelectedValue); model.is_add_category = 0; model.is_add_content = 0; model.is_show_top = 0; model.is_show_foot = 0; if (cblItem.Items[0].Selected == true) { model.is_add_category = 1; } if (cblItem.Items[1].Selected == true) { model.is_add_content = 1; } if (cblItem.Items[2].Selected == true) { model.is_show_top = 1; } if (cblItem.Items[3].Selected == true) { model.is_show_foot = 1; } if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10); //添加频道扩展字段 List<Model.contents.category_field> ls = new List<Model.contents.category_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { ls.Add(new Model.contents.category_field { field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0) }); } } model.category_fields = ls; if (bll.Add(model) > 0) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道栏目分类:" + model.title); //记录日志 return true; } } catch { return false; } return false; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.contents.article_category GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,title,call_index,parent_id,class_list,class_layer,sort_id,model_id,is_add_category,is_add_content,is_show_top,is_show_foot,is_albums,is_attach,page_size,link_url,img_url,content,seo_title,seo_keywords,seo_description,nav_type,sub_title,action_type,is_sys,is_lock from " + databaseprefix + "article_category "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.contents.article_category model = new Model.contents.article_category(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "") { model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString(); } if (ds.Tables[0].Rows[0]["parent_id"] != null && ds.Tables[0].Rows[0]["parent_id"].ToString() != "") { model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString()); } if (ds.Tables[0].Rows[0]["class_list"] != null && ds.Tables[0].Rows[0]["class_list"].ToString() != "") { model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString(); } if (ds.Tables[0].Rows[0]["class_layer"] != null && ds.Tables[0].Rows[0]["class_layer"].ToString() != "") { model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString()); } if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["model_id"] != null && ds.Tables[0].Rows[0]["model_id"].ToString() != "") { model.model_id = int.Parse(ds.Tables[0].Rows[0]["model_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_add_category"] != null && ds.Tables[0].Rows[0]["is_add_category"].ToString() != "") { model.is_add_category = int.Parse(ds.Tables[0].Rows[0]["is_add_category"].ToString()); } if (ds.Tables[0].Rows[0]["is_add_content"] != null && ds.Tables[0].Rows[0]["is_add_content"].ToString() != "") { model.is_add_content = int.Parse(ds.Tables[0].Rows[0]["is_add_content"].ToString()); } if (ds.Tables[0].Rows[0]["is_show_top"] != null && ds.Tables[0].Rows[0]["is_show_top"].ToString() != "") { model.is_show_top = int.Parse(ds.Tables[0].Rows[0]["is_show_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_show_foot"] != null && ds.Tables[0].Rows[0]["is_show_foot"].ToString() != "") { model.is_show_foot = int.Parse(ds.Tables[0].Rows[0]["is_show_foot"].ToString()); } if (ds.Tables[0].Rows[0]["is_albums"].ToString() != "") { model.is_albums = int.Parse(ds.Tables[0].Rows[0]["is_albums"].ToString()); } if (ds.Tables[0].Rows[0]["is_attach"].ToString() != "") { model.is_attach = int.Parse(ds.Tables[0].Rows[0]["is_attach"].ToString()); } if (ds.Tables[0].Rows[0]["page_size"].ToString() != "") { model.page_size = int.Parse(ds.Tables[0].Rows[0]["page_size"].ToString()); } if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "") { model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); } if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "") { model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "") { model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); } if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "") { model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); } if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "") { model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); } if (ds.Tables[0].Rows[0]["nav_type"] != null && ds.Tables[0].Rows[0]["nav_type"].ToString() != "") { model.nav_type = ds.Tables[0].Rows[0]["nav_type"].ToString(); } if (ds.Tables[0].Rows[0]["sub_title"] != null && ds.Tables[0].Rows[0]["sub_title"].ToString() != "") { model.sub_title = ds.Tables[0].Rows[0]["sub_title"].ToString(); } if (ds.Tables[0].Rows[0]["action_type"] != null && ds.Tables[0].Rows[0]["action_type"].ToString() != "") { model.action_type = ds.Tables[0].Rows[0]["action_type"].ToString(); } if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } model.category_fields = new DAL.contents.category_field(databaseprefix).GetList(id); //扩展属性 return(model); } else { return(null); } }
private bool DoAdd() { try { Model.contents.article_category model = new Model.contents.article_category(); BLL.contents.article_category bll = new BLL.contents.article_category(); model.nav_type = OSEnums.NavigationEnum.System.ToString().Trim();; model.title = txtTitle.Text.Trim(); model.channel_id = -1; model.call_index = txtName.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtRemark.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = 0; if (cbIsLock.Checked == true) { model.is_lock = 1; } model.parent_id = int.Parse(ddlParentId.SelectedValue); //添加操作权限类型 string action_type_str = string.Empty; for (int i = 0; i < cblActionType.Items.Count; i++) { if (cblActionType.Items[i].Selected && Utils.ActionType().ContainsKey(cblActionType.Items[i].Value)) { action_type_str += cblActionType.Items[i].Value + ","; } } model.action_type = Utils.DelLastComma(action_type_str); if (bll.Add(model) > 0) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "添加导航信息:" + model.title); //记录日志 return true; } } catch { return false; } return false; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.contents.article_category model) { return(dal.Add(model)); }
/// <summary> /// 得到一个对象实体(重载,带事务) /// </summary> public Model.contents.article_category GetModel(SqlConnection conn, SqlTransaction trans, int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,title,call_index,parent_id,class_list,class_layer,sort_id,model_id,is_add_category,is_add_content,is_show_top,is_show_foot,is_albums,is_attach,page_size,link_url,img_url,content,seo_title,seo_keywords,seo_description,nav_type,sub_title,action_type,is_sys,is_lock from " + databaseprefix + "article_category "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.contents.article_category model = new Model.contents.article_category(); DataSet ds = DbHelperSQL.Query(conn, trans, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "") { model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString(); } if (ds.Tables[0].Rows[0]["parent_id"] != null && ds.Tables[0].Rows[0]["parent_id"].ToString() != "") { model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString()); } if (ds.Tables[0].Rows[0]["class_list"] != null && ds.Tables[0].Rows[0]["class_list"].ToString() != "") { model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString(); } if (ds.Tables[0].Rows[0]["class_layer"] != null && ds.Tables[0].Rows[0]["class_layer"].ToString() != "") { model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString()); } if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["model_id"] != null && ds.Tables[0].Rows[0]["model_id"].ToString() != "") { model.model_id = int.Parse(ds.Tables[0].Rows[0]["model_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_add_category"] != null && ds.Tables[0].Rows[0]["is_add_category"].ToString() != "") { model.is_add_category = int.Parse(ds.Tables[0].Rows[0]["is_add_category"].ToString()); } if (ds.Tables[0].Rows[0]["is_add_content"] != null && ds.Tables[0].Rows[0]["is_add_content"].ToString() != "") { model.is_add_content = int.Parse(ds.Tables[0].Rows[0]["is_add_content"].ToString()); } if (ds.Tables[0].Rows[0]["is_show_top"] != null && ds.Tables[0].Rows[0]["is_show_top"].ToString() != "") { model.is_show_top = int.Parse(ds.Tables[0].Rows[0]["is_show_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_show_foot"] != null && ds.Tables[0].Rows[0]["is_show_foot"].ToString() != "") { model.is_show_foot = int.Parse(ds.Tables[0].Rows[0]["is_show_foot"].ToString()); } if (ds.Tables[0].Rows[0]["is_albums"].ToString() != "") { model.is_albums = int.Parse(ds.Tables[0].Rows[0]["is_albums"].ToString()); } if (ds.Tables[0].Rows[0]["is_attach"].ToString() != "") { model.is_attach = int.Parse(ds.Tables[0].Rows[0]["is_attach"].ToString()); } if (ds.Tables[0].Rows[0]["page_size"].ToString() != "") { model.page_size = int.Parse(ds.Tables[0].Rows[0]["page_size"].ToString()); } if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "") { model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); } if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "") { model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "") { model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); } if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "") { model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); } if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "") { model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); } if (ds.Tables[0].Rows[0]["nav_type"] != null && ds.Tables[0].Rows[0]["nav_type"].ToString() != "") { model.nav_type = ds.Tables[0].Rows[0]["nav_type"].ToString(); } if (ds.Tables[0].Rows[0]["sub_title"] != null && ds.Tables[0].Rows[0]["sub_title"].ToString() != "") { model.sub_title = ds.Tables[0].Rows[0]["sub_title"].ToString(); } if (ds.Tables[0].Rows[0]["action_type"] != null && ds.Tables[0].Rows[0]["action_type"].ToString() != "") { model.action_type = ds.Tables[0].Rows[0]["action_type"].ToString(); } if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } return model; } else { return null; } }