public String ActivatUser(Password pass) { _gestionDb = new GcdbEntities(); if (!IsUserExist(pass)) return "Utilisateur n'existante pas"; Password user = _gestionDb.Passwords.Single(pw => pw.Login.Equals(pass.Login)); user.Status = 1; _gestionDb.SaveChanges(); return "Utilisateur activer avec succes"; }
public static void InitSettings() { var settings = new Setting { CompanyName = "entreprise", Adresse = "adresse", PostalCode = "35000", RC = "11111111111", NF = "11111111111", NIS = "1111111111", AI = "11111111111", City = "Wilaya", Phone = "021234567", MobPhone = "0550123456", Email = "*****@*****.**", FirstTime = true, FactureNumber = "1", FactureProNumber = "1", Licence = "", PassWordApp = "demo", }; String s = MajSettings(settings); PasswordClient passwordClient = new PasswordClient(); Password admin = new Password { Login = "******", Password1 = PasswordClient.CryptePassword("admin"), Status = 2 }; if (passwordClient.IsUserExist(admin))passwordClient.MajUser(admin); else passwordClient.AddUser(admin); admin = passwordClient.GetPassword("admin"); var empc = new EmployeesManager(); var emp = new Employee { EmployeeFirstname = "admin", EmployeeLastname = "admin", Status = 1, Password = admin }; if (!EmployeesManager.IsEmployeeExist(emp)) empc.AddEmployee(emp); }
public String DelUser(Password pass) { _gestionDb = new GcdbEntities(); if (!IsUserExist(pass)) return "Utilisateur n'existante pas"; var user = _gestionDb.Passwords.Where(pw => pw.Login.StartsWith(pass.Login)); int i = user.Count(); if (user.Any()) { foreach (Password usr in user) { _gestionDb.Passwords.Remove(usr); } } _gestionDb.SaveChanges(); return "Utilisateur supprimer avec succes"; }
public String AddUser(Password pass) { try { _gestionDb = new GcdbEntities(); bool v = IsUserExist(pass); if (IsUserExist(pass)) return "Utilisateur existe déjà"; _gestionDb.Passwords.Add(pass); _gestionDb.SaveChanges(); } catch (Exception ex) { return ex.Message; } return "Utilisateur ajouter avec succes"; }
private void AddEmployeeBtn_Click(object sender, RoutedEventArgs e) { Employee emp = new Employee(); EmployeesManager empc = new EmployeesManager(); String photoPath = null; if (imageEdit1.Source != null && imageEdit1.Source is BitmapImage) { BitmapImage bi = (BitmapImage)imageEdit1.Source; FileStream stream = bi.StreamSource as FileStream; photoPath = stream.Name; emp.Photo = Validator.ConvertImageToByteArray(photoPath); } emp.PhotoPath = photoPath; String input = null; input = LastNameTxtBox.Text; if ( !String.IsNullOrEmpty(input)) emp.EmployeeLastname = input; else { MessageBox.Show("Erreur dans le Nom de l'employée"); return; } input = FirstNameTxtBox.Text; if ( !String.IsNullOrEmpty(input)) emp.EmployeeFirstname = input; else { MessageBox.Show("Erreur dans le Prenom de l'employée"); return; } input = TitleTxtBox.Text; if ( !String.IsNullOrEmpty(input)) emp.Title = input; else { MessageBox.Show("Erreur dans le Titre de l'employée"); return; } DateTime date = BirthDayTxtBox.DateTime.Date; if (!String.IsNullOrEmpty(date.ToString())) emp.BirthDate = date; else { MessageBox.Show("Erreur dans la Date de naissance"); return; } // a savoir si un employée est déjà engagé il ya longtemps ???? emp.HireDate = DateTime.Now; emp.Address = AdresseTxtBox.Text; emp.Country = CountryTxtBox.Text; emp.City = CityTxtBox.Text; emp.Region = RegionTxtBox.Text; input = ZipCodeTxtBox.Text; if (Validator.IsPostalCodeValid(input) || String.IsNullOrEmpty(input)) emp.PostalCode = input; else { MessageBox.Show("Erreur dans le code postal"); return; } input = MobileTxtBox.Text; // if (Validator.IsMobPhoneValid(input) || String.IsNullOrEmpty(input)) emp.Phone1 = input; // else { MessageBox.Show("Erreur dans le Telephone mobile (10 chiffres)"); return; } input = FixTxtBox.Text; if (Validator.IsFixPhoneValid(input) || String.IsNullOrEmpty(input)) emp.HomePhone = input; else { MessageBox.Show("Erreur dans le Telephone Fix (09 chiffres)"); return; } input = EmailTxtBox.Text; if (Validator.IsEmailValid(input) || String.IsNullOrEmpty(input)) emp.EmailAdress = input; else { MessageBox.Show("Erreur dans l'Email "); return; } //// emp.ReportsTo = ; var textRange = new TextRange(NotesRichTxtArea.Document.ContentStart, NotesRichTxtArea.Document.ContentEnd); var note = textRange.Text; emp.Notes = note; emp.HireDate = dateEdit2.DateTime; Password pass = new Password(); input = textEdit1.Text; if (!String.IsNullOrEmpty(input)) pass.Login = input; else { MessageBox.Show("Erreur dans le login "); return; } input = textEdit2.Text; if (!String.IsNullOrEmpty(input)) pass.Password1 = PasswordClient.CryptePassword(input); else { MessageBox.Show("Erreur dans le mot de passe "); return; } PasswordClient pc = new PasswordClient(); pc.AddUser(pass); pc.ActivatUser(pass); emp.Password = pass; emp.Status = 0; String s = empc.AddEmployee(emp); MessageBox.Show(s); imageEdit1.Clear(); LastNameTxtBox.Clear(); FirstNameTxtBox.Clear(); TitleTxtBox.Clear(); BirthDayTxtBox.Clear(); AdresseTxtBox.Clear(); CountryTxtBox.Clear(); CityTxtBox.Clear(); RegionTxtBox.Clear(); ZipCodeTxtBox.Clear(); MobileTxtBox.Clear(); FixTxtBox.Clear(); EmailTxtBox.Clear(); dateEdit2.Clear(); NotesRichTxtArea.Document.Blocks.Clear(); textEdit1.Clear(); }
public String MajUser(Password pass) { _gestionDb = new GcdbEntities(); if (!IsUserExist(pass)) return "Utilisateur n'existante pas"; Password user = pass; _gestionDb.SaveChanges(); return "Utilisateur modifier avec succes"; }
public bool IsUserExist(Password pass) { _gestionDb = new GcdbEntities(); try { var query = _gestionDb.Passwords.Where(p => p.Login.Equals(pass.Login)).ToList(); return query.Any(); } catch (Exception) { return false; } }
public bool IsPassWordValid(Password pass) { _gestionDb = new GcdbEntities(); bool result = false; try { Password password = GetPassword(pass.Login); if (password == null) { //traitement user n'existe pas return result; } if (! password.Password1.Equals(pass.Password1)) { // traitement user avec faux mot de passe return result; } // if (! ) } catch (Exception ) { return result; } return true; }
public int GetStatus(Password pass) { _gestionDb = new GcdbEntities(); if (!IsUserExist(pass)) return -1; Password user = _gestionDb.Passwords.Single(pw => pw.Login.Equals(pass.Login)); return user.Status; }
public Employee GetEmployeeByUserId(Password password) { try { _gestionDb = new GcdbEntities(); Employee emp = _gestionDb.Employees.Single(c => c.Password.Login == password.Login); return emp; } catch (Exception) { return null; } }