public bool updateHDNopPhat_BienBanViPham(BienBanViPham bienBan) { using (var db = new QLHTGTEntities()) { try { BienBanViPham bienBanUpdate = db.BienBanViPhams.Find(bienBan.ID); if (bienBan == null) { return(false); } bienBanUpdate.HDNopPhat = bienBan.HDNopPhat; if (db.SaveChanges() > 0) { return(true); } else { return(false); } } catch { return(false); } } }
public void addBienBanViPham() { BienBanViPham bienBanViPham = new BienBanViPham() { TongTien = 0, TongDiemTru = 0, ThoiGianViPham = new DateTime(2021, 1, 15), BangLai_id = 2 }; Assert.AreNotEqual(null, bienBanViPhamRepository.addBienBanViPham(bienBanViPham)); }
private void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { ListView lv = (ListView)sender; // this assumes your List is bound to a List<Club> BienBanViPham bienBan = (BienBanViPham)lv.SelectedItem; Navigation.PushAsync(new ChiTietBienBanViPhamPage { BindingContext = bienBan }); }
public BienBanViPham addBienBanViPham(BienBanViPham bienBanViPham) { using (var db = new QLHTGTEntities()) { db.BienBanViPhams.Add(bienBanViPham); if (db.SaveChanges() > 0) { return(bienBanViPham); } } return(null); }
public BienBanViPham findById(int id) { using (var db = new QLHTGTEntities()) { BienBanViPham bienBanViPham = db.BienBanViPhams.Include("HoaDon").Include("LoiViPhams").Where(b => b.ID == id).FirstOrDefault(); if (bienBanViPham != null) { return(bienBanViPham); } } return(null); }
public BienBanViPham GetLoiViPhamById(BienBanViPham BienBan) { try { var client = new HttpClient(); var response = client.GetAsync(uri + $"/GetById?id={BienBan.Id}"); var result = JsonConvert.DeserializeObject <BienBanViPham>(response.Result.Content.ReadAsStringAsync().Result); return(result); } catch (HttpRequestException ex) { Console.WriteLine("ERROR: " + ex.Message); return(null); } }
protected override void OnAppearing() { bienBan = (BienBanViPham)BindingContext; if (bienBan.HDNopPhat == null) { ChiTietHoaDonSL.IsVisible = false; } else { int hoaDon_id = (int)bienBan.HDNopPhat; hoaDonService = new HoaDonService(); var hoaDon = hoaDonService.GetHoaDonByID(hoaDon_id); ThanhToanSL.IsVisible = false; BindingContext = new { ThanhTien = hoaDon.ThanhTien, NgayThanhToan = hoaDon.NgayThanhToan }; } }
public bool UpdateBienBan(BienBanViPham bienBan) { try { var client = new HttpClient(); var json = JsonConvert.SerializeObject(bienBan); var data = new StringContent(json, Encoding.UTF8, "application/json"); var response = client.PutAsync(uri, data); var result = JsonConvert.DeserializeObject <bool>(response.Result.Content.ReadAsStringAsync().Result); return(result); } catch (HttpRequestException ex) { Console.WriteLine("ERROR: " + ex.Message); return(false); } }
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 bool addLoiToBienBanViPham(int bienBanViPham_id, int loiViPham_id) { using (var db = new QLHTGTEntities()) { LoiViPham loiViPham = db.LoiViPhams.Find(loiViPham_id); if (loiViPham == null) { return(false); } BienBanViPham bienBanViPham = db.BienBanViPhams.Find(bienBanViPham_id); if (bienBanViPham == null) { return(false); } bienBanViPham.LoiViPhams.Add(loiViPham); bienBanViPham.TongDiemTru = bienBanViPham.TongDiemTru + loiViPham.DiemTru; bienBanViPham.TongTien = bienBanViPham.TongTien + loiViPham.MucPhat; if (db.SaveChanges() > 0) { return(true); } } return(false); }
public bool Put([FromBody] BienBanViPham bienBan) { return(bienBanViPhamRepository.updateHDNopPhat_BienBanViPham(bienBan)); }
// PUT api/loaixe public bool Put([FromBody] BienBanViPham bienBanViPham) { return(bienBanViPhamRepository.updateBienBanViPham(bienBanViPham)); }
// POST api/loaixe public bool Post([FromBody] BienBanViPham bienBanViPham) { return(bienBanViPhamRepository.addBienBanViPham(bienBanViPham)); }
//Thêm biên bản vi phạm /* * { * "TongTien":0, * "TongDiemTru":0, * "ThoiGianViPham":"15/1/2021", * "BangLai_id":2 * } */ public BienBanViPham Post(BienBanViPham bienBanViPham) { return(bienBanViPhamRepository.addBienBanViPham(bienBanViPham)); }