Beispiel #1
0
        public Zbor FindOneByDestinatieAndDateTime(String destinatie, String DataTimp)
        {
            IDbConnection con = DBUtils.getConnection(props);

            using (var comm = con.CreateCommand())
            {
                comm.CommandText = "select * from Zboruri where Destinatia=@destinatia and Plecare=@plecare";

                IDbDataParameter paramDestinatie = comm.CreateParameter();
                paramDestinatie.ParameterName = "@destinatia";
                paramDestinatie.Value         = destinatie;
                comm.Parameters.Add(paramDestinatie);

                IDbDataParameter paramPlecare = comm.CreateParameter();
                paramPlecare.ParameterName = "@plecare";
                paramPlecare.Value         = DataTimp;
                comm.Parameters.Add(paramPlecare);

                using (var dataR = comm.ExecuteReader())
                {
                    if (dataR.Read())
                    {
                        int      IdZ        = dataR.GetInt32(0);
                        String   Destinatie = dataR.GetString(1);
                        String   PlecareS   = dataR.GetString(2);
                        DateTime Plecare    = DateTime.Parse(PlecareS);
                        String   Aeroport   = dataR.GetString(3);
                        int      Locuri     = dataR.GetInt32(4);
                        Zbor     z          = new Zbor(IdZ, Destinatie, Plecare, Aeroport, Locuri);
                        log.InfoFormat("Exiting findOne with value {0}", z);
                        return(z);
                    }
                }
            }
            log.InfoFormat("Exiting findOne with value {0}", null);
            return(null);
        }