Exemplo n.º 1
0
        /// <summary>
        /// When closing form save data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            ObjectToSerialize objectToSerialize = new ObjectToSerialize();
            objectToSerialize.Accounts = accounts;
            Serializer serializer = new Serializer();
            serializer.SerializeObject("outputFile.txt", objectToSerialize);

            //Close Form
            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove the Account from List of accounts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateAccountSave_Click(object sender, EventArgs e)
        {
            //Check for Number entered.
            if (!string.IsNullOrEmpty(txtbxAccountNumber.Text))
            {
                try
                {

                    int accountId = int.Parse(txtbxAccountNumber.Text);
                    //Remove account.
                    accounts.RemoveAll(x => x.AccountId == accountId);

                    // Save list of accounts to Text file.
                    ObjectToSerialize objectToSerialize = new ObjectToSerialize();
                    objectToSerialize.Accounts = accounts;
                    Serializer serializer = new Serializer();
                    serializer.SerializeObject("outputFile.txt", objectToSerialize);

                    //Close Form.
                    this.Close();
                }
                    //Error Handling
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    txtbxAccountNumber.Clear();
                    txtbxAccountNumber.Focus();
                    ClearFrom();
                }

            }
            else
                //Error Handling
            {
                MessageBox.Show("Please, Enter a Account Number.");
            }
        }
Exemplo n.º 3
0
        private void btnCreateAccountSave_Click(object sender, EventArgs e)
        {
            try
            {
                int accountId = int.Parse(lblAccountNumber.Text);
                string type = TypeOfAccount();
                string status = "Open";
                decimal balance = decimal.Parse(txtbxInitialBalance.Text);
                decimal rate;
                string maturitydate = txtBxMaturityDate.Text;
                Customer customer = new Customer();
                customer.SSN = txtbxSSN.Text;
                customer.FName = txtbxFName.Text;
                customer.LName = txtbxLName.Text;
                customer.StAddr = txtbxAddress.Text;
                customer.City = txtCity.Text;
                customer.State = txtState.Text;
                customer.Zip = txtbxZip.Text;
                customer.Phone = txtPhoneNumber.Text;
                customer.Email = txtbxEmail.Text;

                bool result = decimal.TryParse(txtbxRate.Text, out rate);
                if (result)
                {
                    account = new Account()
                    {
                        AccountId = accountId,
                        Type = type,
                        Status = status,
                        Balance = balance,
                        Customer = customer,
                        Rate = rate,
                        Maturity = maturitydate
                    };
                }
                else
                {
                    account = new Account()
                    {
                        AccountId = accountId,
                        Type = type,
                        Status = status,
                        Balance = balance,
                        Customer = customer,
                        Rate = 0,
                        Maturity = maturitydate
                    };
                }

                accounts.Add(account);

                //save the accounts list to a file
                ObjectToSerialize objectToSerialize = new ObjectToSerialize();
                objectToSerialize.Accounts = accounts;
                Serializer serializer = new Serializer();
                serializer.SerializeObject("outputFile.txt", objectToSerialize);

                this.Close();

            }
            catch (Exception)
            {
                MessageBox.Show("All boxes should be filled out.");
            }
        }
Exemplo n.º 4
0
        //Load Accounts into Form
        private void CreateAccount_Load(object sender, EventArgs e)
        {
            //Calculate the next Account number
            lblAccountNumber.Text = NextAccountNumber();

            //Pull data from txt file.
            ObjectToSerialize objectToSerialize = new ObjectToSerialize();
            Serializer serializer = new Serializer();
            objectToSerialize = serializer.DeSerializeObject("outputFile.txt");
            accounts = objectToSerialize.Accounts;
            //Calculate the next Account number
            lblAccountNumber.Text = NextAccountNumber();
        }
Exemplo n.º 5
0
 //Load Accounts into Form
 private void CloseAccount_Load(object sender, EventArgs e)
 {
     //Pull data from txt file.
     ObjectToSerialize objectToSerialize = new ObjectToSerialize();
     Serializer serializer = new Serializer();
     objectToSerialize = serializer.DeSerializeObject("outputFile.txt");
     accounts = objectToSerialize.Accounts;
 }
Exemplo n.º 6
0
        //Save changes to text file.
        private void btnCreateAccountSave_Click(object sender, EventArgs e)
        {
            int accountId = int.Parse(txtbxAccountNumber.Text);
            string type = TypeOfAccount();
            string status = "Open";
            decimal balance = decimal.Parse(txtbxInitialBalance.Text);
            decimal rate;
            string maturitydate = txtBxMaturityDate.Text;
            Customer customer = new Customer();
            customer.SSN = txtbxSSN.Text;
            customer.FName = txtbxFName.Text;
            customer.LName = txtbxLName.Text;
            customer.StAddr = txtbxAddress.Text;
            customer.City = txtCity.Text;
            customer.State = txtState.Text;
            customer.Zip = txtbxZip.Text;
            customer.Phone = txtPhoneNumber.Text;
            customer.Email = txtbxEmail.Text;

            //save depending on type of account.
            bool result = decimal.TryParse(txtbxRate.Text, out rate);
            if (result)
            {
                account = new Account()
                {
                    AccountId = accountId,
                    Type = type,
                    Status = status,
                    Balance = balance,
                    Customer = customer,
                    Rate = rate,
                    Maturity = maturitydate
                };
            }
            else
            {
                account = new Account()
                {
                    AccountId = accountId,
                    Type = type,
                    Status = status,
                    Balance = balance,
                    Customer = customer,
                    Rate = 0,
                    Maturity = maturitydate
                };
            }
            //remove account
            accounts.RemoveAll(x => x.AccountId == accountId);
            //readd acount.
            accounts.Add(account);

            //save the accounts list to a file
            ObjectToSerialize objectToSerialize = new ObjectToSerialize();
            objectToSerialize.Accounts = accounts;
            Serializer serializer = new Serializer();
            serializer.SerializeObject("outputFile.txt", objectToSerialize);

            this.Close();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Pull data from text file.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ConductTransaction_Load(object sender, EventArgs e)
 {
     this.pnlTransferDepositWithdrawl.Visible = false;
     //Pull data from txt file.
     ObjectToSerialize objectToSerialize = new ObjectToSerialize();
     Serializer serializer = new Serializer();
     objectToSerialize = serializer.DeSerializeObject("outputFile.txt");
     accounts = objectToSerialize.Accounts;
 }