Example #1
0
 public List <IDomainObject> VratiListu(SqlDataReader reader)
 {
     try
     {
         List <IDomainObject> proforme = new List <IDomainObject>();
         while (reader.Read())
         {
             Debug.WriteLine(reader[7].ToString());
             Proforma proforma = new Proforma
             {
                 Id        = (long)reader[0],
                 Datum     = (DateTime)reader[1],
                 Zaposleni = new Zaposleni()
                 {
                     Id = (long)reader[4]
                 },
                 Porudzbina = new Porudzbina()
                 {
                     Id = (long)reader[5]
                 },
                 Racun = new Racun()
                 {
                     Id = (long)reader[6], Vrednost = reader[7].ToString(), Banka = new Banka()
                     {
                         Id = (long)reader[8]
                     }
                 },
                 NacinIsporuke = new NacinIsporuke()
                 {
                     Id = (long)reader[9], NazivIsporuke = reader[10].ToString()
                 }
             };
             if (reader[2] == DBNull.Value)
             {
                 proforma.Popust = null;
             }
             else
             {
                 proforma.Popust = (int)reader[2];
             }
             if (reader[3] == DBNull.Value)
             {
                 proforma.UkupnaCena = null;
             }
             else
             {
                 proforma.UkupnaCena = (double)reader[3];
             }
             proforme.Add(proforma);
         }
         return(proforme);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #2
0
 public IDomainObject VratiObjekat(SqlDataReader reader)
 {
     try
     {
         Proforma proforma = new Proforma();
         while (reader.Read())
         {
             proforma.Id        = (long)reader[0];
             proforma.Datum     = (DateTime)reader[1];
             proforma.Zaposleni = new Zaposleni()
             {
                 Id = (long)reader[4]
             };
             proforma.Porudzbina = new Porudzbina()
             {
                 Id = (long)reader[5]
             };
             proforma.Racun = new Racun()
             {
                 Id = (long)reader[6], Vrednost = reader[7].ToString(), Banka = new Banka()
                 {
                     Id = (long)reader[8]
                 }
             };
             proforma.NacinIsporuke = new NacinIsporuke()
             {
                 Id = (long)reader[9], NazivIsporuke = reader[10].ToString()
             };
             if (reader[2] == DBNull.Value)
             {
                 proforma.Popust = null;
             }
             else
             {
                 proforma.Popust = (int)reader[2];
             }
             if (reader[3] == DBNull.Value)
             {
                 proforma.UkupnaCena = null;
             }
             else
             {
                 proforma.UkupnaCena = (double)reader[3];
             }
             break;
         }
         return(proforma);
     }
     catch (Exception)
     {
         return(null);
     }
 }