Example #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;
        }
Example #2
0
        internal List<SchedaNotifica> cercaSchedeNotificaPerIstat(DateTime arrivoDa, DateTime arrivoA)
        {
            OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.SoggiorniDbConnectionString);
            string queryString = "SELECT * FROM QuerySchedeByPeriodoIstat";
            OleDbCommand cmd = new OleDbCommand(queryString, conn);
            cmd.Parameters.Add("DataDa", OleDbType.Date).Value = arrivoDa;
            cmd.Parameters.Add("DataA", OleDbType.Date).Value = arrivoA;
            conn.Open();
            OleDbDataReader reader = cmd.ExecuteReader();
            var sclist = new List<SchedaNotifica>();
            SchedaNotifica sc;

            var provta = new ProvenienzaIstatTableAdapter();
            SoggiorniDbDataSet.ProvenienzaIstatDataTable provdt;

            while (reader.Read())
            {
                /*
                 * Soggiorno.Arrivo, Soggiorno.Partenza, Cliente.ProvenienzaIstat
                 */
                sc = new SchedaNotifica
                {
                    Soggiorno = new Soggiorno { 
                        Arrivo = DateTime.Parse(reader[0].ToString()),
                        Partenza = DateTime.Parse(reader[1].ToString())
                    },
                    Cliente = new Cliente{ 
                        ProvenIstat = new ProvenienzaIstat{ Id = int.Parse(reader[2].ToString())}
                    }
                };

                //raccolgo dati su provenienza istat
                provdt = provta.GetDataById(sc.Cliente.ProvenIstat.Id);
                sc.Cliente.ProvenIstat.Sigla = provdt[0].SiglaTuriweb;
                sc.Cliente.ProvenIstat.Regione = provdt[0].Regione;
                sc.Cliente.ProvenIstat.Stato = provdt[0].Stato;
                sclist.Add(sc);

            }
            reader.Close();
            conn.Close();
            return sclist;
        }