コード例 #1
0
        public async Task <ActionResult <Conge> > PostConge(Conge conge)
        {
            _context.conges.Add(conge);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetConge", new { id = conge.Id }, conge));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("CongeId,Debut,Duree,TypeCongeId,Visible,DossierEmployeId")] Conge conge)
        {
            if (id != conge.CongeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(conge);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CongeExists(conge.CongeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DossierEmployeId"] = new SelectList(_context.DossiersEmploye, "DossierId", "DossierId", conge.DossierEmployeId);
            ViewData["TypeCongeId"]      = new SelectList(_context.TypesConges, "TypeCongeId", "TypeCongeId", conge.TypeCongeId);
            return(View(conge));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,DateDebut,DateFin,PeriodeDebut,PeriodeFin,Commentaire,DateDemande,NomResponsable,PrenomResponsable,Decision,TypeCongeId,CollaborateurId")] Conge conge)
        {
            if (id != conge.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(conge);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CongeExists(conge.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CollaborateurId"] = new SelectList(_context.Collaborateur, "ID", "ID", conge.CollaborateurId);
            ViewData["TypeCongeId"]     = new SelectList(_context.TypeConge, "ID", "ID", conge.TypeCongeId);
            return(View(conge));
        }
コード例 #4
0
        public async Task <IActionResult> PutConge(int id, Conge conge)
        {
            if (id != conge.Id)
            {
                return(BadRequest());
            }

            _context.Entry(conge).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CongeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
        private void RemplirEmploye(Employe emp, string operation)
        {
            try
            {
                this.lbEspaceEmploye.Text = "Employé : (" + emp.CodeEmploye + ") " + emp.Prenom + " " + emp.Nom;

                Conge c = emp.getCongeOuvert();
                if (c != null)
                {
                    //Set code_conge of this Window so we can update RetourEffectif
                    code_conge = c.CodeConge;

                    this.ddlType.SelectedValue = c.Type;
                    this.tbAnnee.Text          = c.AnneeFiscale.ToString();
                    this.tbDebut.Text          = c.Debut.ToString();
                    this.tbRetourPrevu.Text    = c.RetourPrevu.ToString();
                }

                this.dgConge.DataSource = emp.getConges();
                this.dgConge.DataBind();
            }
            catch (Exception ex)
            {
                this.lblFailure.Text = ex.Message;
            }
        }
コード例 #6
0
        public static List <Conge> getConges(string code_employe)
        {
            List <Conge> lCarriere = new List <Conge>();
            Connecteur   ct        = new Connecteur();

            try
            {
                SqlDataAdapter da = new SqlDataAdapter(CongeDAL.selectEmployeConges, ct.Connection);
                da.SelectCommand.Parameters.AddWithValue("@CodeEmploye", code_employe);

                DataTable dt = new DataTable("Conge");

                ct.Connection.Open();
                da.Fill(dt);

                Conge s;

                foreach (DataRow dr in dt.Rows)
                {
                    s = new Conge();
                    CongeDAL.Hydrate(s, dr);
                    lCarriere.Add(s);
                }

                return(lCarriere);
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
コード例 #7
0
        public static void Insert(Conge c)
        {
            Connecteur ct = new Connecteur();

            //Proceed Database Command-------------------------------------
            if (ct.Connection.State == ConnectionState.Closed)
            {
                ct.Connection.Open();
            }

            SqlCommand cmd =
                new SqlCommand(CongeDAL.insertConge, ct.Connection);

            try
            {
                //1 - INSERT Conge
                //Conge Params - Insert
                CongeDAL.setCongeParameters(cmd.Parameters, c);
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception("Error: " + ex.Message + " - Code: " + ex.Number + " - Couche(DAL)");
            }
            finally
            {
                ct.Connection.Close();
            }
        }
コード例 #8
0
 public static void setCongeParameters(SqlParameterCollection pc, Conge c)
 {
     pc.AddWithValue("@CodeEmploye", c.CodeEmploye);
     pc.AddWithValue("@Type", c.Type);
     pc.AddWithValue("@Annee", c.AnneeFiscale);
     pc.AddWithValue("@Debut", c.Debut);
     pc.AddWithValue("@RetourPrevu", c.RetourPrevu);
 }
コード例 #9
0
ファイル: CongesTest.cs プロジェクト: meakitfed/Intranet
        public void TestValidationFinale_OK()
        {
            Conge c = new Conge {
                Debut = new System.DateTime(2019, 2, 15), Fin = new System.DateTime(2019, 2, 17), Type = TypeConge.RTT
            };

            dal.AjoutConge(1, c);
            dal.ValiderConge(1, dal.ObtenirCollaborateur(1).Conges[0].Id);
            Assert.AreEqual(dal.ObtenirCollaborateur(1).Conges[0].Statut, StatutConge.Valide);
            Assert.AreEqual(dal.ObtenirCollaborateur(1).CongesRestants, 10);
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("ID,DateDebut,DateFin,PeriodeDebut,PeriodeFin,Commentaire,DateDemande,NomResponsable,PrenomResponsable,Decision,TypeCongeId,CollaborateurId")] Conge conge)
        {
            if (ModelState.IsValid)
            {
                _context.Add(conge);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(conge));
        }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("CongeId,Debut,Duree,TypeCongeId,Visible,DossierEmployeId")] Conge conge)
        {
            if (ModelState.IsValid)
            {
                _context.Add(conge);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DossierEmployeId"] = new SelectList(_context.DossiersEmploye, "DossierId", "DossierId", conge.DossierEmployeId);
            ViewData["TypeCongeId"]      = new SelectList(_context.TypesConges, "TypeCongeId", "TypeCongeId", conge.TypeCongeId);
            return(View(conge));
        }
コード例 #12
0
        public void Inserer(string code_emp, string type, int annee, string debut, string retour_prevu)
        {
            try
            {
                Conge c = new Conge(code_emp, type, annee, DateTime.Parse(debut), DateTime.Parse(retour_prevu));

                CongeDAL.Insert(c);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " - Couche(APP)");
            }
        }
コード例 #13
0
        private void ControleConge(int operation = 1)
        {
            try
            {
                if (conge == null)
                {
                    conge = new Conge();
                }

                conge.Id          = string.IsNullOrEmpty(TxtIdConge.Text) ? 0 : Convert.ToInt32(TxtIdConge.Text);
                conge.Designation = TxtDesignConge.Text.Trim().ToUpper();
                conge.DateDebut   = TxtDebutConge.Text.Trim().ToUpper();
                conge.DateFin     = TxtFinConge.Text.Trim().ToUpper();

                if (operation == 1 || operation == 2)
                {
                    if (!string.IsNullOrEmpty(TxtDesignConge.Text) && !string.IsNullOrEmpty(TxtDebutConge.Text) &&
                        !string.IsNullOrEmpty(TxtFinConge.Text))
                    {
                        Glossaire.Instance.InsertUpdateConge(conge);
                    }
                    else
                    {
                        MessageBox.Show(this, "Certains champs ne sont pas conformes", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (conge.Id != 0)
                    {
                        if (MessageBox.Show(this, "Voulez-vous vraiment supprimer ?", "Question", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            Glossaire.Instance.Delete("conge", conge.Id);
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Selectionne un élément à supprimer", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Une erreur s'est produite lors de cette opération. \nERREUR : " + ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                ClearFields(2);
                LoadGridControl();
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        private void Button_AddUser(object sender, RoutedEventArgs e)
        {
            using (var db = new GestionContext())
            {
                Utilisateurs user = new Utilisateurs();
                // Création d'un utilisateur
                Console.WriteLine("Création d'un utilisateur");
                user.Nom        = this.TextBoxNom.Text;
                user.Prenom     = this.TextBoxPrenom.Text;
                user.Rue        = this.TextBoxRue.Text;
                user.CodePostal = this.TextBoxCodePostal.Text;
                user.Ville      = this.TextBoxVille.Text;
                user.Pays       = this.TextBoxPays.Text;
                user.Role       = Convert.ToInt32(this.TextBoxRole.Text);

                Conge conge = new Conge();

                //Attribue le nombre de jour de congés et de RTT selon le pays de résidence de l'utilisateur
                switch (user.Pays.ToUpper().ToString())
                {
                case "FRANCE":
                    conge.NbConge = 25;
                    conge.NbRTT   = 10;
                    break;

                case "BELGIQUE":
                    conge.NbConge = 25;
                    conge.NbRTT   = 12;
                    break;

                default:
                    conge.NbConge = 30;
                    conge.NbRTT   = 0;
                    break;
                }

                user.Conge = conge;

                db.Add(user);
                db.SaveChanges();
            }
            ChargerListeUser();
        }
コード例 #16
0
        public Conge UpdateConge(Conge conge, Conge inputConge)
        {
            conge.CongeState = inputConge.CongeState;
            if (conge.CongeState == CongeState.APPROVED)

            {
                var date1     = conge.start_Date;
                var date2     = conge.end_Date;
                var sub       = date2.Subtract(date1);
                int empId     = conge.EmployeeId;
                int remaining = _context.Employees.Where(x => x.Id == conge.EmployeeId).Select(x => x.RemainingCongeSolde).First();
                remaining     = remaining - sub.Days;
                remainingSold = remaining;
            }


            _context.Entry(conge).State = EntityState.Modified;
            _context.SaveChanges();
            return(conge);
        }
コード例 #17
0
        private void GridViewConge_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (conge == null)
                {
                    conge = new Conge();
                }

                conge.Id        = Convert.ToInt32(DgvConge.SelectedRows[0].Cells["id"].Value.ToString());
                TxtIdConge.Text = conge.Id.ToString();

                BtnDeleteConge.Enabled = true;
                BtnEditConge.Enabled   = true;
                BtnSaveConge.Enabled   = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Une erreur s'est produite lors de cette opération. \nERREUR : " + ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #18
0
        public static void Hydrate(Conge c, DataRow dr)
        {
            //Statut Carriere
            c.CodeConge    = (int)dr["CodeConge"];
            c.CodeEmploye  = dr["CodeEmploye"].ToString();
            c.Type         = dr["Type"].ToString();
            c.AnneeFiscale = (int)dr["Annee"];

            if (!dr["Debut"].ToString().Equals(""))
            {
                c.Debut = (DateTime)dr["Debut"];
            }

            if (!dr["RetourPrevu"].ToString().Equals(""))
            {
                c.RetourPrevu = (DateTime)dr["RetourPrevu"];
            }

            if (!dr["RetourEffectif"].ToString().Equals(""))
            {
                c.RetourEffectif = (DateTime)dr["RetourEffectif"];
            }
        }
コード例 #19
0
        private void RemplirEmploye(Employe emp, string operation)
        {
            this.lbEspaceEmploye.Content = operation + " de Congé de l'Employé : (" + emp.CodeEmploye + ") " + emp.Prenom + " " + emp.Nom;
            try
            {
                Conge c = emp.getCongeOuvert();
                if (c != null)
                {
                    //Set code_conge of this Window so we can update RetourEffectif
                    code_conge = c.CodeConge;

                    this.cboType.SelectedValue      = c.Type;
                    this.tbAnnee.Text               = c.AnneeFiscale.ToString();
                    this.dpDebut.SelectedDate       = c.Debut;
                    this.dpRetourPrevu.SelectedDate = c.RetourPrevu;
                }

                this.dgConge.ItemsSource = emp.getConges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #20
0
        /// <summary>
        /// Met à jour l'état en bas pour l'utilisateur
        /// </summary>
        /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param>
        /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param>
        public void MiseAJourEtat(string typeEtat, Conge con)
        {
            //Je racalcul le nombre max d'élements
            this.recalculMax();
            //En fonction de l'action, j'affiche le message
            if (typeEtat == "Filtrage")
            {
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Filtrage des congés terminé : " + this.listConge.Count() + " / " + this.max);
            }
            else if (typeEtat == "Ajout")
            {
                //J'ajoute le congé dans le linsting
                this.listConge.Add(con);
                //Je racalcul le nombre max d'élements après l'ajout
                this.recalculMax();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'un congé effectué avec succès. Nombre d'élements : " + this.listConge.Count() + " / " + this.max);
            }
            else if (typeEtat == "Modification")
            {
                //Je raffraichis mon datagrid
                this._DataGridMain.Items.Refresh();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification du congé effectué avec succès. Nombre d'élements : " + this.listConge.Count() + " / " + this.max);
            }
            else if (typeEtat == "Suppression")
            {
                //Je supprime de mon listing l'élément supprimé
                this.listConge.Remove(con);
                //Je racalcul le nombre max d'élements après la suppression
                this.recalculMax();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Suppression du congé effectué avec succès. Nombre d'élements : " + this.listConge.Count() + " / " + this.max);
            }
            else if (typeEtat == "Look")
            {

            }
            else if (typeEtat == "Reponse")
            {
                //Je raffraichis mon datagrid
                this._DataGridMain.Items.Refresh();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Réponse à un congé effectué avec succès. Nombre d'élements : " + this.listConge.Count() + " / " + this.max);
            }
            else
            {
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Chargement des congés terminé : " + this.listConge.Count() + " / " + this.max);
            }
            //Je retri les données dans le sens par défaut
            this.triDatas();
            //J'arrete la progressbar
            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
        }
コード例 #21
0
        /// <summary>
        /// Ouvre le congé séléctionné en lecture seule à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Conge Look(Conge conge)
        {
            if (this._DataGridMain.SelectedItem != null || conge != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1 || conge != null)
                {
                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'un congé en cours ...");

                    //Création de la fenêtre
                    CongeWindow congeWindow = new CongeWindow();

                    //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée
                    congeWindow.DataContext = new Conge();
                    if (conge != null)
                    {
                        congeWindow.DataContext = conge;
                    }
                    else
                    {
                        congeWindow.DataContext = (Conge)this._DataGridMain.SelectedItem;
                    }

                    //Je positionne la lecture seule sur la fenêtre
                    congeWindow.lectureSeule();
                    congeWindow.soloLecture = true;

                    //J'affiche la fenêtre
                    bool? dialogResult = congeWindow.ShowDialog();

                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'un congé terminé : " + this.listConge.Count() + " / " + this.max);

                    //Renvoi null
                    return null;
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'un seul congé.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner un congé.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
コード例 #22
0
        /// <summary>
        /// Ajoute un nouveau congé à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Conge Add(bool verrouillerSalarie)
        {
            //Affichage du message "ajout en cours"
            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une demande de congé en cours ...");

            //Initialisation de la fenêtre
            CongeWindow congeWindow = new CongeWindow(verrouillerSalarie);

            //Création de l'objet temporaire
            Conge tmp = new Conge();
            tmp.Demande_Fait_Le = DateTime.Today;
            tmp.Utilisateur = ((App)App.Current)._connectedUser;

            //Mise de l'objet temporaire dans le datacontext
            congeWindow.DataContext = tmp;

            //Mise en place d'options spéciales sur la fenêtre
            congeWindow.creation = true;
            congeWindow.demande = true;

            //booléen nullable vrai ou faux ou null
            bool? dialogResult = congeWindow.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                //Si j'appuie sur le bouton Ok, je renvoi l'objet commande se trouvant dans le datacontext de la fenêtre
                return (Conge)congeWindow.DataContext;
            }
            else
            {
                try
                {
                    //On détache le congé
                    ((App)App.Current).mySitaffEntities.Detach((Conge)congeWindow.DataContext);
                }
                catch (Exception) { }

                //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout
                ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                this.recalculMax();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une demande de congé annulé : " + this.listConge.Count() + " / " + this.max);

                return null;
            }
        }
コード例 #23
0
 public Conge CreateConge(Conge conge)
 {
     _context.Conges.Add(conge);
     _context.SaveChanges();
     return(conge);
 }
コード例 #24
0
        public async Task <IActionResult> Apply([Bind("DateDebut, DateFin, CongeTypeID")] Conge conge)
        {
            var viewModel = new CongeFormulaire
            {
                CongeTypes = await _context.CongeTypes
                             .Where(t => t.Label != Types.Absence)
                             .AsNoTracking()
                             .ToListAsync(),

                Conge = conge
            };

            var currentUserId = _userManager.GetUserId(HttpContext.User);

            Dictionary <int, int> yearQuota = new Dictionary <int, int>();

            yearQuota.Add(conge.DateDebut.Year, 0);
            if (conge.DateDebut.Year != conge.DateFin.Year)
            {
                yearQuota.Add(conge.DateFin.Year, 0);
            }

            var conges = await _context.Conges
                         .Where(c => c.CollaborateurID == currentUserId)
                         .Where(c => (c.DateDebut.Year == conge.DateDebut.Year || c.DateDebut.Year == conge.DateFin.Year) || (c.DateFin.Year == conge.DateDebut.Year || c.DateFin.Year == conge.DateFin.Year))
                         .Include(s => s.Statut)
                         .Where(s => s.Statut.Label == Statuts.Accepte || s.Statut.Label == Statuts.Attente)
                         .Include(t => t.CongeType)
                         .Where(t => t.CongeType.Label == Types.Conge)
                         .AsNoTracking()
                         .ToListAsync();

            var congesOwner = await _context.Conges
                              .Where(c => c.CollaborateurID == currentUserId)
                              .Include(s => s.Statut)
                              .Where(s => s.Statut.Label == Statuts.Accepte || s.Statut.Label == Statuts.Attente)
                              .AsNoTracking()
                              .ToListAsync();

            conges.Add(conge);

            foreach (var c in congesOwner)
            {
                if (c.DateDebut <= conge.DateFin && c.DateFin >= conge.DateDebut)
                {
                    ViewData["Error"] = "Vous avez déjà une demande de congé durant cette période !";
                    return(View(viewModel));
                }
            }

            var typeConge = await _context.CongeTypes.SingleAsync(t => t.Label == Types.Conge);

            foreach (var c in conges)
            {
                for (DateTime date = c.DateDebut; date <= c.DateFin; date = date.AddDays(1))
                {
                    if ((date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday) && (yearQuota.ContainsKey(date.Year)))
                    {
                        yearQuota[date.Year] = yearQuota[date.Year] + 1;
                        if (yearQuota[date.Year] > 22 && c.CongeTypeID == typeConge.CongeTypeID)
                        {
                            ViewData["Error"] = "Vous dépassez votre quota pour l'année " + date.Year + " !";
                            return(View(viewModel));
                        }
                    }
                }
            }

            try
            {
                conge.CollaborateurID = currentUserId;

                conge.StatutID = _context.Statuts
                                 .Single(s => s.Label == Statuts.Attente)
                                 .StatutID;

                conge.EnvoiDate = DateTime.Now;

                if (ModelState.IsValid)
                {
                    _context.Add(conge);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Show"));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(viewModel));
        }
コード例 #25
0
 private void EnvoiMailReponseConge(Conge conge)
 {
     if (conge.Accepte != null)
     {
         String message = "Une réponse à été donnée à votre demande de congé des dates suivantes : " + conge.Date_Debut + " - " + conge.Date_Fin + " - " + conge.Nombre_Jours + " jours. Le motif de la demande était : " + conge.Motif_Demande1.Libelle + ". Votre demande a été ";
         if (conge.Accepte == true)
         {
             message = message + "acceptée par " + conge.Utilisateur.Salarie_Interne1.Salarie.Personne.fullname;
         }
         else
         {
             if (conge.Accepte == false)
             {
                 message = message + "refusée par " + conge.Utilisateur.Salarie_Interne1.Salarie.Personne.fullname + ".";
             }
         }
         if (conge.Commentaire != null)
         {
             if (conge.Commentaire != "")
             {
                 message = message + " Un commentaire a été donné à la réponse : " + conge.Commentaire;
             }
         }
         String objet = "Réponse à votre demande de congé par " + conge.Utilisateur.Salarie_Interne1.Salarie.Personne.fullname;
         Mail mail = new Mail();
         if (conge.Salarie1.Personne.EMail != "" || conge.Salarie1.Personne.EMail_Pro != "" || conge.Salarie1.Personne.EMail != null || conge.Salarie1.Personne.EMail_Pro != null)
         {
             if (conge.Salarie1.Personne.EMail_Pro != null && conge.Salarie1.Personne.EMail_Pro != "")
             {
                 mail.EnvoiMessage(conge.Salarie1.Personne.EMail_Pro, null, message, objet);
             }
             else
             {
                 if (conge.Salarie1.Personne.EMail != null && conge.Salarie1.Personne.EMail != "")
                 {
                     mail.EnvoiMessage(conge.Salarie1.Personne.EMail, null, message, objet);
                 }
             }
         }
     }
 }
コード例 #26
0
 private void EnvoiMailAuxRepondeursConge(Conge conge)
 {
     //Envoi des mails aux répondeurs
     foreach (Salarie_Repondeur sr in conge.Salarie1.Salarie_Repondeur)
     {
         String message = "Une demande de congé a été demandée par " + conge.Salarie1.Personne.fullname + ". La demande est pour les dates suivantes : " + conge.Date_Debut + " - " + conge.Date_Fin + " - " + conge.Nombre_Jours + " jours. Le motif de la demande est le suivant : " + conge.Motif_Demande1.Libelle + ". Commentaire de cette demande : '" + conge.Observation + "'. Merci d'y répondre au plus vite.";
         String objet = "Demande de congé de la part de : " + conge.Salarie1.Personne.fullname;
         Mail mail = new Mail();
         if (sr.Salarie2.Personne.EMail != null || sr.Salarie2.Personne.EMail_Pro != null)
         {
             if (sr.Salarie2.Personne.EMail_Pro != null && sr.Salarie2.Personne.EMail_Pro != "")
             {
                 mail.EnvoiMessage(sr.Salarie2.Personne.EMail_Pro, null, message, objet);
             }
             else
             {
                 if (sr.Salarie2.Personne.EMail != null && sr.Salarie2.Personne.EMail != "")
                 {
                     mail.EnvoiMessage(sr.Salarie2.Personne.EMail, null, message, objet);
                 }
             }
         }
         if (conge.Salarie1.Personne.EMail == null && conge.Salarie1.Personne.EMail_Pro == null)
         {
             mail.EnvoiMessage("*****@*****.**", null, "Le personne " + conge.Salarie1.Personne.fullname + " n'a pas d'e-mail renseigné dans sa fiche salarié. Pensez à lui faire part de votre réponse ou à renseigner son adresse e-mail afin qu'il reçoive sa réponse de congé.", "Manque adresse e-mail");
         }
     }
     //Envoi d'un mail à la personne si la personne qui a demandée n'est pas la personne du congé
     if (conge.Utilisateur.Salarie_Interne1.Salarie != conge.Salarie1)
     {
         String message = "Une demande de congé a été demandée par " + conge.Utilisateur.Salarie_Interne1.Salarie.Personne.fullname + " pour vous pour les dates suivantes : " + conge.Date_Debut + " - " + conge.Date_Fin + " - " + conge.Nombre_Jours + " jours. Le motif de la demande est le suivant : " + conge.Motif_Demande1.Libelle + ". Commentaire de cette demande : '" + conge.Observation + "'. Si cette demande est exacte et provient bien d'une demande de votre part à cette personne, votre demande sera répondue au plus vite. Si seulement ce n'est pas le cas et que cette demande est une erreur, envoyez un e-mail au plus vite à M. Jean-Loup Esnault et à la personne qui a fait la demande pour vous dans les 3 jours ouvrés.";
         String objet = "Demande de congé de la part de : " + conge.Utilisateur.Salarie_Interne1.Salarie.Personne.fullname + "pour vous";
         Mail mail = new Mail();
         if (conge.Salarie1.Personne.EMail_Pro != null && conge.Salarie1.Personne.EMail_Pro != "")
         {
             mail.EnvoiMessage(conge.Salarie1.Personne.EMail_Pro, null, message, objet);
             if (conge.Salarie1.Personne.EMail == null && conge.Salarie1.Personne.EMail_Pro == null)
             {
                 mail.EnvoiMessage(conge.Salarie1.Personne.EMail_Pro, null, "Le personne pour qui vous venez de faire une demande de congé " + conge.Salarie1.Personne.fullname + " n'a pas d'e-mail renseigné dans sa fiche salarié. Pensez à lui faire part de votre réponse ou à renseigner son adresse e-mail afin qu'il reçoive sa réponse de congé.", "Manque adresse e-mail");
             }
         }
         else
         {
             if (conge.Salarie1.Personne.EMail != null && conge.Salarie1.Personne.EMail != "")
             {
                 mail.EnvoiMessage(conge.Salarie1.Personne.EMail, null, message, objet);
                 if (conge.Salarie1.Personne.EMail == null && conge.Salarie1.Personne.EMail_Pro == null)
                 {
                     mail.EnvoiMessage(conge.Salarie1.Personne.EMail, null, "Le personne pour qui vous venez de faire une demande de congé " + conge.Salarie1.Personne.fullname + " n'a pas d'e-mail renseigné dans sa fiche salarié. Pensez à lui faire part de votre réponse ou à renseigner son adresse e-mail afin qu'il reçoive sa réponse de congé.", "Manque adresse e-mail");
                 }
             }
         }
     }
 }
コード例 #27
0
        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());
        }
コード例 #28
0
        public static void Initialize(MyCompanyContext context, UserManager <User> userManager, RoleManager <IdentityRole> roleManager)
        {
            if (context.Members.Any())
            {
                return;
            }

            CreateRoles(roleManager);
            context.SaveChanges();

            var equipes = new Equipe[]
            {
                new Equipe {
                    Label = "Infrastructure"
                },
                new Equipe {
                    Label = "Developpement"
                }
            };

            for (int i = 0; i < equipes.Length; i++)
            {
                context.Equipes.Add(equipes[i]);
            }
            context.SaveChanges();

            var specialites = new Specialite[]
            {
                new Specialite {
                    Label = "OS", EquipeID = equipes.Single(e => e.Label == "Infrastructure").EquipeID
                },
                new Specialite {
                    Label = "Reseau", EquipeID = equipes.Single(e => e.Label == "Infrastructure").EquipeID
                },
                new Specialite {
                    Label = "Securite", EquipeID = equipes.Single(e => e.Label == "Infrastructure").EquipeID
                },
                new Specialite {
                    Label = "Web", EquipeID = equipes.Single(e => e.Label == "Developpement").EquipeID
                },
                new Specialite {
                    Label = "Mainframe", EquipeID = equipes.Single(e => e.Label == "Developpement").EquipeID
                },
                new Specialite {
                    Label = "Client lourd", EquipeID = equipes.Single(e => e.Label == "Developpement").EquipeID
                }
            };

            foreach (Specialite s in specialites)
            {
                context.Specialites.Add(s);
            }
            context.SaveChanges();

            CreateDirecteur(userManager);
            context.SaveChanges();

            CreateResponsables(userManager, equipes);
            context.SaveChanges();

            CreateCollaborateur(userManager, equipes, specialites);
            context.SaveChanges();

            var congesTypes = new CongeType[]
            {
                new CongeType {
                    Label = Types.Absence
                },
                new CongeType {
                    Label = Types.Conge
                },
                new CongeType {
                    Label = Types.Maladie
                }
            };

            foreach (CongeType t in congesTypes)
            {
                context.CongeTypes.Add(t);
            }
            context.SaveChanges();

            var statuts = new Statut[]
            {
                new Statut {
                    Label = Statuts.Accepte
                },
                new Statut {
                    Label = Statuts.Attente
                },
                new Statut {
                    Label = Statuts.Refuse
                },
                new Statut {
                    Label = Statuts.Suppression
                }
            };

            foreach (Statut s in statuts)
            {
                context.Statuts.Add(s);
            }
            context.SaveChanges();

            var colla1 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla2 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla3 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla4 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla5 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla6 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla7 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla8 = userManager.FindByNameAsync("*****@*****.**").Result;
            var colla9 = userManager.FindByNameAsync("*****@*****.**").Result;

            var conges = new Conge[]
            {
                // CONGES PORTANT SUR UN JOUR
                new Conge {
                    EnvoiDate = DateTime.Parse("15/05/2019"), DateDebut = DateTime.Parse("26/07/2019"), DateFin = DateTime.Parse("26/07/2019"), CollaborateurID = colla1.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("20/04/2019"), DateDebut = DateTime.Parse("26/07/2019"), DateFin = DateTime.Parse("26/07/2019"), CollaborateurID = colla2.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("03/05/2019"), DateDebut = DateTime.Parse("26/07/2019"), DateFin = DateTime.Parse("26/07/2019"), CollaborateurID = colla3.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                // DEMANDES DE CONGES REFUSEES
                new Conge {
                    EnvoiDate = DateTime.Parse("17/05/2019"), DateDebut = DateTime.Parse("15/07/2019"), DateFin = DateTime.Parse("20/07/2019"), CollaborateurID = colla4.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Refuse).StatutID, Commentaire = "Wow, tu prends un peu trop de congé à mon gout, tu vas te calmer tout de suite mon p'tit gars !"
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("12/05/2019"), DateDebut = DateTime.Parse("21/11/2019"), DateFin = DateTime.Parse("02/12/2019"), CollaborateurID = colla2.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Refuse).StatutID, Commentaire = "Trop d'absences pendant cette période."
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("10/05/2019"), DateDebut = DateTime.Parse("04/10/2019"), DateFin = DateTime.Parse("14/10/2019"), CollaborateurID = colla5.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Refuse).StatutID, Commentaire = "Pas d'inspiration, ton congé est refusé !"
                },
                // DEMANDES DE CONGES EN ATTENTE
                new Conge {
                    EnvoiDate = DateTime.Parse("20/05/2019"), DateDebut = DateTime.Parse("12/09/2019"), DateFin = DateTime.Parse("16/09/2019"), CollaborateurID = colla4.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("18/05/2019"), DateDebut = DateTime.Parse("15/09/2019"), DateFin = DateTime.Parse("20/09/2019"), CollaborateurID = colla6.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("26/04/2019"), DateDebut = DateTime.Parse("03/08/2019"), DateFin = DateTime.Parse("13/08/2019"), CollaborateurID = colla7.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                // DEMANDES DE CONGES PORTANT SUR 15 JOURS
                new Conge {
                    EnvoiDate = DateTime.Parse("11/05/2019"), DateDebut = DateTime.Parse("15/10/2019"), DateFin = DateTime.Parse("29/10/2019"), CollaborateurID = colla5.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("09/05/2019"), DateDebut = DateTime.Parse("01/09/2019"), DateFin = DateTime.Parse("15/09/2019"), CollaborateurID = colla1.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                // ABSENCES MALADIE
                new Conge {
                    EnvoiDate = DateTime.Parse("20/05/2019"), DateDebut = DateTime.Parse("27/06/2019"), DateFin = DateTime.Parse("28/06/2019"), CollaborateurID = colla7.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("21/05/2019"), DateDebut = DateTime.Parse("01/07/2019"), DateFin = DateTime.Parse("01/07/2019"), CollaborateurID = colla1.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("22/05/2019"), DateDebut = DateTime.Parse("01/07/2019"), DateFin = DateTime.Parse("05/07/2019"), CollaborateurID = colla3.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("23/05/2019"), DateDebut = DateTime.Parse("02/07/2019"), DateFin = DateTime.Parse("03/07/2019"), CollaborateurID = colla6.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                // CONGES ACCEPTES ET PASSES
                new Conge {
                    EnvoiDate = DateTime.Parse("20/03/2019"), DateDebut = DateTime.Parse("02/04/2019"), DateFin = DateTime.Parse("10/04/2019"), CollaborateurID = colla1.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("14/02/2019"), DateDebut = DateTime.Parse("20/03/2019"), DateFin = DateTime.Parse("25/03/2019"), CollaborateurID = colla7.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                // CREATION D'UN CONFLIT
                new Conge {
                    EnvoiDate = DateTime.Parse("20/05/2019"), DateDebut = DateTime.Parse("02/01/2020"), DateFin = DateTime.Parse("20/01/2020"), CollaborateurID = colla2.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Attente).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("20/05/2019"), DateDebut = DateTime.Parse("15/01/2020"), DateFin = DateTime.Parse("20/01/2020"), CollaborateurID = colla8.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Conge).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                },
                new Conge {
                    EnvoiDate = DateTime.Parse("20/05/2019"), DateDebut = DateTime.Parse("25/12/2019"), DateFin = DateTime.Parse("15/01/2020"), CollaborateurID = colla9.Id, CongeTypeID = congesTypes.Single(t => t.Label == Types.Maladie).CongeTypeID, StatutID = statuts.Single(s => s.Label == Statuts.Accepte).StatutID
                }
            };

            foreach (Conge c in conges)
            {
                context.Conges.Add(c);
            }
            context.SaveChanges();
        }