protected void btnSave_Click(object sender, EventArgs e) { if (this.Action == "edit") { int categoryid = HYRequest.GetQueryInt("categoryid", 0); ProductCategoryModel cate = ProductCategoryFactory.Get(categoryid); cate.categoryname = this.txtcategoryname.Text.Trim(); cate.orderid = Int32.Parse(this.txtorderid.Text.Trim()); cate.parentid = Int32.Parse(this.ddlParentCategory.SelectedValue); ProductCategoryFactory.Update(cate); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('修改分类成功!');window.location='productcategorylist.aspx';</script>"); } else if (this.Action == "add") { ProductCategoryModel cate = new ProductCategoryModel(); cate.categoryname = this.txtcategoryname.Text.Trim(); cate.orderid = Int32.Parse(this.txtorderid.Text.Trim()); cate.parentid = Int32.Parse(this.ddlParentCategory.SelectedValue); ProductCategoryFactory.Add(cate); ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('添加分类成功!');window.location='productcategorylist.aspx';</script>"); } }
protected void dgProductCategoryList_UpdateCommand(object source, DataGridCommandEventArgs e) { int dataKey = Convert.ToInt32(this.dgProductCategoryList.DataKeys[e.Item.ItemIndex]); ProductCategoryModel info = ProductCategoryFactory.Get(dataKey); info.categoryname = ((TextBox)e.Item.FindControl("txteditname")).Text.Trim(); info.parentid = 0; info.orderid = Int32.Parse(((TextBox)e.Item.FindControl("txteditorderid")).Text.Trim()); ProductCategoryFactory.Update(info); this.dgProductCategoryList.EditItemIndex = -1; this.LoadListData(); }