Suivez et participez au développement du nouvel OpenCellar : PLOC.co
> Open Cellar for Windows
> Help Center
> FAQ
> Download Center
> Enter the Forum
> Version history
> Developers resources
> Open Cellar for Mobile
> Help Center
> FAQ
> Download Center
> Enter the Forum
> Version history
> Open Cellar for Mac/Linux
> Help Center
> FAQ
> Download Center
> Enter the Forum
> Version history
> Developers resources
> My Account
> My Live services
> My pages
> My library
> My published wines
> My labels
> My posted messages
> Write a page
> Open Cellar Forum Index
> Windows Forum
> Mac/Linux Forum
> Mobile Forum
> Search for and import wines
> Search for labels
> Compare prices (Sniffer)
Search:
> Search with all engines
> Search in forums
> Search in personal pages
> Search on open-cellar.com
> Search in wine cards
> Search in labels
> Search in price comparison tool (Sniffer)
Welcome (
connect
-
create an account
)
Home
»
The forum
»
Open Cellar Home Edition (Windows)
Nuage de tags
Open Cellar
Scripts
Etiquette
PPP
Cellar book
Mac
Vista
Synchronisation
Excel export
vinoXml
usb
sniffer
backup
import
printing
chardonnet
palm
statistics
Linux
personnalisation stat
08/01/2009
Reply
personnalisation stat
chicoulaf
1 posts
hello
pas tres champion des scripts et autre programmation, je voudrais savoir comment faire ce genre de rapport
par exemple: répartition dans une région donnée par appelation ex répartition des villages dans la section bourgogne ou dans Rhone répartition entre hermitage, cote rotie, Village etc etc
ou encore répartition par millésime soit global, soit plus précisément par région
et enfin un graphique non pas en pourcentage mais en nombre de bouteilles
merci à vous
10/01/2009
Reply
Re : personnalisation stat
Administrateur
3099 posts
Bonjour,
Voici le script qui vous affichera la liste des vins par régions avec en pied de page et pour chaque région le stock, le total.
Pour l'exécuter allez dans l'éditeur de scripts (menu Préférences)
if(App.ActiveCellar == null) { return; } App.Animate(AnimationType.Work, true); App.SetCursor(true); // // Modifiez ici le titre du report // string reportName = "Liste des vins - par région"; // // Creation entete report // ReportTable rt = new ReportTable(reportName); // // Région // ReportColumn rcArea = rt.NewColumn("Région"); rcArea.Size = 110; // // Année // ReportColumn rcYear = rt.NewColumn("Année"); rcYear.Size = 40; rcYear.ContentAlignment = ReportContentAlignment.Right; rcYear.DataType = ReportColumnType.Numeric; // // Nom // ReportColumn rcName = rt.NewColumn("Nom"); rcName.Size = 225; // // Appellation // ReportColumn rcApp = rt.NewColumn("Appellation"); rcApp.Size = 140; // // Couleur // ReportColumn rcColor = rt.NewColumn("Couleur"); rcColor.Size = 60; // // Format // ReportColumn rcFormat = rt.NewColumn("Format"); rcFormat.Size = 70; // // Prix // ReportColumn rcPrice = rt.NewColumn("Prix"); rcPrice.Size = 50; rcPrice.ContentAlignment = ReportContentAlignment.Right; rcPrice.DataType = ReportColumnType.Numeric; // // Bouteilles // ReportColumn rcBottles = rt.NewColumn("Btles"); rcBottles.Size = 40; rcBottles.ContentAlignment = ReportContentAlignment.Right; rcBottles.DataType = ReportColumnType.Numeric; // // Total // ReportColumn rcAmount = rt.NewColumn("Total"); rcAmount.Size = 60; rcAmount.ContentAlignment = ReportContentAlignment.Right; rcAmount.DataType = ReportColumnType.Numeric; // Colonne tri :: workaround /*ReportColumn rcSort = rt.NewColumn("_"); rcSort.Size = 1;*/ // // Alimentation de la source // ObjectCollection wines = App.ActiveCellar.GetCollection((ushort)ObjectType.Wine); for (int i = 0; i < wines.Count; i++) { Wine wine = (Wine)wines[i]; ReportRow row = rt.NewRow(); row[0] = wine.Area.Name; if(wine.Year != 0) { row[1] = wine.Year.ToString(); } row[2] = wine.Name; row[3] = wine.Appellation.Name; row[4] = "Champ"; if(wine.WineColor == ColorType.Red) { row[4] = "Rouge"; } else if(wine.WineColor == ColorType.White) { row[4] = "Blanc"; } else if(wine.WineColor == ColorType.Rosy) { row[4] = "Rosé"; } else if(wine.WineColor == ColorType.Yellow) { row[4] = "Champ"; } else if(wine.WineColor == ColorType.LiqueurLike) { row[4] = "Liquoreux"; } else if(wine.WineColor == ColorType.Misc) { row[4] = "Autre"; } row[5] = wine.BottleType.Name; row[6] = wine.BuyPrice.ToString("f"); // // Gestion manuelle // if(wine.ManualManagement) { row[7] = wine.Bottles.ToString(); row[8] = (wine.Bottles * wine.BuyPrice).ToString("f"); } else { row[7] = wine.RackItems.Count.ToString(); row[8] = (wine.RackItems.Count * wine.BuyPrice).ToString("f"); } // row[9] = wine.Area.Name; } // // Tri des elements, par region, vin puis année // rt.Sort("0-0;2-0;1-1"); /* string lastArea = null; for (int i = 0; i < rt.Rows.Count; i++) { ReportRow row = rt.Rows[i]; if(row[0] != lastArea) { lastArea = row[0]; } else { row[0] = string.Empty; } } */ // Second rapport // Creation entete report ReportTable rtEx = new ReportTable(reportName); rcArea = rtEx.NewColumn("Région"); rcArea.Size = 110; // // Année // rcYear = rtEx.NewColumn("Année"); rcYear.Size = 40; rcYear.ContentAlignment = ReportContentAlignment.Right; rcYear.DataType = ReportColumnType.Numeric; // // Nom // rcName = rtEx.NewColumn("Nom"); rcName.Size = 225; // // Appellation // rcApp = rtEx.NewColumn("Appellation"); rcApp.Size = 140; // // Couleur // rcColor = rtEx.NewColumn("Couleur"); rcColor.Size = 60; // // Format // rcFormat = rtEx.NewColumn("Format"); rcFormat.Size = 70; // // Prix // rcPrice = rtEx.NewColumn("Prix"); rcPrice.Size = 50; rcPrice.ContentAlignment = ReportContentAlignment.Right; rcPrice.DataType = ReportColumnType.Numeric; // // Bouteilles // rcBottles = rtEx.NewColumn("Btles"); rcBottles.Size = 40; rcBottles.ContentAlignment = ReportContentAlignment.Right; rcBottles.DataType = ReportColumnType.Numeric; // // Total // rcAmount = rtEx.NewColumn("Total"); rcAmount.Size = 60; rcAmount.ContentAlignment = ReportContentAlignment.Right; rcAmount.DataType = ReportColumnType.Numeric; float amount = 0; float bottles = 0; float tmpAmount = 0; float tmpBottles = 0; // :: OK string lastArea = null; for (int i = 0; i < rt.Rows.Count; i++) { ReportRow row = rt.Rows[i]; if(row[0] != lastArea) { if(lastArea != null) { // Cumul ReportRow amountRow = rtEx.NewRow(); amountRow[2] = "-----------------------------------------------------------"; amountRow[3] = "Sous total"; amountRow[7] = tmpBottles.ToString(); amountRow[8] = tmpAmount.ToString("f"); } ReportRow areaRow = rtEx.NewRow(); areaRow[0] = row[0]; lastArea = row[0]; tmpBottles = 0; tmpAmount = 0; } ReportRow row2 = rtEx.NewRow(); row2[1] = row[1]; row2[2] = row[2]; row2[3] = row[3]; row2[4] = row[4]; row2[5] = row[5]; row2[6] = row[6]; row2[7] = row[7]; row2[8] = row[8]; amount+= Convert.ToSingle(row[8]); bottles+= Convert.ToSingle(row[7]); tmpAmount+= Convert.ToSingle(row[8]); tmpBottles+= Convert.ToSingle(row[7]); } if(lastArea != null) { // Cumul ReportRow amountRow = rtEx.NewRow(); amountRow[2] = "-----------------------------------------------------------"; amountRow[3] = "Sous total"; amountRow[7] = tmpBottles.ToString(); amountRow[8] = tmpAmount.ToString("f"); } // Cumul total rtEx.NewRow(); ReportRow amountRowEx = rtEx.NewRow(); amountRowEx[2] = "-----------------------------------------------------------"; amountRowEx[3] = "Grand total"; amountRowEx[7] = bottles.ToString(); amountRowEx[8] = amount.ToString("f"); // // Génération // System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(rtEx); IReport report = App.ReportEngine.GetSystemReport(PredefinedReport.Grid); string destFileName = App.Path + "Cache\\UserWinesGrid.pdf"; bool success = false; try { report.Create(list, destFileName); success = true; } catch(Exception ex) { MessageBox.Show("Erreur (1)"); } // // Affichage du report // if(success) { IShellWindow shellWindow = (IShellWindow)App.GetWindow(WindowType.Shell, null); if(shellWindow != null) { shellWindow.Start(destFileName); } } App.SetCursor(false); App.StopAnimate();
Celui des appellations arrive dans la foulée.
Matthieu
10/01/2009
Reply
Re : personnalisation stat
Administrateur
3099 posts
Voici pour le second qui affiche le stock par région et appellation :
if(App.ActiveCellar == null) { return; } App.Animate(AnimationType.Work, true); App.SetCursor(true); // // Modifiez ici le titre du report // string reportName = "Statistiques par appellation"; // // Creation entete report // ReportTable rt = new ReportTable(reportName); // // Région // ReportColumn rcArea = rt.NewColumn("Région"); rcArea.Size = 200; // // Appellation // ReportColumn rcApp = rt.NewColumn("Appellation"); rcApp.Size = 350; // Stock ReportColumn rcBottles = rt.NewColumn("Btles"); rcBottles.Size = 90; rcBottles.ContentAlignment = ReportContentAlignment.Right; rcBottles.DataType = ReportColumnType.Numeric; // Alimentation de la source ObjectCollection wines = App.ActiveCellar.GetCollection((ushort)ObjectType.Wine); Hashtable areas = new Hashtable(); for (int i = 0; i < wines.Count; i++) { Wine wine = (Wine)wines[i]; string areaName = wine.Area.Name.Trim(); if(areaName == string.Empty) { areaName = "ZZZZ"; } string appName = wine.Appellation.Name.Trim(); if(appName == string.Empty) { appName = "ZZZZ"; } Hashtable stats = null; if(areas.ContainsKey(areaName)) { stats = (Hashtable)areas[areaName]; } else { stats = new Hashtable(); areas.Add(areaName, stats); } if(stats.ContainsKey(appName)) { stats[appName] = Convert.ToInt32(stats[appName]) + wine.Grid_Bottles; } else { stats.Add(appName, wine.Grid_Bottles); } } IDictionaryEnumerator areaEnum = areas.GetEnumerator(); while (areaEnum.MoveNext()) { ReportRow row = rt.NewRow(); if(areaEnum.Key.ToString() == "ZZZZ") { row[0] = "(Aucune)"; } else { row[0] = areaEnum.Key.ToString(); } Hashtable apps2 = (Hashtable)areaEnum.Value; IDictionaryEnumerator appEnum = apps2.GetEnumerator(); while (appEnum .MoveNext()) { row = rt.NewRow(); if(appEnum.Key.ToString() == "ZZZZ") { row[1] = "(Aucune)"; } else { row[1] = appEnum.Key.ToString(); } row[2] = appEnum.Value.ToString(); } } // // Génération // System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(rt); IReport report = App.ReportEngine.GetSystemReport(PredefinedReport.Grid); string destFileName = App.Path + "Cache\\StatsApp.pdf"; bool success = false; try { report.Create(list, destFileName); success = true; } catch(Exception ex) { MessageBox.Show("Erreur (1)"); } // // Affichage du report // if(success) { IShellWindow shellWindow = (IShellWindow)App.GetWindow(WindowType.Shell, null); if(shellWindow != null) { shellWindow.Start(destFileName); } } App.SetCursor(false); App.StopAnimate();
Matthieu
© 2006-2014
Matthieu DUCROCQ
- All rights reserved - Last update: january 2014 |
|
Support Open Cellar
|
Contact
|
About