コード例 #1
0
ファイル: BuyBitcoin.cs プロジェクト: srowlison/bbiller
        private void btnPurchase_Click(object sender, EventArgs e)
        {
            String CardId = "";

            nfc = DCPOS.Factory.GetNFC();
            if (nfc.InitReader())
            {
                if (nfc.ConnectReader())
                {
                    if (nfc.ReadTagID(ref CardId))
                    {
                        Decimal FiatAmount = Convert.ToInt32(txtAmount.Text);
                        Decimal Bitcoins   = Convert.ToDecimal(txtBitcoins.Text);

                        String DestinationAddress = "";
                        if (nfc.readPublicKey(ref DestinationAddress))
                        {
                            if (ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01")
                            {
                                PinPad pinform = new PinPad();
                                pinform.ShowDialog();

                                if (checkPin(CardId, Program.Pin) == "00")
                                {
                                    DCCommon common = new DCCommon();
                                    common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, cboCurrency.SelectedItem.ToString());
                                }
                            }
                            else
                            {
                                DCCommon common = new DCCommon();
                                common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, cboCurrency.SelectedItem.ToString());
                                // MessageBox.Show(result);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Cannot read Public Key", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Card not on Reader or cannot read card ", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                    }
                }
                else
                {
                    MessageBox.Show("The Reader cannot be Initalised", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                }
            }

            else
            {
                MessageBox.Show("The Reader cannot be Initalised", "DC PC POS", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
            }
        }
コード例 #2
0
ファイル: BuyBitcoin.cs プロジェクト: srowlison/bbiller
        private void btnPurchase_Click(object sender, EventArgs e)
        {
            UseWaitCursor = true;

            try
            {
                if (!IsValid())
                {
                    return;
                }


                String CardId = "";

                if (common.nfc.InitReader())
                {
                    if (common.nfc.ConnectReader())
                    {
                        if (common.nfc.ReadTagID(ref CardId))
                        {
                            if (common.nfc.ReadTagID(ref CardId))
                            {
                                Decimal FiatAmount = Convert.ToInt32(txtAmount.Text);
                                Decimal Bitcoins   = Convert.ToDecimal(txtBitcoins.Text);

                                String DestinationAddress = "";
                                if (common.nfc.readPublicKey(ref DestinationAddress))
                                {
                                    if (common.ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01")
                                    {
                                        PinPad pinform = new PinPad();
                                        pinform.ShowDialog();

                                        if (common.checkPin(CardId, Program.Pin) == "00")
                                        {
                                            MessageBox.Show(common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, Bitcoins, cboCurrency.SelectedItem.ToString()));
                                        }
                                        else
                                        {
                                            MessageBox.Show("Pin Invalid");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(common.PurchaseBitcoins(CardId, DestinationAddress, FiatAmount, Bitcoins, cboCurrency.SelectedItem.ToString()));
                                    }
                                }
                                else
                                {
                                    _errorMessagePurchase = "Cannot read Public Key";
                                    this.Refresh();
                                }
                            }
                            else
                            {
                                _errorMessagePurchase = "Card not on Reader or cannot read card";
                                this.Refresh();
                            }
                        }
                    }
                    else
                    {
                        _errorMessagePurchase = "The Reader cannot be Connected";
                        this.Refresh();
                    }
                }

                else
                {
                    _errorMessagePurchase = "The Reader cannot be Initalised";
                    this.Refresh();
                }
            }
            catch (Exception ex)
            {
                _errorMessagePurchase = "Error:" + ex.ToString();
                this.Refresh();
            }
            finally
            {
                UseWaitCursor = false;
                ShowValidationMessages();
            }
        }
コード例 #3
0
        private void btnSell_Click(object sender, EventArgs e)
        {
            try
            {
                UseWaitCursor = false;
                if (!IsValid())
                {
                    return;
                }

                String CardId = "";

                if (common.nfc.InitReader())
                {
                    if (common.nfc.ConnectReader())
                    {
                        if (common.nfc.ReadTagID(ref CardId))
                        {
                            Decimal FiatAmount          = Convert.ToInt32(txtAmount.Text);
                            Decimal Bitcoins            = Convert.ToDecimal(txtBitcoins.Text);
                            String  encryptedPrivateKey = "";

                            if (common.nfc.readPrivateKey(ref encryptedPrivateKey))
                            {
                                String FromCardPublicAddress = "";
                                if (common.nfc.readPublicKey(ref FromCardPublicAddress))
                                {
                                    if (common.ChkPINLimit(CardId, FiatAmount, cboCurrency.SelectedItem.ToString()) == "01")
                                    {
                                        PinPad pinform = new PinPad();
                                        pinform.ShowDialog();

                                        if (common.checkPin(CardId, Program.Pin) == "00")
                                        {
                                            String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                            MessageBox.Show(result);
                                        }
                                        else
                                        {
                                            MessageBox.Show("Pin Invalid");
                                        }
                                    }
                                    else
                                    {
                                        String result = common.SendBitcoins(CardId, FromCardPublicAddress, encryptedPrivateKey, Program.MerchantCardId, Bitcoins, FiatAmount, cboCurrency.SelectedItem.ToString());
                                        MessageBox.Show(result);
                                    }
                                }
                                else
                                {
                                    _errorMessageButton = "Cannot read Public Key";
                                    this.Refresh();
                                }
                            }
                            else
                            {
                                _errorMessageButton = "Cannot read Private Key";
                                this.Refresh();
                            }
                        }
                        else
                        {
                            _errorMessageButton = "Card not on Reader or cannot read card ";
                            this.Refresh();
                        }
                    }
                    else
                    {
                        _errorMessageButton = "The Reader cannot be Connected ";
                        this.Refresh();
                    }
                }
                else
                {
                    _errorMessageButton = "The Reader cannot be Initalised ";
                    this.Refresh();
                }
            }
            catch (Exception ex)
            {
                //TODO: log error
                _errorMessageButton = "Error:" + ex.ToString();
                this.Refresh();
            }
            finally
            {
                ShowValidationMessages();
                UseWaitCursor = false;
            }
        }