async void Return_Clicked(object sender, System.EventArgs e) { try { if (AssetEntry.Text == null) { await DisplayAlert("Error", "Please Fill Asset ID.", "OK"); } else { DateTime now = DateTime.Now.ToLocalTime(); Dictionary <string, string> dict = new Dictionary <string, string>(); dict["asset"] = AssetEntry.Text; dict["time"] = now.ToString(); if (AssetEntry.Text != null) { await DisplayAlert("Return Asset", "Are you sure!", "Cancel", "Ok"); var isSuccess = await cloudStore.ReturnAsset(dict); if (isSuccess) { await DisplayAlert("Success", "Asset Returned Successfully", "Ok"); App.Current.MainPage = new UserViewAssetPage(); } else { await DisplayAlert("Error", "Return failure, Please try Again", "Ok"); AssetEntry.Text = string.Empty; } } else { await DisplayAlert("No Asset Found", "Cancel", "Ok"); } } } catch (Exception ex) { } }
async void Assign_Clicked(object sender, System.EventArgs e) { if (assign.Text == "Return Asset") { try { if (AssetEntry.Text == null) { await DisplayAlert("Error", "Please fill in asset ID.", "OK"); } else { DateTime now = DateTime.Now.ToLocalTime(); Dictionary <string, string> dict = new Dictionary <string, string>(); dict["asset"] = AssetEntry.Text; dict["time"] = now.ToString(); if (AssetEntry.Text != null) { await DisplayAlert("Return asset", "Are you sure?", "Cancel", "Ok"); var isSuccess = await cloudStore.ReturnAsset(dict); if (isSuccess) { await DisplayAlert("Success", "Asset returned successfully.", "Ok"); App.Current.MainPage = new MainViewAssetPage(); } else { await DisplayAlert("Error", "Return failed. Please try again.", "Ok"); AssetEntry.Text = string.Empty; } } else { await DisplayAlert("No asset found.", "Cancel", "Ok"); } } } catch (Exception ex) { } } else { try { if (AssetEntry.Text == null && AsigneeEntry.Text == null) { await DisplayAlert("Error", "Please fill in missing fields.", "OK"); } else if (AssetEntry.Text == null) { await DisplayAlert("Error", "Please fill in asset ID/barcode.", "OK"); } else if (AsigneeEntry.Text == null) { //await DisplayAlert("Error", "Please Fill Assignee.", "OK"); try { List <Users> listUsers = await cloudStore.GetUsers(); if (listUsers != null) { List <Users> listManagers = await cloudStore.GetManagers(); for (int i = 0; i < listManagers.Count; i++) { listUsers.Add(listManagers[i]); } lstview.ItemsSource = listUsers; Device.BeginInvokeOnMainThread(() => { lstview.IsVisible = true; Validate = true; }); } else { await DisplayAlert("Error", "No assignee.", "Cancel", "Ok"); } } catch (Exception ex) { } } else { DateTime now = DateTime.Now.ToLocalTime(); Dictionary <string, string> dict = new Dictionary <string, string>(); dict["asset"] = AssetEntry.Text; dict["assignee"] = AsigneeEntry.Text; dict["time"] = now.ToString(); var isSuccess = await cloudStore.AssignAsset(dict); if (isSuccess) { await DisplayAlert("Success", "Asset assigned successfully.", "Ok"); App.Current.MainPage = new MainViewAssetPage(); //AssetEntry.Text = string.Empty; //DescriptionEntry.Text = string.Empty; } else { await DisplayAlert("Error", "Assignment failed. Please try again.", "Ok"); //AssetEntry.Text = string.Empty; //DescriptionEntry.Text = string.Empty; } } } catch (Exception ex) { } } }