protected override bool OnBackButtonPressed() { var scanPage = ScannerView.GetInstance(); scanPage.popupIsOpen = false; return(base.OnBackButtonPressed()); }
public static ScannerView GetInstance() { if (_instance == null) { _instance = new ScannerView(); } return(_instance); }
private async void Confirm_Clicked(object sender, EventArgs e) { var httpClient = new HttpClient(); using (Acr.UserDialogs.UserDialogs.Instance.Loading("Updating..")) { if (AppValue.KKType == 1) //ONLINE { BanKiemKe banKiemKe = AppValue.banKiemKe; try { HttpResponseMessage response; if (!string.IsNullOrEmpty(thietBi.TB_ID)) { response = await httpClient.PostAsJsonAsync(Definitions.Localhost + "api/ChiTietBanKiemKe/CTBKK_XacNhanKK?dv_QL=" + banKiemKe.KK_MADONVI + "&bkk_ID=" + banKiemKe.KK_CODE + "&ngay_TAO=" + banKiemKe.KK_NGAYTAO.ToString("yyyy-MM-dd") + "&ma_TB=" + this.thietBi.TB_ID + "&tt_SAU=" + State_Picker.SelectedItem.ToString(), new { }); } else { response = await httpClient.PostAsJsonAsync(Definitions.Localhost + "api/ChiTietBanKiemKe/CTBKK_XacNhanKK_Ten?dv_QL=" + banKiemKe.KK_MADONVI + "&bkk_ID=" + banKiemKe.KK_CODE + "&ngay_TAO=" + banKiemKe.KK_NGAYTAO.ToString("yyyy-MM-dd") + "&ten_TB=" + this.thietBi.TB_TEN + "&tt_SAU=" + State_Picker.SelectedItem.ToString(), new { }); } var content = await response.Content.ReadAsStringAsync(); JObject rss = JObject.Parse(content); var resultAPI = rss["result"]; string validStr = (resultAPI as JArray).First["result"].ToString(); if (validStr == "Lỗi" || validStr == "Bản kiểm kê ko tồn tại") { await DisplayAlert("Lỗi", "Kiểm kê thất bại, kiểm tra lại thông tin kiểm kê!", "OK"); return; } } catch { await DisplayAlert("Lỗi", "Kết nối server bị lỗi, kiểm tra lại đường dẫn!", "OK"); return; } } else //OFFLINE { using (UserDialogs.Instance.Loading("Updating..")) { //tạo record mới ChiTietBanKiemKe chiTietBanKiemKe = new ChiTietBanKiemKe { CTBKK_MA_TB = thietBi.TB_ID, CTBKK_TEN_TB = thietBi.TB_TEN, CTBKK_TT_SAU = State_Picker.SelectedItem.ToString(), CTBKK_THOI_GIAN = DateTime.Now }; //thêm record vào list (trên source) appvalue DataUpdater.AddNewRecordToKiemKe(chiTietBanKiemKe); //update record vào LocalData(trên source) DataUpdater.UpdateKiemKeInLocalData(); //update data xuống file DataUpdater.UpdateDataToFile(); } } var scanPage = ScannerView.GetInstance(); scanPage.popupIsOpen = false; await App.Current.MainPage.Navigation.PopAsync(); } var message = "Kiểm kê thành công"; DependencyService.Get <IMessage>().Shorttime(message); }