コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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
            });
        }
コード例 #4
0
 public BienBanViPham addBienBanViPham(BienBanViPham bienBanViPham)
 {
     using (var db = new QLHTGTEntities())
     {
         db.BienBanViPhams.Add(bienBanViPham);
         if (db.SaveChanges() > 0)
         {
             return(bienBanViPham);
         }
     }
     return(null);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 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 };
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
        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";
            }
        }
コード例 #10
0
 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);
 }
コード例 #11
0
 public bool Put([FromBody] BienBanViPham bienBan)
 {
     return(bienBanViPhamRepository.updateHDNopPhat_BienBanViPham(bienBan));
 }
コード例 #12
0
        // PUT api/loaixe

        public bool Put([FromBody] BienBanViPham bienBanViPham)
        {
            return(bienBanViPhamRepository.updateBienBanViPham(bienBanViPham));
        }
コード例 #13
0
        // POST api/loaixe

        public bool Post([FromBody] BienBanViPham bienBanViPham)
        {
            return(bienBanViPhamRepository.addBienBanViPham(bienBanViPham));
        }
コード例 #14
0
        //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));
        }