Example #1
0
        /// <summary>
        /// 打印历史结账单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            if (grid_h.SelectedIndex < 0 || grid_h.SelectedIndex >= HList.Count)
            {
                return;
            }
            string s = BillTemplate.GenerateHisorderBill(HList[grid_h.SelectedIndex], HDList);

            BillTemplate.PrintBill(s);
        }
Example #2
0
        /// <summary>
        /// 结账按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            int PayChannel = 0;

            switch (PayTypeString)
            {
            case PayType.微信:
                PayCodeString = tbxWx.Text.Trim();
                PayChannel    = 1;
                break;

            case PayType.支付宝:
                PayCodeString = tbxZfb.Text.Trim();
                PayChannel    = 2;
                break;

            case PayType.积分:
                PayCodeString = tbxJf.Text.Trim();
                PayChannel    = 3;
                break;

            default:
                PayCodeString = string.Empty;
                PayChannel    = 0;
                break;
            }

            if (PayChannel == 0 && tbxMoney.Text.Length > 8)
            {
                MessageBox.Show("输入有误,请重新输入!");
                tbxMoney.Text = string.Empty;
                return;
            }

            if (PayChannel > 0 && string.IsNullOrEmpty(PayCodeString))
            {
                MessageBox.Show(string.Format("请输入{0}付款码!", PayTypeString));
                return;
            }

            MsgArgs arg = new MsgArgs();

            arg.Extra.Add("PayCode", PayCodeString);
            arg.Extra.Add("PayType", PayTypeString);
            arg.Extra.Add("PayChannel", PayChannel);

            //支付中...
            grid_doing.Visibility = Visibility.Visible;
            Task <MsgArgs> task = Task.Factory.StartNew(() =>
            {
                MsgArgs msg = OK(arg) as MsgArgs;
                return(msg);
            });
            Task t = task.ContinueWith((a) =>
            {
                MsgArgs message = a.Result;
                if (message.Code != MsgCode.Succ)
                {//支付失败...
                    grid_doing.Visibility = Visibility.Collapsed;
                    MessageBox.Show(message.ErrMessage);
                    if (PayChannel == 0)
                    {
                        tbxMoney.Focus();
                    }
                    else if (PayChannel == 1)
                    {
                        tbxWx.Text = string.Empty;
                        tbxWx.Focus();
                    }
                    else if (PayChannel == 2)
                    {
                        tbxZfb.Text = string.Empty;
                        tbxZfb.Focus();
                    }
                    else if (PayChannel == 3)
                    {
                        tbxJf.Text = string.Empty;
                        tbxJf.Focus();
                    }
                    return;
                }
                //支付成功...
                grid_doing.Visibility = Visibility.Collapsed;
                grid_succ.Visibility  = Visibility.Visible;
                BillTemplate.PrintBill(message.Content);
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #3
0
        /// <summary>
        /// 结账按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OK_Click(object sender, RoutedEventArgs e)
        {
            int PayChannel = 0;

            switch (PayTypeString)
            {
            case PayType.微信:
                PayCodeString = tbxWx.Text.Trim();
                PayChannel    = 1;
                break;

            case PayType.支付宝:
                PayCodeString = tbxZfb.Text.Trim();
                PayChannel    = 2;
                break;

            case PayType.积分:
                PayCodeString = tbxJf.Text.Trim();
                PayChannel    = 3;
                break;

            default:
                PayCodeString = string.Empty;
                PayChannel    = 0;
                break;
            }

            if (PayChannel == 0 && tbxMoney.Text.Length > 8)
            {
                MessageBox.Show("输入有误,请重新输入!");
                tbxMoney.Text = string.Empty;
                return;
            }

            if (PayChannel > 0 && string.IsNullOrEmpty(PayCodeString))
            {
                MessageBox.Show(string.Format("请输入{0}付款码!", PayTypeString));
                return;
            }

            MsgArgs arg = new MsgArgs();

            arg.Extra.Add("PayCode", PayCodeString);
            arg.Extra.Add("PayType", PayTypeString);
            arg.Extra.Add("PayChannel", PayChannel);

            //支付中...
            grid_doing.Visibility = Visibility.Visible;

            //用线程处理
            MsgArgs message = await Task.Run(() =>
            {
                MsgArgs msg = OK(arg) as MsgArgs;
                return(msg);
            });

            if (message.Code != MsgCode.Succ)
            {//支付失败...
                grid_doing.Visibility = Visibility.Collapsed;
                MessageBox.Show(message.ErrMessage);
                if (PayChannel == 0)
                {
                    tbxMoney.Focus();
                }
                else if (PayChannel == 1)
                {
                    tbxWx.Text = string.Empty;
                    tbxWx.Focus();
                }
                else if (PayChannel == 2)
                {
                    tbxZfb.Text = string.Empty;
                    tbxZfb.Focus();
                }
                else if (PayChannel == 3)
                {
                    tbxJf.Text = string.Empty;
                    tbxJf.Focus();
                }
                return;
            }
            //支付成功...
            BillTemplate.PrintBill(message.Content);
            grid_doing.Visibility = Visibility.Collapsed;
            grid_succ.Visibility  = Visibility.Visible;
        }