/// <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); } }
/// <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); } }