private void Afficher(Employee emp) { imageEdit1.EditValue = emp.Photo; LastNameTxtBox.Text = emp.EmployeeLastname; FirstNameTxtBox.Text = emp.EmployeeFirstname; TitleTxtBox.Text = emp.Title; try { BirthDayTxtBox.DateTime = emp.BirthDate.Value; dateEdit2.DateTime = emp.HireDate.Value; } catch (Exception) { } AdresseTxtBox.Text = emp.Address; CountryTxtBox.Text = emp.Country; CityTxtBox.Text = emp.City; RegionTxtBox.Text = emp.Region; ZipCodeTxtBox.Text = emp.PostalCode; MobileTxtBox.Text = emp.Phone1; FixTxtBox.Text = emp.HomePhone; EmailTxtBox.Text = emp.EmailAdress; textEdit1.Text = emp.Password.Login; textEdit2.Text = "Password"; // textEdit16.Text = emp.Employees2Reference.Value.employee_firstname; NotesRichTxtArea.Document.Blocks.Clear(); NotesRichTxtArea.AppendText(emp.Notes); }
public String DesactivateEmployee(Employee emp) { _gestionDb = new GcdbEntities(); emp.Status = 1; MajEmployee(emp); return "Employee désactiver avec succes"; }
public ListEmployeesView(string animationName, TabHelper hlp) { InitializeComponent(); TabHlp = hlp; employee = new Employee(); employeeClient = new EmployeesManager(); if (!string.IsNullOrEmpty(animationName)) { Storyboard animation = (Storyboard)Application.Current.Resources[animationName]; LayoutRoot.BeginStoryboard(animation); } }
public String AddEmployee(Employee emp) { try { _gestionDb = new GcdbEntities(); if (IsEmployeeExist(emp)) return "Employee existe déjà"; _gestionDb.Employees.Add(emp); _gestionDb.SaveChanges(); return "Employee ajouter avec succes"; } catch (Exception e) { return ""; } }
public String DelEmployee(Employee emp) { try { _gestionDb = new GcdbEntities(); if (!IsEmployeeExist(emp)) return "Employee n'existante pas"; var employee = _gestionDb.Employees.Single(em => em.EmployeeID.Equals(emp.EmployeeID)); _gestionDb.Employees.Remove(employee); _gestionDb.SaveChanges(); return "Employee supprimer avec succes"; } catch (Exception e) { return ""; } }
public static bool IsEmployeeExist(Employee emp) { GcdbEntities gestionDb = new GcdbEntities(); try { var user = gestionDb.Employees.Where (p => (p.EmployeeFirstname.ToLower().Equals(emp.EmployeeFirstname)) ).ToList(); return user.Any(); } catch (Exception ) { return false; } }
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 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 MajEmployee(Employee emp) { _gestionDb = new GcdbEntities(); if (!IsEmployeeExist(emp)) return "Employee n'existante pas"; Employee employee = _gestionDb.Employees.Single(e => e.EmployeeID == emp.EmployeeID); try { employee = emp; // si ca va pas marcher alors attache dettache sinon remplissage champ par champ _gestionDb.SaveChanges(); } catch (Exception ) { return "erreur"; } return "Employee modifier avec succes"; }
private void CreateVente(List<ProduitsSel> productSelSelected, string remarque, Customer customer, DateTime dateTime, decimal tvaValue, Employee newEmployee) { try { Customer getCustomer = gestionDb.Customers.FirstOrDefault(c => c.CustomerID==customer.CustomerID); if(getCustomer!=null) { Order newOrder = new Order { OrderDate = dateTime, CommandeDate = dateTime, CustomerID = getCustomer.CustomerID, Customer = getCustomer, TvaValue = tvaValue, Description = remarque, Status = 0, }; foreach (var entity in productSelSelected) { OrderDetail newOrderDetail = new OrderDetail { ProductID = entity.TheProduct.ProductID, Quantity = (int) entity.UnitsOnOrder, UnitPrice = entity.UnitePrice, TotalPrice = entity.TotalPrice, }; newOrder.OrderDetails.Add(newOrderDetail); } gestionDb.Orders.Add(newOrder); gestionDb.SaveChanges(); theOrder= newOrder; } else theOrder = null; } catch (Exception exe) { MessageBox.Show(exe.ToString()); theOrder= null; } }