예제 #1
0
        private string RicevuteMesePeriodo(DateTime dateTime, SoggettoEconomico soggetto)
        {
            DateTime mese = new DateTime(dateTime.Year, dateTime.Month, 1);

            ClassNumerazione numerazione = new ClassNumerazione();

            XPCollection <Vendita> vendite = new XPCollection <Vendita>(this.unitOfWork1);

            vendite.Criteria = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] {
                new BinaryOperator("Struttura.Oid", _Struttura.Oid),
                new BinaryOperator("DataContabile", mese, BinaryOperatorType.GreaterOrEqual),
                new BinaryOperator("DataContabile", mese.AddMonths(1).AddDays(-1), BinaryOperatorType.LessOrEqual)
            });

            foreach (Vendita vendita in vendite)
            {
                foreach (Stampa stampa in vendita.Stampe)
                {
                    if (soggetto == null)
                    {
                        numerazione.Add(stampa.Vendita.Postazione, stampa.NumeroProgressivo, stampa.Vendita.DataContabile.Year);
                    }
                    else
                    {
                        foreach (RigaStampaIngresso riga in stampa.RigheStampaIngresso)
                        {
                            if (riga.Ingresso.SoggettoEconomico.Oid == soggetto.Oid)
                            {
                                numerazione.Add(stampa.Vendita.Postazione, stampa.NumeroProgressivo, stampa.Vendita.DataContabile.Year);
                            }
                        }
                    }
                }
            }

            return(numerazione.EB());
        }
        private void CreaTabellaIncassi(Session session)
        {
            ClassNumerazione numerazione = new ClassNumerazione();

            XPCollection <Vendita> vendite = new XPCollection <Vendita>(session);

            vendite.Criteria = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] {
                new BinaryOperator("Struttura.Oid", _Struttura.Oid),
                new BinaryOperator("DataContabile", _Inizio, BinaryOperatorType.GreaterOrEqual),
                new BinaryOperator("DataContabile", _Fine, BinaryOperatorType.LessOrEqual)
            });

            decimal posquesta = 0;
            decimal posaltre  = 0;

            decimal conquesta = 0;
            decimal conaltre  = 0;

            var incassi = new Dictionary <string, decimal>();

            foreach (Vendita vendita in vendite)
            {
                switch (vendita.Incasso)
                {
                case EnumIncasso.Pos:
                    foreach (RigaVenditaVariante rigaVenditaVariante in vendita.RigheVenditaVariante)
                    {
                        if (rigaVenditaVariante.Variante.Biglietto.Gestore == _Struttura.SoggettoEconomico)
                        {
                            posquesta += rigaVenditaVariante.PrezzoTotale;
                        }
                        else
                        {
                            posaltre += rigaVenditaVariante.PrezzoTotale;

                            if (!incassi.ContainsKey(rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale))
                            {
                                incassi[rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale] = 0;
                            }
                            incassi[rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale] += rigaVenditaVariante.PrezzoTotale;
                        }
                    }
                    break;

                case EnumIncasso.Internet:
                case EnumIncasso.Contanti:
                    foreach (RigaVenditaVariante rigaVenditaVariante in vendita.RigheVenditaVariante)
                    {
                        if (rigaVenditaVariante.Variante.Biglietto.Gestore == _Struttura.SoggettoEconomico)
                        {
                            conquesta += rigaVenditaVariante.PrezzoTotale;
                        }
                        else
                        {
                            conaltre += rigaVenditaVariante.PrezzoTotale;

                            if (!incassi.ContainsKey(rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale))
                            {
                                incassi[rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale] = 0;
                            }
                            incassi[rigaVenditaVariante.Variante.Biglietto.Gestore.RagioneSociale] += rigaVenditaVariante.PrezzoTotale;
                        }
                    }
                    break;

                default:
                    throw new Exception(String.Format("Caso non previsto: {0}", vendita.Incasso));
                }

                foreach (Stampa stampa in vendita.Stampe)
                {
                    numerazione.Add(stampa.Vendita.Postazione, stampa.NumeroProgressivo, stampa.Vendita.DataContabile.Year);
                }
            }

            XRTableRow lastrow = this.xrTableIncassi.Rows[this.xrTableIncassi.Rows.Count - 1];

            lastrow.Cells[0].Text          = string.Format("{0:MMMM}", _Inizio).ToUpper();
            lastrow.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            lastrow.Cells[0].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[1].Text          = (conquesta + posquesta).ToString("c");
            lastrow.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            //lastrow.Cells[2].Text = (posquesta + posaltre).ToString("c");
            //        lastrow.Cells[2].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            //        lastrow.Cells[2].Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            //lastrow.Cells[3].Text = (conquesta - posaltre).ToString("c");
            //        lastrow.Cells[3].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            //        lastrow.Cells[3].Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow = this.xrTableAltriEnti.Rows[0];

            foreach (var item in incassi)
            {
                lastrow = this.xrTableAltriEnti.InsertRowBelow(lastrow);

                lastrow.Cells[0].Text          = item.Key;
                lastrow.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                lastrow.Cells[0].Font          = xrLabelTitoloTabVersamenti.Font;
                lastrow.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

                lastrow.Cells[1].Text          = item.Value.ToString("c");
                lastrow.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
                lastrow.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);
            }

            lastrow = this.xrTableAltriEnti.InsertRowBelow(lastrow);

            lastrow.Cells[0].Text          = "TOTALI";
            lastrow.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            lastrow.Cells[0].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[1].Text          = (conaltre + posaltre).ToString("c");
            lastrow.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow = this.xrTableTotale.Rows[0];

            lastrow.Cells[0].Text          = "TOTALE INCASSI";
            lastrow.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            lastrow.Cells[0].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[1].Text          = (conquesta + conaltre + posquesta + posaltre).ToString("c");
            lastrow.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            foreach (var item in numerazione.Elenco)
            {
                this.xrLabelBiglietti.Text +=
                    string.Format("{0}: {1} biglietti: {2}", item.Key.Nome, numerazione.NB(item.Key), numerazione.EB(item.Key)) + Environment.NewLine;
            }

            if (totalone != (conquesta + conaltre + posquesta + posaltre))
            {
                this.xrLabelErr.Visible = true;
            }
        }
        private void Postazioni(List <Postazione> list, ClassNumerazione numerazione)
        {
            string   posta      = string.Empty;
            DateTime lastUpdate = DateTime.MaxValue;

            foreach (Postazione postazione in list)
            {
                posta +=
                    string.Format("{0}: {1} biglietti: {2}", postazione.Nome, numerazione.NB(postazione), numerazione.EB(postazione)) +
                    Environment.NewLine;

                if (postazione.Oid != Program.Postazione.Oid)
                {
                    if (postazione.LastUpdate < lastUpdate)
                    {
                        lastUpdate = postazione.LastUpdate;
                    }
                }
                else
                {
                    // Questa postazione e', per definizione, sempre aggiornata
                    if (DateTime.Now < lastUpdate)
                    {
                        lastUpdate = DateTime.Now;
                    }
                }
            }

            this.xrLabelPostazioni.Text    = String.Format("Elenco postazioni:\n{0}", posta);
            this.xrLabelAggiornamento.Text = string.Format("Dati aggiornati a {0:g}", lastUpdate);
        }