public bool Inserthoa(Hoa Hoa) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "qlhoa.db"))) { connection.Insert(Hoa); return(true); } } catch (SQLiteException) { return(false); } }
private void Button_Clicked(object sender, EventArgs e) { Database db = new Database(); Hoa Hoa = new Hoa { Maloai = mySelectedFlower.Maloai, Tenhoa = txttenhoa.Text, Hinh = txthinh.Text, Mota = txtmota.Text, Gia = Convert.ToInt32(txtgia.Text), }; if (db.Inserthoa(Hoa)) { DisplayAlert("Notice", "Add Flower Successful!", "OK"); } else { DisplayAlert("Notice", "Add Flower Failed!", "OK"); } }