private Dictionary <decimal, int> GetNotesValuesAndCount(DateTime startdate, DateTime enddate)
        {
            var distionary = new Dictionary <decimal, int>();

            try
            {
                var operations = WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, startdate, enddate);

                foreach (var cashOperationtData in operations)
                {
                    if (cashOperationtData.operation_type != "CASH_IN")
                    {
                        continue;
                    }
                    if (distionary.ContainsKey(cashOperationtData.amount))
                    {
                        distionary[cashOperationtData.amount]++;
                    }
                    else
                    {
                        distionary.Add(cashOperationtData.amount, 1);
                    }
                }
            }
            catch (FaultException <HubServiceException> ex)
            {
                ShowError(ex.Detail.message);
            }
            return(distionary);
        }
        private List <HistoryFile> GetHistoryFiles()
        {
            var historyFiles = new List <HistoryFile>();

            try
            {
                var records = WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, _datLocal, _datLocal.AddDays(7));
                for (int i = records.Length - 1; i >= 0; i--)
                {
                    var record = records[i];
                    if (record.operation_type != "CASH_IN")
                    {
                        continue;
                    }
                    var historyFile = new HistoryFile();
                    historyFile.DateValue = record.created_at;
                    if (record.amount >= 1)
                    {
                        historyFile.CashValue = ((int)record.amount).ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        historyFile.CashValue = record.amount.ToString(CultureInfo.InvariantCulture);
                    }
                    historyFiles.Add(historyFile);
                }
            }
            catch (FaultException <HubServiceException> exception)
            {
                ShowError(exception.Detail.message);
            }

            if (historyFiles.Count == 0)
            {
                var rowX = new HistoryFile();
                rowX.CashDate  = TranslationProvider.Translate(MultistringTags.CASH_HISTORY_NOT_FOUND);
                rowX.CashValue = "";
                historyFiles.Add(rowX);
            }
            return(historyFiles);
        }
        private ObservableCollection <CashOperation> GetCashOperations(long startId, long endId = long.MaxValue)
        {
            var     cashOperations = new ObservableCollection <CashOperation>();
            decimal cashinValue    = 0;
            decimal cashoutValue   = 0;

            if (startId == 0 && endId == 0)
            {
                CashInOperationsNum  = cashinValue;
                CashOutOperationsNum = cashoutValue;
                OnPropertyChanged("CashInOperationsNum");
                OnPropertyChanged("CashOutOperationsNum");
                return(cashOperations);
            }

            try
            {
                CashOperationtData[] lStationCash;

                if (ChangeTracker.FromCheckPointsAccounting && EndDate == DateTimeUtils.DATETIME1700)
                {
                    lStationCash = WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, StartDate, ChangeTracker.CalendarEndDateAccounting.AddSeconds(1));
                }
                else
                {
                    lStationCash = WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, StartDate, EndDate.AddSeconds(1));
                }

                foreach (CashOperationtData stationCashBo in lStationCash)
                {
                    decimal multiplier;
                    string  type = stationCashBo.operation_type;
                    string  translation;
                    if (type == "CASH_IN")
                    {
                        multiplier   = 1;
                        cashinValue += stationCashBo.amount;
                        translation  = TranslationProvider.Translate(MultistringTags.STATION_CASH_IN).ToString();
                    }
                    else if (type == "EMPTY_BOX")
                    {
                        multiplier    = -1;
                        cashoutValue += stationCashBo.amount;
                        translation   = TranslationProvider.Translate(MultistringTags.STATION_CASH_OUT).ToString();
                    }
                    else
                    {
                        translation = "";
                        multiplier  = 1;
                    }

                    cashOperations.Add(new CashOperation(0, stationCashBo.amount * multiplier, stationCashBo.created_at, translation,
                                                         !string.Equals(stationCashBo.operator_name, ChangeTracker.CurrentUser.Username) ? StationRepository.StationTyp : stationCashBo.operator_name));
                }
            }
            catch (Exception)
            {
            }
            CashInOperationsNum  = cashinValue;
            CashOutOperationsNum = cashoutValue;
            OnPropertyChanged("CashInOperationsNum");
            OnPropertyChanged("CashOutOperationsNum");
            return(cashOperations);
        }
Exemple #4
0
        private ObservableCollection <CashOperation> GetCashOperations(long startId, long endId = long.MaxValue)
        {
            var     cashOperations    = new ObservableCollection <CashOperation>();
            decimal cashinValue       = 0;
            decimal cashoutValue      = 0;
            string  additionalCommand = "";

            if (startId == 0 && endId == 0)
            {
                CashInOperationsNum  = cashinValue;
                CashOutOperationsNum = cashoutValue;
                OnPropertyChanged("CashInOperationsNum");
                OnPropertyChanged("CashOutOperationsNum");
                return(cashOperations);
            }

            try
            {
                if (PayIn && !PayOut)
                {
                    additionalCommand = "and MoneyIn=1";
                }
                else if (!PayIn && PayOut)
                {
                    additionalCommand = "and MoneyIn=0";
                }

                List <IDbDataParameter> lParams = new List <IDbDataParameter>()
                {
                    SqlObjectFactory.CreateParameter("lastCashoutStartId", startId, string.Empty),
                    SqlObjectFactory.CreateParameter("lastCashoutEndId", endId, string.Empty)
                };

                //List<StationCashSr> lStationCash = StationCashSr.GetStationCashListByQuery("SELECT * FROM StationCash where stationcashid >= @lastCashoutStartId and stationcashid <= @lastCashoutEndId " + additionalCommand + " order by DateModified desc", lParams);
                CashOperationtData[] lStationCash = WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, StartDate, EndDate);  //WsdlRepository.GetStationCashHistory(StationRepository.StationNumber, StartDate, EndDate);

                foreach (CashOperationtData stationCashBo in lStationCash)
                {
                    decimal multiplier;
                    string  type = stationCashBo.operation_type;
                    string  translation;
                    if (type == "CASH_IN")
                    {
                        multiplier   = 1;
                        cashinValue += stationCashBo.amount;
                        translation  = TranslationProvider.Translate(MultistringTags.STATION_CASH_IN).ToString();
                    }
                    else if (type == "EMPTY_BOX")
                    {
                        multiplier    = -1;
                        cashoutValue += stationCashBo.amount;
                        translation   = TranslationProvider.Translate(MultistringTags.STATION_CASH_OUT).ToString();
                    }
                    else
                    {
                        translation = "";
                        multiplier  = 1;
                    }

                    //if (type == "CASH_IN")
                    //{
                    //    cashinValue += stationCashBo.amount;
                    //}
                    //else if (type == "EMPTY_BOX")
                    //{
                    //    cashoutValue += stationCashBo.amount;
                    //}
                    cashOperations.Add(new CashOperation(0, stationCashBo.amount * multiplier, stationCashBo.created_at, translation,
                                                         String.IsNullOrEmpty(stationCashBo.operator_name) ? StationRepository.StationTyp : stationCashBo.operator_name));
                }
            }
            catch (Exception)
            {
            }
            CashInOperationsNum  = cashinValue;
            CashOutOperationsNum = cashoutValue;
            OnPropertyChanged("CashInOperationsNum");
            OnPropertyChanged("CashOutOperationsNum");
            return(cashOperations);
        }