public Collaborateur Update(Collaborateur collaborateur) { try { _context.Update(collaborateur); _context.SaveChanges(); return(collaborateur); } catch (Exception ex) { throw ex; } }
public Collaborateur Add(Collaborateur collaborateur) { try { _CollaborateurRepository.Add(collaborateur); return(collaborateur); } catch (Exception ex) { throw ex; } }
/// <summary> /// Method called when the event SavingCollaboData is fired /// Add a new collaborateur the the collection and set the DataGridView's DataSource in the form collaborateurListForm /// </summary> /// <param name="collabo"></param> private void OnSavedNewCollabo(Collaborateur collabo) { try { DAO.getInstance().NewCollaborateur(collabo); collaborateurList.Add(collabo.Id, collabo); RefreshDataSource(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error New Collaborateur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Collaborateur Update(Collaborateur collaborateur) { try { _context.Update(collaborateur); _context.SaveChanges(); } catch (Exception) { return(null); } return(collaborateur); }
private void AddCollaborateur(Collaborateur collaborateur) { if (dt != null) { DataRow dr = dt.NewRow(); dr["Matricule"] = collaborateur.Id; dr["Nom"] = collaborateur.Name; dr["Prénom"] = collaborateur.Firstname; dr["Fonction"] = collaborateur.FonctionCollabo; Contrat contratActif = null; foreach (Contrat c in collaborateur.Contrats) { if (!c.Cloture) { contratActif = c; } } if (contratActif != null) { dr["Qualification"] = contratActif.Qualification; TypeContrat type = TypeContrat.CDI; if (contratActif is Cdi) { type = TypeContrat.CDI; } if (contratActif is Cdd) { type = TypeContrat.CDD; } if (contratActif is Stage) { type = TypeContrat.Stage; } if (contratActif is MissionInterim) { type = TypeContrat.Interim; } dr["Contrat"] = type.ToString(); dr["Statut"] = contratActif.StatutContrat; dr["SalaireBrut"] = contratActif.SalaireBrut; } dr["Actif"] = contratActif == null ? "Inactif" : "Actif"; dt.Rows.Add(dr); } }
public Collaborateur CheckUser_ExistCollaborateur(int id) { Collaborateur result = new Collaborateur(); try { result = _CollaborateurRepository.GetUserByCollaborator(id); return(result); } catch (Exception ex) { throw ex; } }
public ActionResult Conges_ValidationRH(string nb, bool accepter) { IDal dal = new Dal(); System.Diagnostics.Debug.WriteLine("Passage dans validationRH"); bool refus; // Modification du statut du congé if (accepter) { dal.ChangerStatut(Convert.ToInt32(nb), StatutConge.Valide); refus = false; } else { dal.ChangerStatut(Convert.ToInt32(nb), StatutConge.Refuse); refus = true; } Debug.WriteLine("Statut après validation : " + dal.ObtenirConge(Convert.ToInt32(nb)).Type); Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); // Recherche du collaborateur concerné List <Collaborateur> collabs = dal.ObtenirTousLesCollaborateurs(); int idCollab = 0; foreach (Collaborateur col in collabs) { foreach (Conge con in col.Conges) { if (con.Id == Convert.ToInt32(nb)) { idCollab = col.Id; break; } } } //On rend ses congés au collaborateur if (refus && dal.ObtenirConge(Convert.ToInt32(nb)).Type == TypeConge.RTT) { dal.AjouterCongesRestants(idCollab, dal.ObtenirConge(Convert.ToInt32(nb)).GetDuree()); } // Envois de notifications dal.AjoutNotif(idCollab, new Message(TypeMessage.NotifCongeRetour, c.Prenom + c.Nom + " - " + c.Service.Nom, dal.ObtenirConge(Convert.ToInt32(nb)))); return(View()); }
public ActionResult Conges_Validation2(string nb, bool accepter) { // Modification du statut du congé if (accepter) { dal.ChangerStatut(Convert.ToInt32(nb), StatutConge.ValideChef); } else { dal.ChangerStatut(Convert.ToInt32(nb), StatutConge.Refuse); } // Recherche du collaborateur concerné Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); List <Collaborateur> collabs = dal.ObtenirTousLesCollaborateurs(); int idCollab = 0; foreach (Collaborateur col in collabs) { foreach (Conge con in col.Conges) { if (con.Id == Convert.ToInt32(nb)) { idCollab = col.Id; break; } } } // Envois de notifications if (dal.ObtenirCollaborateur(idCollab).Service != c.Service) { dal.ChangerStatut(Convert.ToInt32(nb), StatutConge.Valide); dal.AjoutNotif(idCollab, new Message(TypeMessage.NotifCongeRetour, c.Prenom + " " + c.Nom + " - " + c.Service.Nom, dal.ObtenirConge(Convert.ToInt32(nb)))); } else { dal.AjoutNotif(idCollab, new Message(TypeMessage.NotifCongeRetour, c.Prenom + " " + c.Nom + " - " + c.Service.Nom, dal.ObtenirConge(Convert.ToInt32(nb)))); if (dal.ObtenirConge(Convert.ToInt32(nb)).Statut == StatutConge.ValideChef) { foreach (Collaborateur rh in dal.ObtenirCollaborateursService(dal.ObtenirServiceDeType(TypeService.RessourcesHumaines).Id)) { dal.AjoutNotif(rh.Id, new Message(TypeMessage.NotifCongeAller, dal.ObtenirCollaborateur(idCollab).Nom + " " + dal.ObtenirCollaborateur(idCollab).Prenom + " - " + c.Service.Nom, dal.ObtenirConge(Convert.ToInt32(nb)))); } } } return(View()); }
public async Task <ActionResult> UpdateCollaborateur(Collaborateur collaborateur) { var myContent = JsonConvert.SerializeObject(collaborateur); var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); using (HttpClient client = new HttpClient()) { var response = await client.PostAsync("http://bip14:10000/Service1.svc/rest/update/", byteContent); Console.WriteLine(response); } return(RedirectToAction("Index")); }
/// <summary> /// Method called whenever the event SelectingCollabo is fired /// check that the id exists in the Collaborateur Collection /// instanciate athe controller CtrlDetailCollaborateur /// Listen to the event EditingCollaborateur /// Listen to the event Refreshing /// </summary> /// <param name="id"></param> private void OnSelectedCollabo(Int32 id) { if (collaborateurList.ContainsKey(id)) { Collaborateur collabo = collaborateurList[id]; CtrlDetailCollaborateur ctrlDetailCollabo = new CtrlDetailCollaborateur(collabo); ctrlDetailCollabo.EditingCollaborateur += new CollaboHandler(this.OnEditedCollabo); ctrlDetailCollabo.Refreshing += new EventHandler(this.OnRefreshed); ctrlDetailCollabo.UpdatinCollabo += new CollaboHandler(this.OnUpdatedCollabo); ctrlDetailCollabo.Display(); } else { MessageBox.Show("Cant't find the id ", "Error collabo matricule", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int SubmitDemandeInfo(string DemandeInformation, string DemandeTitre) { System.Diagnostics.Debug.WriteLine(DemandeTitre + DemandeInformation); if (HttpContext.User.Identity.IsAuthenticated) { Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); dal.EnvoiDemandeInformation(new Message { Contenu = DemandeInformation, Emetteur = c.Prenom + " " + c.Nom + " - " + c.Service.Nom, Titre = DemandeTitre }); dal.AjoutNotificationService(TypeService.RessourcesHumaines, new Message { Titre = "Deamande Information", Emetteur = c.Prenom + " " + c.Nom + " - " + c.Service.Nom, Redirection = "/RH/Index", Contenu = "Nouvelle demande d'information" }); return(1); } return(0); }
private Boolean SavedCollabo() { try { if (String.IsNullOrEmpty(txtNom.Text) || String.IsNullOrEmpty(txtPrenom.Text)) { errorProviderNom.SetError(txtNom, "Requis"); errorProviderPrenom.SetError(txtPrenom, "Requis"); return(false); } else { String nom = txtNom.Text.Trim().ToUpper(); String prenom = Tools.FirstLetterUppercase(txtPrenom.Text.Trim()); String fonction = txtFonction.Text.Trim(); String address = txtAdresse.Text.Trim(); String zipCode = txtCodePostal.Text.Trim(); String town = txtVille.Text.Trim(); String tel = txtTel.Text.Trim(); String email = txtEmail.Text.Trim(); if (collaborateur == null) { collaborateur = new Collaborateur(nom, prenom, fonction, address, zipCode, town, tel, email); return(true); } else { collaborateur.Name = nom; collaborateur.Firstname = prenom; collaborateur.FonctionCollabo = fonction; collaborateur.Address = address; collaborateur.ZipCode = zipCode; collaborateur.Town = town; collaborateur.Tel = tel; collaborateur.Email = email; return(true); } } } catch (Exception e) { MessageBox.Show(e.Message, "Error Creation Collaborateur", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public JsonResult GetMissions(string text) { System.Diagnostics.Debug.WriteLine("Passage dans GetMissions dans NoteDeFraisControlleur"); if (HttpContext.User.Identity.IsAuthenticated) { Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); var missions = c.Missions.Select(m => new Mission { Nom = m.Nom, Id = m.Id, Statut = m.Statut, }); System.Diagnostics.Debug.WriteLine("Passage dans GetMissions dans NoteDeFraisControlleur envoie des missions"); return(Json(missions, JsonRequestBehavior.AllowGet)); } return(null); }
/// <summary> /// Méthode évenementielle d'affichage du frmContrat pour l'ajout d'un nouveau contrat au clic sur btnAjoutContrat /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void btnAjoutContrat_Click(Object sender, EventArgs e) { ctrlNouvContrat leFormNouvContrat = new ctrlNouvContrat(); if (leFormNouvContrat.Resultat() == DialogResult.OK) { //Recherche du collaborateur dans la DB et instanciation Collaborateur collabReceveur = DonneesDAO.DbContextAbiDao.CollaborateurSet.Find(leCollab.Matricule); //Insertion du contrat en DB ContratDAOEFStatic.InsereContrat(leFormNouvContrat.Contrat(), collabReceveur); //Attribution du bon numéro au MContrat leFormNouvContrat.Contrat().NumContrat = ContratDAOEFStatic.getContratActif(collabReceveur).GetNumContrat(); //Insertion du contrat dans dictionnaire leCollab.AddContrat(leFormNouvContrat.Contrat()); //Remise à jour de l'affichage leForm.grdContrats.DataSource = leCollab.ListerContrats(); } }
/// <summary> /// Permet la convertion d'un objet collaborateur data en un objet collaborateur DTO /// </summary> /// <param name="collaborateur">collaborateur data</param> /// <returns>L'objet collaborateur DTO</returns> public static Collaborateur EntityToDto(Data.Collaborateur collaborateur) { Collaborateur collaborateurDto = new Collaborateur(); collaborateurDto.Banque = collaborateur.Banque; collaborateurDto.Cin = collaborateur.Cin; collaborateurDto.Cnss = collaborateur.Cnss; collaborateurDto.DateDebutTravail = collaborateur.DateDebutTravail; collaborateurDto.Id = collaborateur.Id; collaborateurDto.IsEligible = collaborateur.IsEligible; collaborateurDto.Nom = collaborateur.Nom; collaborateurDto.Poste = collaborateur.Poste; collaborateurDto.Prenom = collaborateur.Prenom; collaborateurDto.Adresse = collaborateur.Adresse; collaborateurDto.Civilite = CiviliteMapping.EntityToDto(collaborateur.Civilite); return(collaborateurDto); }
public int SupprimerConge(int idConge) { IDal dal = new Dal(); Collaborateur col = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); Conge c = dal.ObtenirConge(idConge); //TODO attention dangereux if (c.Statut == StatutConge.EnCours || c.Statut == StatutConge.ValideChef) { dal.SupprimerDemandeConge(col.Id, idConge); } else { return(-1); } return(0); }
public ActionResult Index(CollaborateurViewModel viewModel, string returnUrl) { if (ModelState.IsValid) { Collaborateur utilisateur = dal.Authentifier(viewModel._Collaborateur.Mail, viewModel._Collaborateur.MotDePasse); if (utilisateur != null) { FormsAuthentication.SetAuthCookie(utilisateur.Id.ToString(), false); /*if (!string.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl)) * return Redirect(returnUrl);*/ return(Redirect("/UserPage/Profil")); } System.Diagnostics.Debug.WriteLine(utilisateur); ModelState.AddModelError("Utilisateur.Prenom", "Prénom et/ou mot de passe incorrect(s)"); } return(View(viewModel)); }
public ActionResult Index(CongesViewModel vm) { IDal dal = new Dal(); Collaborateur col = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); vm._Collaborateur = col; System.Diagnostics.Debug.WriteLine(vm._Collaborateur.Nom); string txt = "Service : " + vm._Collaborateur.Service.Nom + "\n"; Message notif = new Message(TypeMessage.NotifCongeAller, col.Prenom + col.Nom + " - " + col.Service.Nom, vm._Conge); if (HttpContext.User.Identity.IsAuthenticated) { dal.AjoutNotif(col.Service.Chef().Id, notif); dal.AjoutConge(col.Id, vm._Conge); dal.EnvoiCongeChef(col.Service.Id, col.Id, vm._Conge.Id); } return(View(vm)); }
/// <summary>Raoul /// Permet d'instancier le combobox cbbProjet avec les intitulé de projet /// </summary> private void Accuiel_Load(object sender, EventArgs e) { Service s1 = new Service(1, "Invention"); Service s2 = new Service(2, "Ellaborer"); Collaborateur c1 = new Collaborateur(1, "Michel", s1); Collaborateur c2 = new Collaborateur(2, "Patrick", s2); s1.SetCollab(c1); s2.SetCollab(c2); Tache t1 = new Tache(1, "Nettoyer", new DateTime(2020, 02, 06), new DateTime(2020, 02, 08), 10, 15, "En cour", new List <Collaborateur>() { c1, c2 }); Tache t2 = new Tache(1, "Organiser", new DateTime(2020, 02, 06), new DateTime(2020, 02, 08), 15, 20, "En cour", new List <Collaborateur>() { c1, c2 }); Projet p1 = new Projet(1, "AA", new DateTime(2020, 02, 05), new DateTime(2020, 02, 08), new DateTime(2020, 04, 05), new DateTime(2020, 05, 05), "Fini", c1); Lot l1 = new Lot(1, new DateTime(2020, 05, 02), new DateTime(2020, 02, 08), new DateTime(2020, 04, 05), new DateTime(2020, 05, 05), "Fini", p1, new List <Tache>() { t1, t2 }); p1.LesLot = new List <Lot>() { l1 }; p1.LesTacheRestantARealiser = new List <Tache>() { t1, t2 }; foreach (Projet projet in Projet.CollClasseProjet) { cbbProjet.Items.Add(projet.IntituleProjet); } }
public ActionResult Index(CongesViewModel vm) { IDal dal = new Dal(); Collaborateur col = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); vm._Collaborateur = col; System.Diagnostics.Debug.WriteLine(vm._Collaborateur.Nom); string txt = "Service : " + vm._Collaborateur.Service.Nom + "\n"; Message notif = new Message { Titre = "Demande de validation congé", Date = DateTime.Now, Contenu = txt }; if (HttpContext.User.Identity.IsAuthenticated) { dal.AjoutNotif(col.Service.Chef().Id, notif); dal.AjoutConge(col.Id, vm._Conge); dal.EnvoiCongeChef(col.Service.Id, col.Id, vm._Conge.Id); } return(View(vm)); }
public ActionResult ValiderLigne(int Id) { Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); System.Diagnostics.Debug.WriteLine("Valider la ligne" + Id); LigneDeFrais ligne = dal.bdd.LigneDeFrais.FirstOrDefault(l => l.Id == Id); Collaborateur col = dal.bdd.Collaborateurs.FirstOrDefault(co => co.Id == ligne.IdCollab); System.Diagnostics.Debug.WriteLine("Ligne du collaborateur " + col.Nom + " " + col.Prenom + " du service " + col.Service.Nom + " et chef ? " + col.Chef); if ((col.Service.Type == TypeService.Comptabilité || col.Service.Type == TypeService.RessourcesHumaines) && col.Chef) { dal.ChangerStatutLigneDeFrais(Id, StatutLigneDeFrais.Validée); } else { dal.ChangerStatutLigneDeFrais(Id, StatutLigneDeFrais.ValidéeChef); } dal.AjoutNotif(ligne.IdCollab, new Message(TypeMessage.NotifLigneRetour, c, ligne, false)); foreach (NoteDeFrais n in col.NotesDeFrais) { if (n.LignesDeFrais.Contains(ligne)) { if (n.EstValidéeParLeChef()) { System.Diagnostics.Debug.WriteLine("Envoi de la note, elle est bien validée par le chef" + Id); dal.EnvoiNoteDeFrais(col.Service.Id, col.Id, n.Id); dal.EnleverNoteDeFraisDuService(n.Id, c.Service.Id); return(Json(null, JsonRequestBehavior.AllowGet)); } else { return(null); } } } //dal.ValiderConge(c.Id, new Message { Titre = "Validation de Note", Date = DateTime.Now, Contenu = "Une Ligne de frais a été validée par le chef de service"}) return(null); }
public ProjetForfait(int co, string n, DateTime dDebP, DateTime dFinP, Client client, string cont, string ml, decimal montContract, bool ouinon, Collaborateur collaborateur, List<Prevision> list) { this.CodeProjet = co; this.NomProjet = n; this.DDebut = dDebP; this.DFin = dFinP; this.LeClient = client; this.Contact = cont; this.MailContact = ml; this.MontantContrat = montContract; this.ChefDeProjet = collaborateur; this.prevision = list; if (ouinon) { PenaliteOuiNon = Penalite.Oui; } else { PenaliteOuiNon = Penalite.Non; } }
public static Collaborateur retrouverCollaborateurDAO(Int32 leMatricule) { if (DonneesDAO.DbContextCollaborateur == null) { DonneesDAO.DbContextCollaborateur = new CollaborateursEntityContainer(); } var query = from C in DonneesDAO.DbContextCollaborateur.CollaborateursSet where C.matricule == leMatricule select C; Collaborateur unCollaborateur; foreach (Collaborateurs item in query) { unCollaborateur = new Collaborateur(item.matricule, item.Civilite, item.SituationMaritale, item.Nom, item.Prenom, item.Rue, item.Ville, item.CodePostal, item.Augmentation, item.Telephone, item.Photo); return(unCollaborateur); } throw new Exception("le collaborateur n'existe pas"); }
public Collaborateur Add(Collaborateur collaborateur) { try { using (IDbConnection dbConnection = Connection) { string sQuery = @"INSERT INTO F_COLLABORATEUR ( CO_Nom , CO_Prenom , CO_Fonction , CO_Adresse , CO_CodePostal , CO_Ville , CO_Service , CO_Telephone , CO_EMail , CO_Matricule , CO_Type ) VALUES ( @Nom, @Prenom,@Fonction,@Adresse,@CodePostal, @Ville,@Service,@Telephone,@EMail,@Matricule,@Type)"; dbConnection.Open(); dbConnection.Execute(sQuery, collaborateur); } } catch (Exception) { return(null); } return(collaborateur); }
public static List <Collaborateur> GetAllCollaborateurs() { using (SqlConnection sqlConnect = GetConnection()) { using (SqlCommand sqlCde = new SqlCommand()) { sqlCde.Connection = sqlConnect; string strsql = "Select [idColl],[idQualif],[nomColl],[prenomColl],[dEmbauche],[prJournalier]From Collaborateur"; try { sqlCde.CommandText = strsql; SqlDataReader sqlRdr = sqlCde.ExecuteReader(); Collaborateurs = new List <Collaborateur>(); while (sqlRdr.Read()) { Collaborateur colla = new Collaborateur() { CodeColl = sqlRdr.GetInt32(0), LaQualif = new Qualification() { CodeQualif = (sbyte)sqlRdr.GetByte(1) }, Nom = sqlRdr.GetString(2), Prenom = sqlRdr.GetString(3), DEmbauche = sqlRdr.GetDateTime(4), PrJournalier = sqlRdr.GetDecimal(5) }; Collaborateurs.Add(colla); } sqlRdr.Close(); return(Collaborateurs); } catch (Exception ex) { throw new DAOException(ex.Message); } } } }
/// <summary> /// Constructor /// Takes a collaborateur as argument /// initialize a new instanciate of the class CollaborateurForm /// Listen to the event EditingCollabo and FormClosing of the collaborateurForm /// instanciate the CtrlListContrat /// </summary> /// <param name="collaborateur"></param> public CtrlDetailCollaborateur(Collaborateur collaborateur) { this.collaborateur = collaborateur; if (!openedFormList.ContainsKey(collaborateur.Id)) { collaborateurForm = new CollaborateurForm(false); collaborateurForm.SetCollaborateur(collaborateur); collaborateurForm.EditingCollabo += new CollaboHandler(this.OnEditedCollabo); collaborateurForm.FormClosing += new FormClosingEventHandler(this.OnClosedForm); collaborateurForm.Size = new System.Drawing.Size(950, 530); collaborateurForm.MdiParent = CtrlMain.GetInstance().GetMainApp(); CtrlListContrat clc = new CtrlListContrat(collaborateur); clc.UpdatinCollabo += new CollaboHandler(this.OnUpdatedCollabo); ContratListForm contratListForm = clc.GetContratListForm(); contratListForm.FormBorderStyle = FormBorderStyle.None; contratListForm.TopLevel = false; contratListForm.AutoScroll = true; contratListForm.Show(); collaborateurForm.panelContrat.Controls.Add(contratListForm); openedFormList.Add(collaborateur.Id, collaborateurForm); } else { this.collaborateurForm = openedFormList[collaborateur.Id]; if (collaborateurForm.WindowState == FormWindowState.Minimized) { collaborateurForm.WindowState = FormWindowState.Normal; } else { collaborateurForm.Activate(); } } }
public Collaborateur Update(Collaborateur collaborateur) { try { using (IDbConnection dbConnection = Connection) { string sQuery = @"update F_COLLABORATEUR set CO_Nom=@Nom, CO_Prenom=@Prenom,CO_Fonction=@Fonction,CO_Adresse=@Adresse, CO_CodePostal=@CodePostal,CO_Ville=@Ville,CO_Service=@Service, CO_Telephone=@Telephone, CO_EMail=@EMail,CO_Matricule=@Matricule,CO_Type=@Type where CO_NO = @Numero"; dbConnection.Open(); dbConnection.Execute(sQuery, collaborateur); } } catch (Exception) { return(null); } return(collaborateur); }
public void ValiderConges(int idConge) { Debug.WriteLine("Pas inutile"); dal.ChangerStatut(idConge, StatutConge.Valide); Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); List <Collaborateur> collabs = dal.ObtenirCollaborateursService(c.Service.Id); int idCollab = 0; foreach (Collaborateur col in collabs) { if (col.Conges.First(con => con.Id == idConge) != null) { idCollab = col.Id; break; } } dal.AjoutNotif(idCollab, new Message(TypeMessage.NotifCongeRetour, c.Prenom + c.Nom + " - " + c.Service.Nom, dal.ObtenirConge(idConge))); foreach (Collaborateur rh in dal.ObtenirCollaborateursService(dal.ObtenirServiceDeType(TypeService.RessourcesHumaines).Id)) { dal.AjoutNotif(rh.Id, new Message(TypeMessage.NotifCongeAller, dal.ObtenirCollaborateur(idCollab).Nom + dal.ObtenirCollaborateur(idCollab).Prenom + " - " + c.Service.Nom, dal.ObtenirConge(idConge))); } }
public ActionResult Conges_ReadRH([DataSourceRequest] DataSourceRequest request) { IDal dal = new Dal(); if (HttpContext.User.Identity.IsAuthenticated) { Collaborateur c = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); List <ValidationCongesViewModel> vm = new List <ValidationCongesViewModel>(); // Cas DRH if (c.Chef) { // Récupérer les demandes du service RH foreach (Collaborateur col in dal.ObtenirCollaborateursService(dal.ObtenirServiceDeType(TypeService.RessourcesHumaines).Id)) { if (col != c) { float[] congesPris = new float[3] { col.GetNombreRTTPrisCetteAnnee(), col.GetNombreSansSoldePrisCetteAnnee(), col.GetNombreAbsencesPrisCetteAnnee() }; foreach (Conge con in col.Conges) { if (con.Statut == StatutConge.EnCours) { vm.Add(new ValidationCongesViewModel { Id = con.Id, Nom = col.Prenom + " " + col.Nom, Service = col.Service.Nom, CongesRestants = col.CongesRestants, CongesPris = congesPris, Debut = con.Debut, Fin = con.Fin }); } } } } // Récupérer les demandes du PDG Collaborateur chef = dal.ObtenirServiceDeType(TypeService.Direction).Chef(); float[] congesPrisChef = new float[3] { chef.GetNombreRTTPrisCetteAnnee(), chef.GetNombreSansSoldePrisCetteAnnee(), chef.GetNombreAbsencesPrisCetteAnnee() }; foreach (Conge con in chef.Conges) { Debug.WriteLine("Statut avant validation : " + con.Type); if (con.Statut == StatutConge.EnCours) { vm.Add(new ValidationCongesViewModel { Id = con.Id, Nom = chef.Prenom + " " + chef.Nom, Service = chef.Service.Nom, CongesRestants = chef.CongesRestants, CongesPris = congesPrisChef, Debut = con.Debut, Fin = con.Fin }); } } } // Récupérer les demandes des collaborateurs et chefs des autres services foreach (Collaborateur col in dal.ObtenirTousLesCollaborateurs()) { if ((col.Service.Type != TypeService.RessourcesHumaines) && ((col != dal.ObtenirPDG()))) { float[] congesPris = new float[3] { col.GetNombreRTTPrisCetteAnnee(), col.GetNombreSansSoldePrisCetteAnnee(), col.GetNombreAbsencesPrisCetteAnnee() }; foreach (Conge con in col.Conges) { if ((con.Statut == StatutConge.ValideChef) || (col.Chef && con.Statut == StatutConge.EnCours)) { vm.Add(new ValidationCongesViewModel { Id = con.Id, Nom = col.Prenom + " " + col.Nom, Service = col.Service.Nom, CongesRestants = col.CongesRestants, CongesPris = congesPris, Debut = con.Debut, Fin = con.Fin }); } } } } IQueryable <ValidationCongesViewModel> demandes = vm.AsQueryable(); DataSourceResult result = demandes.ToDataSourceResult(request, data => new { data.Id, data.Debut, data.Fin, data.Type, data.Nom, data.Service, data.CongesRestants, data.CongesPris }); return(Json(result)); } return(null); }
public string DemandeConge(DateTime Debut, DateTime Fin, string type) { System.Diagnostics.Debug.WriteLine(type); TypeConge typeConge; if (type == "rtt") { typeConge = TypeConge.RTT; } else if (type == "sans") { typeConge = TypeConge.SansSolde; } else if (type == "abs") { typeConge = TypeConge.Absence; } else { return("erreurTypeConge"); } IDal dal = new Dal(); Collaborateur col = dal.ObtenirCollaborateur(HttpContext.User.Identity.Name); Conge conge = new Conge { Debut = Debut, Fin = Fin, Type = TypeConge.RTT }; //System.Diagnostics.Debug.WriteLine(col + " " + conge + " " + Debut+ " " + Fin ); if (conge.Debut <= DateTime.Today.Date) { return("Erreur : Vous demandez un congé dans le passé"); } string txt = "Service : " + col.Nom + "\n"; Message notif = new Message(TypeMessage.NotifCongeAller, col.Prenom + col.Nom + " - " + col.Service.Nom, conge); ValiditeConge validite = col.isCongeValide(conge); if (HttpContext.User.Identity.IsAuthenticated && validite == ValiditeConge.ok) { if (col.Chef) { if (col.Service.Type == TypeService.RessourcesHumaines) { dal.AjoutNotif(dal.ObtenirPDG().Id, notif); } else if (col.Service.Type == TypeService.Direction) { dal.AjoutNotif(dal.ObtenirDRH().Id, notif); } else { foreach (Collaborateur c in dal.ObtenirCollaborateursService(dal.ObtenirServiceDeType(TypeService.RessourcesHumaines).Id)) { dal.AjoutNotif(c.Id, notif); } } } else { dal.AjoutNotif(col.Service.Chef().Id, notif); } dal.AjoutConge(col.Id, conge, typeConge); } return(validite.ToString()); }
/// <summary> /// Constructor /// Initialize a new instance of the class ContraForm /// Listen to the event SavingContrat of the ContratForm /// </summary> /// <param name="collaborateur"></param> public CtrlNewContrat(Collaborateur collaborateur) { this.collaborateur = collaborateur; cf = new ContratForm(); cf.SavingContrat += new ContratHandler(this.OnSavedContrat); }
public static List<Collaborateur> GetAllCollaborateurs() { using (SqlConnection sqlConnect = ConnectSQLServ()) { using (SqlCommand sqlCde = new SqlCommand()) { try { // Ouvre la connection. sqlConnect.Open(); // Création de la commande SqlDataReader sqlRdr; sqlCde.Connection = sqlConnect; // Constitution Requête SQL //string strSql = "Select * from Projet"; //// Positionnement des propriétés //sqlCde.CommandText = strSql; sqlCde.CommandType = System.Data.CommandType.StoredProcedure; sqlCde.CommandText = "GetAllCollaborateur"; // Exécution de la commande sqlRdr = sqlCde.ExecuteReader(); // Lecture des données du DataReader Collaborateurs = new List<Collaborateur>(); while (sqlRdr.Read()) { Collaborateur coll = new Collaborateur() { CodeColl = sqlRdr.GetInt32(0), LaQualif = new Qualification() { CodeQualif = (sbyte)sqlRdr.GetByte(1) }, Nom = sqlRdr.GetString(2), PreNom = sqlRdr.GetString(3), DEmbauche = sqlRdr.GetDateTime(4), PrJournalier = sqlRdr.GetDecimal(5) }; Collaborateurs.Add(coll); } // Fin des données sqlRdr.Close(); return Collaborateurs; } catch (Exception ex) { throw new DaoException("Récupération des collaborateur impossible :" + ex.Message, ex); } finally { sqlConnect.Close(); } } } }