コード例 #1
0
ファイル: CloseAccount.cs プロジェクト: Evgeniyyy/LearnC-
        /// <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.");
            }
        }
コード例 #2
0
ファイル: Serializer.cs プロジェクト: 2joephillips/LearnC-
 //Serialize
 public void SerializeObject(string filename, ObjectToSerialize objectToSerialize)
 {
     Stream stream = File.Open(filename, FileMode.Create);
     BinaryFormatter bFormatter = new BinaryFormatter();
     bFormatter.Serialize(stream, objectToSerialize);
     stream.Close();
 }
コード例 #3
0
        //Serialize
        public void SerializeObject(string filename, ObjectToSerialize objectToSerialize)
        {
            Stream          stream     = File.Open(filename, FileMode.Create);
            BinaryFormatter bFormatter = new BinaryFormatter();

            bFormatter.Serialize(stream, objectToSerialize);
            stream.Close();
        }
コード例 #4
0
ファイル: ManageAccount.cs プロジェクト: Evgeniyyy/LearnC-
        // Pull data.
        private void ManageAccount_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;
        }
コード例 #5
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();
        }
コード例 #6
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;
        }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
0
ファイル: CloseAccount.cs プロジェクト: 2joephillips/LearnC-
        /// <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.");
            }
        }
コード例 #10
0
ファイル: CreateAccount.cs プロジェクト: 2joephillips/LearnC-
        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.");
            }
        }
コード例 #11
0
ファイル: CreateAccount.cs プロジェクト: 2joephillips/LearnC-
        //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();
        }
コード例 #12
0
ファイル: CloseAccount.cs プロジェクト: 2joephillips/LearnC-
 //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;
 }
コード例 #13
0
ファイル: ManageAccount.cs プロジェクト: 2joephillips/LearnC-
        //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();
        }
コード例 #14
0
ファイル: ManageAccount.cs プロジェクト: Evgeniyyy/LearnC-
        //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();
        }
コード例 #15
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;
 }
コード例 #16
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.");
            }
        }