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