private void Button_Click(object sender, RoutedEventArgs e) { Admin admin = UsersORM.GetAdmin(Login.Text, Password.Text); if (admin != null) { AdminWindow adminWindow = new AdminWindow(); adminWindow.Show(); Close(); } // Admin admin = new Admin(); //admin.SurName = "petr"; //admin.Name = "petr"; //admin.Guid = new Guid(); //admin.Mail = "*****@*****.**"; //admin.Phone = "777777777"; //admin.AdminType = AdminType.Admin; //admin.Address = new Address(); //admin.Address.Id = 1; //admin.Login = "******"; //admin.Password = "******"; //admin.Valid = true; //UsersORM.CreateAdmin(admin); }
///////////////////////////////////// Users ///////////////////////////////////// //////////////////////////////////////// Users ///////////////////////////////////// private void nomPrenomButton_Click(object sender, RoutedEventArgs e) { myDataObject = new UsersViewModel(); myDataObject.nomUsersProperty = nomUsers.Text; myDataObject.prenomUsersProperty = prenomUsers.Text; myDataObject.adresseMailUsersProperty = AdresseMailUsers.Text; myDataObject.identifiantUsersProperty = Identifiant.Text; myDataObject.motDePasseUsersProperty = MotDePasse.Password; UsersViewModel nouveau = new UsersViewModel(UsersDAL.getMaxIdUsers() + 1, myDataObject.nomUsersProperty, myDataObject.prenomUsersProperty, myDataObject.identifiantUsersProperty, myDataObject.adresseMailUsersProperty, myDataObject.motDePasseUsersProperty, 0); lp.Add(nouveau); UsersORM.insertUsers(nouveau); ((TextBox)nomUsers).Text = string.Empty; ((TextBox)prenomUsers).Text = string.Empty; ((TextBox)AdresseMailUsers).Text = string.Empty; ((TextBox)Identifiant).Text = string.Empty; ((PasswordBox)MotDePasse).Password = string.Empty; compteur = lp.Count(); MessageBox.Show("Utilisateur ajouté avec succes ! "); }
private void UpdateRecipientLabelContent() { Bill bill = (Bill)RecipientList.SelectedItem; Customer customer = UsersORM.GetCustomerByGuid(bill.CustomerId); int updatedBillBalance = BillORM.GetBillbyBillNumber(bill.BillNumber).Balance; RecipientLabel.Content = String.Format("Recipient: {0} {1} \nBalance: {2:n} Kč", customer.Name, customer.SurName, updatedBillBalance); }
private void supprimerButton_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { UsersViewModel toRemove = (UsersViewModel)listeUsers.SelectedItem; lp.Remove(toRemove); listeUsers.Items.Refresh(); UsersORM.supprimerUsers(selectedUsersId); MessageBox.Show("Utilisateur supprimée avec succes ! "); }
private void OnPropertyChanged(string info) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(info)); UsersORM.updateUsers(this); } }
private void AdminLogin() { admin = UsersORM.GetAdmin(Login.Text, PasswordBox.Password); if (admin != null) { AdminWindow adminWindow = new AdminWindow(admin); log.Info(string.Format("Admin login: {0} {1} {2}", admin.Name, admin.SurName, admin.Guid)); adminWindow.Show(); Close(); } }
private bool PasswordChangingProcess() { if (oldPasswordCheck) { if (NewPassword1.Text == NewPassword2.Text && !String.IsNullOrEmpty(NewPassword1.Text)) { //Validace hesla if (!Validator.Validator.ValidatePassword(NewPassword1.Text)) { MessageBox.Show(String.Format("Weak password."), "", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } activeOfficial.Password = NewPassword1.Text; bool result = UsersORM.ChangePassword(activeOfficial); if (result) { SetDefaultSettings(); return(true); } } else if (String.IsNullOrEmpty(NewPassword1.Text) || NewPassword1.Text == "New password ..." || String.IsNullOrEmpty(NewPassword2.Text) || NewPassword2.Text == "New password ...") { MessageBox.Show("You have to fill in new password.", "", MessageBoxButton.OK, MessageBoxImage.Warning); } else { MessageBox.Show("Enter twice same new password.", "", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Wrong old password.", "", MessageBoxButton.OK, MessageBoxImage.Warning); } return(false); }
private void OfficialLogin() { Official = UsersORM.GetOfficialById(Login.Text); if (Official != null) { if (Official.Password == PasswordBox.Password) { OfficialWindow officialWindow = new OfficialWindow(Official); log.Info(string.Format("Official login: {0} {1} {2}", Official.Name, Official.SurName, Official.Guid)); officialWindow.Show(); Close(); } else { MessageBox.Show("Incorrect password."); } } }
private void SetDefaultSettings() { customer = UsersORM.GetCustomerByGuid(activeBill.CustomerId); address = UsersORM.SelectAddressById(customer.Address.Id); BillNumberLabel.Content = activeBill.BillNumber; string partialSSN = customer.SSN.Substring(0, 6) + "XXXX"; UserInfo1.Content = String.Format("Name: {0} {1}, SSN: {2}", customer.SurName, customer.Name, partialSSN); UserInfo2.Content = String.Format("Address: {0}", address.ToString()); UserInfo3.Content = String.Format("Contact: {0}, {1}", customer.Phone, customer.Mail); BillInfo1.Content = String.Format("Bill Number: {0}", activeBill.BillNumber); BillInfo2.Content = String.Format("Balance: {0:n} Kč", activeBill.Balance); AllPaymentsRadioButton.IsChecked = true; NewestToOldest.IsChecked = true; GetAllTransactionBySelectedCriterias(); }
private void SelectDataForListView() { List <Customer> customers = UsersORM.GetAllCustomers(); var result = customers.Where(X => X.Name.ToLower().Contains(SearchTextBox.Text.ToLower()) || X.SurName.ToLower().Contains(SearchTextBox.Text.ToLower()) || String.Format("{0} {1}", X.Name, X.SurName).ToLower().Contains(SearchTextBox.Text.ToLower()) || String.Format("{1} {0}", X.Name, X.SurName).ToLower().Contains(SearchTextBox.Text.ToLower()) ); AllCustomersListView.ItemsSource = result; AllCustomersListView.Items.Refresh(); if (result.Any()) { CustomerNotFoundLabel.Visibility = Visibility.Hidden; } else { CustomerNotFoundLabel.Visibility = Visibility.Visible; } }
public ZoneInvestigation() { InitializeComponent(); lp = UsersORM.listeUsers(); listeUsersCombo.ItemsSource = lp; lp1 = PlageORM.listePlages(); listePlageCombo.ItemsSource = lp1; lp4 = EtudeORM.ListeEtude(); listeEtudesCombo.ItemsSource = lp4; listeDateCombo.ItemsSource = lp4; lp7 = ZoneInvestigationORM.ListeZoneInvestigation(); ListeEtudeZone.ItemsSource = lp7; lp7 = ZoneInvestigationORM.ListeZoneInvestigation(); CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd-HH-mm-ss"; //Format BDD culture.DateTimeFormat.LongTimePattern = ""; Thread.CurrentThread.CurrentCulture = culture; }
public Inscription() { InitializeComponent(); lp = UsersORM.listeUsers(); }
private void OpenDetailViewOfUser(Official official) { SetDefaultSettings(); foreach (Control c in userControlsList) { c.Visibility = Visibility.Visible; c.IsEnabled = false; } foreach (Control c in addressControlsList) { c.Visibility = Visibility.Visible; c.IsEnabled = false; } MainPageLabel.Content = "MY ACCOUNT DETAILS:"; MainPageLabel.IsEnabled = true; EditModeButton.Visibility = Visibility.Visible; StornoButton.Visibility = Visibility.Visible; tempOfficial = UsersORM.GetOfficialById(official.CompanyNumber); NameTextBox.Text = official.Name; SurnameTextBox.Text = official.SurName; PhoneTextBox.Text = official.Phone; EmailTextBox.Text = official.Mail; Address address = UsersORM.SelectAddressById(official.Address.Id); official.Address = address; StreetTextBox.Text = official.Address.Street; StreetNumberTextBox.Text = official.Address.StreetNumber; CityTextBox.Text = official.Address.City; PostalCodeTextBox.Text = official.Address.PostalCode; CountryTextBox.Text = official.Address.Country; LoginTextBox.Text = official.CompanyNumber; UserTypeComboBox.Text = "Official"; switch (official.OfficialType) { case OfficialType.Junior: OfficialSubTypeComboBox.SelectedItem = OfficialSubTypeComboBox_Junior; break; case OfficialType.Normal: OfficialSubTypeComboBox.SelectedItem = OfficialSubTypeComboBox_Normal; break; case OfficialType.Senior: OfficialSubTypeComboBox.SelectedItem = OfficialSubTypeComboBox_Senior; break; } switch (official.Valid) { case true: ValidTextBox.Text = "Yes"; break; case false: ValidTextBox.Text = "No"; break; } }
public void OpenDetailViewOfUser(Customer customer) { SetDefaultSettings(); foreach (Control c in userControlsList) { c.Visibility = Visibility.Visible; c.IsEnabled = false; } OfficialSubTypeComboBox.Visibility = Visibility.Hidden; foreach (Control c in addressControlsList) { c.Visibility = Visibility.Visible; c.IsEnabled = false; } MainPageLabel.Content = "CUSTOMER DETAILS:"; MainPageLabel.IsEnabled = true; EditModeButton.Visibility = Visibility.Visible; StornoButton.Visibility = Visibility.Visible; LoginLabel.Content = "SSN"; tempCustomer = UsersORM.GetCustomerBySSN(customer.SSN); NameTextBox.Text = customer.Name; SurnameTextBox.Text = customer.SurName; PhoneTextBox.Text = customer.Phone; EmailTextBox.Text = customer.Mail; Address address = UsersORM.SelectAddressById(customer.Address.Id); customer.Address = address; StreetTextBox.Text = customer.Address.Street; StreetNumberTextBox.Text = customer.Address.StreetNumber; CityTextBox.Text = customer.Address.City; PostalCodeTextBox.Text = customer.Address.PostalCode; CountryTextBox.Text = customer.Address.Country; LoginTextBox.Text = customer.SSN; UserTypeComboBox.Text = "Customer"; switch (customer.CustomerType) { case CustomerType.Person: CustomerSubTypeComboBox.SelectedItem = CustomerSubTypeComboBox_Person; break; case CustomerType.Company: CustomerSubTypeComboBox.SelectedItem = CustomerSubTypeComboBox_Company; break; } switch (customer.Valid) { case true: ValidTextBox.Text = "Yes"; break; case false: ValidTextBox.Text = "No"; break; } AllProductsListView.Visibility = Visibility.Visible; ListOfProductsLabel.Visibility = Visibility.Visible; AllProductsListView.ItemsSource = BillORM.GetBillsByCustomerId(customer); }
public User() { InitializeComponent(); lp = UsersORM.listeUsers(); listeUsers.ItemsSource = lp; }
private void UpdateUserProcess(Customer tempCustomer) { Customer updatedCustomer = new Customer(); Address updatedAddress = new Address(); bool userWasChanged = false; bool addressWasChanged = false; bool addressExistsInDb = false; updatedCustomer.Guid = tempCustomer.Guid; updatedCustomer.Name = NameTextBox.Text; updatedCustomer.SurName = SurnameTextBox.Text; updatedCustomer.Mail = EmailTextBox.Text; updatedCustomer.Phone = PhoneTextBox.Text; updatedCustomer.SSN = LoginTextBox.Text; if (CustomerSubTypeComboBox.SelectedItem == CustomerSubTypeComboBox_Person) { updatedCustomer.CustomerType = CustomerType.Person; } else if (CustomerSubTypeComboBox.SelectedItem == CustomerSubTypeComboBox_Company) { updatedCustomer.CustomerType = CustomerType.Company; } updatedCustomer.Address = tempCustomer.Address; updatedAddress.Id = tempCustomer.Address.Id; updatedAddress.Street = StreetTextBox.Text; updatedAddress.StreetNumber = StreetNumberTextBox.Text; updatedAddress.City = CityTextBox.Text; updatedAddress.PostalCode = PostalCodeTextBox.Text; updatedAddress.Country = CountryTextBox.Text; Address addressFromDb = UsersORM.IsAddressInDatabase(updatedAddress); if (tempCustomer.Name == updatedCustomer.Name && tempCustomer.SurName == updatedCustomer.SurName && tempCustomer.Phone == updatedCustomer.Phone && tempCustomer.Mail == updatedCustomer.Mail && tempCustomer.SSN == updatedCustomer.SSN && tempCustomer.CustomerType == updatedCustomer.CustomerType) { userWasChanged = false; } else { userWasChanged = true; } if (updatedAddress.Street == tempCustomer.Address.Street && updatedAddress.StreetNumber == tempCustomer.Address.StreetNumber && updatedAddress.City == tempCustomer.Address.City && updatedAddress.PostalCode == tempCustomer.Address.PostalCode && updatedAddress.Country == tempCustomer.Address.Country) { addressWasChanged = false; } else { addressWasChanged = true; if (addressFromDb is null) { addressExistsInDb = false; } else { addressExistsInDb = true; } } if (!userWasChanged && !addressWasChanged) { return; } if (addressWasChanged) { if (addressExistsInDb) { updatedCustomer.Address = addressFromDb; } else if (!addressExistsInDb) { updatedAddress.Id = UsersORM.GetNewAddressId(); bool addressIsCreated = UsersORM.CreateAddress(updatedAddress); if (addressIsCreated) { updatedCustomer.Address = updatedAddress; } else { MessageBox.Show("Address was not created. Contact administrator.", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } } } bool result = UsersORM.UpdateCustomer(updatedCustomer); if (result) { MessageBox.Show("Update successful.", "", MessageBoxButton.OK, MessageBoxImage.Information); //try //{ // if (tempCustomer.Guid == activeCustomer.Guid) // activeCustomer = updatedCustomer; //} //catch (Exception ex) //{ //} tempCustomer = updatedCustomer; } else { MessageBox.Show("Update of customer not successful. Contact administrator.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void UpdateUserProcess(Official tempOfficial) { Official updatedOfficial = new Official(); Address updatedAddress = new Address(); bool userWasChanged = false; bool addressWasChanged = false; bool addressExistsInDb = false; updatedOfficial.Guid = tempOfficial.Guid; updatedOfficial.Name = NameTextBox.Text; updatedOfficial.SurName = SurnameTextBox.Text; updatedOfficial.Mail = EmailTextBox.Text; updatedOfficial.Phone = PhoneTextBox.Text; updatedOfficial.CompanyNumber = LoginTextBox.Text; if (OfficialSubTypeComboBox.SelectedItem == OfficialSubTypeComboBox_Junior) { updatedOfficial.OfficialType = OfficialType.Junior; } else if (OfficialSubTypeComboBox.SelectedItem == OfficialSubTypeComboBox_Normal) { updatedOfficial.OfficialType = OfficialType.Normal; } else if (OfficialSubTypeComboBox.SelectedItem == OfficialSubTypeComboBox_Senior) { updatedOfficial.OfficialType = OfficialType.Senior; } updatedOfficial.Address = tempOfficial.Address; updatedAddress.Id = tempOfficial.Address.Id; updatedAddress.Street = StreetTextBox.Text; updatedAddress.StreetNumber = StreetNumberTextBox.Text; updatedAddress.City = CityTextBox.Text; updatedAddress.PostalCode = PostalCodeTextBox.Text; updatedAddress.Country = CountryTextBox.Text; Address addressFromDb = UsersORM.IsAddressInDatabase(updatedAddress); if (tempOfficial.Name == updatedOfficial.Name && tempOfficial.SurName == updatedOfficial.SurName && tempOfficial.Phone == updatedOfficial.Phone && tempOfficial.Mail == updatedOfficial.Mail && tempOfficial.CompanyNumber == updatedOfficial.CompanyNumber && tempOfficial.OfficialType == updatedOfficial.OfficialType) { userWasChanged = false; } else { userWasChanged = true; } if (updatedAddress.Street == tempOfficial.Address.Street && updatedAddress.StreetNumber == tempOfficial.Address.StreetNumber && updatedAddress.City == tempOfficial.Address.City && updatedAddress.PostalCode == tempOfficial.Address.PostalCode && updatedAddress.Country == tempOfficial.Address.Country) { addressWasChanged = false; } else { addressWasChanged = true; if (addressFromDb is null) { addressExistsInDb = false; } else { addressExistsInDb = true; } } if (!userWasChanged && !addressWasChanged) { return; } if (addressWasChanged) { if (addressExistsInDb) { updatedOfficial.Address = addressFromDb; } else if (!addressExistsInDb) { updatedAddress.Id = UsersORM.GetNewAddressId(); bool addressIsCreated = UsersORM.CreateAddress(updatedAddress); if (addressIsCreated) { updatedOfficial.Address = updatedAddress; } else { MessageBox.Show("Address was not created. Contact administrator.", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } } } bool result = UsersORM.UpdateOfficial(updatedOfficial); if (result) { MessageBox.Show("Update of user successful.", "", MessageBoxButton.OK, MessageBoxImage.Information); if (tempOfficial.Guid == activeOfficial.Guid) { activeOfficial = updatedOfficial; } tempOfficial = updatedOfficial; } else { MessageBox.Show("Update of customer not successful. Contact administrator.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CreateNewCustomerInDB_Click(object sender, RoutedEventArgs e) { Customer newCustomer = new Customer(); Address newAddress = new Address(); if (!allUserFieldsAreNotEmpty()) { MessageBox.Show("Please fill in all user information", "", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (!allAddressFieldsAreNotEmpty()) { MessageBox.Show("Please fill in all address fields", "", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (!Validator.Validator.NameValidator(NameTextBox.Text) || !Validator.Validator.NameValidator(SurnameTextBox.Text) || !Validator.Validator.EmailValidator(EmailTextBox.Text) || !Validator.Validator.PhoneValidator(PhoneTextBox.Text) || !Validator.Validator.StreetValidator(StreetTextBox.Text) || !Validator.Validator.StreetNumberValidator(StreetNumberTextBox.Text) || !Validator.Validator.CityValidator(CityTextBox.Text) || !Validator.Validator.PostalCodeValidator(PostalCodeTextBox.Text) || !Validator.Validator.SSNValidator(LoginTextBox.Text) ) { MessageBox.Show("Incorect inputs. Please check user information.", "", MessageBoxButton.OK, MessageBoxImage.Warning); if (!Validator.Validator.NameValidator(NameTextBox.Text)) { NameTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.NameValidator(SurnameTextBox.Text)) { SurnameTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.EmailValidator(EmailTextBox.Text)) { EmailTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.PhoneValidator(PhoneTextBox.Text)) { PhoneTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.StreetValidator(StreetTextBox.Text)) { StreetTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.StreetNumberValidator(StreetNumberTextBox.Text)) { StreetNumberTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.CityValidator(CityTextBox.Text)) { CityTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.PostalCodeValidator(PostalCodeTextBox.Text)) { PostalCodeTextBox_NoIcon.Visibility = Visibility.Visible; } if (!Validator.Validator.SSNValidator(LoginTextBox.Text)) { LoginTextBox_NoIcon.Visibility = Visibility.Visible; } return; } newAddress.Id = UsersORM.GetNewAddressId(); newAddress.Street = StreetTextBox.Text; newAddress.StreetNumber = StreetNumberTextBox.Text; newAddress.City = CityTextBox.Text; newAddress.PostalCode = PostalCodeTextBox.Text; newAddress.Country = CountryTextBox.Text; bool addressIsCreated = UsersORM.CreateAddress(newAddress); if (!addressIsCreated) { MessageBox.Show("New address was not created. Contact administrator", "", MessageBoxButton.OK, MessageBoxImage.Error); } newCustomer.Guid = Guid.NewGuid(); newCustomer.Name = NameTextBox.Text; newCustomer.SurName = SurnameTextBox.Text; newCustomer.Address = newAddress; newCustomer.Mail = EmailTextBox.Text; newCustomer.Phone = PhoneTextBox.Text; newCustomer.Valid = true; newCustomer.Password = "******"; newCustomer.SSN = LoginTextBox.Text; if (CustomerSubTypeComboBox.SelectedItem == CustomerSubTypeComboBox_Person) { newCustomer.CustomerType = CustomerType.Person; } else if (CustomerSubTypeComboBox.SelectedItem == CustomerSubTypeComboBox_Company) { newCustomer.CustomerType = CustomerType.Company; } bool userIsCreated = UsersORM.CreateNewCustomer(newCustomer); if (userIsCreated) { MessageBox.Show(String.Format("New User was created: {0} {1}", newCustomer.Name, newCustomer.SurName), "", MessageBoxButton.OK, MessageBoxImage.Information); OpenDetailViewOfUser(newCustomer); } else { MessageBox.Show("New user was not created. Contact administrator", "", MessageBoxButton.OK, MessageBoxImage.Error); } }