private void login_button_Click(object sender, EventArgs e) { User currentUser = FileManagement.GetUser(Constants.Links.UsersFilePath, cardNumberTextBox.Text, pinTextBox.Text); if (!(currentUser is null)) { var atmForm = new ATM(currentUser); atmForm.Show(); this.Dispose(false); }
private void depositButton_Click(object sender, EventArgs e) { if (Security.CheckTextboxOnlyNumbers(depositTextBox)) { currentUser.BalanceDeposit(float.Parse(depositTextBox.Text)); if (FileManagement.UpdateUsersDataFile(Constants.Links.UsersFilePath, currentUser, float.Parse(depositTextBox.Text))) { SetEditableTextBoxesToZero(); SetNotifyLabel("Money deposited", Color.Green); UpdateCurrentUserBalance(); } else { SetNotifyLabel(Constants.Errors.FileError, Color.Red); } } }
private void withdrawButton_Click(object sender, EventArgs e) { if (Security.CheckTextboxOnlyNumbers(withdrawTextBox)) { if (currentUser.BalanceWithdraw(float.Parse(withdrawTextBox.Text))) { if (FileManagement.UpdateUsersDataFile(Constants.Links.UsersFilePath, currentUser, currentUser.getBalance() - float.Parse(withdrawTextBox.Text))) { SetNotifyLabel("Money withdrawed", Color.Green); UpdateCurrentUserBalance(); } else { SetNotifyLabel(Constants.Errors.FileError, Color.Red); } } else { SetNotifyLabel("Cant withdraw, not enough funds", Color.Red); } } SetEditableTextBoxesToZero(); }