Beispiel #1
0
        private void SaveFptrParameters(Event_EventFiskalProperties checkParameters)
        {
            checkParameters.NumberFtpr    = _fptr.GetSerialNumber();
            checkParameters.ShiftNumber   = _fptr.GetSession() + 1;
            checkParameters.CheckNumber   = _fptr.GetCheckNumber();
            checkParameters.PaymentType   = _choosedPaymentType;
            checkParameters.PaymentAmount = GetEnteredSum();
            checkParameters.Date          = DateTime.Now;

            Utils.TraceMessage($"{Parameters.Splitter}");

            //            var resultDateTime = _fptr.GetDate();
            //            var time = _fptr.GetTime();
            //            Utils.TraceMessage($"GetDate: {_fptr.GetDate()} GetTime: {_fptr.GetTime()}");
            //            resultDateTime = resultDateTime.AddHours(time.Hour);
            //            resultDateTime = resultDateTime.AddMinutes(time.Minute);
            //            resultDateTime = resultDateTime.AddSeconds(time.Second);

            //            checkParameters.Date = resultDateTime;

            DBHelper.SaveEntity(checkParameters);
        }
Beispiel #2
0
        internal void Print_OnClick(object sender, EventArgs e)
        {
            _enteredSumEditText.Enabled = false;

            var checkParameters = new Event_EventFiskalProperties
            {
                Id = DbRef.CreateInstance($"Document_{nameof(Event_EventFiskalProperties)}"
                                          , Guid.NewGuid()),
                Ref  = DbRef.FromString(_eventId),
                User = Settings.UserDetailedInfo.Id
            };

            Dialog.ShowProgressDialog(Translator.Translate("please_wait"), true);

            TaskFactory.RunTaskWithTimeout(() =>
            {
                var checkError = false;

                try
                {
                    PrintCheck();

                    if (_fptr.CloseCheck() < 0)
                    {
                        _fptr.CheckError();
                    }

                    checkParameters.Date = DateTime.Now;

                    DBHelper.SaveEntity(checkParameters, false);
                }
                catch (FPTRException exception)
                {
                    Utils.TraceMessage($"Error code {exception.Result} {exception.Message}");
                    checkError = true;
                    Toast.MakeToast(Translator.Translate(exception.Message));
                }
                catch (Exception exception)
                {
                    Utils.TraceMessage($"{exception.Message}{Environment.NewLine}" +
                                       $"Type {exception.GetType()}");
                }

                Utils.TraceMessage($"Check Error: {checkError}");

                if (!checkError)
                {
                    SaveFptrParameters(checkParameters);
                    BusinessProcess.GlobalVariables[Parameters.IdCurrentEventId] = _eventId;

                    Utils.TraceMessage($"GoTo {nameof(COCScreen)}");
                    Application.InvokeOnMainThread(() =>
                    {
                        Navigation.ModalMove(nameof(COCScreen), new Dictionary <string, object>
                        {
                            { Parameters.IdCurrentEventId, _eventId },
                            { Parameters.IdIsReadonly, _readonly },
                            { Parameters.IdWasEventStarted, _wasStarted }
                        });
                    });
                }
                else
                {
                    try
                    {
                        DBHelper.DeleteByRef(checkParameters.Id, false);
                        _fptr.CancelCheck();
                    }
                    catch (FPTRException exception)
                    {
                        Toast.MakeToast(Translator.Translate(exception.Message));
                    }
                    finally
                    {
                        if (_choosedPaymentType == 0)
                        {
                            Application.InvokeOnMainThread(()
                                                           => _enteredSumEditText.Enabled = true);
                        }
                    }
                }
            }, FptrAction.PrintingTimeOut, result =>
            {
                if (result.Finished)
                {
                    Dialog.HideProgressDialog();
                    return;
                }

                Dialog.HideProgressDialog();
                Toast.MakeToast(Translator.Translate("сonnection_error"));
            });
        }