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