Пример #1
0
        internal List<SchedaNotifica> cercaSchedeNotificaBySoggiorno(int idsoggiorno)
        {
            
            OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.SoggiorniDbConnectionString);
            string queryString = "SELECT * FROM QuerySchedeBySoggiorno";
            OleDbCommand cmd = new OleDbCommand(queryString, conn);
            cmd.Parameters.Add("Soggiorno", OleDbType.Char, 255).Value = idsoggiorno;
            conn.Open();
            OleDbDataReader reader = cmd.ExecuteReader();
            var sclist = new List<SchedaNotifica>();
            SchedaNotifica sc;

            var comta = new ComuneTableAdapter();
            SoggiorniDbDataSet.ComuneDataTable comdt;

            var stata = new StatoTableAdapter();
            SoggiorniDbDataSet.StatoDataTable stadt;

            var tdocta = new TipoDocumentoTableAdapter();
            SoggiorniDbDataSet.TipoDocumentoDataTable tdocdt;

            while (reader.Read())
            {
                /*
                 * SchedaNotifica.Cliente, Cliente.Nome, Cliente.Cognome, Cliente.IsFemmina, Cliente.Indirizzo, 
                 * Cliente.ComuneResid, Cliente.StatoResid, Cliente.DataNascita, Cliente.ComuneNascita, 
                 * Cliente.StatoNascita, Cliente.StatoCittadinanza, Cliente.TipoDocumento, Cliente.NumDocumento, 
                 * Cliente.DataRilascioDoc, Cliente.ComuneRilascioDoc, Cliente.StatoRilascioDoc, Cliente.ProvenienzaIstat,
                 * SchedaNotifica.Numero, SchedaNotifica.Anno
                 */
                sc = new SchedaNotifica
                {
                    SoggiornoId = idsoggiorno,
                    Cliente = new Cliente{
                        Id = int.Parse(reader[0].ToString()),
                        Nome = reader[1].ToString(),
                        Cognome = reader[2].ToString(),
                        IsFemmina = bool.Parse(reader[3].ToString()),
                        Indirizzo = reader[4].ToString(),
                        ComuneResidenza = reader[5].ToString()=="" ? null : new Comune{ Id = int.Parse(reader[5].ToString())},
                        StatoResidenza = reader[6].ToString() == "" ? null : new Stato { Id = int.Parse(reader[6].ToString()) },
                        DataNascita = reader[7].ToString()=="" ? DateTime.MinValue : DateTime.Parse(reader[7].ToString()),
                        ComuneNascita = reader[8].ToString() == "" ? null : new Comune { Id = int.Parse(reader[8].ToString()) },
                        StatoNascita = reader[9].ToString() == "" ? null : new Stato { Id = int.Parse(reader[9].ToString()) },
                        StatoCittadinanza = reader[10].ToString() == "" ? null : new Stato { Id = int.Parse(reader[10].ToString()) },
                        TipoDoc = reader[11].ToString() == "" ? null : new TipoDocumento { Id = int.Parse(reader[11].ToString()) },
                        NumDoc = reader[12].ToString(),
                        DataRilascioDoc = reader[13].ToString() == "" ? DateTime.MinValue : DateTime.Parse(reader[13].ToString()),
                        ComuneRilascioDoc = reader[14].ToString() == "" ? null : new Comune { Id = int.Parse(reader[14].ToString()) },
                        StatoRilascioDoc = reader[15].ToString() == "" ? null : new Stato { Id = int.Parse(reader[15].ToString()) },
                        ProvenIstat= reader[16].ToString() == "" ? null : new ProvenienzaIstat { Id = int.Parse(reader[16].ToString()) }
                    },
                    Numero = reader[17].ToString()=="" ? 0 : int.Parse(reader[17].ToString()),
                    Anno = reader[18].ToString()=="" ? 0 : int.Parse(reader[18].ToString())
                };

                //raccolgo dati comuni, stati e tipo doc
                if (sc.Cliente.ComuneNascita != null)
                {
                    comdt = comta.GetDataById(sc.Cliente.ComuneNascita.Id);
                    sc.Cliente.ComuneNascita.Nome = comdt[0].Nome;
                    sc.Cliente.ComuneNascita.Provincia = comdt[0].Provincia;
                }
                if (sc.Cliente.ComuneResidenza != null)
                {
                    comdt = comta.GetDataById(sc.Cliente.ComuneResidenza.Id);
                    sc.Cliente.ComuneResidenza.Nome = comdt[0].Nome;
                    sc.Cliente.ComuneResidenza.Provincia = comdt[0].Provincia;
                }
                if (sc.Cliente.ComuneRilascioDoc != null)
                {
                    comdt = comta.GetDataById(sc.Cliente.ComuneRilascioDoc.Id);
                    sc.Cliente.ComuneRilascioDoc.Nome = comdt[0].Nome;
                    sc.Cliente.ComuneRilascioDoc.Provincia = comdt[0].Provincia;
                }
                stadt = stata.GetDataById(sc.Cliente.StatoNascita.Id);
                sc.Cliente.StatoNascita.Nome = stadt[0].Nome;
                stadt = stata.GetDataById(sc.Cliente.StatoResidenza.Id);
                sc.Cliente.StatoResidenza.Nome = stadt[0].Nome;
                stadt = stata.GetDataById(sc.Cliente.StatoRilascioDoc.Id);
                sc.Cliente.StatoRilascioDoc.Nome = stadt[0].Nome;
                stadt = stata.GetDataById(sc.Cliente.StatoCittadinanza.Id);
                sc.Cliente.StatoCittadinanza.Nome = stadt[0].Nome;
                tdocdt = tdocta.GetDataById(sc.Cliente.TipoDoc.Id);
                sc.Cliente.TipoDoc.Descrizione = tdocdt[0].Descrizione;
                sclist.Add(sc);

            }
            reader.Close();
            conn.Close();
            return sclist;
        }
