protected void BandInfo(int id) { ShowShop.BLL.Product.ProductUnit bll = new ShowShop.BLL.Product.ProductUnit(); ShowShop.Model.Product.ProductUnit model = bll.GetModelID(id); this.txtName.Text = model.Name; this.txtSort.Text = model.Sort.ToString(); ViewState["ID"] = model.ID; }
protected void Save() { ShowShop.BLL.Product.ProductUnit bll = new ShowShop.BLL.Product.ProductUnit(); ShowShop.Model.Product.ProductUnit model = new ShowShop.Model.Product.ProductUnit(); model.Name = txtName.Text.Trim(); model.Sort = ChangeHope.Common.StringHelper.StringToInt(txtSort.Text.Trim()); if (ViewState["ID"] != null) { model.ID = int.Parse(ViewState["ID"].ToString()); bll.Update(model); this.ltlMsg.Text = "操作成功,已保存该信息"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; } else { bll.Add(model); this.ltlMsg.Text = "操作成功,已保存该信息"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; } }
/// <summary> /// 列表 /// </summary> /// <returns></returns> protected string GetList() { ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table(); ShowShop.BLL.Product.ProductUnit data = new ShowShop.BLL.Product.ProductUnit(); ChangeHope.DataBase.DataByPage dataPage = data.GetList(); //第一步先添加表头 table.AddHeadCol("5%", "序号"); table.AddHeadCol("25%", "单位名称"); table.AddHeadCol("10%", "排序"); table.AddHeadCol("20%", "操作"); table.AddRow(); //添加表的内容 if (dataPage.DataReader != null) { int curpage = ChangeHope.WebPage.PageRequest.GetInt("pageindex"); if (curpage < 0) { curpage = 1; } int count = 0; while (dataPage.DataReader.Read()) { count++; string No = (15 * (curpage - 1) + count).ToString(); table.AddCol(No); table.AddCol(dataPage.DataReader["name"].ToString()); table.AddCol(string.Format("{0}", dataPage.DataReader["sort"].ToString())); table.AddCol(string.Format("<a href=productunit_edit.aspx?id={0}>编辑</a> <a href='#' onclick='Del({0})'>删除</a>", dataPage.DataReader["id"].ToString())); table.AddRow(); } } string view = table.GetTable() + dataPage.PageToolBar; dataPage.Dispose(); dataPage = null; return view; }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> private void del(int id) { ShowShop.BLL.Product.ProductUnit bll = new ShowShop.BLL.Product.ProductUnit(); bll.Delete(id); Response.Write("ok"); }