public ModifierEmpView(IDictionary<string, object> parametre) : this() { _Employe = parametre["Employe"] as Employe; LiaisonProjetEmploye = new ObservableCollection<LiaisonProjetEmploye>(_ServiceMysql.GetLiaison(_Employe.ID.ToString())); List<LiaisonProjetEmploye> ToutProjet = new List<LiaisonProjetEmploye>(_ServiceMysql.GetLiaison(null)); LiaisonProjetEmploye = new ObservableCollection<LiaisonProjetEmploye>(ComparerListe(ToutProjet, _ServiceMysql.GetLiaison(_Employe.ID.ToString()))); //Retrieve Photo photoBD = _ServiceMysql.GetPhoto(_Employe.ID.ToString()); if (photoBD != null) imgPhoto.Source = BitmapToImageSource(ToImage(photoBD)); txtEmployeur.Text = _ServiceMysql.getEmployeur(_Employe.ID.ToString()); DateEmbauche.Text = _ServiceMysql.getDateEmbauche(_Employe.ID.ToString()); }
//Modifier Informations d'un employé public void UpdateInfoEmploye(Employe emp, bool hF,string employeur,string date) { try { // nom, prenom connexion = new MySqlConnexion(); StringBuilder buildReq = new StringBuilder(); buildReq.Append("SELECT Employes.idEmploye,detailfinancies.titreEmploi, detailfinancies.tauxHoraireNormal, detailfinancies.tauxHoraireOver, Employes.nom, Employes.prenom, Employes.horsFonction,detailfinancies.employeur,DATE_FORMAT(detailfinancies.dateEmbauche, '%Y-%m-%d') AS 'dateEmbauche' FROM Employes "); buildReq.Append(" INNER JOIN detailfinancies ON detailfinancies.idEmploye = "); buildReq.Append(emp.ID); DataSet result = connexion.Query(buildReq.ToString()); DataTable table = result.Tables[0]; if (emp.Nom != table.Rows[0]["nom"].ToString() || emp.Prenom != table.Rows[0]["prenom"].ToString() || hF != (bool)table.Rows[0]["horsFonction"]) { buildReq = new StringBuilder(); buildReq.Append("UPDATE Employes SET nom = '"); buildReq.Append(emp.Nom); buildReq.Append("', prenom = '"); buildReq.Append(emp.Prenom); buildReq.Append("', horsFonction = "); buildReq.Append(hF); buildReq.Append(" WHERE idEmploye = "); buildReq.Append(emp.ID); } connexion.Query(buildReq.ToString()); // string s = table.Rows[0]["tauxHoraireNormal"].ToString().Replace(',', '.'); //float salaire = Convert.ToSingle(s); string poste = table.Rows[0]["titreEmploi"].ToString(); //Poste + salaire if (emp.Poste != poste || emp.Salaire != Convert.ToSingle(table.Rows[0]["tauxHoraireNormal"]) || employeur != table.Rows[0]["employeur"].ToString() || date != table.Rows[0]["dateEmbauche"].ToString()) { buildReq = new StringBuilder(); buildReq.Append("UPDATE detailfinancies SET titreEmploi = '"); buildReq.Append(emp.Poste); buildReq.Append("', tauxHoraireOver = '"); double s = Math.Round((emp.Salaire * 3 / 2), 2); ; string sOver = s.ToString().Replace(',','.'); buildReq.Append(sOver); buildReq.Append("', tauxHoraireNormal = '"); string salaire = emp.Salaire.ToString().Replace(',','.'); buildReq.Append(salaire); if(employeur.Length > 0) { buildReq.Append("' , employeur = '"); buildReq.Append(employeur); } buildReq.Append("' , dateEmbauche = '"); buildReq.Append(date); buildReq.Append("' WHERE idEmploye = '"); buildReq.Append(emp.ID); buildReq.Append("'"); } connexion.Query(buildReq.ToString()); } catch (MySqlException) { throw; } }