/// <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); } }
/// <summary> /// Récupère un lecteur d'après son ID. /// </summary> /// <param name="id"></param> private void GetAffiliate(int id) { ServiceReference.IadminServiceClient sClient = new ServiceReference.IadminServiceClient(); try { ServiceReference.Affiliate lecteur = sClient.GetAffiliateById(id); if (lecteur.CardNum != 0) { _affiliate = lecteur; SetAffiliate(); } 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 <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); } }