Example #1
0
        /// <summary>
        /// Retourne tous les volumes.
        /// </summary>
        /// <returns></returns>
        internal static List <Volume> GetAllVolumes()
        {
            List <Volume> _volumes = new List <Volume>();

            try
            {
                using (AffiliateServiceClient _sClient = new AffiliateServiceClient())
                {
                    _volumes = _sClient.GetAllVolumes().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(_volumes);
        }
        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);
            }
        }