Ejemplo n.º 1
0
 /// <summary>
 /// 保存一条Qty的记录数据(Add)
 /// </summary>
 /// <param name="Object">alletQtyDef pqInfo</param>
 public string AddQtyInfo(PalletQtyDef palletQtyInfo)
 {
     FisException ex;
     List<string> paraError = new List<string>();
      PalletQtyInfo palletQtyDBInfo = new PalletQtyInfo();
     try
     {
         IPalletRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
         //IList<PalletQtyInfo> lstPalletQtyInfo = itemRepository.GetPalletByFullQty(int.Parse(palletQtyInfo.fullQty));
         IList<PalletQtyInfo> lstPalletQtyInfo = itemRepository.GetPalletByFullQty(palletQtyInfo.fullQty);
         foreach(PalletQtyInfo item in lstPalletQtyInfo){
             //if (item.fullQty == int.Parse(palletQtyInfo.fullQty))
             if (item.fullQty == palletQtyInfo.fullQty)
             {
                 //要添加的数据已经存在
                 ex = new FisException("DMT060", paraError);
                 throw ex;
              }
         }
         UnitOfWork uow = new UnitOfWork();
         //palletQtyDBInfo.fullQty = int.Parse(palletQtyInfo.fullQty);
         palletQtyDBInfo.fullQty = palletQtyInfo.fullQty;
         palletQtyDBInfo.tierQty = int.Parse(palletQtyInfo.tireQty);
         palletQtyDBInfo.mediumQty = int.Parse(palletQtyInfo.mediumQty);
         palletQtyDBInfo.litterQty = int.Parse(palletQtyInfo.litterQty);
         palletQtyDBInfo.editor = palletQtyInfo.editor;
         palletQtyDBInfo.cdt = DateTime.Now;
         palletQtyDBInfo.udt = DateTime.Now;
         //添加函数
         itemRepository.AddQtyInfoDefered(uow, palletQtyDBInfo);
         uow.Commit();
     }
     catch (Exception)
     {
         throw;
     }
     return palletQtyInfo.fullQty;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条Qty的记录数据(update),
        /// </summary>
        /// <param name="Object">PalletQtyDef pqInfo, string oldFullQty</param>
        public void UpdateQtyInfo(PalletQtyDef pqInfo, string itemId)
        {
            FisException ex;
            IPalletRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository>();
            List<string> erpara = new List<string>();
            //
            try
            {
                //取出原始数据
                PalletQtyInfo palletQtyInfo = itemRepository.GetQtyInfo(int.Parse(itemId));
                //要更新数据的
                if (palletQtyInfo == null)
                {
                    //要更新的数据已被删除
                    ex = new FisException("DMT082", erpara);
                    throw ex;
                }
                //IList<PalletQtyInfo> lstPalletQtyInfo = itemRepository.GetPalletByFullQty(int.Parse(pqInfo.fullQty));
                IList<PalletQtyInfo> lstPalletQtyInfo = itemRepository.GetPalletByFullQty(pqInfo.fullQty);
                foreach (PalletQtyInfo palletQtyInfo2 in lstPalletQtyInfo)
                {
                    //判断非当前记录和要更新的数据是否有重复
                    //if (palletQtyInfo2.id != int.Parse(itemId) & palletQtyInfo2.fullQty == int.Parse(pqInfo.fullQty))
                    if (palletQtyInfo2.id != int.Parse(itemId) & palletQtyInfo2.fullQty == pqInfo.fullQty)
                    {
                        //throw new ApplicationException("The item is exisiting!");
                        ex = new FisException("DMT060", erpara);
                        throw ex;
                    }
                }
                UnitOfWork uow = new UnitOfWork();
                PalletQtyInfo item = new PalletQtyInfo();
                //item.fullQty = int.Parse(pqInfo.fullQty);
                item.fullQty = pqInfo.fullQty;
                item.tierQty = int.Parse(pqInfo.tireQty);
                item.mediumQty = int.Parse(pqInfo.mediumQty);
                item.litterQty = int.Parse(pqInfo.litterQty);
                item.editor = pqInfo.editor;
                item.udt = DateTime.Now;

                //更新动作
                itemRepository.UpdateQtyInfoDefered(uow, item, int.Parse(itemId));
                uow.Commit();
            }
            catch (Exception)
            {
                throw;
            }
        }