public bool DeleteByPMUserSysNo(int pmusersysno) { bool result = false; using (TransactionScope scope = new TransactionScope()) { da.DeleteByPMUserSysNo(pmusersysno); List <ProductLineInfo> list = da.GetByBakPMUserSysNo(pmusersysno); if (list.Count > 0) { BatchUpdatePMEntity entity = new BatchUpdatePMEntity(); entity.IsEmptyC2Create = false; entity.BackupPMSysNoList = pmusersysno.ToString(); entity.ProductLineList = list; entity.BakPMUpdateType = "Remove"; BatchUpdate(entity); } scope.Complete(); result = true; } return(result); }
public void BatchUpdate(BatchUpdatePMEntity entity) { ObjectFactory <ProductLineProcessor> .Instance.BatchUpdate(entity); }
public void BatchUpdate(BatchUpdatePMEntity entity) { if (entity == null) { throw new Exception("Argument is null"); } if (entity.ProductLineList == null || entity.ProductLineList.Count == 0) { string error = string.Empty; if (entity.IsEmptyC2Create) { error = ResouceManager.GetMessageString("IM.Product", "ProductLineBatchUpdateResult1"); } else { error = ResouceManager.GetMessageString("IM.Product", "ProductLineBatchUpdateResult2"); } throw new BizException(error); } StringBuilder failtstring = new StringBuilder(); foreach (var item in entity.ProductLineList) { if (entity.IsEmptyC2Create) { item.PMUserSysNo = entity.PMUserSysNo.Value; item.MerchandiserSysNo = entity.MerchandiserSysNo.Value; item.BackupPMSysNoList = entity.BackupPMSysNoList; item.InUser = entity.InUser; item.CompanyCode = entity.CompanyCode; item.LanguageCode = entity.LanguageCode; try { Create(item); } catch (BizException ex) { failtstring.AppendLine(string.Format(ResouceManager.GetMessageString("IM.Product", "ProductLineBatchUpdateResult3"), item.C2Name, ex.Message)); } } else { ProductLineInfo olditem = LoadBySysNo(item.SysNo.Value); if (entity.PMUserSysNo.HasValue) { olditem.PMUserSysNo = entity.PMUserSysNo.Value; } if (entity.MerchandiserSysNo.HasValue) { olditem.MerchandiserSysNo = entity.MerchandiserSysNo.Value; } olditem.EditUser = entity.InUser; try { olditem.BackupPMSysNoList = ProcessBakPMList(olditem.BackupPMSysNoList, entity.BackupPMList, entity.BakPMUpdateType); Update(olditem); } catch (BizException ex) { failtstring.AppendLine(string.Format(ResouceManager.GetMessageString("IM.Product", "ProductLineBatchUpdateResult4"), item.SysNo, ex.Message)); } } } if (failtstring.Length > 0) { throw new BizException(failtstring.ToString()); } }
public virtual void BatchUpdate(BatchUpdatePMEntity entity) { ObjectFactory <ProductLineAppService> .Instance.BatchUpdate(entity); }