예제 #1
0
 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 ex)
     {
         return(false);
     }
 }
예제 #2
0
        private void btn_themhoa(object sender, EventArgs e)
        {
            Hoa     hoa     = new Hoa();
            LoaiHoa loaihoa = (LoaiHoa)pickerLoaiHoa.SelectedItem;

            hoa.MaLoai = loaihoa.MaLoai;
            hoa.TenHoa = txtTenHoa.Text.ToString();
            hoa.Hinh   = pickerHinh.SelectedItem.ToString();
            hoa.DonGia = int.Parse(txtGiaBan.Text);
            hoa.Mota   = txtMoTa.Text.ToString();
            if (App.db.InsertHoa(hoa))
            {
                DisplayAlert("Notification", "Thêm hoa thành công", "OK");
            }
            else
            {
                DisplayAlert("Notification", "Thất bại ...", "OK");
            }
            Clear();
        }