//赋值操作 private void ShowInfo(int _id) { Spread.BLL.Products bll = new Spread.BLL.Products(); Spread.Model.Products model = bll.GetModel(_id); ddlClassId.SelectedValue = model.ClassId.ToString(); txtTitle.Text = model.Title; txtBrand.Text=model.Brand; txtAuthor.Text = model.AddUser; txtKeyword.Text = model.Keyword; cbIsTop.Checked = model.IsTop; cbIsLock.Checked=model.IsLock; }
//保存 protected void btnSave_Click(object sender, EventArgs e) { Spread.BLL.Products bll = new Spread.BLL.Products(); Spread.Model.Products model = bll.GetModel(this.Id); model.Title = txtTitle.Text.Trim(); model.Brand = txtBrand.Text.Trim(); model.AddUser = txtAuthor.Text.Trim(); model.ClassId = int.Parse(ddlClassId.SelectedValue); model.ImgUrl = ""; model.Url =""; model.Keyword = txtKeyword.Text; model.IsTop = cbIsTop.Checked; model.IsLock = cbIsLock.Checked; model.AddTime = DateTime.Now; bll.Update(model); JscriptPrint("产品编辑成功啦!", "List.aspx", "Success"); }
private void RptBind(string strWhere, string orderby) { if (!int.TryParse(Request.Params["page"] as string, out this.page)) { this.page = 0; } Spread.BLL.Products bll = new Spread.BLL.Products(); //获得总条数 this.pcount = bll.GetCount(strWhere); if (this.pcount > 0) { this.lbtnDel.Enabled = true; } else { this.lbtnDel.Enabled = false; } this.txtKeywords.Text = this.keywords; this.rptList.DataSource = bll.GetPageList(this.pagesize, this.page, strWhere, orderby); this.rptList.DataBind(); }
//删除 protected void lbtnDel_Click(object sender, EventArgs e) { chkLoginLevel("delProducts"); Spread.BLL.Products bll = new Spread.BLL.Products(); //批量删除 for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((Label)rptList.Items[i].FindControl("lb_id")).Text); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("cb_id"); if (cb.Checked) { bll.Delete(id); } } JscriptPrint("批量删除成功啦!", "List.aspx?" + CombUrlTxt(this.classId, this.keywords, this.property) + "page=0", "Success"); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { int id = Convert.ToInt32(((Label)e.Item.FindControl("lb_id")).Text); Spread.BLL.Products bll = new Spread.BLL.Products(); Spread.Model.Products model = bll.GetModel(id); switch (e.CommandName.ToLower()) { case "ibtntop": if (model.IsTop == true) bll.UpdateField(id, "IsTop=0"); else bll.UpdateField(id, "IsTop=1"); break; case "ibtnlock": if (model.IsLock == true) bll.UpdateField(id, "IsLock=0"); else bll.UpdateField(id, "IsLock=1"); break; } RptBind("Id>0" + this.CombSqlTxt(this.classId, this.keywords, this.property), "AddTime desc"); }
/// <summary> /// 初始化 /// </summary> private void info() { Spread.BLL.Products bllProducts = new Spread.BLL.Products(); DataTable dt = bllProducts.GetList(0, "IsLock=0 ", "ID ASC").Tables[0]; Products = dt; }