Пример #1
0
        // Méthode d'ajout d'une intervention dans la liste
        public bool AddIntervInList(C_Intervention interv)
        {
            bool OK = true;

            // Vérifie que l'intervention ne chevauche pas une autre ou n'est pas un double encodage parmis toutes les interventions.
            foreach (C_Intervention i in this.listInterv)
            {
                if (i.TechnicalUsername == interv.TechnicalUsername)
                {
                    if (i.DateBeg == interv.DateBeg && i.DateEnd == interv.DateEnd)
                    {
                        OK = false;
                    }
                    else
                    {
                        if (i.DateEnd > interv.DateBeg || interv.DateBeg < i.DateEnd)
                        {
                            OK = false;
                        }
                    }
                }
            }

            // Si l'intervention passe la recherche de dessus et ne pose aucun problème, on l'encode dans la liste
            if (OK)
            {
                listInterv.Add(interv);
            }

            return(OK);
        }
Пример #2
0
 // Méthode de suppression d'une intervention dans la liste
 public void RemoveIntervFromList(C_Intervention interv)
 {
     foreach (C_Intervention i in this.listInterv)
     {
         if (i.DateBeg == interv.DateBeg && i.DateEnd == interv.DateEnd && i.Label == interv.Label && i.Note == interv.Note && i.TechnicalUsername == interv.TechnicalUsername)
         {
             this.listInterv.Remove(i);
             break;
         }
     }
 }
Пример #3
0
        // Méthode d'ajout d'une note à l'intervention
        public static void AddInterventionNote(C_Intervention interv, C_Ticket ticket)
        {
            int idInterv;

            try
            {
                idInterv = SelectIDIntervention(interv, ticket);
                db.PS_Other_AddInterventionNote(idInterv, interv.Note);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Пример #4
0
        // Delete / Undelete

        // Méthode de suppression d'une intervention
        public static void DeleteIntervention(C_Intervention interv, C_Ticket ticket)
        {
            int idInterv;

            try
            {
                idInterv = SelectIDIntervention(interv, ticket);
                db.PS_Delete_Intervention(idInterv);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Пример #5
0
        // Méthode de récupération de l'ID d'une intervention
        public static int SelectIDIntervention(C_Intervention interv, C_Ticket ticket)
        {
            Intervention interv1;

            try
            {
                interv1 = db.Interventions.Single(i => i.Technical.User.Usn == interv.TechnicalUsername &&
                                                  i.Ticket.Customer.Name == ticket.Client.Name &&
                                                  i.DateBegin == interv.DateBeg &&
                                                  i.DateEnd == interv.DateEnd);
                return(interv1.ID);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Пример #6
0
        // Méthode d'insertion d'une intervention
        public static void InsertIntervention(C_Intervention interv, C_Ticket ticket)
        {
            int idTech, idTicket;

            try
            {
                idTech   = SelectIDTechnical(usn: interv.TechnicalUsername);
                idTicket = SelectIDTicket(ticket);
                db.PS_Insert_Intervention(idTicket,
                                          idTech,
                                          interv.DateBeg,
                                          interv.DateEnd,
                                          interv.Label,
                                          (interv.Note != null) ? interv.Note : DBNull.Value.ToString());
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Пример #7
0
 // Méthode de récupération d'un ticket
 public static C_Ticket SelectTicket(int num)
 {
     try
     {
         db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, db.Tickets);
         var ticket = from t in db.Tickets
                      where t.ID == num
                      select t;
         if (ticket.Count() > 0)
         {
             C_Client tmpClient = SelectClient(ticket.First().IDCustomer);
             C_Ticket tick      = new C_Ticket(ticket.First().DateIN,
                                               ticket.First().Subject,
                                               (ticket.First().Note == null ? null : ticket.First().Note),
                                               tmpClient);
             var interv = from i in db.Interventions
                          where i.IDTicket == ticket.First().ID
                          select i;
             foreach (Intervention i in interv)
             {
                 C_Technical    tech  = SelectTechnical(i.Technical.User.Usn);
                 C_Intervention inter = new C_Intervention(i.DateBegin,
                                                           i.DateEnd,
                                                           i.Subject,
                                                           i.TechnicalNote,
                                                           tech);
                 tick.AddIntervInList(inter);
             }
             return(tick);
         }
         else
         {
             return(new C_Ticket());
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }