private void mInsertBtn_Click(object sender, EventArgs e) { int sum = Convert.ToInt32(mSumTB.Text); string outputMessage = string.Empty; bool res = mAtmData.tryToInsertMoney(sum, mMoneyInserted, ref outputMessage); int returnedSum = 0; foreach (var curPair in mMoneyInserted) { returnedSum += (int)curPair.Key * curPair.Value; } if (sum != returnedSum) { outputMessage += "\nInserted sum is " + (sum - returnedSum).ToString(); } OperationResultForm resultForm = new OperationResultForm(mMoneyInserted, outputMessage, returnedSum); resultForm.StartPosition = FormStartPosition.CenterParent; resultForm.ShowDialog(); if (res) { updateInsertedMoney(); } }
private void mGetMoneyBtn_Click(object sender, EventArgs e) { int sum = (int)mSumField.Value; ATMData.BILL_TYPE prefType = (ATMData.BILL_TYPE)mPrefCB.SelectedItem; string outputMessage = string.Empty; Dictionary <ATMData.BILL_TYPE, int> returnedMoney; OperationResultForm resultForm = null; if (!mAtmData.tryToGiveAwayMoney(sum, prefType, ref outputMessage, out returnedMoney)) { sum = 0; } resultForm = new OperationResultForm(returnedMoney, outputMessage, sum); resultForm.StartPosition = FormStartPosition.CenterParent; resultForm.ShowDialog(); }