public IHttpActionResult PutPhieuNopPhat(int id, PhieuNopPhat phieuNopPhat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != phieuNopPhat.ma_phieu) { return(BadRequest()); } db.Entry(phieuNopPhat).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PhieuNopPhatExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
async void getThongTinPhieuNopPhat(int ma_vi_pham) { PhieuNopPhat phieunopphat = await new PhieuNopPhatsWebServices().GetPhieuNopPhatIdViPhamId(ma_vi_pham); if (phieunopphat.dia_chi_ship != null) { diaChiShipTxt.IsVisible = true; diaChiShipTxt.Text = phieunopphat.dia_chi_ship; tienShipTxt.IsVisible = true; tienShipTxt.Text = phieunopphat.tien_ship.ToString(); flagDaNhanXeTxt.IsVisible = true; if (phieunopphat.flag_da_nhan_xe == 1) { flagDaNhanXeTxt.Text = "Đã nhận xe"; } else { flagDaNhanXeTxt.Text = "Chưa nhận xe"; } } tongTienNopTxt.Text = phieunopphat.tong_tien_nop.ToString(); ngayNopPhatTxt.Text = phieunopphat.ngay_nop_phat.ToString(); }
public IHttpActionResult GetPhieuNopPhatByViPhamId(int idViPham) { PhieuNopPhat phieuNopPhat = db.PhieuNopPhats.Where(s => s.ma_vi_pham == idViPham).FirstOrDefault(); if (phieuNopPhat == null) { return(NotFound()); } return(Ok(phieuNopPhat)); }
public IHttpActionResult GetPhieuNopPhat(int id) { PhieuNopPhat phieuNopPhat = db.PhieuNopPhats.Find(id); if (phieuNopPhat == null) { return(NotFound()); } return(Ok(phieuNopPhat)); }
public IHttpActionResult PostPhieuNopPhat(PhieuNopPhat phieuNopPhat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PhieuNopPhats.Add(phieuNopPhat); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = phieuNopPhat.ma_phieu }, phieuNopPhat)); }
public IHttpActionResult DeletePhieuNopPhat(int id) { PhieuNopPhat phieuNopPhat = db.PhieuNopPhats.Find(id); if (phieuNopPhat == null) { return(NotFound()); } db.PhieuNopPhats.Remove(phieuNopPhat); db.SaveChanges(); return(Ok(phieuNopPhat)); }
public async Task <bool> AddPhieuNopPhat(PhieuNopPhat phieu) { bool ret = false; try { var client = new HttpClient(); var json = JsonConvert.SerializeObject(phieu); var data = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(uri, data); ret = response.IsSuccessStatusCode; } catch (Exception ex) { Debug.WriteLine("\tERROR {0}", ex.Message); } return(ret); }
public async Task <PhieuNopPhat> GetPhieuNopPhatIdViPhamId(int viPhamId) { PhieuNopPhat phieunopphat = new PhieuNopPhat(); try { var client = new HttpClient(); var response = await client.GetAsync(uri + "?idViPham=" + viPhamId); var content = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <PhieuNopPhat>(content); return(result); } catch (Exception ex) { Debug.WriteLine("\tERROR {0} alo alo bug", ex.Message); } return(phieunopphat); }
private async void NopPhatBtn(object sender, EventArgs e) { NopPhats nopphat = (NopPhats)BindingContext; ViPham vipham = new ViPham(); vipham.ma_vi_pham = nopphat.ma_vi_pham; vipham.tien_phat_them = nopphat.tien_phat_them; vipham.tong_tien_phat = nopphat.tong_tien_phat; vipham.thoi_gian_vi_pham = nopphat.thoi_gian_vi_pham; vipham.thoi_gian_xu_phat = nopphat.thoi_gian_xu_phat; vipham.flag_da_nop_phat = nopphat.flag_da_nop_phat; vipham.nguoi_vi_pham = nopphat.nguoi_vi_pham; vipham.nguoi_xu_phat = nopphat.nguoi_xu_phat; vipham.dia_diem_vi_pham = nopphat.dia_diem_vi_pham; vipham.xe_vi_pham = nopphat.xe_vi_pham; vipham.noi_giam_giu_xe = nopphat.noi_giam_giu_xe; PhieuNopPhat phieunopphat = new PhieuNopPhat(); phieunopphat.ma_vi_pham = nopphat.ma_vi_pham; phieunopphat.flag_ship = nopphat.flag_ship; phieunopphat.tien_phat = nopphat.tong_tien_phat; phieunopphat.tien_ship = nopphat.tien_ship; phieunopphat.tong_tien_nop = nopphat.tong_tien_nop; phieunopphat.phuong_thuc_dong_phat = nopphat.phuong_thuc_dong_phat; phieunopphat.dia_chi_ship = nopphat.dia_chi_ship; phieunopphat.flag_da_nhan_xe = 0; phieunopphat.ngay_nop_phat = DateTime.Now; bool status = await new PhieuNopPhatsWebServices().AddPhieuNopPhat(phieunopphat); if (status) { bool status1 = await new ViPhamWebServices().UpdateViPham(vipham); await DisplayAlert("Info", status1? "Nộp phạt hoàn tất!" : "Error", "Cancel"); } await Navigation.PushAsync(new ListChuaNopPhat()); }