Пример #2
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;
        }
Пример #3
0
        internal List<TipoDocumento> getAllTipiDoc()
        {
            var tdta = new TipoDocumentoTableAdapter();
            var tddt = tdta.GetData();

            var tlist = new List<TipoDocumento>();
            foreach (SoggiorniDbDataSet.TipoDocumentoRow tdr in tddt.Rows)
            {
                tlist.Add(
                    new TipoDocumento
                    {
                        Id = tdr.ID,
                        Descrizione = tdr.Descrizione
                    });
            }

            return tlist;
        }
Пример #4
0
        internal List<SchedaNotifica> cercaSchedeNotificaBetween(DateTime arrivoDa, DateTime arrivoA)
        {
            OleDbConnection conn = new OleDbConnection(Properties.Settings.Default.SoggiorniDbConnectionString);
            string queryString = "SELECT * FROM QuerySchedeByArrivo";
            OleDbCommand cmd = new OleDbCommand(queryString, conn);
            cmd.Parameters.Add("ArrivoDa", OleDbType.Date).Value = arrivoDa;
            cmd.Parameters.Add("ArrivoA", OleDbType.Date).Value = arrivoA;
            conn.Open();
            OleDbDataReader reader = cmd.ExecuteReader();
            var sclist = new List<SchedaNotifica>();
            SchedaNotifica sc;

            var comta = new ComuneTableAdapter();
            SoggiorniDbDataSet.ComuneDataTable comdt;

            var stata = new StatoTableAdapter();
            SoggiorniDbDataSet.StatoDataTable stadt;

            var tdocta = new TipoDocumentoTableAdapter();
            SoggiorniDbDataSet.TipoDocumentoDataTable tdocdt;

            while (reader.Read())
            {
                /*
                 * Soggiorno.Arrivo, Cliente.Cognome, Cliente.Nome, Cliente.IsFemmina, Cliente.DataNascita, 
                 * Cliente.ComuneNascita, Cliente.StatoNascita, Cliente.StatoCittadinanza, Cliente.ComuneResid, 
                 * Cliente.StatoResid, Cliente.Indirizzo, Cliente.TipoDocumento, Cliente.NumDocumento, 
                 * Cliente.ComuneRilascioDoc, Cliente.StatoRilascioDoc, Cliente.DataRilascioDoc
                 */
                sc = new SchedaNotifica
                {
                    Soggiorno = new Soggiorno{Arrivo = DateTime.Parse(reader[0].ToString())},
                    Cliente = new Cliente
                    {
                        Cognome = reader[1].ToString(),
                        Nome = reader[2].ToString(),
                        IsFemmina = bool.Parse(reader[3].ToString()),
                        DataNascita = DateTime.Parse(reader[4].ToString()),
                        ComuneNascita = new Comune { Id = int.Parse(reader[5].ToString()) },
                        StatoNascita = new Stato { Id = int.Parse(reader[6].ToString()) },
                        StatoCittadinanza = new Stato { Id = int.Parse(reader[7].ToString()) },
                        ComuneResidenza = new Comune { Id = int.Parse(reader[8].ToString()) },
                        StatoResidenza = new Stato { Id = int.Parse(reader[9].ToString()) },
                        Indirizzo = reader[10].ToString(),
                        TipoDoc = new TipoDocumento { Id = int.Parse(reader[11].ToString()) },
                        NumDoc = reader[12].ToString(),
                        ComuneRilascioDoc = new Comune { Id = int.Parse(reader[13].ToString()) },
                        StatoRilascioDoc = new Stato { Id = int.Parse(reader[14].ToString()) },
                        DataRilascioDoc = DateTime.Parse(reader[15].ToString())
                    }
                };

                //raccolgo dati comuni, stati e tipo doc
                comdt = comta.GetDataById(sc.Cliente.ComuneNascita.Id);
                sc.Cliente.ComuneNascita.CodicePolizia = comdt[0].CodicePolizia;
                sc.Cliente.ComuneNascita.Provincia = comdt[0].Provincia;
                comdt = comta.GetDataById(sc.Cliente.ComuneResidenza.Id);
                sc.Cliente.ComuneResidenza.CodicePolizia = comdt[0].CodicePolizia;
                sc.Cliente.ComuneResidenza.Provincia = comdt[0].Provincia;
                comdt = comta.GetDataById(sc.Cliente.ComuneRilascioDoc.Id);
                sc.Cliente.ComuneRilascioDoc.CodicePolizia = comdt[0].CodicePolizia;
                stadt = stata.GetDataById(sc.Cliente.StatoNascita.Id);
                sc.Cliente.StatoNascita.CodicePolizia = stadt[0].CodicePolizia;
                sc.Cliente.StatoNascita.Nome = stadt[0].Nome;
                stadt = stata.GetDataById(sc.Cliente.StatoResidenza.Id);
                sc.Cliente.StatoResidenza.CodicePolizia = stadt[0].CodicePolizia;
                sc.Cliente.StatoResidenza.Nome = stadt[0].Nome;
                stadt = stata.GetDataById(sc.Cliente.StatoRilascioDoc.Id);
                sc.Cliente.StatoRilascioDoc.Nome = stadt[0].Nome;
                sc.Cliente.StatoRilascioDoc.CodicePolizia = stadt[0].CodicePolizia;
                stadt = stata.GetDataById(sc.Cliente.StatoCittadinanza.Id);
                sc.Cliente.StatoCittadinanza.CodicePolizia = stadt[0].CodicePolizia;
                tdocdt = tdocta.GetDataById(sc.Cliente.TipoDoc.Id);
                sc.Cliente.TipoDoc.CodicePolizia = tdocdt[0].CodicePolizia;
                sclist.Add(sc);

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