예제 #1
0
        private void btnPull_Click(object sender, RoutedEventArgs e)
        //if all the entered data is correct and the action is allowed as instructed by the specification file
        //a pull from the balance will be made.
        {
            if (checkIdAmount() == false)
            {
                return;
            }

            int index = manager.CheckId(int.Parse(txtId.Text));

            if (index != -1)
            {
                int checker = 0;
                //diferent negativ total money amount as instructed at the specification file.
                if (manager[index].CheckClass() == "normal")
                {
                    checker = -10000;
                }
                else if (manager[index].CheckClass() == "vip")
                {
                    checker = -25000;
                }
                else
                {
                    checker = -75000;
                }

                if ((manager[index].TotalAmount - double.Parse(txtSaveAmount.Text) + 1) > checker)
                {
                    manager[index].Balance     -= double.Parse(txtSaveAmount.Text);
                    manager[index].TotalAmount -= double.Parse(txtSaveAmount.Text);
                    MessageBox.Show("Pull was made on the total: " + txtSaveAmount.Text + "$  from account: " + txtId.Text);
                }
                else
                {
                    MessageBox.Show("your acount's total amount will be lower then your allowed negative money");
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("invalid Id has been entered");
            }

            bool?isVip = manager[index].CheckVip(manager[index]); //checking if after the deposit the acount's total money amount is over 100,000.

            if (isVip == true)                                    //if isnt Business acount and total money amount is over 100,000.
            {
                AcountProgram temp = manager[index];
                for (int j = 0; j < manager[index].NumOfSavings.Count; j++)
                {
                    temp.NumOfSavings[j] = new NewSavingAcount(manager[index].NumOfSavings[j].Amount, manager[index].NumOfSavings[j].ClosingDate);
                }
                manager[index] = new Vip(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                for (int j = 0; j < temp.NumOfSavings.Count; j++)
                {
                    manager[index].AddSaveProgramLoad(temp.NumOfSavings[j]);
                }
            }
            else if (isVip == false)//if isnt Business acount and total money amount is under  100,000.
            {
                AcountProgram temp = manager[index];
                for (int j = 0; j < manager[index].NumOfSavings.Count; j++)
                {
                    temp.NumOfSavings[j] = new NewSavingAcount(manager[index].NumOfSavings[j].Amount, manager[index].NumOfSavings[j].ClosingDate);
                }
                manager[index] = new AcountProgram(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                for (int j = 0; j < temp.NumOfSavings.Count; j++)
                {
                    manager[index].AddSaveProgramLoad(temp.NumOfSavings[j]);
                }
            }
            txtSaveAmount.Clear();
        }
예제 #2
0
        private void mbCalculate_Click(object sender, RoutedEventArgs e)
        //calculates and change all of the acount details as instructed at the program's specification file.
        {
            for (int i = 0; i < manager.AcountsCount; i++)
            {
                manager[i].Calculate(i, manager);
                bool?isVip = manager[i].CheckVip(manager[i]);
                if (isVip == true)//if acount total money amount is over 100000 then the acount becomes a vip acount.
                {
                    AcountProgram temp = manager[i];
                    for (int j = 0; j < manager[i].NumOfSavings.Count; j++)
                    {
                        temp.NumOfSavings[j] = new NewSavingAcount(manager[i].NumOfSavings[j].Amount, manager[i].NumOfSavings[j].ClosingDate);
                    }
                    manager[i] = new Vip(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                    for (int j = 0; j < temp.NumOfSavings.Count; j++)
                    {
                        manager[i].AddSaveProgramLoad(temp.NumOfSavings[j]);
                    }
                }
                else if (isVip == false)
                {
                    AcountProgram temp = manager[i];
                    for (int j = 0; j < manager[i].NumOfSavings.Count; j++)
                    {
                        temp.NumOfSavings[j] = new NewSavingAcount(manager[i].NumOfSavings[j].Amount, manager[i].NumOfSavings[j].ClosingDate);
                    }
                    manager[i] = new AcountProgram(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                    for (int j = 0; j < temp.NumOfSavings.Count; j++)
                    {
                        manager[i].AddSaveProgramLoad(temp.NumOfSavings[j]);
                    }
                }
            }

            lbId.Visibility       = Visibility.Visible;
            lblBalance.Visibility = Visibility.Hidden;
            lbFname.Visibility    = Visibility.Hidden;
            lbLname.Visibility    = Visibility.Hidden;
            lbTotal.Visibility    = Visibility.Visible;
            listShowDetails.Items.Clear();
            txtBdetails.Items.Clear();
            showDetails();
        }
예제 #3
0
        private void btnDeposit_Click(object sender, RoutedEventArgs e)
        //making sure a valid ID have been entered.
        {
            if (checkIdAmount() == false)
            {
                return;
            }

            int index = manager.CheckId(int.Parse(txtId.Text));//gets the acount Index by its ID.

            if (index != -1)
            {
                manager[index].Balance     += double.Parse(txtSaveAmount.Text);
                manager[index].TotalAmount += double.Parse(txtSaveAmount.Text);
                MessageBox.Show("Deposit was made on the total: " + txtSaveAmount.Text + "$  to account: " + txtId.Text);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("invalid Id has been entered");
            }

            bool?isVip = manager[index].CheckVip(manager[index]); //checking if after the deposit the acount's total money amount is over 100,000.

            if (isVip == true)                                    //if isnt Business acount and total money amount is over 100,000.
            {
                AcountProgram temp = manager[index];
                for (int j = 0; j < manager[index].NumOfSavings.Count; j++)
                {
                    temp.NumOfSavings[j] = new NewSavingAcount(manager[index].NumOfSavings[j].Amount, manager[index].NumOfSavings[j].ClosingDate);
                }
                manager[index] = new Vip(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                for (int j = 0; j < temp.NumOfSavings.Count; j++)
                {
                    manager[index].AddSaveProgramLoad(temp.NumOfSavings[j]);
                }
            }

            else if (isVip == false)//if isnt Business acount and total money amount is under 100,000.
            {
                AcountProgram temp = manager[index];
                for (int j = 0; j < manager[index].NumOfSavings.Count; j++)
                {
                    temp.NumOfSavings[j] = new NewSavingAcount(manager[index].NumOfSavings[j].Amount, manager[index].NumOfSavings[j].ClosingDate);
                }
                manager[index] = new AcountProgram(temp.FirstName, temp.LastName, temp.IdNum, temp.OpeningDate, temp.Balance, temp.GetImage());
                for (int j = 0; j < temp.NumOfSavings.Count; j++)
                {
                    manager[index].AddSaveProgramLoad(temp.NumOfSavings[j]);
                }
            }
            txtSaveAmount.Clear();
        }