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

            foreach (InterviewPurchaseOrder i in interviewBll.GetAllPurchaseOrdersArray())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            if (maxId != -1)
            {
                Assert.AreEqual(true, interviewBll.DeletePurchaseOrder(maxId));
            }
            Assert.AreEqual(false, interviewBll.DeletePurchaseOrder(-1));
        }