private void AccountLoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                BankSystem bank = new BankSystem();
                // Check if he Filling all the Information
                if (ClientAccountNumberTextBox.Text == "" && AccountPasswordTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your Information !!!! ");
                }
                else if (ClientAccountNumberTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your Account Number!!!! ");
                }
                else if (AccountPasswordTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your PassWord !!!! ");
                }
                else
                {
                    // Check if the acc is Found Or not
                    if (BankSystem.FO_client.CheckFind(ClientAccountNumberTextBox.Text))
                    {
                        // login
                        if (BankSystem.FO_client.Login(ClientAccountNumberTextBox.Text, AccountPasswordTextBox.Text))
                        {
                            AccountOperationsForm accountOperations = new AccountOperationsForm();

                            // Save Change to the Logfile
                            DateTime     time = DateTime.Now;
                            FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                            StreamWriter Sr   = new StreamWriter(fs);
                            Sr.WriteLine(time + "Client With Account Number" + ClientAccountNumberTextBox.Text + " has logged in");
                            Sr.Close();
                            fs.Close();


                            //Open ( accountOperations ) && Hide this Form (AccountLoginForm)
                            this.Hide();
                            // save the satatic accnumber to use it at the following Forms
                            accNum = ClientAccountNumberTextBox.Text;
                            pw     = AccountPasswordTextBox.Text;
                            accountOperations.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show(" The password that you've entered is incorrect");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The ID that you've entered doesn't match any Profile ");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void RemoveEmployeeButton_Click(object sender, EventArgs e)
        {
            // function ->> To remove employee form list & file


            BankSystem            bank    = new BankSystem();
            ManagerOperationsForm manager = new ManagerOperationsForm();


            //Delete Employee With this ID
            bank.BankManager.DeleteEmployee(EmployeeIDTextBox.Text);

            // Save Action to LogFile
            DateTime     time = DateTime.Now;
            FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
            StreamWriter Sr   = new StreamWriter(fs);

            Sr.WriteLine(time + " Employee With ID " + EmployeeIDTextBox.Text + " has been Removed ");
            Sr.Close();
            fs.Close();


            //Return to (  ManagerOperationsForm ) && hide this form (AddEmployeeForm)
            this.Hide();
            manager.ShowDialog();
        }
Beispiel #3
0
        private void ManagerLoginButton_Click(object sender, EventArgs e)
        {
            // It's Function ->> Login of Manager to the system



            BankSystem bank = new BankSystem();

            // Check if he enterd the data or not
            if (ManagerIDTextBox.Text == "" && ManagerPasswordTextBox.Text == "")
            {
                MessageBox.Show("Please Enter Your Information !!!! ");
            }
            else if (ManagerIDTextBox.Text == "")
            {
                MessageBox.Show("Please Enter Your ID !!!! ");
            }
            else if (ManagerPasswordTextBox.Text == "")
            {
                MessageBox.Show("Please Enter Your PassWord !!!! ");
            }


            else
            {
                // Check login
                if (bank.BankManager.Login(ManagerIDTextBox.Text, ManagerPasswordTextBox.Text))
                {
                    //Save at Logfile
                    DateTime     time = DateTime.Now;
                    FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                    StreamWriter Sr   = new StreamWriter(fs);
                    Sr.WriteLine(time + " Manager Of Bank has logged in");
                    Sr.Close();
                    fs.Close();


                    //Open the manager profile Or Account in the system && Hide this form (Manager Login Form )
                    ManagerOperationsForm managerOperations = new ManagerOperationsForm();

                    this.Hide();
                    managerOperations.ShowDialog();
                }
                else
                {
                    // if id & password != id & password of the Bank Manager
                    MessageBox.Show(" The Information that you've entered is incorrect");
                }
            }
        }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            // Function ->> Update Employee Information ( Only which can be logically updated )

            try
            {
                // Copy the information after update to the new object (accountent)
                string     ID         = IDloginEmployee.employee.ID;
                Accountant accountant = IDloginEmployee.employee;
                accountant.FirstName         = FirstNameTextBox.Text;
                accountant.LastName          = LastNameTextBox.Text;
                accountant.Address           = AddressTextBox.Text;
                accountant.CollegeOfGraduate = CollegeOfGraduationTextBox.Text;
                accountant.Mail        = MailTextBox.Text;
                accountant.Grade       = GradeTextBox.Text;
                accountant.Position    = PositionTextBox.Text;
                accountant.ID          = IDTextBox.Text;
                accountant.SSN         = SSNTextBox.Text;
                accountant.PhoneNumber = PhoneNumberTextBox.Text;
                BankSystem bank = new BankSystem();

                // Check if he want to update
                DialogResult result = MessageBox.Show("Are you want to Updata?", "Caution", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.OK)
                {
                    // update the employee By updatefunc in ( Manager)
                    bank.BankManager.Update(IDloginEmployee.employee.ID, accountant);


                    ManagerOperationsForm manager = new ManagerOperationsForm();

                    // Save action to the Logfile
                    DateTime     time = DateTime.Now;
                    FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                    StreamWriter Sr   = new StreamWriter(fs);
                    Sr.WriteLine(time + " Employee With ID " + IDloginEmployee.employee.ID + " has been Updated ");
                    Sr.Close();
                    fs.Close();

                    //Return to (ManagerOperationsForm ) && Hide this Form (EmployeeUpdateForm )
                    this.Hide();
                    manager.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        public StartForm()
        {
            // load files to the lists 1- ClientData , 2-EmployeeData , 3-LoanData ,4-BankManager , 5- Bank Balance ,6-BankBlance



            BankSystem bank = new BankSystem();

            bank.LoadAllFiles();
            Accountant emp = new Accountant();

            emp.LoadLoans();

            InitializeComponent();
        }
Beispiel #6
0
        private void EmployeeRegisterationButton_Click(object sender, EventArgs e)
        {
            BankSystem bank       = new BankSystem();
            Accountant accountant = new Accountant();

            // Check if filling All information or not
            if (EmployeeFirstNameTextBox.Text == "" || EmployeeLastNameTextBox.Text == "" || EmployeeAddressTextBox.Text == "" || CollegeOfGraduationTextBox.Text == "" || YearOfGraduationComboBox.SelectedItem.ToString() == "" || EmployeeBirthDateComboBox.SelectedItem.ToString() == "" || EmployeeMailTextBox.Text == "" || EmployeeGradeComboBox.SelectedItem.ToString() == "" || EmployeePasswordTextBox.Text == "" || EmployeePositionTextBox.Text == "" || (MaleRadioButton.Checked != true && FemaleRadioButton.Checked != true))
            {
                MessageBox.Show("Please complete filling your information.");
            }


            else
            {
                try
                {
                    // Fill accountent object with the information from textbox
                    accountant.FirstName = EmployeeFirstNameTextBox.Text;
                    accountant.LastName  = EmployeeLastNameTextBox.Text;
                    accountant.Address   = EmployeeAddressTextBox.Text;
                    accountant.BirthDate = EmployeeBirthDateComboBox.SelectedItem.ToString();
                    accountant.Mail      = EmployeeMailTextBox.Text;
                    accountant.Grade     = EmployeeGradeComboBox.SelectedItem.ToString();
                    accountant.Password  = EmployeePasswordTextBox.Text;
                    accountant.Position  = EmployeePositionTextBox.Text;
                    long ssn   = Int64.Parse(EmployeeSSNTextBox.Text);
                    long phone = Int64.Parse(EmployeePhoneNumberTextBox.Text);
                    accountant.PhoneNumber       = EmployeePhoneNumberTextBox.Text;
                    accountant.SSN               = EmployeeSSNTextBox.Text;
                    accountant.YearOfGraduation  = YearOfGraduationComboBox.SelectedItem.ToString();
                    accountant.CollegeOfGraduate = CollegeOfGraduationTextBox.Text;
                    accountant.ID = (bank.BankManager.IDOfEmployee).ToString();

                    if (MaleRadioButton.Checked)
                    {
                        accountant.Gender = MaleRadioButton.Text.ToString();
                    }
                    if (FemaleRadioButton.Checked)
                    {
                        accountant.Gender = FemaleRadioButton.Text.ToString();
                    }
                    // add the accountent object to the list of accounants & then save at file
                    bank.BankManager.AddEmployee(accountant);

                    MessageBox.Show("Employee ID is " + accountant.ID);



                    // Save action at LogFile
                    DateTime     time = DateTime.Now;
                    FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                    StreamWriter Sr   = new StreamWriter(fs);
                    Sr.WriteLine(time + " Employee With ID " + accountant.ID + " has been Added ");
                    Sr.Close();
                    fs.Close();


                    //Return to (  ManagerOperationsForm ) && hide this form (AddEmployeeForm)
                    this.Hide();
                    ManagerOperationsForm manger = new ManagerOperationsForm();
                    manger.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void ClientLoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                // It's Function ->> Login of Employee to the system


                BankSystem Bank = new BankSystem();

                // Check if he enterd the data or not
                if (EmployeeIDTextBox.Text == "" && EmployeePasswordTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your Information !!!! ");
                }
                else if (EmployeeIDTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your ID !!!! ");
                }
                else if (EmployeePasswordTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your PassWord !!!! ");
                }
                else

                {
                    // if he found the accnum then he will Check the login
                    if (BankSystem.FO_employee.CheckFind(EmployeeIDTextBox.Text))
                    {
                        if (BankSystem.FO_employee.Login(EmployeeIDTextBox.Text, EmployeePasswordTextBox.Text))

                        {
                            // Save action to LogFile
                            DateTime     time = DateTime.Now;
                            FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                            StreamWriter Sr   = new StreamWriter(fs);
                            Sr.WriteLine(time + "Employee With ID" + EmployeeIDTextBox.Text + " has logged in");
                            Sr.Close();
                            fs.Close();


                            EmployeeOperationsForm employeeOperations = new EmployeeOperationsForm();

                            // Return to (  employeeOperations) && Hide this Form (EmployeLoginForm)
                            this.Hide();
                            // Save the staticValue (store)
                            ID = EmployeeIDTextBox.Text;
                            employeeOperations.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show(" The password that you've entered is incorrect");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The ID that you've entered doesn't match any Profile ");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ClientRegistrationButton_Click(object sender, EventArgs e)
        {
            // Functio->> Add Client To the list && file
            BankSystem bank   = new BankSystem();
            Client     client = new Client();

            // Calculalte the age of Client To check if his age is legal to create an account
            int clientage = client.CalculateAge(ClientBirthDateComboBox.SelectedItem.ToString());

            // Check if he filling All the Information
            if (ClientFirstNameTextBox.Text == "" || ClientLastNameTextBox.Text == "" || ClientMailTextBox.Text == "" ||
                ClientPhoneNumberTextBox.Text == "" || ClientSSNTextBox.Text == "" || ClientAddressTextBox.Text == "" ||
                ClientBirthDateComboBox.SelectedItem.ToString() == "" || AccountBalanceTextBox.Text == "" ||
                (MaleRadioButton.Checked != true && FemaleRadioButton.Checked != true))
            {
                MessageBox.Show("Please complete filling your information.");
            }



            else
            {
                // Check if balance is more than 500
                if (Convert.ToDouble(AccountBalanceTextBox.Text) < 500.0)
                {
                    MessageBox.Show(" The Minimum Balance is 500 L.E ");
                }

                else
                {
                    // Check Age
                    if (clientage <= 18)
                    {
                        MessageBox.Show(" Date that you have entered under Legal Age ");
                    }
                    else
                    {
                        try
                        {
                            // Create a client form Text box to add it to the list & file
                            client.FirstName              = ClientFirstNameTextBox.Text;
                            client.LastName               = ClientLastNameTextBox.Text;
                            client.Mail                   = ClientMailTextBox.Text;
                            client.Address                = ClientAddressTextBox.Text;
                            client.BirthDate              = ClientBirthDateComboBox.SelectedItem.ToString();
                            client.SSN                    = ClientSSNTextBox.Text;
                            client.PhoneNumber            = ClientPhoneNumberTextBox.Text;
                            client.ClientAccount.Password = AccountPasswordTextBox.Text;
                            long ssn   = Int64.Parse(ClientSSNTextBox.Text);
                            long phone = Int64.Parse(ClientPhoneNumberTextBox.Text);
                            client.ClientAccount.setBalance(Convert.ToDouble(AccountBalanceTextBox.Text));
                            client.ClientAccount.AccNum = (bank.AccNumOfClient).ToString(); // Know the last AccNumber in the list && Create a new AccountNumber to the Client
                            if (MaleRadioButton.Checked)
                            {
                                client.Gender = MaleRadioButton.Text.ToString();
                            }
                            if (FemaleRadioButton.Checked)
                            {
                                client.Gender = FemaleRadioButton.Text.ToString();
                            }
                            client.ClientAccount.Activation = true;
                            client.LoanFlag = false;

                            // Add Client
                            BankSystem.FO_client.AddClient(client);

                            // Update the total balance OF Bank && save the  change According to the Account
                            double b = Convert.ToDouble(BankSystem.TotalBalanceOfBank.GetBankBalance()) + Convert.ToDouble(AccountBalanceTextBox.Text);
                            BankSystem.TotalBalanceOfBank.SetBalance(Convert.ToDouble(b));
                            BankSystem.TotalBalanceOfBank.save();

                            //  fo.AddClient(client);
                            MessageBox.Show("Account Number is " + client.ClientAccount.AccNum);

                            // Save Change to the LogFile
                            DateTime     time = DateTime.Now;
                            FileStream   fs   = new FileStream("BankLogFile.txt", FileMode.Append);
                            StreamWriter Sr   = new StreamWriter(fs);
                            Sr.WriteLine(time + " Client With AccountNumber  " + client.ClientAccount.AccNum + " has been Added ");
                            Sr.Close();
                            fs.Close();



                            // Return to (EmployeeOperationsForm ) && Hide this Form (AddClientform )
                            this.Hide();
                            EmployeeOperationsForm employee = new EmployeeOperationsForm();
                            employee.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
            // add client to the list of clients
            // (Acc Number )>> ana ele bdholo
            // a show el ( Employee operations )
        }