public void OperationButtonPress(string operation) { try { if (FirstOperand == string.Empty || LastOperation == "=") { FirstOperand = display; LastOperation = operation; } else { SecondOperand = display; Operation = lastOperation; calculation.CalculateResult(); FullExpression = Math.Round(Convert.ToDouble(FirstOperand), 10) + " " + Operation + " " + Math.Round(Convert.ToDouble(SecondOperand), 10) + " = " + Math.Round(Convert.ToDouble(Result), 10); LastOperation = operation; Display = Result; FirstOperand = display; } newDisplayRequired = true; } catch (Exception ex) { Display = Result == string.Empty ? "Error - see event log" : Result; LogExceptionInformation(ex); } }
public void OperationButtonPress(string operation) { try { if (operation == "CALC") { double val = 0; try { val = Convert.ToDouble(display); } catch { } if (val == 0) { return; } Amount = display; if (state > Convert.ToDouble(Amount)) { calculation.CalculateResult(isChecked1); Display = string.Empty; Balance = (Math.Round(Convert.ToDouble(state), 2) - Math.Round(Convert.ToDouble(Amount), 2)).ToString(); state -= Math.Round(Convert.ToDouble(Amount), 2); Display = Result; } else { Display = "You don't have enough money on your account !"; } } newDisplayRequired = true; } catch (Exception ex) { Display = Result == string.Empty ? "Error - see event log" : Result; LogExceptionInformation(ex); } }