コード例 #1
0
        private void LoadInitialData()
        {
            ObservableCollection <OperatorShiftCheckpoint> tempCollection = new ObservableCollection <OperatorShiftCheckpoint>();
            OperatorShiftCheckpoint testCP = new OperatorShiftCheckpoint();

            tempCollection.Add(testCP);
            _Checkpoints = new ObservableCollection <OperatorShiftCheckpoint>(tempCollection);
            OnPropertyChanged("Checkpoints");
        }
コード例 #2
0
        private void CreateCheckpoint()
        {
            OperatorShiftCheckpoint checkpoint = new OperatorShiftCheckpoint();

            DateTime stDate;
            DateTime enDate;
            int      ebTN;
            int      pTN;
            decimal  ebTA;
            decimal  pTA;
            decimal  tempBalance;
            string   operatorName;

            if (CheckForEmptyBox())
            {
                ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_PLEASE_EMPTY_BOX).ToString(), null, false);
                return;
            }

            try
            {
                OperatorShiftData data = WsdlRepository.CreateOperatorShiftCheckpoint(StationRepository.LocationID, Int16.Parse(StationRepository.GetUid(ChangeTracker.CurrentUser).account_id));
                stDate       = data.startDate;
                enDate       = data.endDate;
                ebTA         = data.emptyBoxTotalAmount;
                pTA          = data.payoutTotalAmount;
                ebTN         = data.emptyBoxTotalNumber;
                pTN          = data.payoutTotalNumber;
                tempBalance  = data.balance;
                operatorName = data.operatorName;
            }
            catch (Exception ex)
            {
                if (ex is System.ServiceModel.FaultException <HubServiceException> )
                {
                    System.ServiceModel.FaultException <HubServiceException> exep = (System.ServiceModel.FaultException <HubServiceException>)ex;
                    ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_NO_EMPTY_BOXES).ToString(), null, false);
                }

                return;
            }

            checkpoint.startDate           = stDate;
            checkpoint.endDate             = enDate;
            checkpoint.emptyBoxTotalAmount = ebTA;
            checkpoint.emptyBoxTotalNumber = ebTN;
            checkpoint.payoutTotalAmount   = pTA;
            checkpoint.payoutTotalNumber   = pTN;
            checkpoint.operatorName        = operatorName;
            checkpoint.operatorId          = (int)ChangeTracker.CurrentUser.AccountId;

            ObservableCollection <OperatorShiftCheckpoint> tempCollection = new ObservableCollection <OperatorShiftCheckpoint>();

            globalCollection.Insert(0, checkpoint);

            if ((currentPosition + pageSize) < globalCollection.Count)
            {
                for (int i = currentPosition; i < pageSize; i++)
                {
                    tempCollection.Add(globalCollection[i]);
                }
            }
            else
            {
                for (int i = currentPosition; i < globalCollection.Count; i++)
                {
                    tempCollection.Add(globalCollection[i]);
                }
            }

            SelectedCheckpoint = tempCollection[0];

            //recalculate balance
            //CalculateBalance();

            _Checkpoints           = new ObservableCollection <OperatorShiftCheckpoint>(tempCollection);
            EnabledPrintCheckpoint = _Checkpoints.Count > 0 && SelectedCheckpoint != null && SelectedCheckpoint.id != -1000;
            OnPropertyChanged("Checkpoints");
            OnPropertyChanged("EnabledPrintCheckpoint");

            Balance = tempBalance;
            OnPropertyChanged("Balance");

            CurrentShiftReport();

            //printout
            bool isPrinted = PrinterHandler.PrintOperatorShiftReport(checkpoint, tempBalance);

            if (!isPrinted)
            {
                ShowPrinterErrorMessage();
            }

            ShowError(TranslationProvider.Translate(MultistringTags.TERMINAL_SHIFT_REPORT_CREATED).ToString() + "\n\n" + SelectedCheckpoint.startDate.ToString() + " - " + SelectedCheckpoint.endDate.ToString(), null, false, 15);
        }