Exemplo n.º 1
0
        public ObservableCollection <Motorista> LeDadosEntrega <S, T>(string query) where S : IDbConnection, new()
            where T : IDbDataAdapter, IDisposable, new()
        {
            var ListaDeMotoristas = new ObservableCollection <Motorista>();

            using (var conn = new S())
            {
                using (var da = new T())
                {
                    using (da.SelectCommand = conn.CreateCommand())
                    {
                        Motorista aux;
                        da.SelectCommand.CommandText = query;
                        da.SelectCommand.Connection.ConnectionString = conexao;
                        DataSet ds = new DataSet();
                        da.Fill(ds);
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            DateTime.TryParse(row["LastCall"].ToString(), out DateTime Ult);
                            DateTime.TryParse(row["DateM"].ToString(), out DateTime Manif);
                            aux = new Motorista(row["Id"].ToString(), row["Name"].ToString(), row["Obs"].ToString())
                            {
                                QuemLigou     = row["Caller"].ToString(),
                                Intervalo     = int.Parse(row["Interval"].ToString()),
                                UltimaLigacao = Ult,
                                NF            = row["NF"].ToString(),
                                Fornecedor    = row["Supplier"].ToString(),
                                Cliente       = row["Client"].ToString(),
                                Acao          = row["Action"].ToString(),
                                DataManifesto = Manif
                            };
                            aux.CalculaProxima();
                            ListaDeMotoristas.Add(aux);
                        }
                    }
                }
            }
            return(ListaDeMotoristas);
        }