예제 #1
0
        private void PrintCertificate(String langue, bool apercu = false)
        {
            if (Model.Id == -1)
            {
                return;
            }

            var template = _data.FetchOne <Xaml>(e => e.Name == "Certificate");

            // Prépare l'impression
            var ip = new Print("Certificate", template.Page, langue);

            ip["NumeroEchantillon"] = Model.Reference;
            ip["Dci"]    = Model.Product.Inn;
            ip["Nom"]    = Model.CommercialName;
            ip["Dosage"] = Model.Product.Dose;
            ip["Forme"]  = Model.Product.Form.Name;

            String expiry = "";

            if (Model.ExpirationDate != null)
            {
                if (!Model.ExpirationDayValid)
                {
                    expiry = Model.ExpirationDate?.ToString("");
                }
                else
                {
                    expiry = Model.ExpirationDate?.ToString("dd/MM/yyyy");
                }
            }
            ip["DatePeremption"] = expiry;

            String dateFabrication = "";

            if (Model.ManufacturingDate != null)
            {
                if (!Model.ManufacturingDayValid)
                {
                    dateFabrication = Model.ManufacturingDate?.ToString("");
                }
                else
                {
                    dateFabrication = Model.ManufacturingDate?.ToString("dd/MM/yyyy");
                }
            }
            ip["DateFabrication"] = dateFabrication;


            ip["Lot"]                       = Model.Batch;
            ip["Demandeur"]                 = JoinNotNull("\n", Model.Customer?.Name, Model.Customer?.Address, Model.Customer?.Country?.Name);
            ip["Fabricant"]                 = JoinNotNull("\n", Model.Manufacturer?.Name, Model.Manufacturer?.Address, Model.Manufacturer?.Country?.Name);
            ip["DateReception"]             = Model.ReceptionDate?.ToString("dd/MM/yyyy");
            ip["DateNotification"]          = apercu ? "Aperçu" : Model.NotificationDate?.ToString("dd/MM/yyyy");
            ip["Pharmacopee"]               = Model.Pharmacopoeia?.NameFr ?? "" + " " + Model.PharmacopoeiaVersion;
            ip["Prelevement"]               = Model.SamplingOrigin;
            ip["Taille"]                    = Model.ReceivedQuantity.ToString(); // + " " + slProduit.String("Forme").ToLower());
            ip["ConditionnementPrimaire"]   = Model.PrimaryPackaging;            // + (TB_ConditionnementSecondaire.Text.Length>0 ? " (" + TB_ConditionnementSecondaire.Text + ")":""));
            ip["ConditionnementSecondaire"] = Model.SecondaryPackaging;
            ip["Produit"]                   = Model.Aspect + "\r\n" + Model.Size;
            ip["Conclusion"]                = Model.Conclusion;
            ip["Validateur"]                = apercu ? "Aperçu" : Model.Validator; //MainWindow._UtilisateurPrenom + " " + MainWindow._UtilisateurNom + "\r\n" + MainWindow._UtilisateurFonction);

            // Cache le bandeau d'aperçu
            if (!apercu)
            {
                ip.Cache("Apercu");
            }

            // Ajout des tests sur la page
            String nomTest = "";

            foreach (var test in Tests.List)
            {
                if (test.Stage != SampleTestWorkflow.InvalidatedResults.Name)
                {
                    // Ajoute la ligne pour le nom du test
                    if (test.TestName != nomTest)
                    {
                        nomTest = test.TestName;
                        ip.AjouteElement("Titre");
                        ip.Element["Titre"] = " " + nomTest;
                    }

                    // Les résultats du test
                    ip.AjouteElement("Test");

                    if (test.EndDate == null || test.EndDate == DateTime.MinValue)
                    {
                        ip.Element["Date"] = "__/ __ /_____";
                    }
                    else if (langue == "US")
                    {
                        ip.Element["Date"] = string.Format(CultureInfo.InvariantCulture, "{0:d}", test.EndDate) + Environment.NewLine;
                    }
                    else
                    {
                        ip.Element["Date"] = string.Format("{0:d}", test.EndDate) + Environment.NewLine;
                    }

                    ip.Element["Description"] = test.Description + Environment.NewLine;
                    //TODO ip.Element["Reference"] = test.Reference + Environment.NewLine;
                    ip.Element["Norme"]    = test.Specification + Environment.NewLine;
                    ip.Element["Resultat"] = test.Result?.Result ?? "" + Environment.NewLine;
                    ip.Element["Conforme"] = test.Result?.Conformity ?? "" + Environment.NewLine;
                }
            }
            // Impression du certificat d'analyse
            String numero = Model.Reference;

            if (ip.Apercu("Certificat_" + numero, null, Print.Langue("{FR=Certificat d'analyse}{US=Certificate of analysis} ", langue) + Model.Reference))
            {
                // Log cette impression
                // TODO : Sql.Log(TypeObjet.Echantillon, IdEchantillon, ip.LogText);
            }
        }