private void ShowInfo(int id) { Model.pro_category model = new BLL.pro_category().GetModel(id); ddlParentId.SelectedValue = model.parent_id.ToString(); txtSortId.Text = model.sort.ToString(); txtTitle.Text = model.title; txtImgUrl.Text = model.img; txtImgUrl2.Text = model.img2; if (!string.IsNullOrEmpty(model.img)) { ImgDiv.Visible = true; ImgUrl.ImageUrl = model.img; } if (!string.IsNullOrEmpty(model.img2)) { ImgDiv2.Visible = true; ImgUrl2.ImageUrl = model.img2; } if (model.is_sys == 1) { div_parent.Visible = false; } else { div_img2.Visible = false; } }
private void RptBind() { BLL.pro_category bll = new BLL.pro_category(); DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("title"); dt.Columns.Add("img"); dt.Columns.Add("img2"); dt.Columns.Add("parent_id"); dt.Columns.Add("sort"); dt.Columns.Add("is_sys"); DataSet ds1 = bll.GetList(0, "parent_id=0", "sort,id"); foreach (DataRow dr in ds1.Tables[0].Rows) { dt.ImportRow(dr); DataSet ds2 = new BLL.pro_category().GetList(0, "parent_id=" + dr["id"].ToString(), "sort,id"); foreach (DataRow dr2 in ds2.Tables[0].Rows) { dt.ImportRow(dr2); } } rptList.DataSource = dt; rptList.DataBind(); }
private bool DoEdit(int _id) { try { BLL.pro_category bll = new BLL.pro_category(); Model.pro_category model = bll.GetModel(_id); model.title = txtTitle.Text; model.img = txtImgUrl.Text; model.img2 = txtImgUrl2.Text; if (model.is_sys != 1) { model.parent_id = Convert.ToInt32(ddlParentId.SelectedValue); } model.sort = Convert.ToInt32(txtSortId.Text); if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改产品栏目分类:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
//类别绑定 private void TreeBind() { DataSet ds = new BLL.pro_category().GetList(0, "parent_id=0", "sort,id"); this.ddlParentId.Items.Add(new ListItem("请选择分类", "")); foreach (DataRow dr in ds.Tables[0].Rows) { this.ddlParentId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } }
//删除类别 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("pro_category", DTEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.pro_category bll = new BLL.pro_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(DTEnums.ActionEnum.Edit.ToString(), "删除产品分类数据"); //记录日志 JscriptMsg("删除数据成功!", Utils.CombUrlTxt("category_list.aspx", "", "")); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("pro_category", DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.pro_category bll = new BLL.pro_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((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(id, "sort=" + sortId.ToString()); } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "保存产品分类排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("category_list.aspx", "", "")); }
//类别绑定 private void TreeBind() { DataTable dt = new BLL.pro_category().GetList(0, "parent_id=0", "sort").Tables[0]; this.ddlCategoryId.Items.Clear(); this.ddlCategoryId.Items.Add(new ListItem("请选择类别...", "")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); string Title = dr["title"].ToString().Trim(); this.ddlCategoryId.Items.Add(new ListItem(Title, Id)); DataTable dt2 = new BLL.pro_category().GetList(0, "parent_id=" + Id, "sort").Tables[0]; foreach (DataRow dr2 in dt2.Rows) { this.ddlCategoryId.Items.Add(new ListItem(" ├ " + dr2["title"].ToString(), dr2["id"].ToString())); } } }
private void get_category_list(HttpContext context) { string city = DTRequest.GetString("city"); string strJson = ""; strJson += "["; DataSet ds = new BLL.pro_category().GetList(0, "parent_id=0", ""); foreach (DataRow dr in ds.Tables[0].Rows) { strJson += "{"; strJson += "\"id\":\"" + dr["id"].ToString() + "\","; strJson += "\"title\":\"" + dr["title"].ToString() + "\","; strJson += "\"img\":\"" + dr["img"].ToString() + "\","; strJson += "\"img2\":\"" + dr["img2"].ToString() + "\","; strJson += "\"son\":"; strJson += "["; DataSet ds2 = new BLL.pro_category().GetList(0, "parent_id=" + dr["id"], ""); foreach (DataRow dr2 in ds2.Tables[0].Rows) { int num = new BLL.product().GetCount("status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + dr2["id"].ToString()); strJson += "{"; strJson += "\"id\":\"" + dr2["id"].ToString() + "\","; strJson += "\"title\":\"" + dr2["title"].ToString() + "\","; strJson += "\"img\":\"" + dr2["img"].ToString() + "\","; strJson += "\"img2\":\"" + dr2["img2"].ToString() + "\","; strJson += "\"num\":" + num; strJson += "},"; } strJson = strJson.TrimEnd(',') + "]"; strJson += "},"; } strJson = strJson.TrimEnd(',') + "]"; context.Response.Write(strJson.TrimEnd(',')); }
private bool DoAdd() { try { Model.pro_category model = new Model.pro_category(); BLL.pro_category bll = new BLL.pro_category(); model.title = txtTitle.Text; model.img = txtImgUrl.Text; model.parent_id = Convert.ToInt32(ddlParentId.SelectedValue); model.sort = Convert.ToInt32(txtSortId.Text); model.is_sys = 0; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加产品栏目分类:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }