Ejemplo n.º 1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            AccountData  account      = accountBL.GetByClientId(selectedItem.Id);

            accountBL.DeleteAccount(account.Id);
            bool valid = employeeBL.DeleteClient(selectedItem.Id);

            if (valid)
            {
                InitializeList();
                UserActionData action = new UserActionData()
                {
                    Description = "Deleted a user",
                    Timestamp   = DateTime.Now,
                    UserId      = this.user.Id
                };

                userActionBL.InsertUserAction(action);
            }
            else
            {
                MessageBox.Show("Error",
                                "Delete has been failed!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1
                                );
            }
        }
Ejemplo n.º 2
0
        private void InitializeList()
        {
            var clients1 = employeeBL.GetAllClients().ToList();
            List <EmployeeName> employees1 = new List <EmployeeName>();

            foreach (var client in clients1)
            {
                EmployeeName employee = new EmployeeName();
                employee.Id   = client.Id;
                employee.Name = client.Firstnme + " " + client.Lastname;
                employees1.Add(employee);
            }
            listBox1.DataSource    = employees1;
            listBox1.DisplayMember = "Name";
            listBox1.ValueMember   = "Id";

            var clients2 = employeeBL.GetAllClients().ToList();
            List <EmployeeName> employees2 = new List <EmployeeName>();

            foreach (var client in clients2)
            {
                EmployeeName employee = new EmployeeName();
                employee.Id   = client.Id;
                employee.Name = client.Firstnme + " " + client.Lastname;
                employees2.Add(employee);
            }

            listBox2.DataSource    = employees2;
            listBox2.DisplayMember = "Name";
            listBox2.ValueMember   = "Id";
        }
Ejemplo n.º 3
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            ClientData   client       = employeeBL.GetAllClients().Where(u => u.Id == selectedItem.Id).First();
            EmployeeData employeeData = new EmployeeData(client, user);

            employeeData.Show();
        }
Ejemplo n.º 4
0
        private void ViewAccountButton_Click(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            AccountData  account      = accountBL.GetByClientId(selectedItem.Id);
            AccountView  accountView  = new AccountView(account);

            accountView.Show();
        }
Ejemplo n.º 5
0
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            UserData     user         = adminBL.GetUserById(selectedItem.Id);
            UserView     userView     = new UserView(user);

            userView.Show();
        }
Ejemplo n.º 6
0
        private void ReportButton_Click(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            UserData     user         = adminBL.GetUserById(selectedItem.Id);
            ReportView   report       = new ReportView(userActionBL.GetByUserId(user.Id).ToList());

            report.Show();
        }
Ejemplo n.º 7
0
        private void InitializeListBox()
        {
            var users = adminBL.GetAllUsers().ToList();
            List <EmployeeName> employees = new List <EmployeeName>();

            foreach (var user in users)
            {
                EmployeeName employee = new EmployeeName();
                employee.Id   = user.Id;
                employee.Name = user.Firstname + " " + user.Lastname;
                employees.Add(employee);
            }
            listBox1.DataSource    = employees;
            listBox1.DisplayMember = "Name";
            listBox1.ValueMember   = "Id";
        }
Ejemplo n.º 8
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            EmployeeName selectedItem = listBox1.SelectedItem as EmployeeName;
            UserData     user         = adminBL.GetUserById(selectedItem.Id);

            switch (MessageBox.Show(this, "Are you sure?", "Do you still want to delete ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            //Stay on this form
            case DialogResult.Yes:
                adminBL.DeleteUser(user.Id);
                InitializeListBox();
                break;

            case DialogResult.No:
                return;

                break;

            default:
                break;
            }
        }
Ejemplo n.º 9
0
        private void TransferButton_Click(object sender, EventArgs e)
        {
            switch (MessageBox.Show(this, "Are you sure?", "Do you still want to make the transfer ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
            //Stay on this form
            case DialogResult.No:
                return;

            default:
                break;
            }

            double amount = 0.0;

            try
            {
                amount = Convert.ToDouble(this.Transfer.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Error", "Wrong amount format", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }

            EmployeeName selectedItem1 = listBox1.SelectedItem as EmployeeName;
            ClientData   fromClient    = employeeBL.GetClientById(selectedItem1.Id);

            EmployeeName selectedItem2 = listBox2.SelectedItem as EmployeeName;
            ClientData   toClient      = employeeBL.GetClientById(selectedItem2.Id);

            bool isValid = transferBL.MakeTransfer(fromClient, toClient, amount);

            if (isValid)
            {
                MessageBox.Show("Success", "Transfer succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                UserActionData action = new UserActionData()
                {
                    Description = "transfer between accounts",
                    Timestamp   = DateTime.Now,
                    UserId      = this.user.Id
                };

                userActionBL.InsertUserAction(action);

                switch (MessageBox.Show(this, "Utility bill!", "Do you want to create a utility bill?", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                //Stay on this form
                case DialogResult.Yes:
                    new UtilityBill(accountBL.GetByClientId(fromClient.Id), amount, DateTime.Now).Show();
                    break;

                case DialogResult.No:
                    return;

                    break;

                default:
                    break;
                }
            }
            else
            {
                MessageBox.Show("Error", "Insuficient money wrong destination!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }