Example #1
0
        /// <summary>
        /// Ajoute un exemplaire à la base de données.
        /// </summary>
        /// <param name="item"></param>
        private void AddItem(ServiceReference.Item item)
        {
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();

            try
            {
                sClient.AddItem(item);
                SetMessage("Exemplaire ajouté !");
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à l'ajout : \n {0}", e.Message), "Erreur",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        /// <summary>
        /// Clôture un emprunt.
        /// </summary>
        /// <param name="XtdEmpruntToClose"></param>
        private void EndEmprunt(EmpruntXtd XtdEmpruntToClose)
        {
            //ServiceReference.Emprunt EmpruntToClose = new ServiceReference.Emprunt();
            //EmpruntToClose.Id = XtdEmpruntToClose.Id;
            //EmpruntToClose.ReturnDte = DateTime.Now.Date;
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();

            try
            {
                sClient.CloseEmprunt(XtdEmpruntToClose.Id, XtdEmpruntToClose.LastModified);
                SetMessage("Emprunt clôturé !");
                _emprunts.Remove(XtdEmpruntToClose);
                _bsDgvEmprunts.ResetBindings(false);
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la clôture de l'emprunt ! : \n {0}", e.Message), "Erreur",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 /// <summary>
 /// Retourne les retards d'une librairie
 /// </summary>
 /// <param name="libId"></param>
 /// <param name="referenceDate"></param>
 private void GetRetardsByLib(int libId, DateTime referenceDate = default(DateTime))
 {
     ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
     if (referenceDate == default(DateTime))
     {
         referenceDate = DateTime.Now.Date;
     }
     try
     {
         List <ServiceReference.Emprunt> retards = sClient.GetRetards(referenceDate, libId).ToList();
         if (retards.Count() >= 1)
         {
             foreach (ServiceReference.Emprunt baseEmprunt in retards)
             {
                 EmpruntFull newEmprunt = new EmpruntFull(baseEmprunt);
                 SetNames(ref newEmprunt);
                 _retards.Add(newEmprunt);
             }
             _bsDataGridView.DataSource = null;
             _bsDataGridView.DataSource = _retards;
             dataGridView1.DataSource   = _bsDataGridView;
             SetMessage(string.Format("Retards de la {0} ajoutés.", _libraries.Find(l => l == comboBoxLibChoice.SelectedItem).Name));
         }
         else
         {
             int cstmErrorN = 11; //"Aucun résultat ne correspond à cette recherche !"
             throw new CstmError(cstmErrorN);
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException endpointEx)
     {
         int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
         CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
         CstmError.Display(cstmError);
     }
     catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
     {
         CstmError.Display(Fault.Message);
     }
     catch (CstmError cstmError)
     {
         CstmError.Display(cstmError);
     }
     catch (Exception e)
     {
         MessageBox.Show("Une exception s'est produite à la récupération des données !", "Erreur",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #4
0
        /// <summary>
        /// Remplace la liste d'emprunts par un emprunt
        /// selon le code de l'exemplaire.
        /// </summary>
        /// <param name="code"></param>
        private void GetEmpruntbyCode(string code)
        {
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
            try
            {
                ServiceReference.Emprunt baseEmprunt = sClient.GetEmpruntByCode(code);
                if (baseEmprunt.Id != 0)
                {
                    EmpruntXtd newEmprunt = new EmpruntXtd(baseEmprunt);
                    _emprunts.Clear();
                    _emprunts.Add(newEmprunt);

                    _bsDgvEmprunts.DataSource = null;
                    _bsDgvEmprunts.DataSource = _emprunts;
                    dgvEmprunts.DataSource    = _bsDgvEmprunts;
                }
                else
                {
                    MessageBox.Show(string.Format("Le code d'exemplaire {0}\n n'a rien retourné !", code.ToString()), "Désolé",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", ex.Message), "Attention",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        /// <summary>
        /// Récupère la liste des emprunts de l'affilié.
        /// </summary>
        /// <param name="affilateId"></param>
        private void GetEmprunts(int affilateId)
        {
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
            try
            {
                List <ServiceReference.Emprunt> emprunts = sClient.GetEmpruntsByAffiliate(affilateId).ToList();
                if (emprunts.Count() >= 1)
                {
                    foreach (ServiceReference.Emprunt baseEmprunt in emprunts)
                    {
                        EmpruntXtd newEmprunt = new EmpruntXtd(baseEmprunt);
                        _emprunts.Add(newEmprunt);
                    }

                    _bsDgvEmprunts.DataSource = null;
                    _bsDgvEmprunts.DataSource = _emprunts;
                    dgvEmprunts.DataSource    = _bsDgvEmprunts;
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", ex.Message), "Attention",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #6
0
        /// <summary>
        /// (PAS UTILISE) Retourne une liste de volumes dont le titre
        /// s'approche du titre recherché.
        /// </summary>
        /// <param name="title"></param>
        private void GetVolumeListByTitle(string title)
        {
            List <ServiceReference.Volume> ListVolumes;

            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();

            try
            {
                List <ServiceReference.Volume> volumes = sClient.GetVolumesByTitle(title).ToList();
                if (volumes != null)
                {
                    ListVolumes = volumes;
                }
                else
                {
                    MessageBox.Show("Le titre  \"{0}\"\n n'a rien retourné !", title,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", e.Message), "Erreur",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Assigne les nom et prénom d'un lecteur à un retard (empruntfull).
        /// </summary>
        /// <param name="retard"></param>
        private void SetNames(ref EmpruntFull retard)
        {
            ServiceReference.Affiliate           affiliate = new ServiceReference.Affiliate();
            ServiceReference.IadminServiceClient sClient   = new ServiceReference.IadminServiceClient();
            try
            {
                ServiceReference.Affiliate lecteur = sClient.GetAffiliateById(retard.CardNum);

                if (lecteur.CardNum != 0)
                {
                    retard.FirstName = lecteur.FirstName;
                    retard.LastName  = lecteur.LastName;
                }
                else
                {
                    MessageBox.Show(string.Format("Une erreur s'est produite en récupérant le lecteur \n pour le retard de {0} !", retard.VolumeTitle), "Désolé",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", ex.Message), "Attention",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
        /// <summary>
        /// Récupère un lecteur d'après son nom et prénom.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        private void GetAffiliate(string firstName, string lastName)
        {
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
            try
            {
                ServiceReference.Affiliate lecteur = sClient.GetAffiliateByName(firstName, lastName);

                if (lecteur.CardNum != 0)
                {
                    _affiliate = lecteur;
                    SetAffiliate();
                }
                else
                {
                    MessageBox.Show(string.Format("la combinaison du prénom \"{0}\" et nom \"{1}\" n'a rien retourné !", firstName, lastName), "Désolé",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", ex.Message), "Attention",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
 /// <summary>
 /// Retourne un volume par son titre.
 /// </summary>
 /// <param name="titleLike"></param>
 private void GetVolumeDetailsByTitle(string titleLike)
 {
     ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
     try
     {
         ServiceReference.Volume volume = sClient.GetVolumeByTitle(tbTitleSearch.Text);
         if (volume.Id != null)
         {
             _currentVolume = volume;
         }
         else
         {
             MessageBox.Show(string.Format("Le titre {0}\n n'a rien retourné !", tbTitleSearch.Text), "Désolé",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         SetVolSrchInfos(true);
         SetVolInfoBox(true);
     }
     catch (System.ServiceModel.EndpointNotFoundException endpointEx)
     {
         int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
         CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
         CstmError.Display(cstmError);
     }
     catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
     {
         CstmError.Display(Fault.Message);
     }
     catch (CstmError cstmError)
     {
         CstmError.Display(cstmError);
     }
     catch (Exception e)
     {
         MessageBox.Show("Une exception s'est produite à la récupération des données !", "Erreur",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #10
0
        /// <summary>
        /// Charge la liste des auteurs déjà existants dans la DB pour choix
        /// lors d'ajout d'un volume.
        /// </summary>
        private void SetAllAuthors()
        {
            ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();

            try
            {
                List <ServiceReference.Author> authors = sClient.GetAllAuthorsNames().ToList();
                if (authors != null)
                {
                    _dBAuthors = authors;
                }
                else
                {
                    MessageBox.Show("La liste des auteurs n'a pas pu être récupérée !", "Une erreur est survenue",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
                CstmError.Display(cstmError);
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Une exception s'est produite à la récupération des données : \n {0}", e.Message), "Erreur",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #11
0
 /// <summary>
 /// Charge toutes les librairies pour le choix de la librairie active.
 /// </summary>
 private void SetAllLibraries()
 {
     ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient();
     try
     {
         List <ServiceReference.Library> libraries = sClient.GetLibraries().ToList();
         if (libraries.Count() >= 1)
         {
             _libraries = libraries;
         }
         else
         {
             int cstmErrorN = 11; //"Aucun résultat ne correspond à cette recherche !"
             throw new CstmError(cstmErrorN);
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException endpointEx)
     {
         int       cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
         CstmError cstmError  = new CstmError(cstmErrorN, endpointEx);
         CstmError.Display(cstmError);
     }
     catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
     {
         CstmError.Display(Fault.Message);
     }
     catch (CstmError cstmError)
     {
         CstmError.Display(cstmError);
     }
     catch (Exception e)
     {
         MessageBox.Show("Une exception s'est produite à la récupération des données !", "Erreur",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }