private void DetermineIfInOrOutAndMakeComment(InOutDRParam p, bool isRemovedItem) { if (_param.ReceiptType == ReceiptType.SDR) { if (isRemovedItem) { p.InOrOut = InOrOut.Out; } else { p.InOrOut = InOrOut.In; p.Note = p.DRItem.Qty + " went from SDR: " + _currentDr.DRNumberToDisplay; } } else if (_param.ReceiptType == ReceiptType.DR) { if (isRemovedItem) { p.InOrOut = InOrOut.In; } else { p.InOrOut = InOrOut.Out; p.Note = p.DRItem.Qty + " went to DR: " + _currentDr.DRNumberToDisplay; } } }
public void InOutWithDR(InOutDRParam inParam) { Item itemAfterInOut = _itemService.Find(inParam.DRItem.Item.Id); double oldQty = itemAfterInOut.GetAppropriateQuantity; if (inParam.InOrOut == InOrOut.In) { InOutHelper.AddToAppopriateMeasurement(itemAfterInOut, inParam.DRItem.Qty); } else if (inParam.InOrOut == InOrOut.Out) { InOutHelper.SubtractToAppopriateMeasurement(itemAfterInOut, inParam.DRItem.Qty); } double newQty = itemAfterInOut.GetAppropriateQuantity; inParam.DRItem.Item = itemAfterInOut; var p = CreateHistoryParameterWithDr(inParam, oldQty, newQty); ItemHistory h = InOutHelper.MakeHistory(p); _historyService.Add(h); _itemService.Edit(itemAfterInOut); _drService.AddToDR(inParam.DRItem.DR.Id, inParam.DRItem); }
private void AddOrSubtractToStockAndMakeHistory(DRItem item) { InOutDRParam p = new InOutDRParam(); p.DRItem = item; p.Name = _name; DetermineIfInOrOutAndMakeComment(p, false); _inOutService.InOutWithDR(p); }
private void RemoveItemFromDBandMakeHistory() { InOutDRParam p = new InOutDRParam(); p.DRItem = GetSelectedItemInListView(); DetermineIfInOrOutAndMakeComment(p, true); _inOutService.RemoveFromDR(p); _drItems.Remove(p.DRItem); }
public void RemoveFromDR(InOutDRParam outParam) { Item itemAfterOut = _itemService.Find(outParam.DRItem.Item.Id); if (outParam.InOrOut == InOrOut.In) { InOutHelper.AddToAppopriateMeasurement(itemAfterOut, outParam.DRItem.Qty); } else { InOutHelper.SubtractToAppopriateMeasurement(itemAfterOut, outParam.DRItem.Qty); } outParam.DRItem.Item = itemAfterOut; _itemService.Edit(itemAfterOut); _historyService.DeleteHistoryByDRAndItem(outParam.DRItem.DR.Id, itemAfterOut.Id); _drService.DeleteDRItem(outParam.DRItem.Id); }
private static HistoryParam CreateHistoryParameterWithDr(InOutDRParam inParam , double oldQty, double newQty) { HistoryParam p = new HistoryParam(); p.InOrOut = inParam.InOrOut; p.ItemToMonitor = inParam.DRItem.Item; p.OldQty = oldQty; p.NewQty = newQty; p.InOutQty = inParam.DRItem.Qty; p.Note = inParam.Note; p.DR = inParam.DRItem.DR; p.Name = inParam.Name; if (inParam.DRItem.DR != null) { p.Type = inParam.DRItem.DR.Type; } return(p); }