public ObservableCollection <DiariaModel> LeDadosDiaria <S, T>(string query) where S : IDbConnection, new() where T : IDbDataAdapter, IDisposable, new() { var ListaDeDiarias = new ObservableCollection <DiariaModel>(); using (var conn = new S()) { using (var da = new T()) { using (da.SelectCommand = conn.CreateCommand()) { DiariaModel 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) { aux = new DiariaModel() { Id = row["Id"].ToString(), Name = row["Name"].ToString(), Client = row["Client"].ToString(), Fornecedor = row["Supplier"].ToString(), Obs = row["Obs"].ToString(), NF = row["NF"].ToString() }; ListaDeDiarias.Add(aux); } } } } return(ListaDeDiarias); }
private void Registrar_Alteracao(object sender, DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) //caso a alteração seja confirmada { DiariaModel teste = e.Row.Item as DiariaModel; //o item da coleção correspondente a linha alterada var el = e.EditingElement as TextBox; //o campo alterado d.AlterarDiaria(teste.Id, "Obs", el.Text); //el.text é o novo valor do campo } }