Example #1
0
        async void MoveToVoucherAtIndex(int index, bool setFocus = false)
        {
            if (index < 0 || envelopes == null || index > envelopes.Length - 1)
            {
                return;
            }
            btnPrev.IsEnabled = btnNext.IsEnabled = true;
            if (selectedIndex == 0)
            {
                btnPrev.IsEnabled = false;
            }
            if (selectedIndex == envelopes.Length - 1)
            {
                btnNext.IsEnabled = false;
            }
            this.documentViewer.Children.Clear();
            currentBlk.Text = NumberConvert.ToString(index + 1);

            try
            {
                VouchersClient vClient = envelopes[selectedIndex];
                if (vClient._Data != null)
                {
                    VoucherCache.SetGlobalVoucherCache(vClient);
                }
                else
                {
                    await UtilDisplay.GetData(vClient, api);
                }

                this.documentViewer.Children.Add(UtilDisplay.LoadControl(vClient, false, setFocus));
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = System.Windows.Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. \n{1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
            }
            SetMetaInfo(voucherClient);
        }
        async private void InitMaster(UnicontaBaseEntity corasauMaster, bool setFocus)
        {
            if (corasauMaster == null)
            {
                return;
            }

            busyIndicator.IsBusy = true;
            ModifiedRow          = await UtilDisplay.GetPhoto(corasauMaster, api);

            busyIndicator.IsBusy = false;

            this.documentViewer.Children.Clear();

            try
            {
                this.documentViewer.Children.Add(UtilDisplay.LoadControl(userDocClient.UserDocument, userDocClient.DocumentType, false, setFocus));
            }
            catch
            {
                this.documentViewer.Children.Add(UtilDisplay.LoadDefaultControl(Uniconta.ClientTools.Localization.lookup("InvalidDocSave")));
            }
            SetMetaInfo(userDocClient);
        }
Example #3
0
        async private void _LoadInitMaster(UnicontaBaseEntity corasauMaster, VouchersClient voucherClient, int RowId, bool setFocus)
        {
            try
            {
                if (voucherClient == null)
                {
                    if (RowId != 0)
                    {
                        voucherClient = new VouchersClient();
                        voucherClient.SelectRowId(RowId);
                        // we will now enter api.read
                    }
                    else
                    {
                        busyIndicator.IsBusy = true;
                        var voucher = await api.Query <VouchersClient>(corasauMaster);

                        voucherClient = voucher?.FirstOrDefault();
                        if (voucherClient?._Data != null)
                        {
                            VoucherCache.SetGlobalVoucherCache(voucherClient);
                        }
                    }
                }

                if (voucherClient._Data == null)
                {
                    busyIndicator.IsBusy = true;
                    var result = await UtilDisplay.GetData(voucherClient, api);

                    if (result != 0)
                    {
                        busyIndicator.IsBusy = false;
                        UtilDisplay.ShowErrorCode(result);
                        return;
                    }
                }

                this.documentViewer.Children.Clear();

                brdMetaInfo.Visibility = Visibility.Visible;
                if (voucherClient._Envelope)
                {
                    btnPrev.IsEnabled    = false;
                    busyIndicator.IsBusy = true;
                    var dapi = new DocumentAPI(api);
                    envelopes = (VouchersClient[])await dapi.GetEnvelopeContent(voucherClient, true);

                    gridPrevNext.Visibility = Visibility.Visible;
                    if (envelopes != null && envelopes.Length > 0)
                    {
                        totalBlk.Text = NumberConvert.ToString(envelopes.Length);
                        MoveToVoucherAtIndex(selectedIndex, setFocus);

                        /*
                         * currentBlk.Text = NumberConvert.ToString(selectedIndex + 1);
                         * var doc = envelopes[selectedIndex];
                         * this.documentViewer.Children.Add(UtilDisplay.LoadControl(doc.Buffer, doc._Fileextension, false, setFocus));
                         */
                    }
                    else
                    {
                        totalBlk.Text   = "0";
                        currentBlk.Text = "0";
                    }
                    busyIndicator.IsBusy = false;
                }
                else
                {
                    busyIndicator.IsBusy = false;
                    this.documentViewer.Children.Add(UtilDisplay.LoadControl(voucherClient, false, setFocus));
                }
            }
            catch (Exception ex)
            {
                brdMetaInfo.Visibility = Visibility.Visible;
                this.documentViewer.Children.Add((UtilDisplay.LoadDefaultControl(string.Format("{0}. {1} : {2}", Uniconta.ClientTools.Localization.lookup("InvalidDocSave"),
                                                                                               Uniconta.ClientTools.Localization.lookup("ViewerFailed"), ex.Message))));
                busyIndicator.IsBusy = false;
            }
            SetMetaInfo(voucherClient);
        }