Esempio n. 1
0
        public void SaveContractBasicInfo()
        {
            //查询一共有多少条数据
            int count1 = service.getTotalCount();

            //插入一个数据
            ContractBasicInfo model = new ContractBasicInfo();

            model.LogicDeleteFlag = false;
            model.EntryName       = "test";
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //更新刚才插入的数据
            model.EntryName = "test2";
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //为其插入list
            model.ActualPayments = new List <ActualPayment>();
            model.RepaymentPlans = new List <RepaymentPlan>();
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //查询数据量有没有增加一条
            int count2 = service.getTotalCount();

            Assert.AreEqual(count1, count2 - 1);

            //删除刚才插入的数据
            service.Delete <ContractBasicInfo>(model.ContractGUID);
            Assert.AreEqual(count1, service.getTotalCount());
        }
Esempio n. 2
0
        /// <summary>
        /// 处理记录项目的一些基本信息
        /// 根据 id 编号判断是否是添加还是更新,然后调用相应的方法进行处理
        /// </summary>
        /// <param name="model">记录项目的一些基本信息信息</param>
        /// <returns>处理是否成功</returns>
        public Guid SaveContractBasicInfo(ContractBasicInfo model)
        {
            //检查是否存在重复数据
            var entity = this.Find <ContractBasicInfo>(model.ContractGUID);

            //更新数据 , 否则新增数据
            if (entity != null)
            {
                if (entity.ActualPayments != null)
                {
                    entity.ActualPayments.ForEach(s => { s.ContractBasicInfo = entity; });
                }
                if (entity.RepaymentPlans != null)
                {
                    entity.RepaymentPlans.ForEach(r => { r.ContractBasicInfo = entity; });
                }

                //更新数据
                entity = Mapper.Map <ContractBasicInfo, ContractBasicInfo>(model, entity);
                this.contractBasicInfoRepository.Update(entity);
            }
            else
            {
                //录入数据
                model.ContractGUID = Guid.NewGuid(); //合同基本信息标识
                this.contractBasicInfoRepository.Insert(model);
            }

            return(model.ContractGUID);
        }
        public JsonResult Save(ContractBasicInfo model)
        {
            var contractBasicInfoService = this.GetService <IContractBasicInfoService>();

            if (contractBasicInfoService.SaveContractBasicInfo(model) != null)
            {
                ShowMessage("I10010");
            }
            return(Json(null));
        }
Esempio n. 4
0
        public void QueryContractBasicInfo()
        {
            //查询一共有多少条数据
            int count1 = service.getTotalCount();

            //插入一个数据
            ContractBasicInfo model = new ContractBasicInfo();

            model.LogicDeleteFlag = false;
            model.EntryName       = "test1";
            model.CustomerName    = "test";
            model.Abbreviation    = "test";
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //更新刚才插入的数据
            model.EntryName = "test";
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //为其插入list
            model.ActualPayments = new List <ActualPayment>();
            model.RepaymentPlans = new List <RepaymentPlan>();
            service.SaveContractBasicInfo(model);
            service.ServiceContext.Commit();

            //查询数据量有没有增加一条
            int count2 = service.getTotalCount();

            Assert.AreEqual(count1, count2 - 1);


            //测试通过传入的查询字段及值来查询数据库
            var enteryNumList = service.QueryContractBasicInfo("EntryName", "test");

            Assert.IsTrue(enteryNumList.Count() > 0);
            var CustomerNameList = service.QueryContractBasicInfo("CustomerName", "test");

            Assert.IsTrue(CustomerNameList.Count() > 0);
            var AbbreList = service.QueryContractBasicInfo("Abbreviation", "test");

            Assert.IsTrue(AbbreList.Count() > 0);

            //删除刚才插入的数据
            service.Delete <ContractBasicInfo>(model.ContractGUID);
            Assert.AreEqual(count1, service.getTotalCount());
        }
        public ActionResult Edit(Guid ContractGUID)
        {
            var entity = new ContractBasicInfo();

            try
            {
                var contractBasicInfoService = this.GetService <IContractBasicInfoService>();
                entity = contractBasicInfoService.Find <ContractBasicInfo>(ContractGUID);
            }
            catch (CLApplicationException ex)
            {
                //修改时若发生异常则提示异常信息,并关闭修改界面
                this.ShowAppErrorMessage(ex.Message);
            }

            return(View("~/views/contractbasicinfo/form.cshtml", entity));
        }
        public ActionResult Add()
        {
            var entity = new ContractBasicInfo();

            return(View("~/views/contractbasicinfo/form.cshtml", entity));
        }