// RackSpaceUsed // Mai 2007 // Ce script calcule le nombre de bouteille par emplacement // et l'espace occupé if(App.ActiveCellar == null) { MessageBox.Show("Aucune cave ouverte"); return; } App.Animate(AnimationType.Work, true); App.SetCursor(true); // // Modifiez ici le titre du report // string reportName = "Espace occupé"; // // Creation entete report // ReportTable rt = new ReportTable(reportName); // // Emplacement // ReportColumn rcRack = rt.NewColumn("Emplacement"); rcRack.Size = 350; // // Occupée // ReportColumn rcUsed = rt.NewColumn("Espace occupé"); rcUsed.Size = 90; rcUsed.ContentAlignment = ReportContentAlignment.Right; rcUsed.DataType = ReportColumnType.Numeric; // // Total // ReportColumn rcTotal = rt.NewColumn("Espace total"); rcTotal.Size = 90; rcTotal.ContentAlignment = ReportContentAlignment.Right; rcTotal.DataType = ReportColumnType.Numeric; // // Alimentation de la source // ObjectCollection racks = App.ActiveCellar.GetCollection((ushort)ObjectType.Rack); for (int i = 0; i < racks.Count; i++) { Rack rack = (Rack)racks[i]; ReportRow row = rt.NewRow(); row[0] = rack.Name.Trim(); int used = 0; int total = 0; for (byte rowZ = 0; rowZ < rack.Rows; rowZ++) { for(byte column = 0; column < rack.Columns; column++) { RackItem ri = rack.Get((byte)column, (byte)rowZ); if(ri != null){ total++; if(ri.Wine != null) { used++; } } } } row[1] = used.ToString(); row[2] = total.ToString(); } // // Tri des éléments // rt.Sort("2-0;1-0;0-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\\SpaceUsed.pdf"; bool success = false; try { report.Create(list, destFileName); success = true; } catch(Exception ex) { MessageBox.Show("Erreur (1)" + ex.ToString()); } // // Affichage du report // if(success) { IShellWindow shellWindow = (IShellWindow)App.GetWindow(WindowType.Shell, null); if(shellWindow != null) { shellWindow.Start(destFileName); } } App.SetCursor(false); App.StopAnimate(); // Fin