protected override void OnAppearing() { bienBan = (BienBanViPham)BindingContext; BienBanViPhamService newService = new BienBanViPhamService(); bienBan = newService.GetLoiViPhamById(bienBan); loiViPhams = bienBan.LoiViPhams; BienBanViPhamView.ItemsSource = loiViPhams; if (bienBan.HDNopPhat == null) { hoaDonBtn.Text = "Thanh toán"; } else { hoaDonBtn.Text = "Xem hóa đơn"; } }
public void OnImageLichSuViPhamTapped(object sender, EventArgs e) { BienBanViPhamService newService = new BienBanViPhamService(); List <BienBanViPham> BienBanViPhams = newService.GetViPhamByUser(user); Navigation.PushAsync(new DanhSachBienBanViPhamPage { BindingContext = BienBanViPhams }); /*try * { * DisplayAlert("Thông báo", "Nhấn", "Tiếp tục"); * } * catch (Exception ex) * { * throw ex; * }*/ }
private void hoanThanh_Clicked(object sender, EventArgs e) { try { HoaDon hoaDon = new HoaDon { ThanhTien = Convert.ToDecimal(bienBan.TongTien), NgayThanhToan = DateTime.Now, HinhThucThanhToan_id = 1 }; HoaDonService createHoaDon = new HoaDonService(); var hd = createHoaDon.CreateHoaDon(hoaDon); if (hd == null) { DisplayAlert("Thành công", "Thanh toán thành công", "Tiếp tục"); return; } bienBan.HDNopPhat = hd.Id; //bienBan.HoaDon = hd; var htService = new BienBanViPhamService(); if (htService.UpdateBienBan(bienBan)) { DisplayAlert("Thành công", "Thanh toán thành công", "Tiếp tục"); ThanhToanSL.IsVisible = false; ChiTietHoaDonSL.IsVisible = true; BindingContext = new { ThanhTien = hd.ThanhTien, NgayThanhToan = hd.NgayThanhToan }; } else { try { DisplayAlert("Thành công", "Thanh toán thất bại", "Tiếp tục"); } catch (Exception ex) { throw ex; } } } catch (Exception ex1) { throw ex1; } }