Exemplo n.º 1
0
        private void LoadEmployeeBranchWindow(Employee loggedEmployee)
        {
            Employee employee = null;
            Branch   branch   = null;

            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            using (var context = new SystemObsługiBankuDBEntities())
            {
                employee = context.Employee
                           .Single(x => x.AuthorizationCode == loggedEmployee.AuthorizationCode);
                branch = context.Branch
                         .Single(x => x.ID == employee.BranchID);
            }

            AppButton.ActionButton btnBack = new AppButton.ActionButton("Powrót");

            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Nazwa oddziału", branch.BranchName.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Adres", branch.Adress.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Miasto", branch.City.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Kod pocztowy", branch.PostalCode.Trim()));
            sp.Children.Add(new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnBack));

            employeeBranchWindow.Children.Add(sp);

            btnBack.Click += DeleteWindow;

            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 2
0
        private void LoadEmployeeInfoWindow(Employee loggedEmployee)
        {
            Employee employee = null;

            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            using (var context = new SystemObsługiBankuDBEntities())
            {
                employee = context.Employee
                           .Single(x => x.AuthorizationCode == loggedEmployee.AuthorizationCode);
            }

            AppButton.ActionButton btnBack = new AppButton.ActionButton("Powrót");

            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Imię", employee.FirstName.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Nazwisko", employee.LastName.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Twój identyfikator", employee.AuthorizationCode.Trim()));
            sp.Children.Add(new AppDockPanel.DescriptionDockPanel("Data zatrudnienia", employee.HireDate.ToString("dd/MM/yyyy").Trim()));
            sp.Children.Add(new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnBack));

            employeeInfoWindow.Children.Add(sp);

            btnBack.Click += DeleteWindow;

            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 3
0
        private void AddCustomerPanel(object sender, EventArgs e)
        {
            StackPanel sp = new StackPanel
            {
                Width      = 400,
                Background = Brushes.DeepSkyBlue,
                Margin     = new Thickness(0, -120, 0, -120),
            };

            AppButton.ActionButton btnCancel  = new AppButton.ActionButton("Anuluj");
            AppButton.ActionButton btnConfirm = new AppButton.ActionButton("Zatwierdź");

            AppDockPanel.InfoInputDockPanel dpCustomerID     = new AppDockPanel.InfoInputDockPanel("Numer PESEL", 11);
            AppDockPanel.InfoInputDockPanel dpCustomerFN     = new AppDockPanel.InfoInputDockPanel("Imię", 30);
            AppDockPanel.InfoInputDockPanel dpCustomerLN     = new AppDockPanel.InfoInputDockPanel("Nazwisko", 30);
            AppDockPanel.InputDateDockPanel dpCustomerBD     = new AppDockPanel.InputDateDockPanel("Data urodzenia");
            AppDockPanel.InfoInputDockPanel dpCustomerGender = new AppDockPanel.InfoInputDockPanel("Płeć ( M / K )", 1);
            AppDockPanel.InfoInputDockPanel dpCustomerAdress = new AppDockPanel.InfoInputDockPanel("Ulica", 50);
            AppDockPanel.InfoInputDockPanel dpCustomerCity   = new AppDockPanel.InfoInputDockPanel("Miasto", 30);
            AppDockPanel.ButtonsDockPanel   buttons          = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnCancel, btnConfirm);

            btnCancel.Click  += DeletePanel;
            btnConfirm.Click += ConfirmCustomerAdd;

            mainWindow.Children.Add(sp);
            sp.Children.Add(dpCustomerID);
            sp.Children.Add(dpCustomerFN);
            sp.Children.Add(dpCustomerLN);
            sp.Children.Add(dpCustomerBD);
            sp.Children.Add(dpCustomerGender);
            sp.Children.Add(dpCustomerAdress);
            sp.Children.Add(dpCustomerCity);
            sp.Children.Add(buttons);

            Grid.SetColumn(sp, 2);
            Grid.SetRow(sp, 3);

            void DeletePanel(object o, EventArgs ev) => mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);

            void ConfirmCustomerAdd(object o, EventArgs ev)
            {
                int element = 1;

                AddCustomer
                (
                    (DatePicker)dpCustomerBD.Children[element],
                    (TextBox)dpCustomerID.Children[element],
                    (TextBox)dpCustomerFN.Children[element],
                    (TextBox)dpCustomerLN.Children[element],
                    (TextBox)dpCustomerGender.Children[element],
                    (TextBox)dpCustomerAdress.Children[element],
                    (TextBox)dpCustomerCity.Children[element]
                );

                mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);
            }
        }
Exemplo n.º 4
0
        private void LoadNewLoanWindow(Customer customer)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            AppButton.ActionButton btnBack  = new AppButton.ActionButton("Powrót");
            AppButton.ActionButton btnApply = new AppButton.ActionButton("Zatwierdź");

            AppDockPanel.SliderDockPanel loanBalance = new AppDockPanel.SliderDockPanel("Kwota ( ZŁ )", new Slider {
                Maximum = 50_000, Minimum = 3000
            });
Exemplo n.º 5
0
        public void LoadNewAccountWindow(Customer customer, Employee loggedEmployee)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            AppButton.ActionButton btnBack  = new AppButton.ActionButton("Powrót");
            AppButton.ActionButton btnApply = new AppButton.ActionButton("Zatwierdź");

            AppDockPanel.InfoInputDockPanel accountName      = new AppDockPanel.InfoInputDockPanel("Nazwa konta", 30);
            AppDockPanel.InfoInputDockPanel accountMoney     = new AppDockPanel.InfoInputDockPanel("Kwota ( ZŁ )", 7);
            AppDockPanel.InputDateDockPanel accountOpenDate  = new AppDockPanel.InputDateDockPanel("Od dnia");
            AppDockPanel.InputDateDockPanel accountCloseDate = new AppDockPanel.InputDateDockPanel("Do dnia");

            AppDockPanel.ButtonsDockPanel buttons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnBack, btnApply);

            sp.Children.Add(accountName);
            sp.Children.Add(accountMoney);
            sp.Children.Add(accountOpenDate);
            sp.Children.Add(accountCloseDate);
            sp.Children.Add(buttons);
            customerNewAccount.Children.Add(sp);

            btnApply.Click += ConfirmNewAccount;
            btnBack.Click  += DeleteWindow;

            void ConfirmNewAccount(object o, EventArgs ev)
            {
                int element = 1;

                CreateNewAccount
                (
                    customer,
                    loggedEmployee,
                    (TextBox)accountName.Children[element],
                    (TextBox)accountMoney.Children[element],
                    (DatePicker)accountOpenDate.Children[element],
                    (DatePicker)accountCloseDate.Children[element]
                );
            }

            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 6
0
        private void LoadCustomerPaymentWindow(Customer customer)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            List <Account> accounts = new List <Account>();

            using (var context = new SystemObsługiBankuDBEntities())
            {
                accounts = context.Account.Where(x => x.CustomerID == customer.ID).ToList();
            }

            AppDockPanel.MultiLabelDockPanel description = new AppDockPanel.MultiLabelDockPanel(
                new string[6] {
                "Akcja", "Wpłata", "Wypłata", "Nazwa konta", "Aktualny stan", "Kwota ( ZŁ )"
            });

            AppButton.ActionButton        btnBack  = new AppButton.ActionButton("Powrót");
            AppButton.ActionButton        btnApply = new AppButton.ActionButton("Zatwierdź");
            AppDockPanel.ButtonsDockPanel buttons  = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 10, 0, 0
            }, btnBack, btnApply);

            sp.Children.Add(description);

            List <AppDockPanel.AccountInfoDockPanel> dockPanelsAccounts = new List <AppDockPanel.AccountInfoDockPanel>();

            foreach (var item in accounts)
            {
                var x = new AppDockPanel.AccountInfoDockPanel(item.AccountName, item.Balance);
                dockPanelsAccounts.Add(x);
                sp.Children.Add(x);
            }

            sp.Children.Add(buttons);
            customerPayment.Children.Add(sp);

            btnApply.Click += CustomerPaymentTransaction;
            btnBack.Click  += DeleteWindow;

            void CustomerPaymentTransaction(object o, EventArgs ev) => ApplyTransaction(dockPanelsAccounts);
            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 7
