/// <summary> /// 删除记录 /// </summary> private void DeleteLog_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show("是否删除该条记录", "删除确认", MessageBoxButtons.YesNoCancel); //设置弹出窗体的格式 if (dialogResult == DialogResult.Yes) //如果选择确认按钮 { string idNum = IdTextBox.Text; //获取清单编号 int id; if (!int.TryParse(idNum, out id)) //将其转换为数字失败 { MessageBox.Show("清单编号错误"); return; } if (interviewBll.DeleteAcceptanceList(id))//调用清单删除方法 { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } DataBind();//数据绑定 }
public void TestDeleteAcceptanceList() { int maxId = -1; foreach (AcceptanceList i in interviewBll.GetAllAcceptanceListArray()) { if (i.Id > maxId) { maxId = i.Id; } } if (maxId != -1) { Assert.AreEqual(true, interviewBll.DeleteAcceptanceList(maxId)); } Assert.AreEqual(false, interviewBll.DeleteAcceptanceList(-1)); }