Ejemplo n.º 1
0
        //判断是否存在相同Model和Type的记录
        //Boolean IsExistPrintInfo(string model, string type)
        //IF EXISTS(SELECT * FROM PilotRunPrintInfo WHERE Model = @Model AND Type = @Type)
        //返回true
        //否则false

        //INSERT INTO [PilotRunPrintInfo]([Family],[Model],[Build],[SKU],[Type],[Descr],[Editor],[Cdt],[Udt])
        //        VALUES (@Family, @Model, @Build, @SKU, @Type, @Description, @Editor, GETDATE(), GETDATE())
        //需要在返回的ITEM的ID中填上当前新加入的记录的ID
        public string AddPrintInfo(PilotRunPrintInfo item)
        {
            string result = "";
            try
            {
                IMiscRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();
                Boolean isExistBuild = itemRepository.IsBuildExist(item.Build);
                if (isExistBuild != true)
                {
                    //选择的Build在数据库中已不存在
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT046", erpara);
                    throw ex;
                }

                Boolean isExistType = itemRepository.IsPrintTypeExist(item.Type);
                if (isExistType != true)
                {
                    //选择的Type在数据库中已不存在
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT047", erpara);
                    throw ex;
                }

                Boolean isExistPrintInfo = itemRepository.IsExistPrintInfo(item.Model,item.Type);
                if (isExistPrintInfo == true)
                {
                    //已经存在具有相同Model、Type的PilotRunPrintInfo记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT048", erpara);
                    throw ex;
                }

                item.Cdt = DateTime.Now;
                item.Udt = DateTime.Now;
                UnitOfWork uow = new UnitOfWork();
                itemRepository.AddPrintInfoDefered(uow,item);
                itemRepository.BSUpdateDefered(uow,item.Family, item.Build, item.SKU, item.Model, item.Editor);
                uow.Commit();
                result = item.ID.ToString();

            }
            catch (Exception)
            {
                throw;
            }
            return result;
        }
Ejemplo n.º 2
0
        //UPDATE PilotRunPrintInfo SET Descr = @Description, Editor = @Editor, Udt = GETDATE()
        //        WHERE ID=id
        public void UpdatePrintInfo(PilotRunPrintInfo item)
        {
            try
            {
                IMiscRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();

                Boolean isExistBuild = itemRepository.IsBuildExist(item.Build);
                if (isExistBuild != true)
                {
                    //选择的Build在数据库中已不存在
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT046", erpara);
                    throw ex;
                }

                Boolean isExistType = itemRepository.IsPrintTypeExist(item.Type);
                if (isExistType != true)
                {
                    //选择的Type在数据库中已不存在
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT047", erpara);
                    throw ex;
                }

                UnitOfWork uow = new UnitOfWork();
                itemRepository.UpdatePrintInfoDefered(uow, item.ID, item.Descr, item.Editor);
                itemRepository.BSUpdateDefered(uow,item.Family, item.Build, item.SKU, item.Model, item.Editor);
                uow.Commit();
             
            }
            catch (Exception)
            {
                throw;
            }

        }