예제 #1
0
파일: MainForm.cs 프로젝트: radtek/appz
        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;
        }
예제 #2
0
파일: MainForm.cs 프로젝트: radtek/appz
        public MainForm()
        {
            InitializeComponent();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR");

            this.checkbook = new Checkbook();
            this.checkbookBindingSource.DataSource = this.checkbook;
        }
예제 #3
0
        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);
        }
예제 #5
0
        //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");
            }
        }
예제 #6
0
        /*
         * 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();
        }
예제 #7
0
 /*
  * 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();
 }
예제 #8
0
 public NPC()
 {
     this.login      = false;
     this.currentAcc = null;
 }
예제 #9
0
 public override void ExecuteNewCommand()
 {
     FormTitle = "Nuevo Talonario";
     CheckBook = new Checkbook();
     ShowDialog(new NewCheckBookView(), this, new Thickness(300, 200, 300, 200));
 }