protected void btnUpdate_Click(object sender, EventArgs e) { //保存修改到数据库 try { DepartmentDal departmentDal = new DepartmentDal(); if (ViewState["OP"].ToString() == "ADD") { departmentDal.Insert(txtDepartmentName.Text, txtRemark.Text); } else { departmentDal.Save(txtDepartmentID.Text, txtDepartmentName.Text, txtRemark.Text); } JScript.Instance.ShowMessage(UpdatePanel1, "保存数据成功。"); } catch (Exception ex) { JScript.Instance.ShowMessage(UpdatePanel1, string.Format("保存数据失败,原因:'{0}'", ex.Message)); } }