Example #1
0
        public ICollection <Titolo> GetSottotitoliByIdPadre(decimal titoloKey)
        {
            List <Titolo> collection = null;

            using (var dbcontext = new FAXPECContext())
            {
                try
                {
                    var ls = dbcontext.COMUNICAZIONI_SOTTOTITOLI.Where(x => x.REF_ID_TITOLO == titoloKey).ToList();
                    if (ls.Count > 0)
                    {
                        collection = new List <Titolo>();
                    }
                    foreach (var s in ls)
                    {
                        Titolo t = AutoMapperConfiguration.MapSottotitoliToTitoli(s);
                        collection.Add(t);
                    }
                }
                catch (SqlException oex)
                {
                    ManagedException mEx = new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO,
                                                                "DAL_TIT_001", string.Empty,
                                                                string.Empty, oex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;
                }
            }
            return(collection);
        }
        protected void btnSalva_Click(object sender, EventArgs e)
        {
            TitolarioService <SendMail.Model.Titolo> ts = new TitolarioService <SendMail.Model.Titolo>();
            Titolo titolo = new Titolo();

            if (CodiceApplicazione.Text.Trim() != string.Empty && TitoloNome.Text.Trim() != string.Empty)
            {
                titolo.AppCode          = CodiceApplicazione.Text;
                titolo.CodiceProtocollo = CodiceProtocollo.Text;
                titolo.Nome             = TitoloNome.Text;
                titolo.Deleted          = !(TitoloIsActive.Checked);
                try
                {
                    ts.insertTitolo(titolo);
                }
                catch (Exception ex)
                {
                    info.AddError("Creazione titolo errata dettagli: " + ex.Message);
                    return;
                }
                info.AddInfo("Titolo creato");
                IList <SendMail.Model.Titolo> titoli = ts.GetAll(null);
                ddlTitolo.DataTextField  = "Nome";
                ddlTitolo.DataValueField = "Id";
                titoli.RemoveAt(0);
                ddlTitolo.DataSource = titoli;
                ddlTitolo.DataBind();
                this.ddlTitolo.Items.Insert(0, "-- Selezionare un titolo --");
            }
            else
            {
                info.AddError("Inserire i campi obbligatori");
            }
        }
 protected void buttonSalvaSottoTitolo_Click(object sender, EventArgs e)
 {
     if (SottoTitoloCodiceComunicazione.Text.Trim() != string.Empty && NomeSottotitolo.Text.Trim() != string.Empty && ddlTitolo.SelectedValue != "0")
     {
         TitolarioService <SendMail.Model.SottoTitolo> st = new TitolarioService <SendMail.Model.SottoTitolo>();
         TitolarioService <SendMail.Model.Titolo>      ts = new TitolarioService <SendMail.Model.Titolo>();
         Titolo      titolo      = ts.LoadTitoloById(int.Parse(ddlTitolo.SelectedValue));
         SottoTitolo sottotitolo = new SottoTitolo(titolo);
         SottoTitolo s           = null;
         sottotitolo.ComCode        = SottoTitoloCodiceComunicazione.Text;
         sottotitolo.ProtocolloCode = SottoTitoloCodiceProtocollo.Text;
         sottotitolo.Nome           = NomeSottotitolo.Text;
         sottotitolo.RefIdTitolo    = titolo.Id;
         sottotitolo.UsaProtocollo  = CheckProtocolloAttivo.Checked;
         sottotitolo.Deleted        = CheckProtocolloAttivo.Checked;
         try
         {
             s = st.insertTitolo(sottotitolo);
         }
         catch (Exception ex)
         {
             info.AddError("Creazione sottotitolo errata dettagli: " + ex.Message);
         }
         if (titolo.Id > 0)
         {
             info.AddInfo("Titolo creato");
         }
     }
 }
Example #4
0
        private void BuildTreeTitoli(TreeList albero)
        {
            albero.BeginUnboundLoad();
            albero.ClearNodes();

            foreach (string gruppo in Titolo.GetAllGroups(m_Uow))
            {
                TreeListNode capogruppo = null;

                foreach (Titolo item in m_ElencoTitoli)
                {
                    if (item.Gruppo == gruppo)
                    {
                        if (capogruppo == null)
                        {
                            capogruppo = albero.AppendNode(new object[] { gruppo }, null);
                        }

                        TreeListNode nodo = albero.AppendNode(new object[] { item.Descrizione, item.Ridotto, item.Omaggio }, capogruppo);
                        nodo.Tag = item;
                    }
                }
            }
            foreach (Titolo item in m_ElencoTitoli)
            {
                if (string.IsNullOrEmpty(item.Gruppo))
                {
                    TreeListNode nodo = albero.AppendNode(new object[] { item.Descrizione, item.Ridotto, item.Omaggio }, null);
                    nodo.Tag = item;
                }
            }

            albero.EndUnboundLoad();
            albero.BestFitColumns();
        }
        private void AddToList(Titolo titolo, string descrizione)
        {
            DatiReport02 target = null;

            foreach (DatiReport02 dataReport02 in _List)
            {
                if (dataReport02.Titolo == titolo)
                {
                    target = dataReport02;
                }
            }

            if (target == null)
            {
                target              = new DatiReport02();
                target.Museo        = descrizione;
                target.Titolo       = titolo;
                target.Descrizione  = titolo.Descrizione;
                target.Tipologia    = EnumTipologiaBiglietto.Museo;
                target.TipologiaUno = EnumTipologiaUno.Singolo;
                target.TipologiaDue = EnumTipologiaDue.Ridotto;
                target.TipologiaTre = EnumTipologiaTre.Standard;

                target.Ordine = 50;

                _List.Add(target);
            }
        }
Example #6
0
        public SoluzioneIngressiItem(Variante variante, Titolo titolo, int quantita)
        {
            Variante = variante;
            Titolo   = titolo;
            Quantita = quantita;

            m_PrezzoUnitario = Variante.Prezzo;
            m_PrezzoTotale   = PrezzoUnitario * Quantita;
        }
        public ProfiloCliente(int numero, Titolo titolo, bool scuola)
        {
            m_ElencoSoluzioni  = new ElencoSoluzioni();
            ElencoTitoli       = new List <Titolo>();
            ElencoCodiciSconto = new List <CodiceSconto>();
            NumeroPersone      = numero;
            Scuola             = scuola;

            if (titolo != null) // && titolo.Tipologia == EnumTipologiaTitolo.Normale)
            {
                ElencoTitoli.Add(titolo);
            }
        }
Example #8
0
        public void MapTitoliContatto(Titolo titolo)
        {
            this.T_MappedAppID   = (long)(titolo.Id);
            this.T_MappedAppName = titolo.Nome;

            if (this.MappedAppsId.Contains((long)titolo.Id))
            {
                this.T_isMappedAppDefault = true;
            }
            else
            {
                this.T_isMappedAppDefault = false;
            }
        }
Example #9
0
 private void ApplyElencoTitoli(List <Titolo> titoli, TreeListNode nodo)
 {
     foreach (TreeListNode item in nodo.Nodes)
     {
         if (!item.HasChildren)
         {
             Titolo titolo = item.Tag as Titolo;
             item.Checked = titoli.Contains(titolo);
         }
         else
         {
             ApplyElencoTitoli(titoli, item);
         }
     }
 }
Example #10
0
        private OracleParameter[] MapObjectToParams(Titolo r, bool isInsert)
        {
            OracleParameter[] oparams = new OracleParameter[4];

            oparams[0] = new OracleParameter("pAPPCODE", OracleDbType.Varchar2, 200, r.AppCode, ParameterDirection.Input);
            oparams[1] = new OracleParameter("pPROT_CODE", OracleDbType.Varchar2, 100, r.CodiceProtocollo, ParameterDirection.Input);
            oparams[2] = new OracleParameter("pDESCR", OracleDbType.Varchar2, 200, r.Note, ParameterDirection.Input);
            if (isInsert)
            {
                oparams[3] = new OracleParameter("pID_TIT", OracleDbType.Decimal, r.Id, ParameterDirection.Output);
            }
            else
            {
                oparams[3] = new OracleParameter("pID_TIT", OracleDbType.Decimal, r.Id, ParameterDirection.Input);
            }

            return(oparams);
        }
Example #11
0
        //Inserisce un nuovo titolo, automaticamente viene inserito anche il sottotiolo di default se presente
        public void Insert(Titolo titolo)
        {
            using (var dbcontext = new FAXPECContext())
            {
                using (var transaction = dbcontext.Database.BeginTransaction())
                {
                    COMUNICAZIONI_TITOLI t = AutoMapperConfiguration.MapToComunicazioniTitoli(titolo, true);
                    try
                    {
                        dbcontext.COMUNICAZIONI_TITOLI.Add(t);
                        int r = dbcontext.SaveChanges();
                        if (r == 0)
                        {
                            transaction.Rollback();
                            throw new Exception(DalExMessages.ID_NON_RESTITUITO);
                        }
                        transaction.Commit();
                    }
                    catch (InvalidOperationException ioex)
                    {
                        transaction.Rollback();
                        ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_INSERITA,
                                                                    "DAL_RUB_002", string.Empty,
                                                                    string.Empty, ioex);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);

                        log.Error(mEx);
                        throw mEx;
                    }
                    catch (SqlException oex)
                    {
                        transaction.Rollback();
                        ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_INSERITA,
                                                                    "DAL_RUB_001", string.Empty,
                                                                    string.Empty, oex);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);

                        log.Error(mEx);
                        throw mEx;
                    }
                }
            }
        }
Example #12
0
        public void Update(Titolo titolo)
        {
            using (OracleCommand ocmd = new OracleCommand())
            {
                ocmd.CommandText = updateStatement;
                ocmd.Parameters.AddRange(MapObjectToParams(titolo, false));
                ocmd.Connection = base.CurrentConnection;
                // eseguo il command
                try
                {
                    int rowAff = ocmd.ExecuteNonQuery();
                    //todo.. MIGLIORARE
                    if (rowAff != 1)
                    //throw new DALException(DalExMessages.NESSUNA_RIGA_MODIFICATA);
                    {
                        //TASK: Allineamento log - Ciro
                        ManagedException mEx = new ManagedException(DalExMessages.NESSUNA_RIGA_MODIFICATA,
                                                                    "DAL_TIT_009", string.Empty,
                                                                    string.Empty, null);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);

                        log.Error(mEx);
                        throw mEx;
                    }
                    //throw new ManagedException(DalExMessages.NESSUNA_RIGA_MODIFICATA, "DAL_TIT_009", "", "", "", "", "", null);
                }
                /*TODO: INSERIRE I LOG DELLE ECCEZIONI*/ catch (InvalidOperationException ex)
                {
                    //throw new DALException(DalExMessages.RUBRICA_NON_AGGIORNATA, ex);

                    //TASK: Allineamento log - Ciro
                    ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA,
                                                                "DAL_UNIQUE_CODE", string.Empty,
                                                                string.Empty, ex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;
                    //throw new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA, "DAL_UNIQUE_CODE", "", "", "", "", "", ex);
                }
            }
        }
Example #13
0
        public virtual int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            if (obj.GetType() != GetType())
            {
                throw new ArgumentException();
            }
            Libro l = (Libro)obj;

            if (l.Titolo == Titolo && l.Autore == Autore && l.Gen == Gen && l.Anno == Anno)
            {
                return(0);
            }
            else
            {
                return(Titolo.CompareTo(l.Titolo));
            }
        }
Example #14
0
        internal static Titolo MapToTitolo(IDataRecord dr, List <string> col)
        {
            Titolo t = new Titolo();

            if (col.Contains("ID_TITOLO"))
            {
                t.Id = (Int32)dr.GetDecimal("ID_TITOLO");
            }
            if (col.Contains("TITOLO"))
            {
                t.Nome = dr.GetString("TITOLO");
            }
            if (col.Contains("PROT_CODE"))
            {
                t.CodiceProtocollo = dr.GetString("PROT_CODE");
            }
            if (col.Contains("NOTE"))
            {
                t.Note = dr.GetString("NOTE");
            }
            if (col.Contains("APP_CODE"))
            {
                t.AppCode = dr.GetString("APP_CODE");
            }
            if (col.Contains("ACTIVE"))
            {
                decimal temp = dr.GetDecimal("ACTIVE");
                if (temp == 0)
                {
                    t.Deleted = true;
                }
                else
                {
                    t.Deleted = false;
                }
            }
            return(t);
        }
Example #15
0
        internal int ApplyElencoTitoli(GestoreProfili gestoreProfili, TreeList albero, bool scuola)
        {
            int num = 0;

            List <ProfiloCliente> elenco = new List <ProfiloCliente>();

            foreach (TreeListNode item in albero.Nodes)
            {
                if (item.HasChildren)
                {
                    num += ApplyElencoTitoli(gestoreProfili, item, albero, elenco, scuola);
                }
                else
                {
                    Titolo titolo = item.Tag as Titolo;
                    foreach (ProfiloCliente profilo in gestoreProfili.ElencoProfili)
                    {
                        if (profilo.Scuola != scuola)
                        {
                            continue;
                        }

                        if ((titolo != null && profilo.ElencoTitoli.Contains(titolo)) ||
                            (titolo == null && profilo.ElencoTitoli.Count == 0))
                        {
                            if (!elenco.Contains(profilo))
                            {
                                item.SetValue(albero.Columns[3], profilo.NumeroPersone);
                                elenco.Add(profilo);
                                num++;
                            }
                        }
                    }
                }
            }

            return(num);
        }
Example #16
0
        public void Update(Titolo titolo)
        {
            using (var dbcontext = new FAXPECContext())
            {
                using (var transaction = dbcontext.Database.BeginTransaction())
                {
                    try
                    {
                        var updated = dbcontext.COMUNICAZIONI_TITOLI.Where(x => x.ID_TITOLO == titolo.Id).First();
                        updated.APP_CODE  = titolo.AppCode;
                        updated.NOTE      = titolo.Note;
                        updated.TITOLO    = titolo.Nome;
                        updated.PROT_CODE = titolo.CodiceProtocollo;
                        int rowAff = dbcontext.SaveChanges();
                        if (rowAff != 1)
                        {
                            ManagedException mEx = new ManagedException(DalExMessages.NESSUNA_RIGA_MODIFICATA,
                                                                        "DAL_TIT_009", string.Empty,
                                                                        string.Empty, null);
                            ErrorLogInfo err = new ErrorLogInfo(mEx);

                            log.Error(mEx);
                            throw mEx;
                        }
                    }
                    catch (InvalidOperationException ex)
                    {
                        ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_AGGIORNATA,
                                                                    "DAL_UNIQUE_CODE", string.Empty,
                                                                    string.Empty, ex);
                        ErrorLogInfo err = new ErrorLogInfo(mEx);

                        log.Error(mEx);
                        throw mEx;
                    }
                }
            }
        }
Example #17
0
        internal static Titolo MapToTitolo(IDataRecord dr)
        {
            Titolo t = new Titolo();

            t.Id               = dr.GetInt64("ID_TITOLO");
            t.Nome             = dr.GetString("TITOLO");
            t.CodiceProtocollo = dr.GetString("PROT_CODE");
            t.AppCode          = dr.GetString("APP_CODE");
            t.Note             = dr.GetString("NOTE");

            decimal temp = dr.GetDecimal("ACTIVE");

            if (temp == 0)
            {
                t.Deleted = true;
            }
            else
            {
                t.Deleted = false;
            }

            return(t);
        }
Example #18
0
        public Titolo GetById(decimal id)
        {
            Titolo titolo = null;

            using (var dbcontext = new FAXPECContext())
            {
                try
                {
                    var t = dbcontext.COMUNICAZIONI_TITOLI.Where(x => x.ID_TITOLO == id).First();
                    titolo = AutoMapperConfiguration.MapToTitolo(t);
                }
                catch (SqlException oex)
                {
                    ManagedException mEx = new ManagedException(DalExMessages.TITOLO_NON_RECUPERATO,
                                                                "DAL_TIT_010", string.Empty,
                                                                string.Empty, oex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;
                }
            }
            return(titolo);
        }
Example #19
0
        private void Tentativo(ProfiloCliente cliente, List <SoluzioneIngressiItem> elencoPercorso, decimal importoPercorso, int indice, List <Ingresso> dafare)
        {
            if (dafare.Count == 0)
            {
                // valida soluzione per bigliettone
                if (SoluzioneValidaPerBigliettone(elencoPercorso))
                {
                    decimal importoTotale   = 0;
                    decimal importoUnitario = 0;

                    // ho trovato una soluzione
                    foreach (SoluzioneIngressiItem item in elencoPercorso)
                    {
                        importoTotale   += item.PrezzoTotale;
                        importoUnitario += item.PrezzoUnitario;
                    }

                    List <Ingresso> visitati = new List <Ingresso>();
                    foreach (SoluzioneIngressiItem variante1 in elencoPercorso)
                    {
                        foreach (Ingresso item in variante1.Variante.Biglietto.Percorso.Ingressi)
                        {
                            if (!visitati.Contains(item))
                            {
                                visitati.Add(item);
                            }
                        }
                    }

                    SoluzioneIngressi sol = new SoluzioneIngressi();

                    sol.Elenco = new List <SoluzioneIngressiItem>();
                    sol.Elenco.AddRange(elencoPercorso);

                    sol.NumeroIngressi  = visitati.Count;
                    sol.NumeroPercorsi  = elencoPercorso.Count;
                    sol.ImportoTotale   = importoTotale;
                    sol.ImportoUnitario = importoUnitario;
                    sol.NumeroPersone   = cliente.NumeroPersone;

                    cliente.ElencoSoluzioni.AggiungiSoluzioneSeNonDuplicata(sol);
                }
            }
            else
            {
                if (cliente.OttimizzaCalcolo && cliente.ElencoSoluzioni.SogliaImporto >= 0)
                {
                    // inutile proseguire ulteriormente
                    if (importoPercorso > cliente.ElencoSoluzioni.SogliaImporto)
                    {
                        return;
                    }
                }

                for (int newIndice = indice + 1; newIndice < m_TutteLeVarianti.Count; newIndice++)
                {
                    Titolo   titolo   = null;
                    Variante variante = m_TutteLeVarianti[newIndice];

                    if (variante.TipologiaTre == EnumTipologiaTre.CardMyFE)
                    {
                        // CARD MY-FE con prezzo sdoppiato -C]
                        if (variante.ComprendeAlmenoUno(dafare) && variante.GiorniCardMyFe() == m_GestoreProfili.TipologiaMyFe && variante.Note.Contains("-C]"))
                        {
                            List <Ingresso> davisitare = new List <Ingresso>(dafare);
                            foreach (Ingresso ingresso in variante.Biglietto.Percorso.Ingressi)
                            {
                                davisitare.Remove(ingresso);
                            }

                            decimal prezzo = 0;
                            SoluzioneIngressiItem tentativo           = null;
                            SoluzioneIngressiItem tentativoSecondario = null;

                            tentativo = new SoluzioneIngressiItem(variante, null, cliente.NumeroPersone);
                            prezzo    = tentativo.PrezzoTotale;

                            tentativoSecondario = new SoluzioneIngressiItem(variante.PrezzoAttuale.PrezzoRidotto, null, cliente.NumeroPersone);
                            prezzo += tentativoSecondario.PrezzoTotale;

                            elencoPercorso.Add(tentativo);
                            elencoPercorso.Add(tentativoSecondario);

                            Tentativo(cliente, elencoPercorso, importoPercorso + prezzo, newIndice, davisitare);

                            elencoPercorso.Remove(tentativoSecondario);
                            elencoPercorso.Remove(tentativo);
                        }

                        // campo note che finisce con -B è solo COMUNE
                        if (variante.ComprendeAlmenoUno(dafare) && variante.GiorniCardMyFe() == m_GestoreProfili.TipologiaMyFe && variante.Note.Contains("-B]"))
                        {
                            List <Ingresso> davisitare = new List <Ingresso>(dafare);
                            foreach (Ingresso ingresso in variante.Biglietto.Percorso.Ingressi)
                            {
                                davisitare.Remove(ingresso);
                            }

                            decimal prezzo = 0;
                            SoluzioneIngressiItem tentativo = null;
                            //SoluzioneIngressiItem tentativoSecondario = null;

                            tentativo = new SoluzioneIngressiItem(variante, null, cliente.NumeroPersone);
                            prezzo    = tentativo.PrezzoTotale;

                            //tentativoSecondario = new SoluzioneIngressiItem(variante.PrezzoAttuale.PrezzoRidotto, null, cliente.NumeroPersone);
                            //prezzo += tentativoSecondario.PrezzoTotale;

                            elencoPercorso.Add(tentativo);
                            //elencoPercorso.Add(tentativoSecondario);

                            Tentativo(cliente, elencoPercorso, importoPercorso + prezzo, newIndice, davisitare);

                            //elencoPercorso.Remove(tentativoSecondario);
                            elencoPercorso.Remove(tentativo);
                        }
                    }
                    else
                    {
                        if (variante.HoTitoloPerComprarlo(cliente.ElencoTitoli, cliente.ElencoCodiciSconto, cliente.NumeroPersone, cliente.Scuola, out titolo))
                        {
                            if (variante.ComprendeAlmenoUno(dafare))
                            {
                                List <Ingresso> davisitare = new List <Ingresso>(dafare);
                                foreach (Ingresso ingresso in variante.Biglietto.Percorso.Ingressi)
                                {
                                    davisitare.Remove(ingresso);
                                }

                                decimal prezzo = 0;
                                SoluzioneIngressiItem tentativo           = null;
                                SoluzioneIngressiItem tentativoSecondario = null;
                                if (titolo != null && titolo.TitoloPrincipale != null && titolo.TitoloSecondario != null)
                                {
                                    // GESTIONE TITOLI SECONDARI (solo il primo e' titolare, gli altri accompagnatori)
                                    tentativo = new SoluzioneIngressiItem(variante, titolo.TitoloPrincipale, 1);
                                    prezzo    = tentativo.PrezzoTotale;

                                    if (cliente.NumeroPersone > 1)
                                    {
                                        tentativoSecondario = new SoluzioneIngressiItem(variante, titolo.TitoloSecondario, cliente.NumeroPersone - 1);
                                        prezzo += tentativoSecondario.PrezzoTotale;
                                    }
                                }
                                else
                                {
                                    if (variante.PrezzoAttuale.UnaRiduzioneOgni > 0 && variante.PrezzoAttuale.PrezzoRidotto != null)
                                    {
                                        int numRidotti = cliente.NumeroPersone / variante.PrezzoAttuale.UnaRiduzioneOgni;
                                        int numInteri  = cliente.NumeroPersone - numRidotti;

                                        tentativo = new SoluzioneIngressiItem(variante, titolo, numInteri);
                                        prezzo    = tentativo.PrezzoTotale;

                                        if (numRidotti > 0)
                                        {
                                            tentativoSecondario = new SoluzioneIngressiItem(variante.PrezzoAttuale.PrezzoRidotto, titolo, numRidotti);
                                            prezzo += tentativoSecondario.PrezzoTotale;
                                        }
                                    }
                                    else
                                    {
                                        tentativo = new SoluzioneIngressiItem(variante, titolo, cliente.NumeroPersone);
                                        prezzo    = tentativo.PrezzoTotale;
                                    }
                                }

                                elencoPercorso.Add(tentativo);
                                if (tentativoSecondario != null)
                                {
                                    elencoPercorso.Add(tentativoSecondario);
                                    foreach (Ingresso ingresso in tentativoSecondario.Variante.Biglietto.Percorso.Ingressi)
                                    {
                                        davisitare.Remove(ingresso);
                                    }
                                }

                                Tentativo(cliente, elencoPercorso, importoPercorso + prezzo, newIndice, davisitare);

                                if (tentativoSecondario != null)
                                {
                                    elencoPercorso.Remove(tentativoSecondario);
                                }
                                elencoPercorso.Remove(tentativo);
                            }
                        }
                    }
                }
            }
        }
Example #20
0
        private bool CreaVendita()
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                Vendita vendita = new Vendita(uow);

                vendita.Incasso         = this.checkEditPos.Checked ? EnumIncasso.Pos : EnumIncasso.Contanti;
                vendita.CodiceLeggibile = Vendita.NuovoCodiceVendita();
                vendita.CodicePrevent   = "";

                vendita.DataContabile = DateTime.Now.Date;
                vendita.DataOraStampa = DateTime.Now;

                vendita.Descrizione = "";

                vendita.Utente        = uow.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid);
                vendita.Postazione    = uow.GetObjectByKey <Postazione>(Program.Postazione.Oid);
                vendita.Struttura     = uow.GetObjectByKey <Struttura>(Program.Postazione.Struttura.Oid);
                vendita.TotalePersone = ElencoCard.Count;
                vendita.TotaleImporto = CalcolaTotale(ElencoCard);
                vendita.Save();

                //Percorso per = uow.FindObject<Percorso>(new BinaryOperator("Descrizione", "MyFE"));
                for (int i = 0; i < ElencoCard.Count; i++)
                {
                    Matricola card  = uow.GetObjectByKey <Matricola>(ElencoCard[i].Oid);
                    Titolo    unife = uow.FindObject <Titolo>(new BinaryOperator("Attributi", "-UNIFE-"));

                    //Variante v1 = per.GetVarianteMyFe("Com", "C", card.TipologiaCard);
                    //Variante v2 = per.GetVarianteMyFe("Pin", "C", card.TipologiaCard);

                    if (unife == null)
                    {
                        XtraMessageBox.Show("Titolo per -UNIFE- mancante", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    if (card == null)
                    {
                        XtraMessageBox.Show("Tessera unife mancante", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    if (card.ValidaDal > DateTime.Today)
                    {
                        XtraMessageBox.Show("Tessera " + card.Codice + " valida dal " + card.ValidaDal.ToString("d"), "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    if (card.ValidaAl < DateTime.Today)
                    {
                        XtraMessageBox.Show("Tessera " + card.Codice + " valida fino al " + card.ValidaAl.ToString("d"), "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    decimal totale = 0; // = v1.Prezzo + v2.Prezzo;

                    //List<Ingresso> ingressi = new List<Ingresso>();
                    //ingressi.AddRange(per.Ingressi);

                    foreach (Ingresso ingresso in ElencoIngressi)
                    {
                        Variante v1 = FindVarianteSingoleOmaggio(uow, ingresso);

                        if (v1 == null)
                        {
                            XtraMessageBox.Show("Per ingresso " + ingresso.Descrizione + " non esiste una variante adeguata.", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        RigaVenditaVariante rvv1 = new RigaVenditaVariante(uow);
                        rvv1.PrezzoTotale   = v1.Prezzo;
                        rvv1.PrezzoUnitario = v1.Prezzo;
                        rvv1.Profilo        = i;
                        rvv1.Quantita       = 1;
                        rvv1.Variante       = v1;
                        rvv1.Vendita        = vendita;
                        rvv1.Titolo         = unife;
                        //rvv1.Card = card;
                        rvv1.Matricola = card.Codice;
                        rvv1.Save();

                        totale += v1.Prezzo;
                    }

                    //RigaVenditaVariante rvv2 = new RigaVenditaVariante(uow);
                    //rvv2.PrezzoTotale = v2.Prezzo;
                    //rvv2.PrezzoUnitario = v2.Prezzo;
                    //rvv2.Profilo = i;
                    //rvv2.Quantita = 1;
                    //rvv2.Variante = v2;
                    //rvv2.Vendita = vendita;
                    //rvv2.Card = card;
                    //rvv2.Save();

                    DateTime inizioVal = DateTime.Now.Date;
                    DateTime fineVal   = DateTime.Now.Date;

                    Stampa stampa = new Stampa(uow);
                    stampa.Vendita        = vendita;
                    stampa.InizioValidita = inizioVal;
                    stampa.FineValidita   = fineVal;
                    stampa.Quantita       = 1;
                    stampa.ImportoTotale  = totale;
                    stampa.StatoStampa    = i;
                    stampa.TipoStampa     = EnumTipoStampa.Standard;
                    //stampa.Card = card;
                    stampa.Matricola = card.Codice;
                    stampa.Save();
                    stampa.GeneraBarCode(Program.Postazione, ElencoIngressi);

                    //card.Status = EnumStatoCard.Emessa;
                    //card.Stampa = stampa;
                    ////if (_Albergo)
                    ////    card.Albergo = uow.GetObjectByKey<AnagraficaCard>((this.lookUpEditAlbergo.EditValue as AnagraficaCard).Oid);
                    //card.Save();

                    Stampa doppia = uow.FindObject <Stampa>(new BinaryOperator("BarCode", stampa.BarCode));
                    if (doppia != null)
                    {
                        stampa.GeneraBarCode(Program.Postazione, ElencoIngressi);

                        doppia = uow.FindObject <Stampa>(new BinaryOperator("BarCode", stampa.BarCode));
                        if (doppia != null)
                        {
                            stampa.GeneraBarCode(Program.Postazione, ElencoIngressi);

                            doppia = uow.FindObject <Stampa>(new BinaryOperator("BarCode", stampa.BarCode));
                            if (doppia != null)
                            {
                                stampa.GeneraBarCode(Program.Postazione, ElencoIngressi);
                            }
                        }
                    }

                    stampa.Save();

                    foreach (Ingresso ingresso in ElencoIngressi)
                    {
                        RigaStampaIngresso rigaingresso = new RigaStampaIngresso(uow);
                        rigaingresso.Ingresso      = uow.GetObjectByKey <Ingresso>(ingresso.Oid);
                        rigaingresso.Stampa        = stampa;
                        rigaingresso.TotalePersone = 1;
                        rigaingresso.Save();
                    }
                }

                // registra ingressi per QUESTA postazione
                foreach (Stampa item1 in vendita.Stampe)
                {
                    foreach (RigaStampaIngresso item2 in item1.RigheStampaIngresso)
                    {
                        if (VarcoPostazione(item2))
                        {
                            Entrata entrata = new Entrata(uow);
                            entrata.DataOraEntrata     = vendita.DataOraStampa;
                            entrata.Quantita           = item2.TotalePersone;
                            entrata.RigaStampaIngresso = item2;
                            entrata.Save();

                            item2.TotaleIngressi = item2.TotalePersone;
                            item2.Save();
                        }
                    }
                }

                uow.CommitChanges();

                m_Vendita = this._UnitOfWork.GetObjectByKey <Vendita>(vendita.Oid);
            }

            return(true);
        }
        private void simpleButtonOk_Click(object sender, EventArgs e)
        {
            Variante   variante    = this.lookUpEditVariante.EditValue as Variante;
            Titolo     titolo      = this.lookUpEditTitolo.EditValue as Titolo;
            Postazione postazione  = this.lookUpEdit1.EditValue as Postazione;
            int        quantita    = (int)this.spinEditQta.Value;
            DateTime   dataVendita = this.dateEditData.DateTime;

            if (dataVendita > DateEnd || dataVendita < DateStart)
            {
                this.dateEditData.ErrorText = string.Format("Deve essere compresa fra {0:g} e {1:g}", DateStart, DateEnd);
                return;
            }

            if (dataVendita > DateTime.Today)
            {
                this.dateEditData.ErrorText = string.Format("Non può essere nel futuro ...");
                return;
            }

            if ((DateTime.Today - dataVendita).TotalDays > 240)
            {
                this.dateEditData.ErrorText = string.Format("Non può essere oltre 8 mesi indietro");
                return;
            }

            if (dataVendita.Year <= 2013)
            {
                this.dateEditData.ErrorText = string.Format("Non può essere nel 2013 o prima");
                return;
            }

            if (variante != null && postazione != null)
            {
                if (!variante.Biglietto.IsAttrib(Biglietto.STR_BIGLIETTO_STORICO))
                {
                    if (dataVendita.Date > new DateTime(2011, 6, 1))
                    {
                        XtraMessageBox.Show("Data deve essere precedente a giugno 2011.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if (variante.Biglietto.Percorso.Ingressi.Count > 1)
                {
                    XtraMessageBox.Show("Non biglietti cumulativi", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    Ingresso ingresso = variante.Biglietto.Percorso.Ingressi[0];

                    Vendita vendita = new Vendita(this.unitOfWork1);
                    vendita.DataContabile   = dataVendita.Date;
                    vendita.DataOraStampa   = dataVendita.Add(this.timeEditOra.Time.TimeOfDay);
                    vendita.Incasso         = (EnumIncasso)this.imageComboBoxEditIncasso.EditValue;
                    vendita.Postazione      = postazione;
                    vendita.Struttura       = ingresso.Struttura;
                    vendita.TotaleImporto   = variante.PrezzoAttuale.Prezzo * quantita;
                    vendita.TotalePersone   = quantita;
                    vendita.Utente          = this.unitOfWork1.GetObjectByKey <Utente>(Program.UtenteCollegato.Oid);
                    vendita.CodiceLeggibile = Vendita.NuovoCodiceVendita();
                    vendita.Save();

                    RigaVenditaVariante riga = new RigaVenditaVariante(this.unitOfWork1);
                    riga.PrezzoTotale   = vendita.TotaleImporto;
                    riga.PrezzoUnitario = variante.PrezzoAttuale.Prezzo;
                    riga.Quantita       = quantita;
                    riga.Titolo         = titolo;
                    riga.Variante       = variante;
                    riga.Vendita        = vendita;
                    riga.Save();

                    Stampa stampa = new Stampa(this.unitOfWork1);
                    stampa.FineValidita   = vendita.DataContabile;
                    stampa.InizioValidita = vendita.DataContabile;
                    stampa.ImportoTotale  = vendita.TotaleImporto;
                    stampa.Quantita       = quantita;
                    stampa.Vendita        = vendita;
                    stampa.Save();

                    stampa.GeneraBarCode(Program.Postazione, new List <Ingresso>());
                    stampa.Save();

                    RigaStampaIngresso rigastampa = new RigaStampaIngresso(this.unitOfWork1);
                    rigastampa.Ingresso       = ingresso;
                    rigastampa.Stampa         = stampa;
                    rigastampa.TotaleIngressi = quantita;
                    rigastampa.TotalePersone  = quantita;
                    rigastampa.Save();

                    Entrata entrata = new Entrata(this.unitOfWork1);
                    entrata.DataOraEntrata     = vendita.DataOraStampa;
                    entrata.Quantita           = quantita;
                    entrata.RigaStampaIngresso = rigastampa;
                    entrata.Save();

                    this.unitOfWork1.CommitChanges();

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            else
            {
                XtraMessageBox.Show("Selezionare Variante e Postazione", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #22
0
        //Inserisce un nuovo titolo, automaticamente viene inserito anche il sottotiolo di default
        public void Insert(Titolo titolo)
        {
            using (OracleCommand ocmd = new OracleCommand())
            {
                SottoTitolo s1 = new SottoTitolo(titolo);
                s1.Id          = 0;
                s1.RefIdTitolo = titolo.Id;

                ocmd.CommandText = insertStatement;
                ocmd.Parameters.AddRange(MapObjectToParams(titolo, true));
                ocmd.Connection = base.CurrentConnection;

                try
                {
                    ocmd.ExecuteNonQuery();

                    //param out
                    Int64 iNewID = default(Int64);
                    Int64.TryParse(ocmd.Parameters["pID_TIT"].Value.ToString(), out iNewID);
                    s1.RefIdTitolo = iNewID;

                    Context.DaoImpl.SottoTitoloDao.Insert(s1);

                    //todo.. MIGLIORARE
                    if (iNewID != default(int))
                    {
                        titolo.Id = iNewID;
                    }
                    else
                    {
                        throw new Exception(DalExMessages.ID_NON_RESTITUITO);
                    }
                }
                /*TODO: INSERIRE I LOG DELLE ECCEZIONI*/ catch (InvalidOperationException ioex)
                {
                    //throw new DALException(DalExMessages.RUBRICA_NON_INSERITA, ioex);

                    //TASK: Allineamento log - Ciro
                    ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_INSERITA,
                                                                "DAL_RUB_002", string.Empty,
                                                                string.Empty, ioex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;

                    //throw new ManagedException(DalExMessages.RUBRICA_NON_INSERITA, "DAL_RUB_002", "", "", "", "", "", ioex);
                }
                catch (OracleException oex)
                {
                    //throw new DALException(DalExMessages.RUBRICA_NON_INSERITA, oex);

                    //TASK: Allineamento log - Ciro
                    ManagedException mEx = new ManagedException(DalExMessages.RUBRICA_NON_INSERITA,
                                                                "DAL_RUB_001", string.Empty,
                                                                string.Empty, oex);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(mEx);
                    throw mEx;

                    //throw new ManagedException(DalExMessages.RUBRICA_NON_INSERITA, "DAL_RUB_001", "", "", "", "", "", oex);
                }
            }
        }
Example #23
0
        void ReleaseDesignerOutlets()
        {
            if (Carico1 != null)
            {
                Carico1.Dispose();
                Carico1 = null;
            }

            if (Desc != null)
            {
                Desc.Dispose();
                Desc = null;
            }

            if (InfoStack != null)
            {
                InfoStack.Dispose();
                InfoStack = null;
            }

            if (Ne1 != null)
            {
                Ne1.Dispose();
                Ne1 = null;
            }

            if (Ne10 != null)
            {
                Ne10.Dispose();
                Ne10 = null;
            }

            if (Ne11 != null)
            {
                Ne11.Dispose();
                Ne11 = null;
            }

            if (Ne12 != null)
            {
                Ne12.Dispose();
                Ne12 = null;
            }

            if (Ne13 != null)
            {
                Ne13.Dispose();
                Ne13 = null;
            }

            if (Ne14 != null)
            {
                Ne14.Dispose();
                Ne14 = null;
            }

            if (Ne15 != null)
            {
                Ne15.Dispose();
                Ne15 = null;
            }

            if (Ne2 != null)
            {
                Ne2.Dispose();
                Ne2 = null;
            }

            if (Ne3 != null)
            {
                Ne3.Dispose();
                Ne3 = null;
            }

            if (Ne4 != null)
            {
                Ne4.Dispose();
                Ne4 = null;
            }

            if (Ne5 != null)
            {
                Ne5.Dispose();
                Ne5 = null;
            }

            if (Ne6 != null)
            {
                Ne6.Dispose();
                Ne6 = null;
            }

            if (Ne7 != null)
            {
                Ne7.Dispose();
                Ne7 = null;
            }

            if (Ne8 != null)
            {
                Ne8.Dispose();
                Ne8 = null;
            }

            if (Ne9 != null)
            {
                Ne9.Dispose();
                Ne9 = null;
            }

            if (Pausa1 != null)
            {
                Pausa1.Dispose();
                Pausa1 = null;
            }

            if (Rips1 != null)
            {
                Rips1.Dispose();
                Rips1 = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (Serie1 != null)
            {
                Serie1.Dispose();
                Serie1 = null;
            }

            if (Slow1_Check != null)
            {
                Slow1_Check.Dispose();
                Slow1_Check = null;
            }

            if (Split1_Check != null)
            {
                Split1_Check.Dispose();
                Split1_Check = null;
            }

            if (StackES10 != null)
            {
                StackES10.Dispose();
                StackES10 = null;
            }

            if (StackES11 != null)
            {
                StackES11.Dispose();
                StackES11 = null;
            }

            if (StackES12 != null)
            {
                StackES12.Dispose();
                StackES12 = null;
            }

            if (StackES13 != null)
            {
                StackES13.Dispose();
                StackES13 = null;
            }

            if (StackES14 != null)
            {
                StackES14.Dispose();
                StackES14 = null;
            }

            if (StackES15 != null)
            {
                StackES15.Dispose();
                StackES15 = null;
            }

            if (StackES2 != null)
            {
                StackES2.Dispose();
                StackES2 = null;
            }

            if (StackES3 != null)
            {
                StackES3.Dispose();
                StackES3 = null;
            }

            if (StackES4 != null)
            {
                StackES4.Dispose();
                StackES4 = null;
            }

            if (StackES5 != null)
            {
                StackES5.Dispose();
                StackES5 = null;
            }

            if (StackES6 != null)
            {
                StackES6.Dispose();
                StackES6 = null;
            }

            if (StackES7 != null)
            {
                StackES7.Dispose();
                StackES7 = null;
            }

            if (StackES8 != null)
            {
                StackES8.Dispose();
                StackES8 = null;
            }

            if (StackES9 != null)
            {
                StackES9.Dispose();
                StackES9 = null;
            }

            if (StackEsercizio != null)
            {
                StackEsercizio.Dispose();
                StackEsercizio = null;
            }

            if (Stop1_Check != null)
            {
                Stop1_Check.Dispose();
                Stop1_Check = null;
            }

            if (Time1_Check != null)
            {
                Time1_Check.Dispose();
                Time1_Check = null;
            }

            if (Titolo != null)
            {
                Titolo.Dispose();
                Titolo = null;
            }

            if (ViewBackground != null)
            {
                ViewBackground.Dispose();
                ViewBackground = null;
            }

            if (ViewPrincipale != null)
            {
                ViewPrincipale.Dispose();
                ViewPrincipale = null;
            }
        }