protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Paciente); pacienteDAO = new PacienteDAO(); modelPaciete = pacienteDAO.GetPacienteById(1); // Preencher view EditText edtNomePaciente = FindViewById <EditText>(Resource.Id.paciente_edt_paciente); EditText edtNomeResponsavel = FindViewById <EditText>(Resource.Id.paciente_edt_responsavel); edtNomePaciente.Text = modelPaciete.NomePaciente; edtNomeResponsavel.Text = modelPaciete.NomeResponsavel; // Salvar informações Button btmSalvar = FindViewById <Button>(Resource.Id.paciente_btn_salvar); btmSalvar.Click += delegate { modelPaciete.NomePaciente = edtNomePaciente.Text; modelPaciete.NomeResponsavel = edtNomeResponsavel.Text; pacienteDAO.UpdatePaciente(modelPaciete); Toast.MakeText(ApplicationContext, "Salvo", ToastLength.Short).Show(); }; }
public ModelPaciente GetPacienteById(int id) { try { ModelPaciente modelPaciente = new ModelPaciente(); string sqldb_query; sqldb_query = "SELECT idPaciente, nomePaciente, nomeResponsavel " + "FROM paciente " + "WHERE idPaciente = " + id; Android.Database.ICursor sqldb_cursor = null; sqldb_cursor = sqldb.RawQuery(sqldb_query, null); if (sqldb_cursor.MoveToFirst()) { modelPaciente.IdPaciente = sqldb_cursor.GetInt(0); modelPaciente.NomePaciente = sqldb_cursor.GetString(1); modelPaciente.NomeResponsavel = sqldb_cursor.GetString(2); } return(modelPaciente); } catch (SQLiteException ex) { return(null); } }
public void UpdatePaciente(ModelPaciente modelPaciente) { try { string sqldb_query = "UPDATE paciente " + "SET nomePaciente = '" + modelPaciente.NomePaciente + "'," + " nomeResponsavel = '" + modelPaciente.NomeResponsavel + "' " + "WHERE idPaciente = " + modelPaciente.IdPaciente; sqldb.ExecSQL(sqldb_query); } catch (SQLiteException ex) { } }