Esempio n. 1
0
        /// <summary>
        /// Renvoie la whislist de l'affilié.
        /// </summary>
        /// <param name="cardNum"></param>
        /// <returns></returns>
        internal static List <WishListItem> GetWishList(int cardNum)
        {
            List <WishListItem> _wishList = new List <WishListItem>();

            try
            {
                using (AffiliateServiceClient _sClient = new AffiliateServiceClient())
                {
                    _wishList = _sClient.GetWishListByCardNum(cardNum).ToList();
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError.Display(new CstmError(cstmErrorN, endpointEx));
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                CstmError.Display(new CstmError(7, e)); //Un problème est survenu à la récupération des données !
            }
            return(_wishList);
        }
Esempio n. 2
0
        /// <summary>
        /// Récupère les retards.
        ///
        /// </summary>
        /// <param name="libId"></param>
        /// <param name="referenceDate"></param>
        /// <returns></returns>
        internal static List <Emprunt> GetRetards(int affId) //, DateTime referenceDate = default(DateTime)
        {
            List <Emprunt> _Retards = new List <Emprunt>();

            try
            {
                using (AffiliateServiceClient _sClient = new AffiliateServiceClient())
                {
                    _Retards = _sClient.GetRetards(affId).ToList();
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError.Display(new CstmError(cstmErrorN, endpointEx));
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                CstmError.Display(new CstmError(7, e)); //Un problème est survenu à la récupération des données !
            }
            return(_Retards);
        }
Esempio n. 3
0
 /// <summary>
 /// Ajout d'une "réservation".
 /// </summary>
 /// <param name="cardNum"></param>
 /// <param name="volume_Id"></param>
 internal static void AddToWishList(int cardNum, int volume_Id)
 {
     try
     {
         using (AffiliateServiceClient _sClient = new AffiliateServiceClient())
         {
             _sClient.AddWishListItem(cardNum, volume_Id);
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException endpointEx)
     {
         int cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
         CstmError.Display(new CstmError(cstmErrorN, endpointEx));
     }
     catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
     {
         CstmError.Display(Fault.Message);
     }
     catch (CstmError cstmError)
     {
         CstmError.Display(cstmError);
     }
     catch (Exception e)
     {
         CstmError.Display(new CstmError(12, e)); // "erreur à l'ajout..."
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Retourne le tarif d'une bibliothèque (ne prend que le premier).
        /// </summary>
        /// <param name="idLib"></param>
        /// <returns></returns>
        internal static Tarif getTarif(int idLib)
        {
            Tarif _tarifToReturn = new Tarif();

            try
            {
                using (AffiliateServiceClient _sClient = new AffiliateServiceClient())
                {
                    _tarifToReturn = _sClient.GetTarifsByLib(idLib)[0];
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException endpointEx)
            {
                int cstmErrorN = 9; // "End point not found! Vérifiez que le serveur est lancé."
                CstmError.Display(new CstmError(cstmErrorN, endpointEx));
            }
            catch (System.ServiceModel.FaultException <ServiceReference.CustomFault> Fault)
            {
                CstmError.Display(Fault.Message);
            }
            catch (CstmError cstmError)
            {
                CstmError.Display(cstmError);
            }
            catch (Exception e)
            {
                CstmError.Display(new CstmError(7, e)); //Un problème est survenu à la récupération des données !
            }
            return(_tarifToReturn);
        }
        /// <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)
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                vEmpruntDetail baseEmprunt = sClient.GetEmpruntByCode(code);
                if (baseEmprunt.IdEmprunt != 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 <ClientAffiliate.ServiceReference1.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);
            }
        }
        /// <summary>
        /// Récupère la liste des emprunts de l'affilié.
        /// </summary>
        /// <param name="affilateId"></param>
        private void GetEmprunts(int affilateId)
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                List <vEmpruntDetail> emprunts = sClient.GetEmpruntsByAffiliate(affilateId).ToList();
                if (emprunts.Count() >= 1)
                {
                    foreach (vEmpruntDetail 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 <ClientAffiliate.ServiceReference1.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);
            }
        }
        /// <summary>
        /// Récupère un lecteur d'après son ID.
        /// </summary>
        /// <param name="id"></param>
        private void GetAffiliate(int id)
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                vAffiliate lecteur = sClient.GetAffiliateById(id);

                if (lecteur.CardNum != 0)
                {
                    _affiliate = lecteur;
                    SetAffiliate();
                    GetAllVolumes();
                }
                else
                {
                    MessageBox.Show(string.Format("Le numéro de carte {0}\n n'a rien retourné !", id.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 <ClientAffiliate.ServiceReference1.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);
            }
        }
        /// <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)
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                vAffiliate 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 <ClientAffiliate.ServiceReference1.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);
            }
        }
        /// <summary>
        /// Charge toutes les librairies pour le choix de la librairie active.
        /// </summary>
        private void SetAllLibraries()
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                List <vLibrary> 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 <ClientAffiliate.ServiceReference1.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);
            }
        }
        private void GetAllVolumes()
        {
            AffiliateServiceClient sClient = new AffiliateServiceClient();

            try
            {
                List <vVolume> volumes = sClient.GetAllVolumes().ToList();
                if (volumes.Count() >= 1)
                {
                    _allVolumes = volumes;

                    _bsDgvEmprunts.DataSource = null;
                    _bsDgvEmprunts.DataSource = _allVolumes;
                    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 <ClientAffiliate.ServiceReference1.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);
            }
        }