0
        private void LoadEmployeeSettingsWindow()
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            AppButton.ActionButton btnBack = new AppButton.ActionButton("Powrót");

            AppButton.ThemeButton btnTheme1 = new AppButton.ThemeButton(Brushes.Black);
            AppButton.ThemeButton btnTheme2 = new AppButton.ThemeButton(Brushes.DarkGray);
            AppButton.ThemeButton btnTheme3 = new AppButton.ThemeButton(Brushes.DimGray);
            AppButton.ThemeButton btnTheme4 = new AppButton.ThemeButton(Brushes.SlateGray);
            AppButton.ThemeButton btnTheme5 = new AppButton.ThemeButton(Brushes.DarkSlateGray);

            btnTheme1.Click += ChangeTheme;
            btnTheme2.Click += ChangeTheme;
            btnTheme3.Click += ChangeTheme;
            btnTheme4.Click += ChangeTheme;
            btnTheme5.Click += ChangeTheme;
            btnBack.Click   += DeleteWindow;

            sp.Children.Add(new AppDockPanel.ColorsDockPanel("Motyw", btnTheme1, btnTheme2, btnTheme3, btnTheme4, btnTheme5));
            sp.Children.Add(new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnBack));

            employeeSettingsWindow.Children.Add(sp);

            void ChangeTheme(object sender, EventArgs e)
            {
                Button btn = (Button)sender;

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Background = btn.Background;
                    }
                }
            }

            void DeleteWindow(object sender, EventArgs e) => Close();
        }
Exemplo n.º 8
0
        private void LoadRepaymentLoanWindow(Customer customer)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            AppButton.ActionButton btnBack  = new AppButton.ActionButton("Powrót");
            AppButton.ActionButton btnApply = new AppButton.ActionButton("Spłać");

            List <Loan> loans = new List <Loan>();

            using (var context = new SystemObsługiBankuDBEntities())
            {
                loans = context.Loan.Where(x => x.CustomerID == customer.ID).ToList();
            }

            List <AppDockPanel.ActionDockPanel> dockPanelsLoans = new List <AppDockPanel.ActionDockPanel>();

            foreach (var item in loans)
            {
                var x = new AppDockPanel.ActionDockPanel(
                    ("Kwota początkowa " + Math.Round(item.Balance, 2).ToString() + " + " +
                     Math.Round(item.Balance / 100 * (item.PercentValue / ((item.EndDate - item.StartDate).Days)) *
                                (DateTime.Now - item.StartDate).Days)).ToString() + " odsetki ( ZŁ )", true);

                dockPanelsLoans.Add(x);
                sp.Children.Add(x);
            }

            AppDockPanel.ButtonsDockPanel buttons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 40, 0, 0
            }, btnBack, btnApply);

            sp.Children.Add(buttons);
            customerRepaymentLoan.Children.Add(sp);

            btnApply.Click += DeleteLoan;
            btnBack.Click  += DeleteWindow;

            void DeleteLoan(object o, EventArgs ev) => RepaymentLoanAction(dockPanelsLoans, customer);
            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 9
0
        private void LoadCustomerLoansWindow(Customer customer)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            List <Loan> loans = new List <Loan>();

            using (var context = new SystemObsługiBankuDBEntities())
            {
                loans = context.Loan.Where(x => x.CustomerID == customer.ID).ToList();
            }

            AppDockPanel.MultiLabelDockPanel description = new AppDockPanel.MultiLabelDockPanel(
                new string[6] {
                "Kwota ( ZŁ )", "Procent", "Pożyczono", "Spłata do", "Do spłaty ( ZŁ )", "Pozostało dni"
            });

            sp.Children.Add(description);

            List <AppDockPanel.LoanInfoDockPanel> dockPanelsAccounts = new List <AppDockPanel.LoanInfoDockPanel>();

            foreach (var item in loans)
            {
                var x = new AppDockPanel.LoanInfoDockPanel(item.Balance, item.PercentValue, item.StartDate, item.EndDate);
                dockPanelsAccounts.Add(x);
                sp.Children.Add(x);
            }

            AppButton.ActionButton        btnBack = new AppButton.ActionButton("Powrót");
            AppDockPanel.ButtonsDockPanel buttons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 10, 0, 0
            }, btnBack);

            sp.Children.Add(buttons);
            customerLoans.Children.Add(sp);

            btnBack.Click += DeleteWindow;

            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 10
0
        private void LoadDeleteAccountWindow(Customer customer)
        {
            StackPanel sp = new StackPanel
            {
                Height = 320,
            };

            List <Account> accounts = new List <Account>();

            using (var context = new SystemObsługiBankuDBEntities())
            {
                accounts = context.Account.Where(x => x.CustomerID == customer.ID).ToList();
            }

            List <AppDockPanel.ActionDockPanel> dockPanelsAccounts = new List <AppDockPanel.ActionDockPanel>();

            foreach (var item in accounts)
            {
                var x = new AppDockPanel.ActionDockPanel(item.AccountName, true);
                dockPanelsAccounts.Add(x);
                sp.Children.Add(x);
            }

            AppButton.ActionButton btnBack  = new AppButton.ActionButton("Powrót");
            AppButton.ActionButton btnApply = new AppButton.ActionButton("Zatwierdź");

            AppDockPanel.ButtonsDockPanel buttons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 30, 0, 0
            }, btnBack, btnApply);

            sp.Children.Add(buttons);
            customerDeleteAccount.Children.Add(sp);

            btnApply.Click += DeleteCustomerAccount;
            btnBack.Click  += DeleteWindow;

            void DeleteCustomerAccount(object o, EventArgs ev) => DeleteAccount(dockPanelsAccounts);
            void DeleteWindow(object o, EventArgs ev) => Close();
        }
Exemplo n.º 11
0
        private void LoadMenuPanel(Employee employee)
        {
            loggedEmployee = employee;
            DeleteLoginPanel();

            string day   = DateTime.Now.ToString("dddd");
            string month = DateTime.Now.ToString("MMMM");

            AppLabel.DescriptionLabel lblCustomer    = new AppLabel.DescriptionLabel("Strefa klienta");
            AppLabel.DescriptionLabel lblTime        = new AppLabel.DescriptionLabel("Data: " + DateTime.Now.Day + " " + month + " " + day);
            AppLabel.DescriptionLabel lblLogged      = new AppLabel.DescriptionLabel($"Zalogowany: {employee.FirstName} {employee.LastName}");
            AppLabel.DescriptionLabel lblSessionTime = new AppLabel.DescriptionLabel(null);
            AppLabel.DescriptionLabel lblEmployee    = new AppLabel.DescriptionLabel("Strefa pracownika");

            AppButton.MenuButton btnCustomerService  = new AppButton.MenuButton("Obsługa klienta");
            AppButton.MenuButton btnCustomerAdd      = new AppButton.MenuButton("Dodawanie klienta");
            AppButton.MenuButton btnCustomerDelete   = new AppButton.MenuButton("Usuwanie klienta");
            AppButton.MenuButton btnBranchInfo       = new AppButton.MenuButton("Informacje o oddziale");
            AppButton.MenuButton btnEmployeeInfo     = new AppButton.MenuButton("Twoje dane");
            AppButton.MenuButton btnEmployeeSettings = new AppButton.MenuButton("Ustawienia");

            AppButton.ActionButton btnLogout = new AppButton.ActionButton("Wyloguj");

            SetSessionTimer();

            mainWindow.Children.Add(lblCustomer);
            mainWindow.Children.Add(lblSessionTime);
            mainWindow.Children.Add(lblLogged);
            mainWindow.Children.Add(lblTime);
            mainWindow.Children.Add(lblEmployee);
            mainWindow.Children.Add(btnCustomerService);
            mainWindow.Children.Add(btnCustomerAdd);
            mainWindow.Children.Add(btnCustomerDelete);
            mainWindow.Children.Add(btnBranchInfo);
            mainWindow.Children.Add(btnEmployeeInfo);
            mainWindow.Children.Add(btnEmployeeSettings);
            mainWindow.Children.Add(btnLogout);

            Grid.SetColumn(lblCustomer, 0); Grid.SetRow(lblCustomer, 0);
            Grid.SetColumn(lblTime, 1); Grid.SetRow(lblTime, 0);
            Grid.SetColumn(lblLogged, 2); Grid.SetRow(lblLogged, 0);
            Grid.SetColumn(lblSessionTime, 3); Grid.SetRow(lblCustomer, 0);
            Grid.SetColumn(lblEmployee, 4); Grid.SetRow(lblEmployee, 0);
            Grid.SetColumn(btnCustomerService, 0); Grid.SetRow(btnCustomerService, 1);
            Grid.SetColumn(btnCustomerAdd, 0); Grid.SetRow(btnCustomerAdd, 2);
            Grid.SetColumn(btnCustomerDelete, 0); Grid.SetRow(btnCustomerDelete, 3);
            Grid.SetColumn(btnBranchInfo, 4); Grid.SetRow(btnBranchInfo, 1);
            Grid.SetColumn(btnEmployeeInfo, 4); Grid.SetRow(btnEmployeeInfo, 2);
            Grid.SetColumn(btnEmployeeSettings, 4); Grid.SetRow(btnEmployeeSettings, 3);
            Grid.SetColumn(btnLogout, 4); Grid.SetRow(btnLogout, 6);

            btnCustomerService.Click  += ServiceCustomerNumberPanel;
            btnCustomerAdd.Click      += AddCustomerPanel;
            btnCustomerDelete.Click   += DeleteCustomerPanel;
            btnBranchInfo.Click       += OpenEmployeeBranchWindow;
            btnEmployeeInfo.Click     += OpenEmployeeInfoWindow;
            btnEmployeeSettings.Click += OpenEmployeeSettingsWindow;
            btnLogout.Click           += Logout;

            void OpenEmployeeBranchWindow(object sender, EventArgs e)
            {
                EmployeeBranchWindow employeeBranchWindow = new EmployeeBranchWindow(loggedEmployee);

                employeeBranchWindow.Show();
            }

            void OpenEmployeeInfoWindow(object sender, EventArgs e)
            {
                EmployeeInfoWindow employeeInfoWindow = new EmployeeInfoWindow(loggedEmployee);

                employeeInfoWindow.Show();
            }

            void OpenEmployeeSettingsWindow(object sender, EventArgs e)
            {
                EmployeeSettingsWindow employeeSettingsWindow = new EmployeeSettingsWindow();

                employeeSettingsWindow.Show();
            }

            void SetSessionTimer()
            {
                DispatcherTimer clock = new DispatcherTimer();

                clock.Interval = new TimeSpan(0, 0, 1);
                clock.Tick    += TimerTick;
                clock.Start();
            }

            void TimerTick(object sender, EventArgs e)
            {
                var child = lblSessionTime.Content = new TextBlock()
                {
                    Text         = "Godzina: " + DateTime.Now.ToLongTimeString().ToString(),
                    FontSize     = 15,
                    FontWeight   = FontWeights.Bold,
                    TextWrapping = TextWrapping.Wrap,
                };
            }
        }
Exemplo n.º 12
0
        private void ServiceCustomerPanel(Customer customer, Employee loggedEmployee)
        {
            StackPanel sp = new StackPanel
            {
                Width      = 400,
                Height     = 300,
                Background = Brushes.DeepSkyBlue,
                Margin     = new Thickness(0, -120, 0, -120),
            };

            AppButton.ActionButton btnCancel = new AppButton.ActionButton("Powrót");

            Expander accountMenu = new Expander
            {
                Header     = "Konto klienta",
                Background = Brushes.LightGray,
                Padding    = new Thickness(10),
                FontWeight = FontWeights.Bold,
            };

            Expander loanMenu = new Expander
            {
                Header     = "Pożyczki klienta",
                Background = Brushes.LightGray,
                Padding    = new Thickness(10),
                FontWeight = FontWeights.Bold,
            };

            AppButton.OperationCustomerButton btnCreateAccount = new AppButton.OperationCustomerButton("Zakładanie konta");
            AppButton.OperationCustomerButton btnPayment       = new AppButton.OperationCustomerButton("Wpłata / wypłata");
            AppButton.OperationCustomerButton btnDeleteAccount = new AppButton.OperationCustomerButton("Usuń konto");
            AppButton.OperationCustomerButton btnNewLoan       = new AppButton.OperationCustomerButton("Nowa pożyczka");
            AppButton.OperationCustomerButton btnActualLoan    = new AppButton.OperationCustomerButton("Aktualne pożyczki");
            AppButton.OperationCustomerButton btnRepaymentLoan = new AppButton.OperationCustomerButton("Spłać pożyczkę");

            AppDockPanel.ButtonsDockPanel customerAccount = new AppDockPanel.ButtonsDockPanel(
                null, btnCreateAccount, btnPayment, btnDeleteAccount);
            AppDockPanel.ButtonsDockPanel customerLoan = new AppDockPanel.ButtonsDockPanel(
                null, btnNewLoan, btnActualLoan, btnRepaymentLoan);

            accountMenu.Content = customerAccount;
            loanMenu.Content    = customerLoan;

            Label lblTitle = new Label
            {
                Content    = $"Operacje dla klienta {customer.FirstName} {customer.LastName}",
                Background = Brushes.DodgerBlue,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            AppDockPanel.ButtonsDockPanel dpButton = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnCancel);

            btnCreateAccount.Click += NewAccountWindow;
            btnPayment.Click       += PaymentWindow;
            btnDeleteAccount.Click += DeleteAccountWindow;

            btnNewLoan.Click       += NewLoanWindow;
            btnActualLoan.Click    += ActualLoanWindow;
            btnRepaymentLoan.Click += RepaymentLoanWindow;

            btnCancel.Click += DeletePanel;

            mainWindow.Children.Add(sp);
            sp.Children.Add(lblTitle);
            sp.Children.Add(accountMenu);
            sp.Children.Add(loanMenu);
            sp.Children.Add(dpButton);

            Grid.SetColumn(sp, 2);
            Grid.SetRow(sp, 3);

            void NewAccountWindow(object o, EventArgs ev)
            {
                List <Account> accounts = new List <Account>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    accounts = context.Account.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (accounts.Count < 2)
                {
                    CustomerNewAccount customerNewAccount = new CustomerNewAccount(customer, loggedEmployee);
                    customerNewAccount.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient posiada maksymalną ilość kont ( {accounts.Count} ).",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void PaymentWindow(object o, EventArgs ev)
            {
                List <Account> accounts = new List <Account>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    accounts = context.Account.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (accounts.Count > 0)
                {
                    CustomerPayment customerPayment = new CustomerPayment(customer);
                    customerPayment.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient nie posiada jeszcze konta.",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void DeleteAccountWindow(object o, EventArgs ev)
            {
                List <Account> accounts = new List <Account>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    accounts = context.Account.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (accounts.Count > 0)
                {
                    CustomerDeleteAccount customerDeleteWindow = new CustomerDeleteAccount(customer);
                    customerDeleteWindow.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient nie posiada kont do usunięcia.",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void NewLoanWindow(object o, EventArgs ev)
            {
                List <Loan> loans = new List <Loan>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    loans = context.Loan.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (loans.Count < 2)
                {
                    CustomerNewLoan customerNewLoan = new CustomerNewLoan(customer);
                    customerNewLoan.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient posiada maksymalną ilość pożyczek ( {loans.Count} ).",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void ActualLoanWindow(object o, EventArgs ev)
            {
                List <Loan> loans = new List <Loan>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    loans = context.Loan.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (loans.Count > 0)
                {
                    CustomerLoans customerLoans = new CustomerLoans(customer);
                    customerLoans.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient nie posiada aktualnie pożyczek.",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void RepaymentLoanWindow(object o, EventArgs e)
            {
                List <Loan> loans = new List <Loan>();

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    loans = context.Loan.Where(x => x.CustomerID == customer.ID).ToList();
                }

                if (loans.Count > 0)
                {
                    CustomerRepaymentLoan customerRepaymentLoan = new CustomerRepaymentLoan(customer);
                    customerRepaymentLoan.Show();
                }
                else
                {
                    MessageBox.Show
                    (
                        $"Klient nie posiada aktualnie pożyczek do spłacenia.",
                        "Informacja",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information
                    );
                }
            }

            void DeletePanel(object o, EventArgs ev) => mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);
        }
Exemplo n.º 13
0
        private void ServiceCustomerNumberPanel(object sender, EventArgs e)
        {
            Customer customer = null;

            AppOtherControls.PeselTextBox[] numberInput = new AppOtherControls.PeselTextBox[11];

            for (int i = 0; i < numberInput.Length; i++)
            {
                numberInput[i] = new AppOtherControls.PeselTextBox();
            }

            StackPanel sp = new StackPanel
            {
                Width      = 400,
                Height     = 300,
                Background = Brushes.DeepSkyBlue,
                Margin     = new Thickness(0, -120, 0, -120),
            };

            AppButton.ActionButton btnCancel  = new AppButton.ActionButton("Anuluj");
            AppButton.ActionButton btnConfirm = new AppButton.ActionButton("Dalej");

            Label lblTitle = new Label
            {
                Content    = "Podaj numer PESEL klienta do operacji",
                Background = Brushes.DodgerBlue,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            DockPanel dpMain = new DockPanel
            {
                Height     = 200,
                Background = Brushes.LightGray,
            };

            DockPanel dpNumbers = new DockPanel
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            foreach (var item in numberInput)
            {
                dpNumbers.Children.Add(item);
            }

            AppDockPanel.ButtonsDockPanel dpButtons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnCancel, btnConfirm);

            btnCancel.Click  += DeletePanel;
            btnConfirm.Click += ServiceCustomer;

            mainWindow.Children.Add(sp);
            dpMain.Children.Add(dpNumbers);
            sp.Children.Add(lblTitle);
            sp.Children.Add(dpMain);
            sp.Children.Add(dpButtons);

            Grid.SetColumn(sp, 2);
            Grid.SetRow(sp, 3);

            void DeletePanel(object o, EventArgs ev) => mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);

            void ServiceCustomer(object o, EventArgs ev)
            {
                bool   isSuccess      = true;
                string customerNumber = null;
                var    numbers        = ControlFinder.FindVisualChildren <TextBox>(mainWindow.Children[mainWindow.Children.Count - 1]);

                foreach (var item in numbers)
                {
                    customerNumber += item.Text;
                }

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    try
                    {
                        customer = context.Customer.Single(x => x.ID == customerNumber);
                    }
                    catch (InvalidOperationException)
                    {
                        isSuccess = false;
                        MessageBoxResult confirm = MessageBox.Show
                                                   (
                            "Operacja zakończona niepowodzeniem.\nBrak klienta o danym numerze PESEL.",
                            "Wynik operacji",
                            MessageBoxButton.OK,
                            MessageBoxImage.Error
                                                   );
                    }
                }

                if (isSuccess)
                {
                    mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);
                    ServiceCustomerPanel(customer, loggedEmployee);
                }
            }
        }
Exemplo n.º 14
0
        private void EmployeeLoginPanel()
        {
            StackPanel spLoginBox = new StackPanel {
                VerticalAlignment = VerticalAlignment.Center
            };
            StackPanel spInfoBox = new StackPanel {
                VerticalAlignment = VerticalAlignment.Center
            };
            DockPanel dpLoginBox = new DockPanel {
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Label lblTitleApp = new Label
            {
                Content    = "System Obsługi Banku",
                Background = Brushes.DeepSkyBlue,
                Foreground = Brushes.White,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
                FontSize = 24,
            };

            Label lblInfoEmployee = new Label
            {
                Content    = "Zaloguj się do systemu używając swojego indentyfikatora",
                Background = Brushes.DeepSkyBlue,
                Foreground = Brushes.White,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            Label lblLoginError = new Label
            {
                Content    = "",
                FontWeight = FontWeights.Bold,
                Foreground = Brushes.White,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            PasswordBox pbLogin = new PasswordBox
            {
                Password     = "",
                PasswordChar = '*',
                FontSize     = 18,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Bottom,
                FontWeight = FontWeights.Bold,
                Padding    = new Thickness(6),
            };

            AppButton.ActionButton btnExit  = new AppButton.ActionButton("Wyjście");
            AppButton.ActionButton btnLogin = new AppButton.ActionButton("Zaloguj");

            mainWindow.Children.Add(lblTitleApp);
            mainWindow.Children.Add(spLoginBox);
            mainWindow.Children.Add(spInfoBox);
            mainWindow.Children.Add(lblLoginError);

            Grid.SetColumn(lblTitleApp, 2); Grid.SetRow(lblTitleApp, 1);
            Grid.SetColumn(spInfoBox, 2); Grid.SetRow(spInfoBox, 3);
            Grid.SetColumn(spLoginBox, 2); Grid.SetRow(spLoginBox, 4);
            Grid.SetColumn(lblLoginError, 2); Grid.SetRow(lblLoginError, 5);

            spInfoBox.Children.Add(lblInfoEmployee);
            spInfoBox.Children.Add(pbLogin);

            spLoginBox.Children.Add(dpLoginBox);

            dpLoginBox.Children.Add(btnExit);
            dpLoginBox.Children.Add(btnLogin);

            btnExit.Click  += ExitApp;
            btnLogin.Click += LoginApp;
        }
Exemplo n.º 15
0
        private void DeleteCustomerPanel(object sender, EventArgs e)
        {
            AppOtherControls.PeselTextBox[] numberInput = new AppOtherControls.PeselTextBox[11];
            for (int i = 0; i < numberInput.Length; i++)
            {
                numberInput[i] = new AppOtherControls.PeselTextBox();
            }

            StackPanel sp = new StackPanel
            {
                Width      = 400,
                Background = Brushes.DeepSkyBlue,
                Margin     = new Thickness(0, -120, 0, -120),
            };

            AppButton.ActionButton btnCancel  = new AppButton.ActionButton("Anuluj");
            AppButton.ActionButton btnConfirm = new AppButton.ActionButton("Zatwierdź");

            Label lblTitle = new Label
            {
                Content    = "Podaj numer PESEL klienta do usunięcia",
                Background = Brushes.DodgerBlue,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            Label lblWarning = new Label
            {
                Content    = "UWAGA, brak możliwości cofnięcia operacji!",
                Background = Brushes.PaleVioletRed,
                Foreground = Brushes.Maroon,
                FontWeight = FontWeights.Bold,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            DockPanel dpMain = new DockPanel
            {
                Height     = 200,
                Background = Brushes.LightGray,
            };

            DockPanel dpNumbers = new DockPanel
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            foreach (var item in numberInput)
            {
                dpNumbers.Children.Add(item);
            }

            AppDockPanel.ButtonsDockPanel dpButtons = new AppDockPanel.ButtonsDockPanel(new int[4] {
                0, 15, 0, 0
            }, btnCancel, btnConfirm);

            btnCancel.Click  += DeletePanel;
            btnConfirm.Click += DeleteCustomer;

            mainWindow.Children.Add(sp);
            dpMain.Children.Add(dpNumbers);
            sp.Children.Add(lblTitle);
            sp.Children.Add(lblWarning);
            sp.Children.Add(dpMain);
            sp.Children.Add(dpButtons);

            Grid.SetColumn(sp, 2);
            Grid.SetRow(sp, 3);

            void DeletePanel(object o, EventArgs ev) => mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);

            void DeleteCustomer(object o, EventArgs ev)
            {
                bool   isSuccess      = true;
                string customerNumber = null;
                var    numbers        = ControlFinder.FindVisualChildren <TextBox>(mainWindow.Children[mainWindow.Children.Count - 1]);

                foreach (var item in numbers)
                {
                    customerNumber += item.Text;
                }

                using (var context = new SystemObsługiBankuDBEntities())
                {
                    try
                    {
                        var accounts = context.Account.Where(x => x.CustomerID == customerNumber).ToList();
                        if (accounts.Count != 0)
                        {
                            foreach (var item in accounts)
                            {
                                context.Account.Remove(item);
                            }
                        }

                        var loans = context.Loan.Where(x => x.CustomerID == customerNumber).ToList();
                        if (accounts.Count != 0)
                        {
                            foreach (var item in loans)
                            {
                                context.Loan.Remove(item);
                            }
                        }

                        context.Customer.Remove(context.Customer.Single(x => x.ID == customerNumber));
                        context.SaveChanges();
                    }
                    catch (InvalidOperationException) { isSuccess = false; }
                }

                MessageBoxResult confirm = MessageBox.Show
                                           (
                    isSuccess == true ? "Operacja zakończona pomyślnie.":
                    "Operacja zakończona niepowodzeniem. \nBrak klienta o danym numerze PESEL.",
                    "Wynik operacji",
                    MessageBoxButton.OK,
                    isSuccess == true ? MessageBoxImage.Information : MessageBoxImage.Error
                                           );

                if (isSuccess)
                {
                    mainWindow.Children.RemoveAt(mainWindow.Children.Count - 1);
                }
            }
        }