Example #1
0
        public void open(string cbkName)
        {
            fileIO fIO = new fileIO();

            currBalance = fIO.getCurrentBalance(cbkName);
            transaction_gui t = new transaction_gui(cbkName);

            t.ShowDialog();
        }
Example #2
0
        public void create(string cbkName)
        {
            //creates new checkbook in the folder.
            fileIO fIO = new fileIO();

            fIO.makeNewCheckbook(cbkName);
            currBalance = 0.00;
            //Makes a new transaction_gui and opens it so the user can choose
            //what type of transaction to make.
            transaction_gui t = new transaction_gui(cbkName);

            t.ShowDialog();
        }
Example #3
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            fileIO fIO1 = new fileIO();
            double newBalance;
            //gathers the info in the textboxes when the user clicks the submit button
            Submit s      = new Submit();
            string toLine = toLineTextBox.Text.ToString();
            string amount = amountTextBox.Text.ToString();
            string memo   = memoTextBox.Text.ToString();

            //sends the info to the submit class
            s.submit(toLine, amount, memo, this.viewCheck.Checked);

            //today's date in MM/dd/yyyy format
            string date = DateTime.Today.ToString("MM/dd/yyyy");
            //writes new transaction to the .cbk file given.
            double          amountDoub = Convert.ToDouble(amount);
            transaction_gui t          = new transaction_gui(name);

            if (typeTrans == "deposit")
            {
                newBalance = fIO1.getCurrentBalance(name) + amountDoub;
                fIO1.writeTransaction(name, date, typeTrans.ToUpper(), amountDoub, toLine, memo, newBalance);
                MessageBox.Show("Current Account Balance: $" + newBalance);
                t.ShowDialog();
            }
            else
            {
                newBalance = fIO1.getCurrentBalance(name) - amountDoub;
                if (newBalance >= 0.00)
                {
                    fIO1.writeTransaction(name, date, typeTrans.ToUpper(), amountDoub, toLine, memo, fIO1.getCurrentBalance(name) - amountDoub);
                    MessageBox.Show("Current Account Balance: $" + newBalance);
                    t.ShowDialog();
                }
                else
                {
                    MessageBox.Show("This transaction will result in a negative account balance.\nContinue?");
                    MessageBox.Show("Current Account Balance: $" + newBalance);
                    t.ShowDialog();
                }
            }
        }
Example #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new in_gui());

            //TESTING
            //create file
            fileIO fio      = new fileIO();
            string filename = "test2";

            //error prevenetion in document name
            string[] file = filename.Split('.');
            if (!File.Exists(file[0] + ".cbk"))
            {
                fio.makeNewCheckbook(filename);
            }
            //tally checker
            int    tally1   = 2001;
            int    tally2   = 2002;
            string tallyOne = tally1.ToString();
            string tallyTwo = tally2.ToString();

            //write to the file
            fio.writeTransaction(filename, "1/21/2018", "CASH", 12.25, "CASH", "CASH", 12.25);
            fio.writeTransaction(filename, "1/21/2018", tallyOne, 12.25, "DEPOSIT", "PAY DAY", 34.50);
            fio.writeTransaction(filename, "1/21/2018", "DEPOSIT", 12.25, "DEPOSIT", "PAY DAY", 24.50);
            fio.writeTransaction(filename, "1/21/2018", "DEPOSIT", 12.25, "DEPOSIT", "PAY DAY", 34.50);
            fio.writeTransaction(filename, "1/21/2018", tallyTwo, 12.25, "DEPOSIT", "PAY DAY", 34.50);
            //get last balance back (read)
            double currentBalance = fio.getCurrentBalance(filename);
            string output         = currentBalance.ToString();

            Console.WriteLine("Balance: " + output);
            //get last check number back
            int    checkTally = fio.getCurrentCheckNum(filename);
            string checkNum   = checkTally.ToString();

            if (checkTally != 0)
            {
                Console.WriteLine("Last check number: " + checkNum);
            }
            else
            {
                Console.WriteLine("No check created yet. Start at check 2001");
            }
            //find the .cbk files in the folder
            //received help from articel on stack overflow: https://stackoverflow.com/questions/1277222/how-to-list-text-files-in-the-selected-directory-in-a-listbox
            string folder = "";

            string[] Files     = Directory.GetFiles(folder, "*.cbk");
            string   fileNames = "Exisiting Checkbooks:\n";

            for (int i = 0; i < Files.Length; i++)
            {
                fileNames += Path.GetFileNameWithoutExtension(Files[i]) + "\n";
            }
            //display the folders
            Console.WriteLine(fileNames);
            Console.ReadLine();
        }