Exemplo n.º 1
0
        public void TestUpdatePurchaseOrder()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"C:\Users\Mr.Feng\Desktop\软工\测试用例\Update_InterviewPurchaseOrder.xls");
            IEnumerable          purchaseOrders = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in purchaseOrders)
            {
                Assert.AreEqual(false, interviewBll.UpdatePurchaseOrder((InterviewPurchaseOrder)i, ref errorList));
            }
            int maxId = -1;

            foreach (InterviewPurchaseOrder i in interviewBll.GetAllPurchaseOrdersArray())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            if (maxId != -1)
            {
                InterviewPurchaseOrder order = new InterviewPurchaseOrder()
                {
                    Id                = maxId,
                    OrdererId         = 1,
                    ISBN              = "1234567890",
                    BookName          = "采访单元测试",
                    Price             = 10,
                    SubDate           = DateTime.Now,
                    DocumentType      = "期刊",
                    PublishingHouseId = 1,
                    CurrencyType      = "美元$",
                };
                Assert.AreEqual(true, interviewBll.UpdatePurchaseOrder(order, ref errorList));
            }
        }
 /// <summary>
 /// 保存记录
 /// </summary>
 private void SaveLog_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>(); //创建一个错误列表
         //获取根据当前页面内容生成的订单(若有错误会被添加到错误列表中)
         string orderNum = orderNumTextBox.Text;        //获取订单编号
         int    id;
         if (!int.TryParse(orderNum, out id))           //将其转换为数字失败
         {
             MessageBox.Show("订单编号错误");
             return;
         }
         InterviewPurchaseOrder order = GetPurchaseOrder(ref errorList);
         order.Id = id;//设置订单ID
         //判断是否添加订单成功
         if (interviewBll.UpdatePurchaseOrder(order, ref errorList))
         {
             MessageBox.Show("修改成功");
         }
         else
         {
             MessageBox.Show("修改失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();                 //数据绑定
     ChangeControlEnableState(); //改变菜单按钮启用状态
 }