public void cadastrar(Prato prat) { ContentValues values = new ContentValues(); values.Put("nome", prat.Nome); values.Put("valor", prat.Valor); WritableDatabase.Insert(TABELA, null, values); Log.Info(TAG, "Prato cadastradado: " + prat.Nome); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Adicionar); b = FindViewById <Button>(Resource.Id.button1); nome = FindViewById <EditText>(Resource.Id.editText1); valor = FindViewById <EditText>(Resource.Id.editText2); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); b.Click += (object sender, EventArgs e) => { Prato prat = new Prato(); prat.Nome = nome.Text; if (valor.Text != "") { prat.Valor = double.Parse(valor.Text, CultureInfo.InvariantCulture); //TESTS } else { prat.Valor = 0.0; } PratoDAO dao = new PratoDAO(this); dao.cadastrar(prat); dao.Close(); Finish(); }; }
public void deletar(Prato prat) { String[] args = { prat.ID.ToString() }; WritableDatabase.Delete(TABELA, "id=?", args); }