Ejemplo n.º 1
0
        /// <summary>
        /// 保存一条kitting Code的记录数据(Add), 若Code与相同Type存在记录的Code的名称相同,则提示业务异常
        /// </summary>
        /// <param name="obj">KittingCodeDef结构</param>
        public void AddKittingCode(KittingCodeDef obj)
        {
            try
            {
                IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();

                //Code与相同Type存在记录的Code的名称相同,则提示业务异常
                DataTable exists = itemRepository.GetExistLabelKittingCode(obj.Code, obj.Type);
                if (exists != null && exists.Rows.Count > 0)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT081", erpara);
                    throw ex;

                }

                LabelKittingCode newItem = new LabelKittingCode();
                newItem.code = obj.Code;
                newItem.editor = obj.Editor;
                newItem.descr = obj.Descr;
                newItem.remark = obj.Remark;
                newItem.type = obj.Type;
                itemRepository.AddLabelKittingCode(newItem);  
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存一条kitting Code的记录数据(update), 若Code与相同Type存在记录的Code的名称相同,则提示业务异常
        /// </summary>
        /// <param name="obj">更新KittingCodeDef结构</param>
        /// <param name="oldCode">修改前Code</param>
        public void UpdateKittingCode(KittingCodeDef obj, string oldCode) {

            try
            {
                IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();

                //Code与相同Type存在记录的Code的名称相同,则提示业务异常
                DataTable exists = itemRepository.GetExistLabelKittingCode(obj.Code, obj.Type);
                if (exists != null && exists.Rows.Count > 0 && oldCode != obj.Code)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT081", erpara);
                    throw ex;

                }

                LabelKittingCode itemOld = itemRepository.FindLabelKittingCode(oldCode, obj.Type);
                if (itemOld == null)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT082", erpara);
                    throw ex;
                }

                LabelKittingCode newItem = new LabelKittingCode();
                newItem.code = obj.Code;
                newItem.editor = obj.Editor;
                newItem.descr = obj.Descr;
                newItem.remark = obj.Remark;
                newItem.type = obj.Type;
                newItem.cdt = DateTime.Now; //Convert.ToDateTime(obj.Cdt);
                itemRepository.ChangeLabelKittingCode(newItem, oldCode, obj.Type);
            }
            catch (Exception)
            {
                throw;
            }

        }