示例#1
0
        public void AjoutNoteDeFrais(int year, int idCollab, int month)
        {
            Collaborateur c = bdd.Collaborateurs.FirstOrDefault(collab => collab.Id == idCollab);

            if (c != null)
            {
                NoteDeFrais n = new NoteDeFrais {
                    Date = new DateTime(year, month, 1), Statut = StatutNote.Brouillon, Actif = false, typeDuService = c.Service.Type
                };
                c.NotesDeFrais.Add(n);
                bdd.NotesDeFrais.Add(n);
                bdd.SaveChanges();
            }
        }
示例#2
0
文件: Dal.cs 项目: meakitfed/Intranet
        public void EnvoiCongeChef(int idService, int idCollab, int idConge)
        {
            Collaborateur c = bdd.Collaborateurs.FirstOrDefault(col => col.Id == idCollab);
            Service       s = bdd.Services.FirstOrDefault(serv => serv.Id == idService);
            Conge         l = bdd.Conges.FirstOrDefault(conge => conge.Id == idConge);

            if (c != null && s != null && l != null)
            {
                List <Conge> liste = bdd.Services.FirstOrDefault(serv => serv.Id == idService).Conges;
                liste.Add(l);
                bdd.Services.FirstOrDefault(serv => serv.Id == idService).Conges.Add(l);
                bdd.SaveChanges();
            }
        }
示例#3
0
        public List <Collaborateur> getChefRhEtCompta()
        {
            List <Collaborateur> l      = new List <Collaborateur>();
            Collaborateur        compta = bdd.Collaborateurs.FirstOrDefault(c => (c.Service.Type == TypeService.Comptabilité && c.Chef == true));

            if (compta != null)
            {
                l.Add(compta);
            }
            Collaborateur rh = bdd.Collaborateurs.FirstOrDefault(c => (c.Service.Type == TypeService.RessourcesHumaines && c.Chef == true));

            if (compta != null)
            {
                l.Add(rh);
            }
            return(l);
        }
示例#4
0
文件: Dal.cs 项目: meakitfed/Intranet
        public void AjoutLigneDeFrais(int idCollab, int idNote, LigneDeFrais ligne)
        {
            Collaborateur c = bdd.Collaborateurs.FirstOrDefault(collab => collab.Id == idCollab);

            if (c != null)
            {
                NoteDeFrais note = c.NotesDeFrais.FirstOrDefault(n => n.Id == idNote);
                if (note != null)
                {
                    //ligne.Note = note;

                    note.LignesDeFrais.Add(ligne);
                    bdd.LigneDeFrais.Add(ligne);
                    System.Diagnostics.Debug.WriteLine("Création ligne de frais dans la BDD");
                    bdd.SaveChanges();
                }
            }
        }
示例#5
0
 public void SetRedirectionAller(Collaborateur c, NoteDeFrais n)
 {
     if (n.Statut == StatutNote.EnAttenteDeValidation)
     {
         if (c.Service.Type == TypeService.Direction)
         {
             Redirection = "/Compta/Index";
         }
         else if (c.Service.Type == TypeService.Comptabilité)
         {
             if (c.Chef)
             {
                 //TODO CHanger maybe ? Le PDG a peut-être une interface unique ?
                 Redirection = "/ChefDeService/Index";
             }
             else
             {
                 Redirection = "/ChefDeService/Index";
             }
         }
         else
         {
             if (c.Chef)
             {
                 Redirection = "/Compta/Index";
             }
             else
             {
                 Redirection = "/ChefDeService/Index";
             }
         }
     }
     else if (n.Statut == StatutNote.ValidéeParLeChef)
     {
         Redirection = "/Compta/Index";
     }
 }
示例#6
0
        public Message(TypeMessage t, Collaborateur c, NoteDeFrais n)
        {
            Type     = t;
            Emetteur = c.Prenom + c.Nom + " - " + c.Service.Nom;
            //Date = DateTime.Now;
            Lu = false;
            switch (t)
            {
            case TypeMessage.NotifNoteAller:
                Titre   = "Demande de validation de note de frais";
                Contenu = "";
                SetRedirectionAller(c, n);
                break;

            case TypeMessage.NotifNoteRetour:
                Titre       = "Validation de votre note de frais";
                Contenu     = n.Date.ToString("Y");
                Redirection = "/NoteDeFrais/Index";
                break;

            default:
                throw new HttpUnhandledException();
            }
        }
示例#7
0
文件: Dal.cs 项目: meakitfed/Intranet
        public void InitializeBdd()
        {
            try
            {
                Collaborateur nathan = new Collaborateur {
                    Mail = "*****@*****.**", Nom = "bonnard", Prenom = "nathan", MotDePasse = EncodeMD5("mdp")
                };
                nathan.LastUpdate = new DateTime(2018, 1, 1);
                Collaborateur brian = new Collaborateur {
                    Mail = "*****@*****.**", Nom = "Martin", Prenom = "Brian", MotDePasse = EncodeMD5("admin"), Admin = true, CongesRestants = 12
                };
                brian.LastUpdate = new DateTime(2017, 1, 1);
                Collaborateur didier = new Collaborateur {
                    Mail = "*****@*****.**", Nom = "Degroote", Prenom = "Didier", MotDePasse = EncodeMD5("dede"), Chef = true, CongesRestants = 12
                };
                Collaborateur isabelle = new Collaborateur {
                    Mail = "*****@*****.**", Nom = "Soun", Prenom = "Isabelle", MotDePasse = EncodeMD5("isa"), Chef = true
                };

                Service compta = new Service {
                    Nom = "Comptabilité", Collaborateurs = { didier }, Type = TypeService.Comptabilité
                };
                Service rh = new Service {
                    Nom = "RH", Type = TypeService.RessourcesHumaines
                };
                Service marketing = new Service {
                    Nom = "Marketing", Type = TypeService.ServiceLambda
                };

                didier.Service   = compta;
                isabelle.Service = rh;
                nathan.Service   = marketing;
                brian.Service    = marketing;
                brian.Chef       = true;

                List <Service> services = new List <Service>
                {
                    compta,
                    rh,
                    marketing
                };
                List <Collaborateur> collabos = new List <Collaborateur>
                {
                    nathan,
                    brian,
                    didier,
                    isabelle
                };

                Random         r             = new Random();
                List <Mission> Missions      = new List <Mission>();
                string[]       labelsMission = { "Chantier Paris", "Parking Velizy", "Publicité", "Démarchage" };
                for (int j = 0; j < labelsMission.Length; j++)
                {
                    int rand = r.Next(0, labelsMission.Length);
                    Missions.Add(new Mission {
                        Nom = labelsMission[rand], Service = compta, Statut = StatutMission.EnCours
                    });
                }

                foreach (Mission m in Missions)
                {
                    nathan.Missions.Add(m);
                    //brian.Missions.Add(m);
                    bdd.Missions.Add(m);
                }

                foreach (Service s in services)
                {
                    bdd.Services.Add(s);
                }
                foreach (Collaborateur c in collabos)
                {
                    bdd.Collaborateurs.Add(c);
                }

                bdd.SaveChanges();

                MiseAJourNotesDeFrais(nathan.Id);
                string[] labelsLigne = { "Restaurant", "Taxi", "Avion", "Péage", "Essence" };
                foreach (NoteDeFrais n in nathan.NotesDeFrais)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        int rand  = r.Next(0, labelsLigne.Length);
                        int rand2 = r.Next(0, Missions.Count);
                        AjoutLigneDeFrais(nathan.Id, n.Id, new LigneDeFrais {
                            Nom = labelsLigne[rand], Complete = true, Mission = Missions[rand2], Somme = rand * rand2 * 5, Statut = (n.Actif ? StatutLigneDeFrais.EnAttente : StatutLigneDeFrais.Validée), Date = DateTime.Now
                        });
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Value: \"{1}\", Error: \"{2}\"",
                                                           ve.PropertyName,
                                                           eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName),
                                                           ve.ErrorMessage);
                    }
                }
                //throw;
            }
        }
示例#8
0
        public void InitializeBdd()
        {
            try
            {
                //création collaborateurs
                Collaborateur nathan = AjoutCollaborateur("Bonnard", "Nathan", "*****@*****.**", "mdp", "06 06 12 09 11");
                Collaborateur brian  = AjoutCollaborateur("Martin", "Brian", "*****@*****.**", "admin", "07 06 12 09 83", admin: true);

                Collaborateur didier   = AjoutCollaborateur("Degroote", "Didier", "*****@*****.**", "dede", "06 54 12 09 83");
                Collaborateur coco     = AjoutCollaborateur("Manscour", "Corentin", "*****@*****.**", "coco", "07 06 06 06 06");
                Collaborateur isabelle = AjoutCollaborateur("Soun", "Isabelle", "*****@*****.**", "isa", "07 06 12 09 83");
                Collaborateur marie    = AjoutCollaborateur("Henriot", "Marie-Christine", "*****@*****.**", "mch", "06 13 63 32 18");
                Collaborateur jean     = AjoutCollaborateur("Monrant", "Jean", "*****@*****.**", "mdp", "06 28 15 32 25");
                Collaborateur luc      = AjoutCollaborateur("Baton", "Luc", "*****@*****.**", "mdp", "06 13 47 32 89");
                Collaborateur john     = AjoutCollaborateur("Licencié", "John", "*****@*****.**", "mdp", "06 65 54 54 54");
                Collaborateur jeanne   = AjoutCollaborateur("Jean", "Jeanne", "*****@*****.**", "jeanne", "06 65 54 54 54");

                //création services
                Service direction = AjoutService("Direction", TypeService.Direction);
                AssignerService(direction.Id, marie.Id);
                AssignerChefDeService(marie.Id);

                Service compta = AjoutService("Comptabilité", TypeService.Comptabilité);
                AssignerService(compta.Id, didier.Id);
                AssignerService(compta.Id, coco.Id);
                AssignerService(compta.Id, luc.Id);
                AssignerService(compta.Id, jean.Id);
                AssignerChefDeService(didier.Id);

                Service rh = AjoutService("Ressource Humaines", TypeService.RessourcesHumaines);
                AssignerService(rh.Id, isabelle.Id);
                AssignerChefDeService(isabelle.Id);
                AssignerService(rh.Id, john.Id);
                AssignerService(rh.Id, jeanne.Id);

                string Demande =
                    "Bonjour, \n" +
                    "J'ai des inquiétudes pour ce qui est du projet Parking Velizy, je n'ai toujours pas de nouvelles de l'agent commercial\n" +
                    "Serait-il possible de prendre contact par un autre biais ?\n" +
                    "Merci d'avance,\n" +
                    "Nathan.\n";
                EnvoiDemandeInformation(new Message {
                    Contenu = (Demande), Emetteur = "Nathan Bonnard - Marketing", Titre = "Problème Parking Velizy"
                });

                Service marketing = AjoutService("Marketing");
                AssignerService(marketing.Id, nathan.Id);
                AssignerService(marketing.Id, brian.Id);
                AssignerChefDeService(brian.Id);

                //??
                MiseAJourNotesDeFrais(nathan.Id);
                MiseAJourNotesDeFrais(brian.Id);
                MiseAJourNotesDeFrais(didier.Id);
                MiseAJourNotesDeFrais(isabelle.Id);
                MiseAJourNotesDeFrais(marie.Id);
                MiseAJourNotesDeFrais(coco.Id);
                MiseAJourNotesDeFrais(jean.Id);
                MiseAJourNotesDeFrais(luc.Id);
                MiseAJourNotesDeFrais(john.Id);
                MiseAJourNotesDeFrais(jeanne.Id);

                //tout le monde se voit assigner toutes les missions
                List <Mission> Missions      = new List <Mission>();
                string[]       labelsMission = { "Chantier Paris", "Parking Velizy", "Publicité", "R&D" };
                for (int j = 0; j < labelsMission.Length; j++)
                {
                    Mission m = AjoutMission(labelsMission[j], compta.Id);
                    AssignerMission(m.Id, nathan.Id);
                    AssignerMission(m.Id, brian.Id);
                    AssignerMission(m.Id, didier.Id);
                    AssignerMission(m.Id, isabelle.Id);
                    AssignerMission(m.Id, marie.Id);
                    AssignerMission(m.Id, coco.Id);
                }
                Mission edm = AjoutMission("Etude de marché", marketing.Id);
                Mission es  = AjoutMission("Enquête satisfaction", marketing.Id);
                AssignerMission(edm.Id, brian.Id);
                AssignerMission(edm.Id, nathan.Id);
                AssignerMission(es.Id, brian.Id);


                //Gestion congé
                AjoutConge(brian.Id, new Conge {
                    Debut = new DateTime(2019, 10, 2), Fin = new DateTime(2019, 10, 10), Statut = StatutConge.EnCours, Type = TypeConge.RTT
                });
                AjoutConge(nathan.Id, new Conge {
                    Debut = new DateTime(2019, 10, 3), Fin = new DateTime(2019, 10, 10), Statut = StatutConge.EnCours, Type = TypeConge.RTT
                });
                AjoutConge(nathan.Id, new Conge {
                    Debut = new DateTime(2019, 10, 6), Fin = new DateTime(2019, 10, 10), Statut = StatutConge.EnCours, Type = TypeConge.RTT
                });
                AjoutConge(brian.Id, new Conge {
                    Debut = new DateTime(2019, 10, 4), Fin = new DateTime(2019, 10, 10), Statut = StatutConge.EnCours, Type = TypeConge.RTT
                });
                AjoutConge(brian.Id, new Conge {
                    Debut = new DateTime(2019, 10, 5), Fin = new DateTime(2019, 10, 10), Statut = StatutConge.EnCours, Type = TypeConge.RTT
                });
                AjoutConge(nathan.Id, new Conge {
                    Debut = new DateTime(2019, 3, 12), Fin = new DateTime(2019, 3, 15), Statut = StatutConge.Refuse, Type = TypeConge.RTT
                });
                AjoutConge(nathan.Id, new Conge {
                    Debut = new DateTime(2019, 3, 1), Fin = new DateTime(2019, 3, 2), Statut = StatutConge.Valide, Type = TypeConge.RTT
                });

                SupprimerCollaborateur(john.Id);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Value: \"{1}\", Error: \"{2}\"",
                                                           ve.PropertyName,
                                                           eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName),
                                                           ve.ErrorMessage);
                    }
                }
                //throw;
            }
        }
示例#9
0
        public void EnvoiNoteDeFrais(int idService, int idCollab, int idNote)
        {
            Collaborateur c = bdd.Collaborateurs.FirstOrDefault(col => col.Id == idCollab);
            Service       s = bdd.Services.FirstOrDefault(serv => serv.Id == idService);
            NoteDeFrais   n = bdd.NotesDeFrais.FirstOrDefault(note => note.Id == idNote);

            if (c != null && s != null && n != null)
            {
                switch (n.Statut)
                {
                case StatutNote.Brouillon:
                    n.Statut = StatutNote.EnAttenteDeValidation;
                    if (c.Service.Type == TypeService.Direction)
                    {
                        //Cas PDG
                        Collaborateur directeurFinancier = ObtenirDirecteurFinancier();
                        AjoutNotif(directeurFinancier.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                        directeurFinancier.Service.NotesDeFrais.Add(n);
                    }
                    else if (c.Service.Type == TypeService.Comptabilité)
                    {
                        if (c.Chef)
                        {
                            Collaborateur pdg = ObtenirPDG();
                            AjoutNotif(pdg.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                            pdg.Service.NotesDeFrais.Add(n);
                            //Cas chef de service compta
                        }
                        else
                        {
                            Collaborateur comptaChef = c.Service.Chef();
                            AjoutNotif(comptaChef.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                            comptaChef.Service.NotesDeFrais.Add(n);
                            //Cas collab compta
                        }
                    }
                    else
                    {
                        if (c.Chef)
                        {
                            Service compta = bdd.Services.FirstOrDefault(serv => serv.Type == TypeService.Comptabilité);
                            //TODO envoyer notif à tout le service compta ?
                            //Collaborateur pdg = ObtenirPDG();
                            //AjoutNotif(pdg.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                            compta.NotesDeFrais.Add(n);
                            //Cas chef de service d'un autre service
                        }
                        else
                        {
                            Collaborateur chef = c.Service.Chef();
                            AjoutNotif(chef.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                            chef.Service.NotesDeFrais.Add(n);
                            //Cas collab d'un autre service
                        }
                    }
                    break;

                case StatutNote.EnAttenteDeValidation:
                    if (c.Service.Type == TypeService.Direction)
                    {
                        n.Statut = StatutNote.Validée;
                        AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                        //Cas PDG
                    }
                    else if (c.Service.Type == TypeService.Comptabilité)
                    {
                        if (c.Chef)
                        {
                            n.Statut = StatutNote.Validée;
                            AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                            //Cas chef de service compta
                        }
                        else
                        {
                            n.Statut = StatutNote.Validée;
                            AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                            //Cas collab compta
                        }
                    }
                    else
                    {
                        if (c.Chef)
                        {
                            n.Statut = StatutNote.Validée;
                            AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                            //Cas chef de service d'un autre service
                        }
                        else
                        {
                            n.Statut = StatutNote.ValidéeParLeChef;
                            AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                            //TODO envoyer notif à toute la compta faire fct
                            //AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteAller, c, n));
                            Service compta = bdd.Services.FirstOrDefault(serv => serv.Type == TypeService.Comptabilité);
                            compta.NotesDeFrais.Add(n);
                            //Cas collab d'un autre service
                        }
                    }
                    break;

                case StatutNote.ValidéeParLeChef:
                    n.Statut = StatutNote.Validée;
                    AjoutNotif(c.Id, new Message(TypeMessage.NotifNoteRetour, c, n));
                    System.Diagnostics.Debug.WriteLine("Valider d'une note par le service Compta");
                    break;

                default:
                    break;
                }
            }
            bdd.SaveChanges();
        }