Beispiel #1
0
 private void addHoa_Clicked(object sender, EventArgs e)
 {
     if (cboloaihoa.SelectedIndex >= 0)
     {
         LoaiHoa l = (LoaiHoa)cboloaihoa.SelectedItem;
         Hoa     h = new Hoa
         {
             MaLoai = l.MaLoai,
             TenHoa = txttenhoa.Text,
             Hinh   = txthinh.Text,
             Gia    = double.Parse(txtgia.Text),
             MoTa   = txtMota.Text
         };
         if (db.InsertHoa(h) == true)
         {
             DisplayAlert("Thông báo", "Thêm hoa thành công", "OK");
         }
         else
         {
             DisplayAlert("Thông báo", "Thêm hoa Thất bại", "OK");
         }
     }
     else
     {
         DisplayAlert("Thông báo", "Bạn phải chọn loại hoa", "OK");
     }
 }
Beispiel #2
0
 //Xử lý thêm hoa
 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);
     }
 }