internal void SetFicheDeLivre(LivreBO pLivreBo, FicheLivreBO ficheLivre) { if (ficheLivre == null){ MessageBox.Show("Erreur lors de la récupération de la fiche du livre!"); return; } lblReservationStatus.Visible = false; lblReservationTitle.Visible = false; lblTitre.Text = ficheLivre.RefLivre.Titre; webDescription.DocumentText = ficheLivre.RefLivre.Description; lblAuteurs.Text = ficheLivre.RefLivre.Auteur; lblPublication.Text = ficheLivre.RefLivre.Published.ToShortDateString(); Action<String> getImage = (imageUrl) => { // Create a web request to the URL for the picture var webRequest = WebRequest.Create(imageUrl); // Execute the request synchronuously var webResponse = (HttpWebResponse)webRequest.GetResponse(); // Create an image from the stream returned by the web request picBook.Image = new Bitmap(webResponse.GetResponseStream()); }; getImage(ficheLivre.RefLivre.ImageUrl); lblBibliotheque.Text = pLivreBo.Bibliotheque.BibliothequeName; if (ficheLivre.LstEmprunt.Any()){ var lastEmpruntState = ficheLivre.LstEmprunt[ficheLivre.LstEmprunt.Count() - 1]; lblEmpruntStatus.Text = lastEmpruntState.Transition + "\n" + lastEmpruntState.CreatedAt.ToShortDateString(); } else{ lblEmpruntStatus.Text = ""; } String newDemandeReservation = "", oldDemandeReservation = ""; foreach (var objDr in ficheLivre.LstDemandeReservation.OrderByDescending(xx => xx.CreatedAt)) { if (objDr.Valide == 1) { newDemandeReservation += ((newDemandeReservation == "") ? "": "\n" ) + "Depuis: " + objDr.CreatedAt.ToShortDateString(); } else { oldDemandeReservation += ((oldDemandeReservation == "") ? "": "\n" ) + "Anciennes demandes: " + objDr.CreatedAt.ToShortDateString(); } } lblDemandeReservationStatus.Text = newDemandeReservation + "\n" + oldDemandeReservation; var empruntByClient = CGlobalCache.LstEmpruntByClient.LastOrDefault(xx => xx.Livre.RefLivreId == ficheLivre.RefLivre.RefLivreId); if (empruntByClient != null && empruntByClient.State == "emp") { lblEmpruntStatus.Text = String.Format("Emprunté depuis le: {0}",empruntByClient.CreatedAt.ToShortDateString()); } else if (empruntByClient != null && empruntByClient.State == "res") { lblEmpruntStatus.Text = String.Format("Reservé depuis le: {0}",empruntByClient.CreatedAt.ToShortDateString()); } else if (empruntByClient != null && empruntByClient.State == "reg") { lblEmpruntStatus.Text = String.Format("Dernier emprunt le: {0}",empruntByClient.CreatedAt.ToShortDateString()); } else{ lblEmpruntStatus.Text = ""; } }
public static FicheLivreBO SelectFicheLivreForClientByRefLivreId(int pClientId, int pRefLivreId) { FicheLivreBO result = null; try { var objRefLivre = RefLivreBL.SelectById(pRefLivreId); if (objRefLivre != null) { result = new FicheLivreBO { RefLivre = objRefLivre, LstEmprunt = null, LstDemandeReservation = DemandeReservationBL.SelectForClientByRefLivreId(pClientId, objRefLivre.RefLivreId) }; } } catch (Exception ex) { throw; } return result; }
private void LoadFicheLivre(LivreBO pLivreBo) { CreateFicheLivre(); var livreIFac = new LivreIFACClient(); AsyncGuiFicheDeLivreSelectForClientById asyncExecute = livreIFac.SelectFicheLivreForClientByLivreId; try { asyncExecute.BeginInvoke(CGlobalCache.SessionManager.Token, CGlobalCache.SessionManager.Personne.Client.ClientId, pLivreBo.LivreId, xx => { var samplePersDelegate = (AsyncGuiFicheDeLivreSelectForClientById)((AsyncResult)xx).AsyncDelegate; _actualFicheLivre = samplePersDelegate.EndInvoke(xx); if (_ficheDeLivre == null || _actualFicheLivre == null) { livreIFac.Close(); return; } _ficheDeLivre.SetFicheDeLivre(pLivreBo, _actualFicheLivre); livreIFac.Close(); }, null); } catch(Exception) { livreIFac.Close(); MessageBox.Show(Resources.DashboardManager_loadFicheLivre_Erreur_lors_de_la_recuperation_des_informations_sur_le_livre_demande_); } }