Exemplo n.º 1
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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        //loads the acount list data from a text file
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "txt files (*.txt)|*.txt";
            bool?res = dialog.ShowDialog();

            if (res != null && res.Value == true)
            {
                StreamReader loadMe = new StreamReader(dialog.FileName);
                string       line;
                while ((line = loadMe.ReadLine()) != null)
                {
                    if (string.IsNullOrWhiteSpace(line))//empty line for separete clients
                    {
                        continue;
                    }

                    string[] subValues = line.Split('|');//last element is All saving programs
                    string[] subSaving = null;

                    if (!string.IsNullOrWhiteSpace(subValues[subValues.Length - 1]))
                    {
                        subSaving = subValues[subValues.Length - 1].Split(new char[] { '!' },
                                                                          StringSplitOptions.RemoveEmptyEntries);
                    }

                    AcountProgram ap;
                    if (subValues[0] == "Normal")
                    {
                        ap = new AcountProgram(subValues[1], subValues[2], int.Parse(subValues[3]),
                                               DateTime.Parse(subValues[4]), double.Parse(subValues[5]), subValues[6]);
                    }
                    else if (subValues[0] == "vip")
                    {
                        ap = new Vip(subValues[1], subValues[2], int.Parse(subValues[3]), DateTime.Parse(subValues[4]),
                                     double.Parse(subValues[5]), subValues[6]);
                    }
                    else //if(subValues[0] == "business")
                    {
                        ap = new Business(subValues[1], subValues[2], int.Parse(subValues[3]), DateTime.Parse(subValues[4]),
                                          subValues[7], double.Parse(subValues[5]), subValues[6]);
                    }

                    if (subSaving != null) //then the client has saving programs
                    {
                        string[] subSavingDetail = null;
                        for (int i = 0; i < subSaving.Length; i++)
                        {
                            subSavingDetail = subSaving[i].Split('~');
                            NewSavingAcount newsave = new NewSavingAcount(double.Parse(subSavingDetail[2]),
                                                                          DateTime.Parse(subSavingDetail[1]), DateTime.Parse(subSavingDetail[0]));
                            ap.AddSaveProgramLoad(newsave);
                        }
                    }
                    manager.Add(ap);
                }
                MessageBox.Show("File has been successfuly loded");
                loadMe.Close();
            }
        }