protected void Page_Load(object sender, EventArgs e) { this.id = RequestHelper.GetQueryInt("id", 0); this.cate = RequestHelper.GetQueryInt("cate", 0); if (!new BLL.common_category().Exists(this.cate)) { Response.Write("<script>alert('没有此分类');history.back(-1);</script>"); Response.End(); return; } if (!IsPostBack) { Model.common_category cateModel = new BLL.common_category().GetModel(this.cate); if (cateModel != null) { this.cate_name = cateModel.name; } Model.common_article model = new BLL.common_article().GetModel(this.id); if (model == null) { Response.Write("<script>alert('没有此新闻');history.back(-1);</script>"); Response.End(); return; } title = model.title; subtitle = model.subtitle; add_time = Convert.ToDateTime(model.add_time).ToString("yyyy-MM-dd"); contents = model.contents; } }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", "")); return; } } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_category bll = new BLL.common_category(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("Manage.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void BindSelect() { //DataTable dt = new BLL.common_category().GetListNew(" group_id = " + (int)EnumCollection.category_group.精品微课, "0"); DataTable dt = new BLL.common_category().GetList(" group_id = " + (int)EnumCollection.category_group.精品微课 + " order by sort "); this.ddlCategory.Items.Clear(); this.ddlCategory.DataSource = dt; this.ddlCategory.DataTextField = "name"; this.ddlCategory.DataValueField = "id"; this.ddlCategory.DataBind(); this.ddlCategory.SelectedIndex = 0; //foreach (DataRow dr in dt.Rows) //{ // string Id = dr["id"].ToString(); // int ClassLayer = int.Parse(dr["category_level"].ToString()); // string Title = dr["name"].ToString().Trim(); // if (ClassLayer == 1) // { // this.ddlCategory.Items.Add(new ListItem(Title, Id)); // } // else // { // Title = "├ " + Title; // Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; // this.ddlCategory.Items.Add(new ListItem(Title, Id)); // } //} }
private bool DoAdd() { bool result = false; Model.common_category model = new Model.common_category(); model.name = txtName.Text.Trim(); model.sort = Utils.StrToInt(txtSort.Text.Trim(), 0); model.img_src = txtImg.Text.Trim(); model.group_id = (int)EnumCollection.category_group.精品微课; model.add_time = DateTime.Now; model.parent_id = this.parent_id; model.category_level = 1; if (model.parent_id > 0) { Model.common_category parent_model = new BLL.common_category().GetModel(model.parent_id); if (parent_model != null) { model.category_level = parent_model.category_level + 1; } } int id = new BLL.common_category().Add(model); if (id > 0) { result = true; } return(result); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_category", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.common_category bll = new BLL.common_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除全局分类" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", this.keywords)); }
private void BindSelect() { DataTable dt = EnumCollection.EnumToDataTable(typeof(EnumCollection.goods_group), "key", "val"); this.ddlGroup.DataSource = dt; this.ddlGroup.DataTextField = "key"; this.ddlGroup.DataValueField = "val"; this.ddlGroup.DataBind(); this.ddlGroup.Items.Insert(0, new ListItem("所属分组", "0")); dt = new BLL.common_category().GetListNew(" group_id = " + (int)EnumCollection.category_group.商城, "0"); this.ddlCategory.Items.Add(new ListItem("所属分类", "0")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); int ClassLayer = int.Parse(dr["category_level"].ToString()); string Title = dr["name"].ToString().Trim(); string parent_name = dr["parent_name"].ToString().Trim(); if (ClassLayer == 2) { if (!string.IsNullOrEmpty(parent_name)) { Title = parent_name + " ├ " + Title; //Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; this.ddlCategory.Items.Add(new ListItem(Title, Id)); } } } }
private void BindData() { BLL.common_category catebll = new BLL.common_category(); DataTable dt = catebll.GetList(" group_id = " + (int)EnumCollection.category_group.新闻动态 + " order by sort asc "); this.rptCategory.DataSource = dt; this.rptCategory.DataBind(); if (this.cate <= 0) { Model.common_category cateModel = catebll.GetModel(1, " group_id = " + (int)EnumCollection.category_group.新闻动态, " sort asc "); if (cateModel != null) { this.cate = cateModel.id; } } this.pageIndex = RequestHelper.GetQueryInt("page", 1); BLL.common_article bll = new BLL.common_article(); string whereStr = " group_id = " + (int)EnumCollection.article_group.新闻动态 + " and category_id = " + this.cate; dt = bll.GetListByPage("*", "View_NewsList", whereStr, " add_time desc ", pageIndex, pageSize); this.rptNews.DataSource = dt; this.rptNews.DataBind(); int totalCount = bll.GetRecordCount("View_NewsList", whereStr); string pageUrl = Utils.CombUrlTxt("news_list.aspx", "page={0}", "__id__"); PageContent.InnerHtml = PageListHelper.OutPageList(totalCount, pageIndex, pageSize, pageUrl); }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("goods_list.aspx", "keywords={0}", "")); return; } } if (this.group > 0) { whereStr += " and group_id = " + this.group; this.ddlGroup.SelectedValue = this.group + ""; } if (this.type > 0) { Model.common_category cate = new BLL.common_category().GetModel(this.type); if (cate != null) { if (cate.category_level == 1) { } else { whereStr += " and category_id = " + this.type; } } else { whereStr += " and category_id = " + this.type; } this.ddlCategory.SelectedValue = this.type + ""; } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.goods_goods bll = new BLL.goods_goods(); this.rptList.DataSource = bll.GetListByPage("*", "View_GoodsList", whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("goods_list.aspx", "keywords={0}&page={1}&group={2}&type={3}", this.keywords, "__id__", this.group + "", this.type + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//数据绑定 private void RptBind() { BLL.common_category bll = new BLL.common_category(); DataTable dt = bll.GetListNew("group_id=" + (int)EnumCollection.category_group.商城, "0"); this.rptList.DataSource = dt; this.rptList.DataBind(); }
private void ShowInfo(int _id) { BLL.common_category bll = new BLL.common_category(); Model.common_category model = bll.GetModel(_id); txtImg.Text = model.img_src; txtSort.Text = model.sort.ToString(); txtName.Text = model.name; }
private void BindSelect() { DataTable dt = new BLL.common_category().GetList(" group_id = " + (int)EnumCollection.category_group.精品微课 + " order by sort "); this.ddlCategory.Items.Clear(); this.ddlCategory.DataSource = dt; this.ddlCategory.DataTextField = "name"; this.ddlCategory.DataValueField = "id"; this.ddlCategory.DataBind(); this.ddlCategory.Items.Add(new ListItem("所属分类", "0")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.common_category bll = new BLL.common_category(); this.rptCaseCategory.DataSource = bll.GetList(" group_id = " + (int)EnumCollection.category_group.客户案例 + " order by sort asc "); this.rptCaseCategory.DataBind(); this.rptNewsCategory.DataSource = bll.GetList(" group_id = " + (int)EnumCollection.category_group.新闻动态 + " order by sort asc "); this.rptNewsCategory.DataBind(); } }
//删除导航 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_goods_category", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 BLL.common_category bll = new BLL.common_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { bll.Delete(id); } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除分类"); //记录日志 JscriptMsg("删除数据成功!", "category_list.aspx", "parent.loadMenuTree"); }
private bool DoEdit(int _id) { bool result = false; Model.common_category model = new BLL.common_category().GetModel(_id); model.name = txtName.Text.Trim(); model.sort = Utils.StrToInt(txtSort.Text.Trim(), 0); model.img_src = txtImg.Text.Trim(); if (new BLL.common_category().Update(model)) { result = true; } return(result); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("_case_category", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.common_category bll = new BLL.common_category(); for (int i = 0; i < rptList.Items.Count; i++) { string id = ((HiddenField)rptList.Items[i].FindControl("hidId")).Value; int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(Convert.ToInt32(id), " sort = " + sortId.ToString()); } AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "保存案例分类排序"); //记录日志 JscriptMsg("保存排序成功!", "case_category.aspx"); }
private void BindInfo() { BLL.common_category bll = new BLL.common_category(); Model.common_category model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtcategory_level.Text = model.category_level + ""; txtparent_id.Text = model.parent_id + ""; txtimg_src.Text = model.img_src + ""; txtname.Text = model.name + ""; txtsort.Text = model.sort + ""; txtadd_time.Text = model.add_time + ""; }
//数据绑定 private void RptBind() { this.page = RequestHelper.GetQueryInt("page", 1); BLL.common_category bll = new BLL.common_category(); DataTable dt = bll.GetListByPage("group_id=" + (int)EnumCollection.category_group.客户案例, " sort asc ", this.page, this.pageSize); this.rptList.DataSource = dt; this.rptList.DataBind(); this.totalCount = bll.GetRecordCount("group_id = " + (int)EnumCollection.category_group.客户案例); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("case_category.aspx", "page={0}", "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void BindSelect() { DataTable dt = new BLL.common_category().GetListNew(" group_id = " + (int)EnumCollection.category_group.精品微课, "0"); this.ddlCategory.Items.Clear(); this.ddlCategory.Items.Add(new ListItem("无父级分类", "0")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); int ClassLayer = int.Parse(dr["category_level"].ToString()); string Title = dr["name"].ToString().Trim(); if (ClassLayer == 1) { this.ddlCategory.Items.Add(new ListItem(Title, Id)); } else { Title = "├ " + Title; Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; this.ddlCategory.Items.Add(new ListItem(Title, Id)); } } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_category", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.common_category bll = new BLL.common_category(); Model.common_category model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.category_level = Convert.ToInt32(txtcategory_level.Text); model.parent_id = Convert.ToInt32(txtparent_id.Text); model.img_src = Convert.ToString(txtimg_src.Text); model.name = Convert.ToString(txtname.Text); model.sort = Convert.ToInt32(txtsort.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改全局分类信息,主键:" + id); //记录日志 JscriptMsg("修改全局分类信息成功!", "Manage.aspx"); } else { JscriptMsg("保存过程中发生错误!", ""); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_category", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4) { strError += "分组ID为空或超出长度![br]"; } if (txtcategory_level.Text.Trim() == "" || txtcategory_level.Text.Trim().Length > 4) { strError += "分类级别为空或超出长度![br]"; } if (txtparent_id.Text.Trim() == "" || txtparent_id.Text.Trim().Length > 4) { strError += "父级分类ID为空或超出长度![br]"; } if (txtimg_src.Text.Trim() == "" || txtimg_src.Text.Trim().Length > 255) { strError += "分类配图为空或超出长度![br]"; } if (txtname.Text.Trim() == "" || txtname.Text.Trim().Length > 50) { strError += "分类名称为空或超出长度![br]"; } if (txtsort.Text.Trim() == "" || txtsort.Text.Trim().Length > 4) { strError += "排序为空或超出长度![br]"; } if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8) { strError += "添加时间为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.common_category model = new Model.common_category(); BLL.common_category bll = new BLL.common_category(); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.category_level = Convert.ToInt32(txtcategory_level.Text); model.parent_id = Convert.ToInt32(txtparent_id.Text); model.img_src = Convert.ToString(txtimg_src.Text); model.name = Convert.ToString(txtname.Text); model.sort = Convert.ToInt32(txtsort.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加全局分类信息,主键:" + id); //记录日志 JscriptMsg("添加全局分类信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }