예제 #1
0
        internal Cliente cercaCliente(int idcliente)
        {
            var cta = new ClienteTableAdapter();
            var cdt = cta.GetDataById(idcliente);
            var cl = cdt[0];

            var foundcliente = new Cliente
            {
                //ID, Nome, Cognome, IsFemmina, Indirizzo, ComuneResid, StatoResid, Telefoni, Descrizione, 
                //Email, DataNascita, ComuneNascita, StatoNascita, StatoCittadinanza, TipoDocumento, NumDocumento, 
                //DataRilascioDoc, ComuneRilascioDoc, StatoRilascioDoc, ProvenienzaIstat
                Id = cl.ID,
                Nome = cl.IsNomeNull() ? "" : cl.Nome,
                Cognome = cl.Cognome,
                IsFemmina = cl.IsFemmina,
                Indirizzo = cl.IsIndirizzoNull() ? "" : cl.Indirizzo,
                ComuneResidenza = cl.IsComuneResidNull() ? null : new Comune { Id = cl.ComuneResid },
                StatoResidenza = cl.IsStatoResidNull() ? null : new Stato { Id = cl.StatoResid },
                Telefoni = cl.IsTelefoniNull() ? "" : cl.Telefoni,
                Descr = cl.IsDescrizioneNull() ? "" : cl.Descrizione,
                Email = cl.IsEmailNull() ? "" : cl.Email,
                DataNascita = cl.IsDataNascitaNull() ? DateTime.MinValue : cl.DataNascita,
                ComuneNascita = cl.IsComuneNascitaNull() ? null : new Comune { Id = cl.ComuneNascita },
                StatoNascita = cl.IsStatoNascitaNull() ? null : new Stato { Id = cl.StatoNascita },
                StatoCittadinanza = cl.IsStatoCittadinanzaNull() ? null : new Stato { Id = cl.StatoCittadinanza },
                TipoDoc = cl.IsTipoDocumentoNull() ? null : new TipoDocumento { Id = cl.TipoDocumento },
                NumDoc = cl.IsNumDocumentoNull() ? "" : cl.NumDocumento,
                DataRilascioDoc = cl.IsDataRilascioDocNull() ? DateTime.MinValue : cl.DataRilascioDoc,
                ComuneRilascioDoc = cl.IsComuneRilascioDocNull() ? null : new Comune { Id = cl.ComuneRilascioDoc },
                StatoRilascioDoc = cl.IsStatoRilascioDocNull() ? null : new Stato { Id = cl.StatoRilascioDoc },
                ProvenIstat = cl.IsProvenienzaIstatNull() ? null : new ProvenienzaIstat { Id = cl.ProvenienzaIstat }
            };

            //raccolgo dati comuni (se presenti)
            var comta = new ComuneTableAdapter();
            SoggiorniDbDataSet.ComuneDataTable comdt;

            if (foundcliente.ComuneNascita != null)
            {
                comdt = comta.GetDataById(foundcliente.ComuneNascita.Id);
                foundcliente.ComuneNascita.Nome = comdt[0].Nome;
                foundcliente.ComuneNascita.Provincia = comdt[0].Provincia;
            }
            if (foundcliente.ComuneResidenza != null)
            {
                comdt = comta.GetDataById(foundcliente.ComuneResidenza.Id);
                foundcliente.ComuneResidenza.Nome = comdt[0].Nome;
                foundcliente.ComuneResidenza.Provincia = comdt[0].Provincia;
            }
            if (foundcliente.ComuneRilascioDoc != null)
            {
                comdt = comta.GetDataById(foundcliente.ComuneRilascioDoc.Id);
                foundcliente.ComuneRilascioDoc.Nome = comdt[0].Nome;
                foundcliente.ComuneRilascioDoc.Provincia = comdt[0].Provincia;
            }

            //raccolgo dati stati (se presenti)
            var stata = new StatoTableAdapter();
            SoggiorniDbDataSet.StatoDataTable stadt;

            if (foundcliente.StatoNascita != null)
            {
                stadt = stata.GetDataById(foundcliente.StatoNascita.Id);
                foundcliente.StatoNascita.Nome = stadt[0].Nome;
            }
            if (foundcliente.StatoResidenza != null)
            {
                stadt = stata.GetDataById(foundcliente.StatoResidenza.Id);
                foundcliente.StatoResidenza.Nome = stadt[0].Nome;
            }
            if (foundcliente.StatoRilascioDoc != null)
            {
                stadt = stata.GetDataById(foundcliente.StatoRilascioDoc.Id);
                foundcliente.StatoRilascioDoc.Nome = stadt[0].Nome;
            }
            if (foundcliente.StatoCittadinanza != null)
            {
                stadt = stata.GetDataById(foundcliente.StatoCittadinanza.Id);
                foundcliente.StatoCittadinanza.Nome = stadt[0].Nome;
            }

            //raccolgo dati provenienza istat
            if (foundcliente.ProvenIstat != null)
            {
                var prota = new ProvenienzaIstatTableAdapter();
                var prodt = prota.GetDataById(foundcliente.ProvenIstat.Id);
                foundcliente.ProvenIstat.Regione = prodt[0].Regione;
                foundcliente.ProvenIstat.Stato = prodt[0].Stato;
            }

            //raccolgo dati tipo documento
            if (foundcliente.TipoDoc != null)
            {
                var tdocta = new TipoDocumentoTableAdapter();
                var tdocdt = tdocta.GetDataById(foundcliente.TipoDoc.Id);
                foundcliente.TipoDoc.Descrizione = tdocdt[0].Descrizione;
            }


            return foundcliente;
        }
예제 #2
0
        internal List<Soggiorno> cercaSoggiorniByPagamento(int idpag)
        {
            var sogta = new SoggiornoTableAdapter();
            var sogdt = sogta.GetDataByPagamento(idpag);

            var clita = new ClienteTableAdapter();
            var camta = new CameraTableAdapter();
            var slist = new List<Soggiorno>();
            Soggiorno sog;
            foreach (var s in sogdt)
            {
                sog = new Soggiorno
                {
                    Id = s.ID,
                    Arrivo = s.Arrivo,
                    Partenza = s.Partenza,
                    TotaleSoggiorno = s.IsTotaleSoggiornoNull() ? 0 : s.TotaleSoggiorno,
                    TotalePernotto = s.IsTotaleCameraNull() ? 0 : s.TotaleCamera
                };
                var clidt = clita.GetDataById(s.ClienteId);
                sog.Cliente = new Cliente
                {
                    Id = clidt[0].ID,
                    Cognome = clidt[0].Cognome
                };
                var camdt = camta.GetDataById(s.CameraId);
                sog.Camera = new Camera
                {
                    Id = camdt[0].ID,
                    Numero = camdt[0].Numero
                };
                slist.Add(sog);
            }
            return slist;
        }