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 )
Nuage de tags
Aide Script impression inventaire
02/09/2007
Reply
Aide Script impression inventaire
dan768
2 posts
tu avais proposé un script d'édition d'inventaire oserai-je me permettre une nouvelle présentation. Ci-joint le script nouveau
je viens de terminer la saisie de ma cave (ouf 1164 bouteilles pour 234 vins) et je trouve ton logiciel vraiment superbe, j'en avai sessayer d'autre le tien est de loin le mieux

script proposé

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;

//
// Prix
//
ReportColumn rcPrice = rt.NewColumn("Prix");
rcPrice.Size = 50;
rcPrice.ContentAlignment = ReportContentAlignment.Right;
rcPrice.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[7] = wine.BuyPrice.ToString("f");


//
// Gestion manuelle
//
if(wine.ManualManagement)
{
row[6] = wine.Bottles.ToString();
row[8] = (wine.Bottles * wine.BuyPrice).ToString("f");
}
else
{
row[6] = 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("Btles");
rcPrice.Size = 40;
rcPrice.ContentAlignment = ReportContentAlignment.Right;
rcPrice.DataType = ReportColumnType.Numeric;

//
// Bouteilles
//
rcBottles = rtEx.NewColumn("Prix");
rcBottles.Size = 50;
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] ="Sous total "+lastArea+ " ----->";
amountRow[3] = "";
amountRow[5] = "Btles";
amountRow[6] = tmpBottles.ToString();
amountRow[7] = "Montant";
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[6]);

tmpAmount+= Convert.ToSingle(row[8]);
tmpBottles+= Convert.ToSingle(row[6]);
}

if(lastArea != null)
{
// Cumul
ReportRow amountRow = rtEx.NewRow();
amountRow[2] ="Sous total "+lastArea+ " ----->";
amountRow[3] = " ";
amountRow[5] = "Btles";
amountRow[6] = tmpBottles.ToString();
amountRow[7] = "Montant";
amountRow[8] = tmpAmount.ToString("f");
}

// Cumul total
rtEx.NewRow();

ReportRow amountRowEx = rtEx.NewRow();
amountRowEx[2] = "Total général";
amountRowEx[3] = "";
amountRowEx[5] = "Btles";
amountRowEx[6] = bottles.ToString();
amountRowEx[7] = "Montant";
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();
 

03/09/2007
Reply
Re : Aide Script impression inventaire
AdministrateurView your blog
3099 posts
Bien :-))

Je l'ajouterai dans le centre d'aide.

Matthieu
 

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