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(); } }