Пример #1
0
        private void UpdateExchangeRates()
        {
            BEL.Transaction sellRates = new BEL.Transaction
            {
                exchangeRate = Convert.ToDouble(sellexchangeRateTxt.Text),
                lowerLimit   = Convert.ToDouble(selllowerLimitTxt.Text),
                upperLimit   = 0,
            };

            if (!(sellRates.exchangeRate >= sellRates.lowerLimit))
            {
                MessageBox.Show("The Exchange Rate must be greater than or equal lower limit (" + sellRates.lowerLimit + ")", "Invalid Sell Exchange Rate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            BEL.Transaction buyRates = new BEL.Transaction
            {
                exchangeRate = Convert.ToDouble(buyexchangeRateTxt.Text),
                upperLimit   = Convert.ToDouble(buyupperLimitTxt.Text),
            };

            if (buyRates.exchangeRate > buyRates.upperLimit)
            {
                MessageBox.Show("The Buying Exchange Rate must be less than or equal to lower limit (" + buyRates.upperLimit + ")", "Invalid Buy Exchange Rate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            currencyExchange.updateExchangeRates(1, buyRates);
            currencyExchange.updateExchangeRates(2, sellRates);

            MessageBox.Show("Exchange rates updated successfully", "Rates Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void SellUC_VisibleChanged(object sender, EventArgs e)
        {
            sellRecorDGV.DataSource = currencyExchange.getallRecords("sell");
            ExchangeRate            = currencyExchange.getExchangeRate("sell");
            ResetForm();

            this.sellRecorDGV.Columns[1].DefaultCellStyle.Format = "N2";
            this.sellRecorDGV.Columns[2].DefaultCellStyle.Format = "N2";
            this.sellRecorDGV.Columns[3].DefaultCellStyle.Format = "N2";

            dolarTxtBox.Focus();
        }
Пример #3
0
        private void SellUserControl_Load(object sender, EventArgs e)
        {
            BEL.Transaction trans = currencyExchange.getExchangeRate("sell");
            sellexchangeRateTxt.Text = trans.exchangeRate.ToString();
            selllowerLimitTxt.Text   = trans.lowerLimit.ToString();



            trans = currencyExchange.getExchangeRate("buy");
            buyexchangeRateTxt.Text = trans.exchangeRate.ToString();
            buyupperLimitTxt.Text   = trans.upperLimit.ToString();

            sellexchangeRateTxt.Text = string.Format("{0:#,##0.00}", double.Parse(sellexchangeRateTxt.Text));
            selllowerLimitTxt.Text   = string.Format("{0:#,##0.00}", double.Parse(selllowerLimitTxt.Text));

            buyexchangeRateTxt.Text = string.Format("{0:#,##0.00}", double.Parse(buyexchangeRateTxt.Text));
            buyupperLimitTxt.Text   = string.Format("{0:#,##0.00}", double.Parse(buyupperLimitTxt.Text));
        }
        private void DoTransaction()
        {
            exchangeRateTxtBox.Text = string.Format("{0:#,##0.00}", double.Parse(exchangeRateTxtBox.Text));
            pesoTxtBox.Text         = string.Format("{0:#,##0.00}", double.Parse(pesoTxtBox.Text));


            BEL.Transaction transaction = new BEL.Transaction();
            try
            {
                transaction.dolars       = Convert.ToDouble(dolarTxtBox.Text);
                transaction.exchangeRate = Convert.ToDouble(exchangeRateTxtBox.Text);
                transaction.pesos        = Convert.ToDouble(pesoTxtBox.Text);
            }
            catch
            {
                MessageBox.Show("Input must be in numbers", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (transaction.exchangeRate < ExchangeRate.lowerLimit)
            {
                MessageBox.Show("The exchange rate must be greater than " + ExchangeRate.lowerLimit, "Invalid Exchange Rate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }


            if (transaction.dolars <= 0)
            {
                return;
            }

            if (currencyExchange.addTransaction("sell", transaction) > 0)
            {
                //Show in gridview,
                //print recipt
                sellRecorDGV.DataSource = currencyExchange.getallRecords("sell");
                if (printChkBox.Checked)
                {
                    ReceiptModel.printReceipt("sell", transaction.dolars, transaction.pesos, transaction.exchangeRate);
                }

                ResetForm();
            }
        }
        private void DoTransaction()
        {
            BEL.Transaction transaction = new BEL.Transaction();
            try
            {
                transaction.dolars       = Convert.ToDouble(dolarTxtBox.Text);
                transaction.exchangeRate = Convert.ToDouble(exchangeRateTxtBox.Text);
                transaction.pesos        = Convert.ToDouble(pesoTxtBox.Text);
            }
            catch
            {
                MessageBox.Show("Input must be in numbers", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (transaction.exchangeRate > ExchangeRate.upperLimit)
            {
                MessageBox.Show("The Exchange Rate must be less than or equal to " + ExchangeRate.upperLimit, "Invalid Exchange Rate", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }


            if (transaction.dolars <= 0)
            {
                return;
            }

            if (currencyExchange.addTransaction("buy", transaction) > 0)
            {
                //Show in gridview,
                //print recipt
                buyRecordDGV.DataSource = currencyExchange.getallRecords("buy");
                if (printChkBox.Checked)
                {
                    ReceiptModel.printReceipt("buy", transaction.dolars, transaction.pesos, transaction.exchangeRate);
                }

                ResetForm();
            }
        }