Exemple #1
0
        public void EnleverNoteDeFraisDuService(int IdNote, int IdService)
        {
            Service     s = bdd.Services.FirstOrDefault(serv => serv.Id == IdService);
            NoteDeFrais n = bdd.NotesDeFrais.FirstOrDefault(note => note.Id == IdNote);

            s.NotesDeFrais.Remove(n);
            bdd.SaveChanges();
        }
Exemple #2
0
        public void EnvoiNoteDeFraisChefService(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)
            {
                s.NotesDeFrais.Add(n);
            }
        }
Exemple #3
0
        //public virtual Collaborateur Collaborateur { get; set; }

        public NoteDeFrais GetJSON()
        {
            NoteDeFrais n = new NoteDeFrais();

            foreach (LigneDeFrais l in this.LignesDeFrais)
            {
                n.LignesDeFrais.Add(new LigneDeFrais {
                    Nom = l.Nom
                });
            }
            return(n);
        }
Exemple #4
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();
            }
        }
Exemple #5
0
        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();
                }
            }
        }
 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";
     }
 }
        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();
            }
        }
Exemple #8
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();
        }