예제 #1
0
        public void UpdateCatalogListTest()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"E:\大三课程文档汇总\软件工程\FunctionTest\Update_CreateCatalogList.xls");
            IEnumerable          createCatalog  = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in createCatalog)
            {
                Assert.AreEqual(false, createCatalogBll.UpdateCatalogList((CreateCatalogList)i, ref errorList));
            }
            int maxId = -1;

            foreach (CreateCatalogList i in createCatalogBll.GetAllCreateCatalogArray())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            if (maxId != -1)
            {
                CreateCatalogList list = new CreateCatalogList()
                {
                    Id                = maxId,
                    ISBN              = "1234567890",
                    PositiveTitle     = "阿衰正传" + DateTime.Now.Date.ToString("yy-MM-dd"),
                    FirstAuthor       = "小七" + DateTime.Now.Date.ToString("yy-MM-dd"),
                    PrimaryLiability  = "笑哈哈出版社" + DateTime.Now.Date.ToString("yy-MM-dd"),
                    CatalogerId       = 1,
                    CatalogingDate    = DateTime.Now,
                    DocumentType      = "专著",
                    PublishingHouseId = 1,
                };
                Assert.AreEqual(true, createCatalogBll.UpdateCatalogList(list, ref errorList));
            }
        }
 /// <summary>
 /// 保存记录
 /// </summary>
 private void SaveLog_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>(); //创建一个错误列表
         //获取根据当前页面内容生成的清单(若有错误会被添加到错误列表中)
         string createId = idTextBox.Text;              //获取清单号
         int    id;
         if (!int.TryParse(createId, out id))           //将其转换为数字失败
         {
             MessageBox.Show("清单号错误");
             return;
         }
         CreateCatalogList list = GetCatalogList(ref errorList);
         list.Id = id;//设置清单号
         //判断是否添加清单成功
         if (createCatalogBll.UpdateCatalogList(list, ref errorList))
         {
             MessageBox.Show("修改成功");
         }
         else
         {
             MessageBox.Show("修改失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();                 //数据绑定
     ChangeControlEnableState(); //改变菜单按钮启用状态
 }