public StackPhysicalCountInfo GetBlankStackCount(PhysicalCountInfo physicalCount) { return(new StackPhysicalCountInfo() { Balance = 0, CummulatedShortage = 0, ExpectedBalance = 0, Id = Guid.NewGuid(), PhysicalCountId = physicalCount.Id, ShedId = Guid.Empty, StackId = Guid.Empty }); }
public void Copy(PhysicalCountInfo count) { Id = count.Id; WarehouseId = count.WarehouseId; PhysicalCountDate = count.PhysicalCountDate; IsBeginingCount = count.IsBeginingCount; }
public void AddStackPhysicalCount(PhysicalCountInfo physicalCount, StackPhysicalCountInfo stackPhysicalCount) { if (physicalCount.Stacks.Any(s => (s.StackId == stackPhysicalCount.StackId))) { throw new Exception("Invalid Stack Count : Stack count shall not be duplicated"); } Dictionary <string, object> contextParameters = new Dictionary <string, object>(); contextParameters.Add("StackId", stackPhysicalCount.StackId); contextParameters.Add("PhysicalCountId", stackPhysicalCount.PhysicalCountId); try { XmlSerializer s = new XmlSerializer(typeof(StackInventoryStatusInfo)); XmlDocument document = PersistenceTransactionFactory.CreatePersistenceTransaction().Open( "spGetStackInventoryStatus", contextParameters); StringBuilder sb = new StringBuilder(); TextWriter writer = new StringWriter(sb); document.Save(writer); StackInventoryStatusInfo sis = (StackInventoryStatusInfo)s.Deserialize(new StringReader(sb.ToString())); stackPhysicalCount.CummulatedShortage = sis.CummulatedShortage; stackPhysicalCount.CumulatedOverage = sis.CumulatedOverage; stackPhysicalCount.ExpectedBalance = sis.ExpectedBalance; } catch (Exception ex) { throw new Exception("The database failed to load a required Stack Inventory Status ", ex); } physicalCount.Stacks.Add(stackPhysicalCount); }
public void SavePhysicalCount(PhysicalCountInfo physicalCount) { PhysicalCountInfo originalPhysicalCount = OpenPhysicalCount(physicalCount.Id); AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount, new object[][] { new object[] { originalPhysicalCount, physicalCount, AuditTrailWrapper.ExistingRecord } }, "Inventory Control"); foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors) { PhysicalCountInspectorInfo originalInspector = originalPhysicalCount.Inspectors.Find(oi => oi.Id == inspector.Id); if (originalInspector == null) { atw.AddChange(null, inspector, AuditTrailWrapper.NewRecord); } else { atw.AddChange(originalInspector, inspector, AuditTrailWrapper.ExistingRecord); } } foreach (StackPhysicalCountInfo stack in originalPhysicalCount.Stacks) { StackPhysicalCountInfo originalStack = physicalCount.Stacks.Find(os => os.Id == stack.Id); if (originalStack == null) { atw.AddChange(null, stack, AuditTrailWrapper.NewRecord); } else { atw.AddChange(originalStack, stack, AuditTrailWrapper.ExistingRecord); } } Dictionary <string, object> contextParameters = new Dictionary <string, object>(); contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"])); Queue <object> queue = new Queue <object>(new object[] { physicalCount }); foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors) { queue.Enqueue(inspector); } foreach (StackPhysicalCountInfo stack in physicalCount.Stacks) { queue.Enqueue(stack); } try { SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist( queue, contextParameters); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } transaction.Commit(); } catch (Exception ex) { throw new Exception("Physical Count couldn't be saved to the database", ex); } }
public void AddInspector(PhysicalCountInfo physicalCount, PhysicalCountInspectorInfo inspector) { if (physicalCount.Inspectors.Any(i => (i.UserId == inspector.UserId) || (i.IsSupervisor && inspector.IsSupervisor))) { throw new Exception("Invalid Inspector : Inspector shall not be duplicated and only 1 supervisor is admitted"); } physicalCount.Inspectors.Add(inspector); }
public PhysicalCountInspectorInfo GetBlankInspector(PhysicalCountInfo physicalCount) { Guid inspectorId = (Guid)LookupSource.GetLookup("Inspector").Keys.FirstOrDefault(); if ((inspectorId == null) || (inspectorId == Guid.Empty)) { throw new Exception("No Physical Count Inspector has been configured"); } return(new PhysicalCountInspectorInfo() { Id = Guid.NewGuid(), PhysicalCountId = physicalCount.Id, IsSupervisor = false, UserId = inspectorId }); }
public void CreatePhysicalCount(PhysicalCountInfo physicalCount) { AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount, new object[][] { new object[] { null, physicalCount, AuditTrailWrapper.NewRecord } }, "Inventory Control"); Dictionary <string, object> contextParameters = new Dictionary <string, object>(); contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"])); try { SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist( new Queue <object>(new object[] { physicalCount }), contextParameters); transaction.Commit(); if (!atw.Save()) { transaction.Rollback(); throw new Exception("Failed to save audit trail!"); } } catch (Exception ex) { throw new Exception("Physical Count couldn't be saved to the database", ex); } }