protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { MojoCube.Web.Image.Category category = new MojoCube.Web.Image.Category(); int index = Convert.ToInt32(e.CommandArgument); //保存 if (e.CommandName == "_save") { category.GetData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text)); category.CategoryName = ((TextBox)GridView1.Rows[index].FindControl("txtCategoryNameGV")).Text; category.Visible = ((CheckBox)GridView1.Rows[index].FindControl("cbVisible")).Checked; category.UpdateData(category.pk_Category); } //删除 if (e.CommandName == "_delete") { category.DeleteData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text)); } //上移 if (e.CommandName == "_up") { MojoCube.Web.Sql.SetSortID("Image_Category", "pk_Category", ((Label)GridView1.Rows[index].FindControl("lblID")).Text, -1); } //下移 if (e.CommandName == "_down") { MojoCube.Web.Sql.SetSortID("Image_Category", "pk_Category", ((Label)GridView1.Rows[index].FindControl("lblID")).Text, 1); } CategoryBind(); }
protected void btnAdd_Click(object sender, EventArgs e) { if (txtCategoryName.Text.Trim() != "") { MojoCube.Web.Image.Category category = new MojoCube.Web.Image.Category(); category.CategoryName = txtCategoryName.Text.Trim(); category.ParentID = 0; category.SortID = 0; category.Visible = true; category.CreateDate = DateTime.Now.ToString(); category.CreateUserID = int.Parse(Session["UserID"].ToString()); category.ModifyDate = DateTime.Now.ToString(); category.ModifyUserID = 0; category.Language = MojoCube.Api.UI.Language.GetLanguage(); category.InsertData(); CategoryBind(); } }