Esempio n. 1
0
        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>");
            }
        }
Esempio n. 2
0
        protected void dgProductCategoryList_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Footer && e.CommandArgument.ToString() == "AddInfo")
            {
                ProductCategoryModel info = new ProductCategoryModel();
                info.categoryname = ((TextBox)e.Item.FindControl("txtaddname")).Text.Trim();
                info.orderid      = Int32.Parse(((TextBox)e.Item.FindControl("txtaddorderid")).Text.Trim());
                info.parentid     = 0;

                ProductCategoryFactory.Add(info);
                this.LoadListData();
            }

            if (e.CommandArgument.ToString() == "DeleteInfo")
            {
                int dataKey = Convert.ToInt32(this.dgProductCategoryList.DataKeys[e.Item.ItemIndex]);

                //todo:删除之前,检查该分类下是否有产品。
                ProductCategoryFactory.Delete(dataKey);

                this.LoadListData();
            }
        }