private async void GetPacientes(long id) { isVisible = true; IsRunning = true; //testa a conexao var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { } else { await PageDialogService.DisplayAlertAsync("app", "Sem conexao!", "Ok"); IsRunning = false; isVisible = false; await NavigationService.GoBackAsync(); return; } //var apiSecurity = App.Current.Resources["URLAPI"].ToString(); // if (CrossConnectivity.Current.IsConnected) // { Lista = await apiService.getPacientes(id); if (Lista == null) { await PageDialogService.DisplayAlertAsync("app", "lista nula", "OK"); return; } if (Lista.Count == 0) { await PageDialogService.DisplayAlertAsync("app", "Dentista sem pacientes para o periodo", "OK"); IsRunning = false; isVisible = false; await NavigationService.GoBackAsync(); return; } pacs = new ObservableCollection <paciente>(Lista); /* foreach (var item in Lista) * { * pacs.Add(new paciente() * { * Id = item.Id, * nome = item.nome, * dt_atendimento = item.dt_atendimento, * dt_nascimento = item.dt_nascimento, * photo = item.photo * * }); * }*/ IsRunning = false; isVisible = false; }
private async void GetExames() { isVisible = true; IsRunning = true; var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { } else { await PageDialogService.DisplayAlertAsync("app", "Sem conexao!", "Ok"); IsRunning = false; isVisible = false; await NavigationService.GoBackAsync(); return; } try { var Lista = await apiService.getExamespdf(_paciente); if (Lista == null) { IsRunning = false; isVisible = false; // await _navigationService.GoBackAsync(); Mostra_label = true; Mostra_listview = false; Mensagem = "Paciente sem Arquivos Pdf!"; return; } if (Lista.Count == 0) { // await _dialogService.DisplayAlertAsync("app", "Paciente sem exames", "OK"); IsRunning = false; isVisible = false; // await _navigationService.GoBackAsync(); Mostra_label = true; Mostra_listview = false; Mensagem = "Paciente sem Arquivos Pdf!"; return; } pdf = new ObservableCollection <ArqImagens>(Lista); /*foreach (var item in Lista) * { * imgs.Add(new ArqImagens() * { * nome_arquivo_completo = item.nome_arquivo_completo * * }); * }*/ } catch (Exception ex) { ex.Message.ToString(); } IsRunning = false; isVisible = false; }
private async void OnSelectImage(object obj) { if (IsBusy) { return; } if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await PageDialogService.DisplayAlertAsync("Lỗi", "Điện thoại không hổ trợ máy ảnh", "Đóng"); return; } var filePath = ""; IsBusy = true; try { // Thuc hien cong viec tai day var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>(); if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted) { cameraStatus = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); storageStatus = await CrossPermissions.Current.RequestPermissionAsync <StoragePermission>(); } if (storageStatus == PermissionStatus.Granted && cameraStatus == PermissionStatus.Granted) { try { var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Full, CompressionQuality = 92 }); if (file != null) { filePath = file.Path; } } catch (Exception ex) { await ShowError(ex); } } else if (storageStatus != PermissionStatus.Unknown || cameraStatus != PermissionStatus.Unknown) { await PageDialogService.DisplayAlertAsync("Yêu cầu bị từ chối", "Không thể chụp ảnh.", "Đóng"); } if (string.IsNullOrEmpty(filePath) == false) { ImagePathBindProp = filePath; } else { ImagePathBindProp = ""; } } catch (Exception e) { await ShowError(e); } finally { IsBusy = false; } }
private async void OnSubmit() { if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await PageDialogService.DisplayAlertAsync("No Internet", "Unable to submit feedback without internet, try finding a paper copy", "OK"); return; } if (Busy) { return; } var requiredQuestions = Questions.Where(x => x.IsRequired); if (requiredQuestions.Any(x => string.IsNullOrWhiteSpace(x.Answer))) { await PageDialogService.DisplayAlertAsync("Missing Fields", "Survey is incomplete, complete highlighted questions", "OK"); foreach (var item in Questions.Where(x => x.IsRequired)) { item.TextColor = string.IsNullOrWhiteSpace(item.Answer) ? Color.Red : (Color)App.Current.Resources["DarkBlue"]; } return; } Busy = true; bool anyErrors = false; foreach (var endpoint in _endpoints) { try { var deviceId = await AppCenter.GetInstallIdAsync(); var model = new FeedbackPayload { Year = 2019, DeviceId = deviceId.ToString(), SurveyAnswers = JsonConvert.SerializeObject(Questions.Select(x => new { x.Question, x.Answer })) }; var isSuccessful = await EndpointService.PostAsync(endpoint, model); if (!isSuccessful) { anyErrors = true; } } catch (Exception ex) { anyErrors = true; } } if (anyErrors) { Busy = false; await PageDialogService.DisplayAlertAsync("Unable to Submit", "Find event staff for paper survey", "OK"); return; } var messages = await CompleteMessageService.GetAsync(); var complete = messages .Select(x => new Complete { Message = x.Title, Summary = x.Message }) .FirstOrDefault(); var parameters = new NavigationParameters { { Constants.Navigation.Parameters.GoBackToRoot, true }, { Constants.Navigation.Parameters.Title, "Survey" }, { Constants.Navigation.Parameters.Complete, complete } }; await NavigationService.NavigateAsync(Constants.Navigation.CompletePage, parameters); }
public override async void OnNavigatedTo(INavigationParameters parameters) { try { if (_dataviewColumnList == null) { _dataviewColumnList = await _restClient.GetDataviewAtributeList(Settings.WorkgroupInventoryThumbnailDataview); if (_dataviewColumnList != null) { if (_dataviewColumnList.Count > 1) { Header1 = _dataviewColumnList[1].title; } if (_dataviewColumnList.Count > 2) { Header2 = _dataviewColumnList[2].title; } if (_dataviewColumnList.Count > 3) { Header3 = _dataviewColumnList[3].title; } if (_dataviewColumnList.Count > 4) { Header4 = _dataviewColumnList[4].title; } if (_dataviewColumnList.Count > 5) { Header5 = _dataviewColumnList[5].title; } if (_dataviewColumnList.Count > 6) { Header6 = _dataviewColumnList[6].title; } if (_dataviewColumnList.Count > 7) { Header7 = _dataviewColumnList[7].title; } } } if (parameters.ContainsKey("inventory")) //Update UI { InventoryThumbnail tempInventory = (InventoryThumbnail)parameters["inventory"]; WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == tempInventory.inventory_id); if (inventoryThumbnailItem == null) { InventoryList.Add(new WrappedSelection <InventoryThumbnail> { Item = tempInventory, IsSelected = false }); } else { inventoryThumbnailItem.Item = tempInventory; /* * int index = InventoryList.IndexOf(inventoryThumbnailItem); * InventoryList.Remove(inventoryThumbnailItem); * InventoryList.Insert(index, new WrappedSelection<InventoryThumbnail> { Item = tempInventory, IsSelected = false }); */ } } if (parameters.ContainsKey("InventoryThumbnail")) { InventoryThumbnail tempInventory = (InventoryThumbnail)parameters["InventoryThumbnail"]; WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == tempInventory.inventory_id); if (inventoryThumbnailItem == null) { InventoryList.Add(new WrappedSelection <InventoryThumbnail> { Item = tempInventory, IsSelected = false }); } else { inventoryThumbnailItem.Item = tempInventory; } AccessionCount = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count(); TotalQuantity = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum(); } if (parameters.ContainsKey("InventoryThumbnailList")) { List <InventoryThumbnail> inventoryList = (List <InventoryThumbnail>)parameters["InventoryThumbnailList"]; foreach (var inventoryThumbnail in inventoryList) { var wrappedInventory = InventoryList.FirstOrDefault(x => x.Item.inventory_id == inventoryThumbnail.inventory_id); if (wrappedInventory == null) { WrappedSelection <InventoryThumbnail> temp = new WrappedSelection <InventoryThumbnail>() { Item = inventoryThumbnail, IsSelected = false }; InventoryList.Add(temp); } else { wrappedInventory.Item = inventoryThumbnail; /*int index = _inventoryList.IndexOf(wrappedInventory); * InventoryList.Remove(wrappedInventory); * InventoryList.Insert(index, new WrappedSelection<InventoryThumbnail> { Item = inventoryThumbnail, IsSelected = wrappedInventory.IsSelected });*/ } } AccessionCount = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count(); TotalQuantity = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum(); } } catch (Exception ex) { await PageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); } }
private async void OnSaveInventoryCommandExecuted() { try { /*foreach (var att in InventoryAtributeList) * { * if (att.IsRequired) * { * if (att.Value == null) * { * throw new Exception(string.Format("{0} is required", att.Caption)); * } * if (att.Value.GetType() == typeof(string) && att.Type != typeof(string) && string.IsNullOrWhiteSpace(att.Value.ToString())) * { * throw new Exception(string.Format("{0} is required", att.Caption)); * } * if (att.Type == typeof(int) && (int)att.Value <= 0) * { * throw new Exception(string.Format("{0} is required", att.Caption)); * } * } * }*/ foreach (var att in InventoryAtributeList) { if (!att.IsReadOnly) { PropertyInfo[] props = typeof(Inventory).GetProperties(); var prop = props.FirstOrDefault(x => x.Name.Equals(att.Name)); if (prop != null) { if (att.ControlType.Equals("TEXTPICKER")) { string value; if (att.IsPicker) { value = att.Value == null ? null : (string)att.Value; } else { value = att.SecondValue; } prop.SetValue(NewInventory, value); } else if (att.ControlType.Equals("DROPDOWN")) { if (att.CodeValueList != null && att.CodeValue != null) { prop.SetValue(NewInventory, (string)att.CodeValue.ValueMember); } else { prop.SetValue(NewInventory, null); } } else { //check if Value is null if (att.Value == null) { prop.SetValue(NewInventory, null); } else { if (att.Value.GetType() == typeof(string)) //If value is empty and attribute type is different from string, assign null or 0? { TypeConverter converter = TypeDescriptor.GetConverter(att.Type); converter = TypeDescriptor.GetConverter(att.Type); var newValue = converter.ConvertFrom(att.Value); prop.SetValue(NewInventory, newValue); } else { if (att.ControlType.Equals("CHECKBOX") && att.Value.GetType() == typeof(bool)) { if ((bool)att.Value) { prop.SetValue(NewInventory, "Y"); } else { prop.SetValue(NewInventory, "N"); } } else { prop.SetValue(NewInventory, att.Value); } } } } } } } string result = null; List <InventoryThumbnail> newInventoryList = null; if (_isNewInventory) { result = await _restClient.CreateInventory(NewInventory); await PageDialogService.DisplayAlertAsync("Saved Inventory Id", result, "OK"); newInventoryList = await _restClient.Search("@inventory.inventory_id = " + result, "get_mob_inventory_thumbnail", "inventory"); } else { result = await _restClient.UpdateInventory(NewInventory); await PageDialogService.DisplayAlertAsync("Message", "Successfully saved", "OK"); newInventoryList = await _restClient.Search("@inventory.inventory_id = " + NewInventory.inventory_id, "get_mob_inventory_thumbnail", "inventory"); } InventoryThumbnail newInventory = newInventoryList[0]; var navigationParams = new NavigationParameters(); navigationParams.Add("InventoryThumbnail", newInventory); await NavigationService.GoBackAsync(navigationParams); } catch (Exception ex) { await PageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); } }
private async Task ExecuteUploadimagecommandAsync() { try { var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>(); var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); var status = await CrossPermissions.Current.CheckPermissionStatusAsync <MediaLibraryPermission>(); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.MediaLibrary)) { await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the media library.", "OK"); } status = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); } if (status == PermissionStatus.Granted) { } if (cameraStatus != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera)) { await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the camera.", "OK"); } cameraStatus = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); } if (storageStatus != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await PageDialogService.DisplayAlertAsync(null, "App needs permission to access the phone's local storage.", "OK"); } storageStatus = await CrossPermissions.Current.RequestPermissionAsync <StoragePermission>(); } if (status == PermissionStatus.Granted && cameraStatus == PermissionStatus.Granted) { List <IActionSheetButton> buttons = new List <IActionSheetButton>() { ActionSheetButton.CreateButton("Gallery", new Action(async() => { await UplaodImageFromGallery(); })), ActionSheetButton.CreateButton("Camera", new Action(async() => { await UplaodImageFromCamera(); })), ActionSheetButton.CreateCancelButton("Cancel", new Action(() => { })) }; await PageDialogService.DisplayActionSheetAsync("Select Option", buttons.ToArray()); } else { await PageDialogService.DisplayAlertAsync(null, "Sorry, permission is not granted to use the media library.", "OK"); } } catch (Exception ex) { string st = ex.ToString(); } }
public AboutViewModel(INavigationService navigationService, IEventAggregator eventAggregator, IStoreManager storeManager, IToast toast, IFavoriteService favoriteService, ILoggerFacade logger, ILaunchTwitter twitter, ISSOClient ssoClient, IPushNotifications pushNotifications, IReminderService reminderService, IPageDialogService pageDialogService) : base(navigationService, eventAggregator, storeManager, toast, favoriteService, logger, twitter, ssoClient, pushNotifications, reminderService, pageDialogService) { ToolBarItems.Add(new ToolbarItem { Text = LoginText, Command = LoginCommand }); AboutItems.Clear(); AboutItems.Add(new Models.MenuItem { Name = "About this app", Icon = "icon_venue.png" }); InfoItems.AddRange(new[] { new Models.MenuItem { Name = "Conference Feed", Icon = "menu_feed.png", Pagename = nameof(FeedPage) }, new Models.MenuItem { Name = "Sponsors", Icon = "menu_sponsors.png", Pagename = nameof(SponsorsPage) }, new Models.MenuItem { Name = "Venue", Icon = "menu_venue.png", Pagename = nameof(VenuePage) }, new Models.MenuItem { Name = "Floor Maps", Icon = "menu_plan.png", Pagename = nameof(FloorMapsPage) }, new Models.MenuItem { Name = "Conference Info", Icon = "menu_info.png", Pagename = nameof(ConferenceInformationPage) }, new Models.MenuItem { Name = "Settings", Icon = "menu_settings.png", Pagename = nameof(SettingsPage) } }); accountItem = new Models.MenuItem { Name = "Logged in as:" }; syncItem = new Models.MenuItem { Name = "Last Sync:" }; pushItem = new Models.MenuItem { Name = "Enable push notifications" }; pushItem.Command = DelegateCommand.FromAsyncHandler(async () => { if (PushNotifications.IsRegistered) { UpdateItems(); return; } if (Settings.AttemptedPush) { var response = await PageDialogService.DisplayAlertAsync("Push Notification", "To enable push notifications, please go into Settings, Tap Notifications, and set Allow Notifications to on.", "Settings", "Maybe Later"); if (response) { PushNotifications.OpenSettings(); } } await PushNotifications.RegisterForNotifications(); }); UpdateItems(); AccountItems.Add(accountItem); AccountItems.Add(syncItem); AccountItems.Add(pushItem); //This will be triggered wen Settings.PropertyChanged += (sender, e) => { if (e.PropertyName == "Email" || e.PropertyName == "LastSync" || e.PropertyName == "PushNotificationsEnabled") { UpdateItems(); OnPropertyChanged("AccountItems"); } }; AccountItems.CollectionChanged += (sender, e) => { AccountListHeightAdjustment = AccountItems.Count; }; AccountListHeightAdjustment = AccountItems.Count; _isRegistered = PushNotifications.IsRegistered; }
private async Task ComprarItemAsync(Item item) { await PageDialogService.DisplayAlertAsync("Compra item", $"Compra do item '{item.Descricao}' confirmada com sucesso.", "OK"); }
public IngredientDetailsPageViewModel(PageDialogService pageDialogService, INavigationService navigationService, ICocktailsManager cocktailsManager, IIngredientsManager ingredientsManager) : base(pageDialogService, navigationService) { _cocktailsManager = cocktailsManager; _ingredientsManager = ingredientsManager; GoToDrinksCommand = new DelegateCommand <string>(async(param) => { await GoToDrinksByIngredient(param); }); }
public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IBluetoothService bluetoothService) : base(navigationService, pageDialogService) { //_blueToothService = DependencyService.Get<IBluetoothService>(); Title = "Main Page"; PrintMessage = ""; _blueToothService = bluetoothService; _printer = new Printer(bluetoothService); BindDeviceList(); PrintCommand = new DelegateCommand(async() => { if (String.IsNullOrEmpty(SelectedDevice)) { await PageDialogService.DisplayAlertAsync("Please select a Bluetooh Printer...", null, "Ok"); } else { _printer.MyPrinter = SelectedDevice; if (String.IsNullOrEmpty(PrintMessage)) { await PageDialogService.DisplayAlertAsync("Field to Print can not be empty...", null, "Ok"); } else { await _printer.Reset(); await _printer.SetAlignCenter(); await _printer.WriteLine($"Normal: {PrintMessage}"); await _printer.LineFeed(); await _printer.BoldOn(); await _printer.WriteLine($"Bold: {PrintMessage}"); await _printer.BoldOff(); await _printer.LineFeed(); await _printer.WriteLine_Big($"Grande: \n{PrintMessage}"); await _printer.LineFeed(); await _printer.SetUnderLine($"Subrayado: {PrintMessage}"); await _printer.LineFeed(); await _printer.SetAlignRight(); await _printer.WriteLine_Bold("Negrito en la Derecha:"); await _printer.BoldOn(); await _printer.WriteLine_Bigger($"G1: {PrintMessage}", 1); await _printer.BoldOff(); await _printer.WriteLine_Bold("Underline..."); await _printer.SetUnderLineOn(); await _printer.WriteLine_Bigger($"G2: {PrintMessage}", 2); await _printer.WriteLine_Bigger($"G3: {PrintMessage}", 3); await _printer.SetUnderLineOff(); await _printer.LineFeed(2); await _printer.SetAlignCenter(); await _printer.WriteLine_Bold("Texto Reverse..."); await _printer.SetReverseOn(); await _printer.WriteLine_Bigger($"Reverse: {PrintMessage}", 1); await _printer.SetReverseOff(); await _printer.WriteLine_Bigger($"Not Reverse: {PrintMessage}", 1); await _printer.LineFeed(3); await _printer.Reset(); } } }); }
private async void OnSaveInvoice(object obj) { IsBusy = true; try { // Thuc hien cong viec tai day if (!Application.Current.Properties.ContainsKey("session")) { await PageDialogService.DisplayAlertAsync("Thông báo", "Chưa bắt đầu phiên làm việc!", "Đồng ý"); await NavigationService.NavigateAsync(nameof(SessionPage)); return; } if (InvoiceBindProp.Table == null) { await PageDialogService.DisplayAlertAsync("Thông báo", "Chưa chọn bàn!", "Đồng ý"); var selectedCategory = ListCategoryBindProp.FirstOrDefault(z => z.IsSelected); if (selectedCategory != null) { selectedCategory.IsSelected = false; } MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = true; ListInvoiceFrameVisibleBindProp = false; ZoneFrameVisibleBindProp = true; } else { var invoiceToCreate = new InvoiceForCreateDto(InvoiceBindProp); var json = JsonConvert.SerializeObject(invoiceToCreate); var content = new StringContent(json, Encoding.UTF8, "application/json"); // Thuc hien cong viec tai day using (var client = new HttpClient()) { HttpResponseMessage response = new HttpResponseMessage(); if (InvoiceBindProp.Id == Guid.Empty) { response = await client.PostAsync(Properties.Resources.BaseUrl + "invoices/", content); } else { response = await client.PutAsync(Properties.Resources.BaseUrl + "invoices/", content); } switch (response.StatusCode) { case HttpStatusCode.Created: var invoice = JsonConvert.DeserializeObject <InvoiceDto>(await response.Content.ReadAsStringAsync()); await _connection.InvokeAsync("SendInvoice", invoice); CurrentZone.IsSelected = false; CurrentCategory.IsSelected = false; InvoiceBindProp = null; MenuFrameVisibleBindProp = false; ListInvoiceFrameVisibleBindProp = true; ZoneFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = true; SettingFrameVisibleBindProp = false; DiscountFrameVisibleBindProp = false; break; case HttpStatusCode.NoContent: await _connection.InvokeAsync("UpdateInvoice", InvoiceBindProp); TempInvoiceBindProp = InvoiceBindProp; TempInvoiceBindProp = null; InvoiceBindProp = null; CurrentCategory.IsSelected = false; CurrentZone.IsSelected = false; MenuFrameVisibleBindProp = false; ListInvoiceFrameVisibleBindProp = true; ZoneFrameVisibleBindProp = false; MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = true; SettingFrameVisibleBindProp = false; DiscountFrameVisibleBindProp = false; break; } }; } } catch (Exception e) { await ShowErrorAsync(e); } finally { IsBusy = false; } }
private async void OnSelectFrame(string obj) { if (IsBusy) { return; } IsBusy = true; try { // Thuc hien cong viec tai day var selectedCategory = ListCategoryBindProp.FirstOrDefault(z => z.IsSelected); var selectedZone = ListZoneBindProp.FindFirst(z => z.IsSelected); switch (obj) { case "setting": if (InvoiceBindProp != null) { var ok = await PageDialogService.DisplayAlertAsync("Cảnh báo", "Hủy hóa đơn?", "Đồng ý", "Không"); if (ok) { if (selectedCategory != null) { selectedCategory.IsSelected = false; } MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = false; SettingFrameVisibleBindProp = true; DiscountFrameVisibleBindProp = false; InvoiceBindProp = null; TempInvoiceBindProp = null; } } else { MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = false; SettingFrameVisibleBindProp = true; DiscountFrameVisibleBindProp = false; } break; case "invoice": if (InvoiceBindProp != null) { var ok = await PageDialogService.DisplayAlertAsync("Cảnh báo", "Hủy hóa đơn?", "Đồng ý", "Không"); if (ok) { if (selectedZone != null) { selectedZone.IsSelected = false; } if (selectedCategory != null) { selectedCategory.IsSelected = false; } InvoiceBindProp = null; TempInvoiceBindProp = null; MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = true; SettingFrameVisibleBindProp = false; DiscountFrameVisibleBindProp = false; ListInvoiceFrameVisibleBindProp = true; ZoneFrameVisibleBindProp = false; } } else { if (selectedCategory != null) { selectedCategory.IsSelected = false; } MenuFrameVisibleBindProp = false; InvoiceFrameVisibleBindProp = true; SettingFrameVisibleBindProp = false; DiscountFrameVisibleBindProp = false; } break; case "discount": if (selectedCategory != null) { selectedCategory.IsSelected = false; } MenuFrameVisibleBindProp = true; InvoiceFrameVisibleBindProp = false; ItemFrameVisibleBindProp = false; DiscountFrameVisibleBindProp = true; SettingFrameVisibleBindProp = false; break; case "invoicelist": if (selectedZone != null) { selectedZone.IsSelected = false; } if (selectedCategory != null) { selectedCategory.IsSelected = false; } ListInvoiceFrameVisibleBindProp = true; ZoneFrameVisibleBindProp = false; break; default: break; } } catch (Exception e) { await ShowErrorAsync(e); } finally { IsBusy = false; } }
public async override void OnNavigatedTo(INavigationParameters parameters) { switch (parameters.GetNavigationMode()) { case NavigationMode.Back: if (parameters.ContainsKey("item")) { var item = parameters["item"] as ItemForInvoiceDto; if (InvoiceBindProp == null) { InvoiceBindProp = new InvoiceDto(); } InvoiceBindProp.Items.Add(item); InvoiceBindProp.TotalPrice += item.Value; } if (parameters.ContainsKey(nameof(InvoiceBindProp))) { var invoice = parameters[nameof(InvoiceBindProp)] as InvoiceDto; await _connection.InvokeAsync("DeleteInvoice", InvoiceBindProp.Id); InvoiceBindProp = null; TempInvoiceBindProp = null; } break; case NavigationMode.New: using (var client = new HttpClient()) { var categoryTask = client.GetAsync(Properties.Resources.BaseUrl + "categories/"); var discountTask = client.GetAsync(Properties.Resources.BaseUrl + "discounts/"); var invoiceTask = client.GetAsync(Properties.Resources.BaseUrl + "invoices/"); var zoneTask = client.GetAsync(Properties.Resources.BaseUrl + "zones/"); var allTasks = new List <Task> { categoryTask, discountTask, invoiceTask, zoneTask }; while (allTasks.Any()) { Task finished = await Task.WhenAny(allTasks); if (finished == categoryTask) { if (categoryTask.Result.IsSuccessStatusCode) { var categories = JsonConvert.DeserializeObject <IEnumerable <CategoryDto> >(await categoryTask.Result.Content.ReadAsStringAsync()); foreach (var category in categories) { ListCategoryBindProp.Add(category); } } else { await PageDialogService.DisplayAlertAsync("Lỗi", $"{await categoryTask.Result.Content.ReadAsStringAsync()}", "Đóng"); } } else if (finished == discountTask) { if (discountTask.Result.IsSuccessStatusCode) { var discounts = JsonConvert.DeserializeObject <IEnumerable <DiscountDto> >(await discountTask.Result.Content.ReadAsStringAsync()); foreach (var discount in discounts) { ListDiscountBindProp.Add(discount); } } else { await PageDialogService.DisplayAlertAsync("Lỗi", $"{await discountTask.Result.Content.ReadAsStringAsync()}", "Đóng"); } } else if (finished == invoiceTask) { if (invoiceTask.Result.IsSuccessStatusCode) { var invoices = JsonConvert.DeserializeObject <IEnumerable <InvoiceDto> >(await invoiceTask.Result.Content.ReadAsStringAsync()); foreach (var invoice in invoices) { ListInvoiceBindProp.Add(invoice); } } else { await PageDialogService.DisplayAlertAsync("Lỗi", $"{await invoiceTask.Result.Content.ReadAsStringAsync()}", "Đóng"); } } else if (finished == zoneTask) { if (zoneTask.Result.IsSuccessStatusCode) { var zones = JsonConvert.DeserializeObject <IEnumerable <ZoneDto> >(await zoneTask.Result.Content.ReadAsStringAsync()); foreach (var zone in zones) { ListZoneBindProp.Add(zone); } } else { await PageDialogService.DisplayAlertAsync("Lỗi", $"{await zoneTask.Result.Content.ReadAsStringAsync()}", "Đóng"); } } allTasks.Remove(finished); } var id = Xamarin.Essentials.Preferences.Get("token", "token"); var response = await client.GetAsync(Properties.Resources.BaseUrl + "users/" + id); if (response.IsSuccessStatusCode) { var user = JsonConvert.DeserializeObject <UserDto>(await response.Content.ReadAsStringAsync()); CurrentUserBindProp = user; } } break; case NavigationMode.Forward: break; case NavigationMode.Refresh: break; default: break; } }
private void AlertAction() { //_dialogService.DisplayAlertAsync("Alert", "You have been alerted", "OK"); PageDialogService.DisplayAlertAsync("Alert", "You have been alerted!", "OK"); }
public PlayerInfoPageViewModel(INavigationService navigationService, IApiService apiService, PageDialogService pagedialogservice, SeassonData seassonData) : base(navigationService, apiService, pagedialogservice, seassonData) { ViewTeamRosterCommand = new DelegateCommand(async() => { if (!string.IsNullOrEmpty(Player.TeamId)) { await GoToTeamRosterPage(); } }); OpenTwitterProfileCommand = new DelegateCommand(async() => { if (await this.HasInternet()) { if (!string.IsNullOrEmpty(Player.TwitterId)) { try { await Browser.OpenAsync(new Uri($"{TwitterUrl}{Player.TwitterId.Replace("@", "")}"), BrowserLaunchMode.SystemPreferred); } catch (Exception) { await pagedialogservice.DisplayAlertAsync("Alert", "Twitter profile does not exist", "OK"); } } else { await pagedialogservice.DisplayAlertAsync("Alert", "Twitter profile does not exist", "OK"); } } }); }
private async void ConfirmAction() { var action = await PageDialogService.DisplayAlertAsync("Confirm", "Would you like to play a game?", "Yes", "No"); await PageDialogService.DisplayAlertAsync("Alert", $"You choose '{action}'", "OK"); }
private async void Login() { var testa = await ChecapermisaoService.checa_permissao(); if (string.IsNullOrEmpty(Usuarioid)) { await PageDialogService.DisplayAlertAsync("Erro", "Prencha o campo Email!", "OK"); mostra_mensagem = true; mensagem = "Prencha o campo Email!"; // await dialogServices.ShowMessage("Erro", "Prencha o campo Usuário!"); return; } if (string.IsNullOrEmpty(Senha)) { await PageDialogService.DisplayAlertAsync("Erro", "Prencha o campo Senha!", "OK"); return; } var response = new Response(); IsRunning = true; var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { response = await apiService.Login(Usuarioid, Senha); } else { await PageDialogService.DisplayAlertAsync("Erro", "Dispositivo sem Conexâo", "OK"); //await dialogServices.ShowMessage("Erro", response.Message); IsRunning = false; return; } IsRunning = false; if (!response.IsSuccess) { await PageDialogService.DisplayAlertAsync("Erro", response.Message, "OK"); //await dialogServices.ShowMessage("Erro", response.Message); return; } var User = (Dentista)response.Result; if (User.Id == 999999999) { User.tipo = "Administrador"; App.usuariologado = User; //Settings.Grava_Settings(JsonConvert.SerializeObject(User)); Preferences.Set("dentistaserializado", JsonConvert.SerializeObject(User)); //Preferences.Get("dentistaserializado", JsonConvert.SerializeObject(User)); await NavigationService.NavigateAsync("/MasterPage/NavigationPage/DentistaPage"); } else { User.tipo = "Dentista"; App.usuariologado = User; // Settings.Grava_Settings(JsonConvert.SerializeObject(User)); Preferences.Set("dentistaserializado", JsonConvert.SerializeObject(User)); //Preferences.Get("dentistaserializado", JsonConvert.SerializeObject(User)); var navigationParams = new NavigationParameters(); navigationParams.Add("paciente", User); await NavigationService.NavigateAsync("/MasterPage/NavigationPage/DentistaPage"); // await _navigationService.NavigateAsync("/MasterPage/NavigationPage/ExamesPage", navigationParams); } //grava usuario // //await _navigationService.NavigateAsync("MainPage"); //navigationServices.SetMainPage(User); }
public override async void OnNavigatedTo(INavigationParameters parameters) { try { if (_dataviewColumnList == null) { _dataviewColumnList = await _restClient.GetDataviewAtributeList(Settings.WorkgroupInventoryDataview); } InventoryThumbnail tempInventory; if (parameters.ContainsKey("InventoryThumbnail")) { _isNewInventory = false; tempInventory = (InventoryThumbnail)parameters["InventoryThumbnail"]; NewInventory = await _restClient.ReadInventory(tempInventory.inventory_id); PropertyInfo[] props = typeof(Inventory).GetProperties(); foreach (PropertyInfo prop in props) { var att = _inventoryAttributeArray.FirstOrDefault(x => x.Name.Equals(prop.Name)); if (att != null) { att.Value = prop.GetValue(NewInventory, null); if (att.ControlType.Equals("DROPDOWN")) { //var displayName = await _restClient.GetCodeValueDisplayName(att.ControlSource, att.Value.ToString()); //att.DisplayValue = displayName; att.CodeValueList = await _restClient.GetCodeValueByGroupName(att.ControlSource); //Apply gui_filter if (_dataviewColumnList != null) { var dvField = _dataviewColumnList.FirstOrDefault(f => f.field_name.Equals(att.Name)); if (dvField != null && !string.IsNullOrEmpty(dvField.gui_filter)) { var filterList = dvField.gui_filter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = att.CodeValueList.Count - 1; i >= 0; i--) { if (!filterList.Any(x => x.Equals(att.CodeValueList[i].ValueMember))) { att.CodeValueList.RemoveAt(i); } } } } if (att.CodeValueList != null && att.CodeValueList.Count > 0 && att.Value != null) { att.CodeValue = att.CodeValueList.FirstOrDefault(c => c.ValueMember.Equals((string)att.Value)); } } else if (att.ControlType.Equals("LOOKUPPICKER") && att.Value != null && (int)att.Value > 0) { var displayName = await _restClient.GetLookupByValueMember(att.ControlSource, (int)att.Value); att.DisplayValue = displayName; } } } var attLocation1 = _inventoryAttributeArray.FirstOrDefault(att => att.Name.Equals("storage_location_part1")); attLocation1.ControlType = "TEXTPICKER"; attLocation1.ListValues = await _restClient.GetAllLocation1List(); attLocation1.IsPicker = true; var attLocation2 = _inventoryAttributeArray.FirstOrDefault(att => att.Name.Equals("storage_location_part2")); attLocation2.ControlType = "TEXTPICKER"; attLocation2.ListValues = await _restClient.GetAllLocation2List(); attLocation2.IsPicker = true; InventoryAtributeList = new ObservableCollection <EntityAttribute>(_inventoryAttributeArray.ToList()); } if (parameters.ContainsKey("inventory")) { _isNewInventory = false; Inventory = (InventoryThumbnail)parameters["inventory"]; PropertyInfo[] props = typeof(InventoryThumbnail).GetProperties(); foreach (PropertyInfo prop in props) { var att = _inventoryAttributeArray.FirstOrDefault(x => x.Name.Equals(prop.Name)); if (att != null) { att.Value = prop.GetValue(Inventory, null); } } InventoryAtributeList = new ObservableCollection <EntityAttribute>(_inventoryAttributeArray.ToList()); } //Updete from LookupPicker if (parameters.ContainsKey("LookupPicker")) { EntityAttribute tempAtt = (EntityAttribute)parameters["LookupPicker"]; /* * int index = InventoryAtributeList.IndexOf(tempAtt); * if (index > -1) * { * InventoryAtributeList[index] = tempAtt; * //InventoryAtributeList.RemoveAt(index); * //InventoryAtributeList.Insert(index, tempAtt); * } */ /* * var att = InventoryAtributeList.FirstOrDefault(a => a.Name.Equals(tempAtt.Name)); * if (att != null) * { * att.Value = tempAtt.Value; * } */ } if (_isNewInventory && NewInventory == null) { NewInventory = new Inventory() { inventory_id = -1 }; PropertyInfo[] props = typeof(Inventory).GetProperties(); foreach (PropertyInfo prop in props) { var att = _inventoryAttributeArray.FirstOrDefault(x => x.Name.Equals(prop.Name)); if (att != null) { att.Value = prop.GetValue(NewInventory, null); if (att.ControlType.Equals("DROPDOWN")) { att.CodeValueList = await _restClient.GetCodeValueByGroupName(att.ControlSource); } else if (att.ControlType.Equals("CHECKBOX")) { att.Value = "N"; } } } var attLocation1 = _inventoryAttributeArray.FirstOrDefault(att => att.Name.Equals("storage_location_part1")); attLocation1.ControlType = "TEXTPICKER"; attLocation1.ListValues = await _restClient.GetAllLocation1List(); attLocation1.IsPicker = true; var attLocation2 = _inventoryAttributeArray.FirstOrDefault(att => att.Name.Equals("storage_location_part2")); attLocation2.ControlType = "TEXTPICKER"; attLocation2.ListValues = await _restClient.GetAllLocation2List(); attLocation2.IsPicker = true; InventoryAtributeList = new ObservableCollection <EntityAttribute>(_inventoryAttributeArray.ToList()); } } catch (Exception ex) { await PageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); } }
public BaseViewModel(PageDialogService pageDialogService, INavigationService navigationService) { this.PageDialogService = pageDialogService; this.NavigationService = navigationService; }
public GlassesListPageViewModel(PageDialogService pageDialogService, INavigationService navigationService, IGlassesManager glassesManager) : base(pageDialogService, navigationService) { _glassesManager = glassesManager; GoToDrinksCommand = new DelegateCommand <string>(async(param) => { await GoToDrinks(param); }); GetGlasses().GetAwaiter(); }
public override void OnNavigatingTo(INavigationParameters parameters) // Navegando para { //Ação acontece no decorrer da navegação PageDialogService.DisplayAlertAsync("", "Teste 1", "ok"); }
private async Task SendWiFiError() { await PageDialogService.DisplayAlertAsync("Wi-Fi Configuration", "Unable to configure WiFi, you may have to configure manually or try again.", "OK"); }
public override void OnNavigatedFrom(INavigationParameters parameters) // Navegar de { //Ação acontece na página de onde chamou a ação. PageDialogService.DisplayAlertAsync("", "Teste 2", "ok"); }
private async void OnSave(object obj) { if (IsBusy) { return; } IsBusy = true; try { // Thuc hien cong viec tai day var dataContext = Helper.GetDataContext(); var itemLogic = new ItemLogic(dataContext); var historyLogic = new ImportExportHistoryLogic(dataContext); var param = new NavigationParameters(); //Update Số lượng Item và Material if (QuantityBindProp > 0) { await itemLogic.ModifyQuantityAsync(Item.Id, QuantityBindProp, false); var history = new ImportExportHistory { FkItemOrMaterial = Item.Id, IsImported = 1, Quantity = QuantityBindProp, Reason = IsSelectingOtherReason == true ? OtherReasonBindProp : _reason }; var his = await historyLogic.CreateAsync(history, false); var visualHistory = new VisualHistoryModel { Quantity = history.Quantity, Reason = history.Reason, CreationDate = his.CreationDate, Item = Item.ItemName }; await dataContext.SaveChangesAsync(); Item.CurrentQuantity += QuantityBindProp; param.Add(Keys.HISTORY, visualHistory); await NavigationService.GoBackAsync(param); } else { await PageDialogService.DisplayAlertAsync("Cảnh báo", "Bạn chưa nhập số lượng giảm!", "OK"); } } catch (Exception e) { await ShowError(e); } finally { IsBusy = false; } }
public override void OnNavigatedTo(INavigationParameters parameters) // Navegar para { //Ação acontece aqui PageDialogService.DisplayAlertAsync("", "Teste 3", "ok"); }
private async void salvaPerfil() { IsRunning = true; if (string.IsNullOrEmpty(Email)) { await PageDialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", "Prencha o campo Email!", "OK"); // await dialogServices.ShowMessage("Erro", "Prencha o campo Usuário!"); IsRunning = false; return; } if (string.IsNullOrEmpty(Senha)) { await PageDialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", "Prencha o campo Senha!", "OK"); IsRunning = false; return; } if (string.IsNullOrEmpty(Login)) { await PageDialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", "Prencha o campo Login!", "OK"); IsRunning = false; return; } Dentista dentistaatualizado = new Dentista(); dentistaatualizado.Id = id; dentistaatualizado.nome = Nome; dentistaatualizado.Email = Email; dentistaatualizado.logon = Login; dentistaatualizado.status = "0"; dentistaatualizado.senha = Senha; dentistaatualizado.ImagePath = ""; dentistaatualizado.ImageArray = imageArray; //Lista = await apiService.getDentistas(); // await _dialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", _dentista.senha, "Ok"); var response = await apiService.PutDentista(dentistaatualizado); if (!response.IsSuccess) { await PageDialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", response.Message, "Ok"); return; } var result = (Dentista)response.Result; // await _dialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", result.senha, "Ok"); limpaFormulario(); gravaUsuarioLogado(result); Photo = ""; atribuivalores(result); await PageDialogService.DisplayAlertAsync("Painel Studio - Perboyre Castelo", response.Message, "OK"); IsRunning = false; /* Settings.ClearAllData(); * App.usuariologado = null;*/ // Page nova = Navegacao_aux.GetMainPage(); // App.Current.MainPage = nova; }
private async Task LoadPoisAsync(bool isRefresh = false) { try { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); if (status != PermissionStatus.Granted) { //task.yield! var tmp = await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location); if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location)) { await PageDialogService.DisplayAlertAsync("Need location", "Gunna need that location", "OK"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location); //Best practice to always check that the key exists if (results.ContainsKey(Permission.Location)) { status = results[Permission.Location]; } } if (status == PermissionStatus.Granted) { if (CrossGeolocator.IsSupported && CrossGeolocator.Current.IsGeolocationAvailable) { var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; //var location = await locator.GetLastKnownLocationAsync(); //UWP: only this works on desktop and only after allowing location service in location privacy settings var position = await locator.GetPositionAsync(); //CrossLocalNotifications.Current.Show($"{position.Latitude}", $"{position.Longitude}", 101 /*DateTime.Now.AddSeconds(10)*/); bool connected = false; if (CrossConnectivity.IsSupported) { connected = CrossConnectivity.Current.IsConnected; } if (!connected) { await PageDialogService.DisplayAlertAsync("Networking", "Internet connection is down", "OK"); } if (isRefresh) { IsRefreshing = true; } else { IsBusy = true; } var poik = await EnvironmentApi.GetClosestPoisAsync(new SearchPoiDto { Latitude = position.Latitude, Longitude = position.Longitude }); Pois = new ObservableCollection <PoiDto>(poik); if (isRefresh) { IsRefreshing = false; } else { IsBusy = false; } } } else if (status != PermissionStatus.Unknown) { await PageDialogService.DisplayAlertAsync("Location Denied", "Can not continue, try again.", "OK"); } } catch (Exception ex) { IsBusy = IsRefreshing = false; } finally { IsBusy = IsRefreshing = false; } }
private async void OnTakeImage(object obj) { if (IsBusy) { return; } if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await PageDialogService.DisplayAlertAsync("Lỗi", "Điện thoại không hổ trợ máy ảnh", "Đóng"); return; } IsBusy = true; var fileName = $"{Guid.NewGuid().ToString()}.jpg"; var filePath = ""; try { // Thuc hien cong viec tai day var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>(); var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>(); if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted) { cameraStatus = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); storageStatus = await CrossPermissions.Current.RequestPermissionAsync <StoragePermission>(); } if (storageStatus == PermissionStatus.Granted && cameraStatus == PermissionStatus.Granted) { try { var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "my_images", Name = fileName, PhotoSize = PhotoSize.Full, CompressionQuality = 92, DefaultCamera = CameraDevice.Front, SaveToAlbum = true, }); if (file != null) { filePath = file.Path; } } catch (Exception ex) { await ShowError(ex); } } else if (storageStatus != PermissionStatus.Unknown || cameraStatus != PermissionStatus.Unknown) { await PageDialogService.DisplayAlertAsync("Yêu cầu bị từ chối", "Không thể chụp ảnh.", "Đóng"); } if (string.IsNullOrEmpty(filePath) == false) { ImagePathBindProp = filePath; } else { ImagePathBindProp = ""; } } catch (Exception e) { await ShowError(e); } finally { IsBusy = false; } }
private async void OnSave(object obj) { if (IsBusy) { return; } IsBusy = true; try { // Thuc hien cong viec tai day if (string.IsNullOrWhiteSpace(TempEmployee.Username)) { await PageDialogService.DisplayAlertAsync("Lỗi", "Tên tài khoản không được để trống", "Đóng"); } if (string.IsNullOrWhiteSpace(TempEmployee.Fullname)) { await PageDialogService.DisplayAlertAsync("Lỗi", "Tên nhân viên không được để trống", "Đóng"); } if (string.IsNullOrWhiteSpace(PasswordBindProp) || PasswordBindProp.Length < 8) { await PageDialogService.DisplayAlertAsync("Lỗi", "Mật khẩu phải tối thiểu 8 ký tự", "Đóng"); } if (!ConfirmedPasswordBindProp.SequenceEqual(PasswordBindProp)) { await PageDialogService.DisplayAlertAsync("Lỗi", "Mật khẩu xác nhận không trùng khớp", "Đóng"); } TempEmployee.Password = PasswordBindProp; TempEmployee.Username = TempEmployee.Username.ToLower().Trim(); var json = JsonConvert.SerializeObject(TempEmployee); var content = new StringContent(json, Encoding.UTF8, "application/json"); // Thuc hien cong viec tai day using (var client = new HttpClient()) { HttpResponseMessage response = new HttpResponseMessage(); if (!IsEditing) { response = await client.PostAsync(Properties.Resources.BaseUrl + "users/register", content); if (response.IsSuccessStatusCode) { var user = JsonConvert.DeserializeObject <UserDto>(await response.Content.ReadAsStringAsync()); var param = new NavigationParameters(); param.Add(nameof(EmployeeBindProp), user); await NavigationService.GoBackAsync(param); } } else { response = await client.PutAsync(Properties.Resources.BaseUrl + "users/", content); if (response.IsSuccessStatusCode) { EmployeeBindProp.Fullname = TempEmployee.Fullname; EmployeeBindProp.Role = TempEmployee.Role; await NavigationService.GoBackAsync(); } } }; } catch (Exception e) { await ShowErrorAsync(e); } finally { IsBusy = false; } }