/// <summary> /// 修改、删除部门信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvBranchList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { try { int branchId = Convert.ToInt32(e.CommandArgument.ToString()); BranchManager.DeleteBranchById(branchId); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('请先删除外键中的数据!')", true); } BindBranchInfo(); } if (e.CommandName == "Update") { int id = Convert.ToInt32(e.CommandArgument.ToString()); ViewState["BranchId"] = id; this.btnAdd.Enabled = false; this.btnUpdate.Enabled = true; Branch branch = BranchManager.GetBranchById(UpdateBranchId); this.txtBranchName.Text = branch.BranchName; txtBranchShortName.Text = branch.BranchShortName; } }