private void fileOpenMenu_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; using (FileDialog openDialog = new OpenFileDialog()) { openDialog.Filter = "XML Files (*.xml)|*.xml"; if (openDialog.ShowDialog() == DialogResult.OK) { try { var xml = new XmlSerializer(typeof(Checkbook)); using (StreamReader sr = File.OpenText(openDialog.FileName)) { this.checkbook = (Checkbook)xml.Deserialize(sr); this.checkbookBindingSource.DataSource = null; this.checkbookBindingSource.DataSource = this.checkbook; } } catch (Exception ex) { this.statusLabel.Text = ex.Message; } } } Cursor.Current = Cursors.Default; }
public MainForm() { InitializeComponent(); Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR"); this.checkbook = new Checkbook(); this.checkbookBindingSource.DataSource = this.checkbook; }
public static void Add(Checkbook checkBook) { var db = ContextFactory.GetDBContext(); using (var scope = new TransactionScope()) { db.Checkbooks.Add(checkBook); db.SaveChanges(); scope.Complete(); } }
public void CalculatesAverageExpenses_Test() { // Arrange var testCase = "500.00\n" + "1 Market 10.00\n" + "2 Hardware 20.00"; var expected = 15d; // Act var checkbook = new Checkbook(testCase); var actual = checkbook.AverageExpenses; // Assert Assert.Equal(expected, actual); }
//Checks if user and password matches private void updateLogStatus(string name, string pass) { foreach (Checkbook person in this.accounts) { if (name == person.USERID) { this.login = person.checkPassword(pass); this.currentAcc = person; } } if (this.login) { Console.WriteLine("Login Successful"); } else { Console.WriteLine("Login Failed"); } }
/* * Function: createAcc * Job: Lets the user create an account to login with * Params: none * Returns: none; stores the new acc in class' Account to keep track of */ public void createAcc() { string userName; string userPass; bool valid = false; Console.Write("Username :"******"Please pick a different username."); Console.Write("Username :"******"Password :"******"Starting Balance: "); string balance = Console.ReadLine(); // https://social.msdn.microsoft.com/Forums/windows/en-US/84990ad2-5046-472b-b103-f862bfcd5dbc/how-to-check-string-is-number-or-not-in-c?forum=winforms // // Prevents user from inputing letters and symbols into a numerical value// double conversion; bool numberInput = double.TryParse(balance, out conversion); while (!numberInput) { Console.Write("Please enter a numerical value. Starting Balance: "); balance = Console.ReadLine(); numberInput = double.TryParse(balance, out conversion); } conversion = truncateInputs(Convert.ToDouble(balance)); Checkbook newUser = new Checkbook(userName, userPass, conversion); this.accounts.Add(newUser); Console.Clear(); }
/* * Function: logout() * Job: Logs the user out by nulling our currentAcc field aka the target acc all transaction go to; and setting the login (bool status) to false * Parameters: None * Returns: None */ public void logout() { this.currentAcc = null; this.login = false; Console.Clear(); }
public NPC() { this.login = false; this.currentAcc = null; }
public override void ExecuteNewCommand() { FormTitle = "Nuevo Talonario"; CheckBook = new Checkbook(); ShowDialog(new NewCheckBookView(), this, new Thickness(300, 200, 300, 200)); }