Exemplo n.º 1
0
        private void btnGXRZ_Click(object sender, RoutedEventArgs e)
        {
            int count = invoiceList.Count(x => x.IsChecked);

            if (count == 0)
            {
                MessageBoxEx.Show(JXManager.JXManagerInstance, PRO_ReceiptsInvMgr.Resources.Message.SelectGXInvoice, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Information);
                return;
            }
            else if (count > 20)
            {
                MessageBoxEx.Show(JXManager.JXManagerInstance, PRO_ReceiptsInvMgr.Resources.Message.OutOfFpCount, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                return;
            }

            var checkedList = invoiceList.Where(x => x.IsChecked).ToList();
            var totalAmount = checkedList.Sum(x => x.HJBHSJE).Value;
            var totalSe     = checkedList.Sum(x => x.SE).Value;

            YqyjViewModelInstance.TotalAmount = totalAmount.ToString("f2");
            YqyjViewModelInstance.TotalSE     = totalSe.ToString("f2");

            string      confirmTip = string.Format("勾选总张数:{0} 张  总金额:{1} 元  总税额:{2} 元", count, YqyjViewModelInstance.TotalAmount, YqyjViewModelInstance.TotalSE);
            GxrzConfirm confirmWin = new GxrzConfirm();

            confirmWin.ConfirmTip   = confirmTip;
            confirmWin.SelectedList = checkedList;
            confirmWin.DoRzAction   = () =>
            {
                Task.Factory.StartNew(() =>
                {
                    string msg = string.Empty;
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        WaitingBox.Show(() =>
                        {
                            service.GXRZ(checkedList, out msg);
                            //20190409 取数据失败时,如果是token过期则重新获取并重试
                            if (msg.Contains("token过期"))
                            {
                                int retryCount = 3;
                                do
                                {
                                    --retryCount;
                                    GlobalInfo.token = GetTokenHelper.GetToken_dll(GlobalInfo.NSRSBH, GlobalInfo.JxPwd, GlobalInfo.Dqdm);
                                } while (GlobalInfo.token.Length == 0 && retryCount > 0);

                                service.GXRZ(checkedList, out msg);
                            }
                        }, PRO_ReceiptsInvMgr.Resources.Message.GxrzWait);
                    }));
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            MessageBoxEx.Show(JXManager.JXManagerInstance, msg, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                        }
                        btnQuery_Click(null, null);
                    }));
                });
            };
            confirmWin.Owner = JXManager.JXManagerInstance;
            confirmWin.ShowDialog();
        }
Exemplo n.º 2
0
        private void btnGXRZ_Click(object sender, RoutedEventArgs e)
        {
            var checkedList = m_invoiceList.Where(x => x.IsChecked).ToList();
            int count       = checkedList.Count;

            if (count == 0)
            {
                MessageBoxEx.Show(JXManager.JXManagerInstance, PRO_ReceiptsInvMgr.Resources.Message.SelectGXInvoice, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Information);
                return;
            }
            else if (count > 60)
            {
                MessageBoxEx.Show(JXManager.JXManagerInstance, PRO_ReceiptsInvMgr.Resources.Message.OutOfFpCount, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                return;
            }

            string      confirmTip = string.Format("勾选总张数:{0} 张  总金额:{1} 元  总税额:{2} 元", count, SmrzViewModelInstance.TotalAmount, SmrzViewModelInstance.TotalSE);
            GxrzConfirm confirmWin = new GxrzConfirm();

            confirmWin.ConfirmTip   = confirmTip;
            confirmWin.SelectedList = checkedList;
            confirmWin.DoRzAction   = () =>
            {
                Task.Factory.StartNew(() =>
                {
                    string msg = string.Empty;
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        WaitingBox.Show(() =>
                        {
                            service.GXRZ(checkedList, out msg);
                            //20190409 取数据失败时,如果是token过期则重新获取并重试
                            if (msg.Contains("token过期"))
                            {
                                int retryCount = 3;
                                do
                                {
                                    --retryCount;
                                    GlobalInfo.token = GetTokenHelper.GetToken_dll(GlobalInfo.NSRSBH, GlobalInfo.JxPwd, GlobalInfo.Dqdm);
                                } while (GlobalInfo.token.Length == 0 && retryCount > 0);

                                service.GXRZ(checkedList, out msg);
                            }
                        }, PRO_ReceiptsInvMgr.Resources.Message.GxrzWait);
                    }));

                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (!string.IsNullOrEmpty(msg))
                        {
                            MessageBoxEx.Show(JXManager.JXManagerInstance, msg, PRO_ReceiptsInvMgr.Resources.Message.Tips, MessageBoxExButtons.OK, MessageBoxExIcon.Error);
                        }

                        if (msg.IndexOf("成功") != -1)
                        {
                            m_invoiceList.RemoveAll(x => x.IsChecked);
                        }

                        //显示
                        SmrzViewModelInstance.InvoiceList = new ObservableCollection <JXInvoiceInfo>(m_invoiceList);
//                        SmrzViewModelInstance.YqTipCounts = SmrzViewModelInstance.InvoiceList.Count(x => x.YQTXBZ);

                        this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            splYqRemain.Visibility = SmrzViewModelInstance.YqTipCounts > 0 ? Visibility.Visible : Visibility.Collapsed;
                            pcPage.TotalCount      = m_invoiceList.Count;
                            gifLoading.Visibility  = Visibility.Collapsed;

                            if (m_invoiceList.Count > 0)
                            {
                                pcPage.Visibility = Visibility.Visible;
                                pcPage_DataSourcePageSize(null, null);
                            }
                            else
                            {
                                imgTip.Visibility = Visibility.Visible;
                            }
                            CalcTotalChecked();
                        }));
                    }));
                });
            };
            confirmWin.Owner = JXManager.JXManagerInstance;
            confirmWin.ShowDialog();
        }