public BizPosition[] PositionGet(Guid?supplierId) { if (!supplierId.HasValue) { return(new BizPosition[0]); } var _result = new List <BizPosition>(); lock (GParams.Instance.ComLockObj) { try { var _rows = GParams.Instance.PositionsTable.SelectBySupplierId(supplierId); if (_rows != null && _rows.Length > 0) { foreach (var _row in _rows) { _result.Add(BizPosition.ConvertFromDataRow(_row)); } } } catch (Exception) { _result.Clear(); } } return(_result.Count > 0 ? _result.ToArray() : null); }
public BizPosition[] GetNotSoldNotReturnedPositions(Guid supplierId) { var _result = new List <BizPosition>(); lock (GParams.Instance.ComLockObj) { try { var _rows = GParams.Instance.PositionsTable.SelectBySupplierId(supplierId); for (var _i = 0; _i < _rows.Length; _i++) { var _orgPositionRow = _rows[_i]; var _orgPosition = BizPosition.ConvertFromDataRow(_orgPositionRow); if (_orgPosition != null) { if (!_orgPosition.SoldAt.HasValue && !_orgPosition.ReturnedToSupplierAt.HasValue) { _result.Add(_orgPosition); } } } } catch { // ignored } } return(_result.Count > 0 ? _result.ToArray() : null); }
public BizPosition PositionGet(int positionNo) { lock (GParams.Instance.ComLockObj) { try { var _row = GParams.Instance.PositionsTable.FetchByNo(positionNo); if (_row != null) { return(BizPosition.ConvertFromDataRow(_row)); } } catch { // ignored } } return(null); }
public PositionSellResult PositionSell(BizPosition[] position) { var _result = new PositionSellResult(); lock (GParams.Instance.ComLockObj) { try { var _soldPositions = new List <BizPosition>(); var _notPossibleToSell = new List <BizPosition>(); var _notSoldPosReason = new List <PositionSellResult.NotSoldPosReasonTypes>(); foreach (var _positionToSell in position) { var _orgPositionrow = GParams.Instance.PositionsTable.FetchByNo(_positionToSell.PositionNo); var _orgPosition = BizPosition.ConvertFromDataRow(_orgPositionrow); if (_orgPosition != null) { if (_orgPosition.SoldAt != _positionToSell.SoldAt) { _notPossibleToSell.Add(_positionToSell); _notSoldPosReason.Add(PositionSellResult.NotSoldPosReasonTypes.MeanTimeSold); } else if (_orgPosition.ReturnedToSupplierAt != _positionToSell.ReturnedToSupplierAt) { _notPossibleToSell.Add(_positionToSell); _notSoldPosReason.Add(PositionSellResult.NotSoldPosReasonTypes.MeanTimeReturned); } //else if (_orgPosition.LastChange != _positionToSell.LastChange) //{ // _notPossibleToSell.Add(_positionToSell); // _notSoldPosReason.Add(PositionSellResult.NotSoldPosReasonTypes.MeanTimeChanged); //} else { try { _orgPosition.SoldAt = DateTime.Now; _orgPosition.SoldFor = _positionToSell.SoldFor; _orgPosition.ConvertToDataRow(ref _orgPositionrow); GParams.Instance.PositionsTable.SaveDataTable(GParams.Instance.ApplicationDataPath); _soldPositions.Add(_orgPosition); } catch (Exception) { // ignored } } } else { _notPossibleToSell.Add(_positionToSell); _notSoldPosReason.Add(PositionSellResult.NotSoldPosReasonTypes.NotFound); } } _result.SoldPositions = (_soldPositions.Count > 0) ? _soldPositions.ToArray() : null; _result.NotPossibleToSell = (_notPossibleToSell.Count > 0) ? _notPossibleToSell.ToArray() : null; _result.NotSoldPosReason = (_notSoldPosReason.Count > 0) ? _notSoldPosReason.ToArray() : null; } catch { // ignored } } return(_result); }
public PositionReturnedResult PositionReturn(Guid supplierId) { var _result = new PositionReturnedResult(); lock (GParams.Instance.ComLockObj) { try { var _rows = GParams.Instance.PositionsTable.SelectBySupplierId(supplierId); var _alreadyReturnedPositions = new List <BizPosition>(); var _soldPositions = new List <BizPosition>(); var _notSoldPositions = new List <BizPosition>(); for (var _i = 0; _i < _rows.Length; _i++) { var _orgPositionRow = _rows[_i]; var _orgPosition = BizPosition.ConvertFromDataRow(_orgPositionRow); if (_orgPosition != null) { if (_orgPosition.SoldAt.HasValue && !_orgPosition.ReturnedToSupplierAt.HasValue) { if (_orgPosition.SoldFor.HasValue) { _result.PositionsToReturnMoney += _orgPosition.SoldFor.Value; } _soldPositions.Add(_orgPosition); } else if (!_orgPosition.ReturnedToSupplierAt.HasValue) { _notSoldPositions.Add(_orgPosition); } else { _alreadyReturnedPositions.Add(_orgPosition); } try { if (!_orgPosition.ReturnedToSupplierAt.HasValue) { _result.PositionsToReturnCountTotal++; _orgPosition.ReturnedToSupplierAt = DateTime.Now; _orgPosition.LastChange = DateTime.Now; _orgPosition.ConvertToDataRow(ref _orgPositionRow); GParams.Instance.PositionsTable.SaveDataTable(GParams.Instance.ApplicationDataPath); } } catch (Exception) { // ignored } } } _result.AlreadyReturnedPositions = _alreadyReturnedPositions.ToArray(); _result.SoldPositions = _soldPositions.ToArray(); _result.NotSoldPositions = _notSoldPositions.ToArray(); } catch { // ignored } } return(_result); }