Suivez et participez au développement du nouvel OpenCellar : PLOC.co
Home Page
 
Français  English  
Open Cellar Home Edition - 1.2 - Windows 98, Me, 2000, XP and Vista. The free Windows wine cellar management software. Open Cellar Mobile Edition - Beta 2 (French version) - Pocket PC. The free Pocket PC wine cellar management software. Open Cellar Cross Platform - Beta 1 (French version) - Mac OSX and Linux. The free MacOS/Linux wine cellar management software. My Open Cellar Open Cellar Forums Place des vins
Search: Welcome (connect - create an account )
Page settings

Nuage de tags
Livre de cave compacté (variante 3)
Le script suivant vous permet d'imprimer le livre de cave compacté avec les colonnes Région, Nom, Couleur, Appellation, Année et producteur
Pour l'éxécuter allez dans le menu "Préférences" -> "Editeurs de scripts"

App.Animate(AnimationType.Work, true);
App.SetCursor(true);


//
// Modifiez ici le titre du report
//
string reportName = "Liste des vins";

//
// Creation entete report
//
ReportTable rt = new ReportTable(reportName);

// Région
ReportColumn rcArea = rt.NewColumn("Région");
rcArea.Size = 150;

// Nom
ReportColumn rcName = rt.NewColumn("Nom");
rcName.Size = 200;

// Couleur
ReportColumn rcColor = rt.NewColumn("Couleur");
rcColor.Size = 75;

// Appellation
ReportColumn rcApp = rt.NewColumn("Appellation");
rcApp.Size = 150;

// Année
ReportColumn rcYear = rt.NewColumn("Année");
rcYear.Size = 40;
rcYear.ContentAlignment = ReportContentAlignment.Right;
rcYear.DataType = ReportColumnType.Numeric;

// Producteur
ReportColumn rcOwner = rt.NewColumn("Producteur");
rcOwner.Size = 150;

// 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;
  row[1] = wine.Name;
  if(wine.WineColor == ColorType.Red)
  {
    row[2] = "Rouge";     
  }
  else if(wine.WineColor == ColorType.White)
  {
    row[2] = "Blanc";     
  }
  else if(wine.WineColor == ColorType.Rosy)
  {
    row[2] = "Rosé";     
  }
  else if(wine.WineColor == ColorType.Yellow)
  {
    row[2] = "Champagne";     
  }
  else if(wine.WineColor == ColorType.LiqueurLike)
  {
    row[2] = "Liquoreux";     
  }
  else if(wine.WineColor == ColorType.Misc)
  {
    row[2] = "Autre";     
  }

  row[3] = wine.Appellation.Name;
    
  if(wine.Year != 0)
  {
     row[4] = wine.Year.ToString();
  }

  row[5] = wine.Owner.Name;

}


//
// Tri des elements
//
rt.Sort("0-0;1-0");

//
// 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\\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();

© 2006-2014 Matthieu DUCROCQ  Open Cellar official blog - All rights reserved - Last update: january 2014 | twitter