/// <summary> /// 保存添加的保管人员 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (txtKeeper.Text == "填写新保管员的工号") { untCommon.InfoMsg("填写新保管员的工号"); return; } if (txtKeeper.Text.Trim() == "") { untCommon.InfoMsg("填写新保管员的工号"); return; } int empid; try { empid = int.Parse(txtKeeper.Text); DataTable dt = EmployeeMgr.GetOneEmp(empid);//检查用户输入的工号是否正确 if (dt != null) { if (dt.Rows.Count != 0) { //如果输入的工号正确 string name = dt.Rows[0][1].ToString(); if (KeeperMgr.Add(empid, name)) { //添加成功以后根据需要设置相关按钮的状态 this.btnCancel.Enabled = false; this.btnSave.Enabled = false; this.btnDel.Enabled = true; txtKeeper.Text = ""; txtKeeper.Enabled = false; InitKeeper(); } else { untCommon.InfoMsg("添加失败"); } } else { untCommon.ErrorMsg("您所填的员工不是本单位员工,不能保管本单位的资产。\r\n请确认员工编号是否正确。"); } } } catch (FormatException) { untCommon.ErrorMsg("工号请输入数字"); } }