Esempio n. 1
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>
        /// 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);
            }
        }
 public FormDetails(EmpruntXtd emprunt)
 {
     InitializeComponent();
     _currentEmprunt = emprunt;
 }