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); } }
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(); }
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(); }
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(); }
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(); }
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(); }
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); }
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); } } }
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); } } }