private void Scanbarcodeupdateasset_ItemTapped(object sender, ItemTappedEventArgs e) { var Asset_list = e.Item as AssetDisplayClass; var AssetRecord = AssetClass.DbToAssetClass(Database.Assets.GetAssetDataByAssetIDInternal(_connection, Asset_list.AssetIdInternal)).First(); Navigation.PushAsync(new AddAssetPage(_connection, AssetRecord)); }
private async void AuditButton(object sender, EventArgs e) { if (ActualQuantity_.Text == null) { _Actual = -1; } else { _Actual = Convert.ToInt16(ActualQuantity_.Text); } var _assetclass = AssetClass.DbToAssetClass(IEnumAsset_).First(); AuditClass.Audit(_SiteID, _LocationID, _Sublocation, _Department, _assetclass, _connection, _Actual, _Person); Application.Current.Properties["AuditedSite"] = _SiteID; Application.Current.Properties["AuditedLocation"] = _LocationID; Application.Current.Properties["AuditedSublocation"] = _Sublocation; Application.Current.Properties["LastAssetID"] = _assetclass.AssetIdInternal; Application.Current.Properties["Department"] = _Department; await Application.Current.SavePropertiesAsync(); await DisplayAlert("Complete", "Asset Audited", "OK"); try { await Navigation.PopModalAsync(); MessagingCenter.Send(this, "Pop", ""); } catch (Exception exc) { DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); } }
List <AssetClass> GetAssetList(LocationClass location, SublocationClass sublocation, DepartmentClass department, string searchText = null) { var AssetList = AssetClass.DbToAssetClass(Database.Assets.GetAssetListForSearch(_connection, location, sublocation, department), _Names); if (String.IsNullOrWhiteSpace(searchText)) { return(AssetList); } return(AssetList.Where(c => (c.AssetName.Contains(searchText) || c.Barcode.Contains(searchText))).ToList()); }
private void LoadAssetData() { if (Application.Current.Properties.ContainsKey("LastAssetID") && Application.Current.Properties["LastAssetID"] != null) { //get asset based on ID then assign it to list var IEnumAsset = Database.Assets.GetAssetDataByAssetIDInternal(_connection, Application.Current.Properties["LastAssetID"].ToString()); if (Database.Settings.GetTableData(_connection).BlindAudit) { AssetListView2.IsVisible = true; AssetListView.IsVisible = false; AssetListView2.ItemsSource = AssetClass.DbToAssetClass(IEnumAsset, _Names); } else { AssetListView.IsVisible = true; AssetListView2.IsVisible = false; AssetListView.ItemsSource = AssetClass.DbToAssetClass(IEnumAsset, _Names); } } else { var _defaultAsset = new AssetClass { AssetName = "Default Asset Name", AuditStatusDisplay_ = _Names.AssetStatus, Barcode = "Default Barcode", QuantityDisplay_ = _Names.Quantity, OriginalPartDisplay_ = _Names.OriginalPartNo, UIDDisplay_ = _Names.Asset_UID, AssetSerialNumberDisplay_ = _Names.SerialNo, BarcodeDisplay_ = _Names.Barcode, AssetJSON = new AssetJsonObject { AssetStatus = "Default Asset Status", Quantity = 0, OriginalPartNo = "00000000", Asset_UID = "Example UID", AssetSerialNo = "01010101", Barcode = "Default Barcode", AuditStatus = "RECON", } }; AssetListView.ItemsSource = new List <AssetClass> { _defaultAsset }; } SettingsData = Database.Settings.GetTableData(_connection); }
private async void AuditListView_ItemTapped(object sender, ItemTappedEventArgs e) { if (_Auditing) { //Get asset class var asset_class = e.Item as AssetClass; //convert class to DB var asset = AssetClass.AssetClassToDb(asset_class, asset_class.Synced); if (_PersonID != null) { await Navigation.PushModalAsync(new AuditRecordPage(_Names, asset, _Site, _Location, _Sublocation, _Department, _connection, _PersonID)); } else { var SettingsData = Database.Settings.GetTableData(_connection); if (SettingsData.FastAudit && !SettingsData.FastAuditEntry) { try { var _assetclass = AssetClass.DbToAssetClass(new List <AssetDbClass> { asset }, _Names).First(); AuditClass.Audit(_Site, _Location, _Sublocation, _Department, _assetclass, _connection); Application.Current.Properties["AuditedSite"] = _Site; Application.Current.Properties["AuditedLocation"] = _Location; Application.Current.Properties["AuditedSublocation"] = _Sublocation; Application.Current.Properties["LastAssetID"] = _assetclass.AssetIdInternal; Application.Current.Properties["Department"] = _Department; await Application.Current.SavePropertiesAsync(); await DisplayAlert("Complete", "Asset Audited", "OK"); await Navigation.PopAsync(); } catch (Exception exc) { DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", asset_class); await DisplayAlert("Error", exc.Message, "OK"); } } else { await Navigation.PushModalAsync(new AuditRecordPage(_Names, asset, _Site, _Location, _Sublocation, _Department, _connection)); } } } }
public AuditList(AssetDetailNames Names_, IEnumerable <AssetDbClass> AssetList, SQLiteConnection connection, bool Auditing, string Site, string Location, string Sublocation, int Department, string Person = null, string PersonName = null) { try { MessagingCenter.Subscribe <AuditRecordPage, string>(this, "Pop", (sender, arg) => { Navigation.PopAsync(); }); _Names = Names_; InitializeComponent(); _AssetList = AssetList; _Auditing = Auditing; _Site = Site; _Location = Location; _Sublocation = Sublocation; _Department = Department; _connection = connection; if (Database.Settings.GetTableData(_connection).BlindAudit) { AuditListView2.IsVisible = true; AuditListView.IsVisible = false; AuditListView2.ItemsSource = AssetClass.DbToAssetClass(_AssetList, _Names, _connection); } else { AuditListView.IsVisible = true; AuditListView2.IsVisible = false; AuditListView.ItemsSource = AssetClass.DbToAssetClass(_AssetList, _Names, _connection); } if (Person != null) { PersonButton.IsVisible = true; _PersonID = Person; PersonName_.Text = PersonName + "'s Assets"; } } catch (Exception exe) { DependencyService.Get <IError>().SendRaygunError(exe, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); throw (new Exception(exe.Message)); } }
public ScanBarcodeUpdatePage(AssetDetailNames Names_, AssetDisplayClass details, SQLiteConnection connection_) { InitializeComponent(); BindingContext = details; _connection = connection_; var inermediate = Database.Assets.GetAssetDataByAssetIDInternal(_connection, details.AssetIdInternal); _synced = inermediate.First().Synced; _Asset = AssetClass.DbToAssetClass(inermediate).First().AssetJSON; details.Quantity = _Asset.Quantity; _Names = Names_; scanbarcodeupdateasset.ItemsSource = new List <AssetDisplayClass>() { AssetDisplayClass.GetDetails(details) }; //if (Application.Current.MainPage.Height <= 568) //{ // Scan_scroll.HeightRequest = 550; //} }
private async void Button_Clicked(object sender, EventArgs e) { try { SearchButton.IsEnabled = false; string departmentName; DepartmentClass departmentInfo = new DepartmentClass(); if (assetDepartment_.SelectedIndex >= 1) { departmentName = assetDepartment_.Items[assetDepartment_.SelectedIndex]; departmentInfo = DepartmentClass.DbToDepartment(Database.Department.GetTableData(_connection)).First(cm => cm.DepartmentName == departmentName); } if (AuditSearchBar.Text == null) { await DisplayAlert("Error", "Please enter a barcode", "OK"); } else { var assetData = Database.Assets.GetTableDataByBarcodeLike(_connection, AuditSearchBar.Text); if (assetData.Count() > 0) { //Not empty 1 or greater if (assetData.Count() == 1) { if (SettingsData.FastAudit) { //Fast audit turned on on single asset try { var _assetclass = AssetClass.DbToAssetClass(assetData, _Names).First(); AuditClass.Audit(_SiteID, _LocationID, _Sublocation, departmentInfo.ID, _assetclass, _connection); Application.Current.Properties["AuditedSite"] = _SiteID; Application.Current.Properties["AuditedLocation"] = _LocationID; Application.Current.Properties["AuditedSublocation"] = _Sublocation; Application.Current.Properties["LastAssetID"] = _assetclass.AssetIdInternal; Application.Current.Properties["Department"] = departmentInfo.ID; await Application.Current.SavePropertiesAsync(); LoadSound(1); //await DisplayAlert("Complete","Asset Audited", "OK"); LoadAssetData(); } catch (Exception exc) { SearchButton.IsEnabled = true; DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); await DisplayAlert("Error", exc.Message, "OK"); } } else { //regular audit await Navigation.PushModalAsync(new AuditRecordPage(_Names, assetData.First(), _SiteID, _LocationID, _Sublocation, departmentInfo.ID, _connection)); //bring up screen } } else { //Display multiple LoadSound(2); await Navigation.PushAsync(new AuditList(_Names, assetData, _connection, true, _SiteID, _LocationID, _Sublocation, departmentInfo.ID)); } } else { if (CrossConnectivity.Current.IsConnected) { //check database for asset var logindata_ = Database.Login.GetTableData(_connection); var test = await SyncClass.NewSyncClass.API_GetAssetByBarcode(logindata_.First().UserID, Application.Current.Properties["url"].ToString(), AuditSearchBar.Text); var record = JsonConvert.DeserializeObject <List <AssetJsonObject> >(test); if (record.Count() > 0) { var AssetClassRecord = new AssetClass(record.First(), true); Database.Assets.Insert(_connection, AssetClass.AssetClassToDb(AssetClassRecord, true)); if (SettingsData.FastAudit) { //may need to insert then audit AuditClass.Audit(_SiteID, _LocationID, _Sublocation, departmentInfo.ID, AssetClassRecord, _connection); Application.Current.Properties["AuditedSite"] = _SiteID; Application.Current.Properties["AuditedLocation"] = _LocationID; Application.Current.Properties["AuditedSublocation"] = _Sublocation; Application.Current.Properties["LastAssetID"] = AssetClassRecord.AssetIdInternal; LoadSound(1); //await DisplayAlert("Complete", "Asset Audited", "OK"); LoadAssetData(); } else { //display the asset record pulled //convert asset class to asset db class await Navigation.PushModalAsync(new AuditRecordPage(_Names, AssetClass.AssetClassToDb(AssetClassRecord, false), _SiteID, _LocationID, _Sublocation, departmentInfo.ID, _connection)); } } else { if (SettingsData.FastAudit && !SettingsData.FastAuditEntry) { AddAssetData(departmentInfo.ID); } else { LoadSound(0); //display screen to add asset await Navigation.PushModalAsync(new AddAuditPage(_Names, _SiteID, _LocationID, _Sublocation, departmentInfo.ID, AuditSearchBar.Text, _connection)); } } } else { LoadSound(0); //Add Asset if (SettingsData.FastAudit && !SettingsData.FastAuditEntry) { AddAssetData(departmentInfo.ID); } else { //display screen to add asset await Navigation.PushModalAsync(new AddAuditPage(_Names, _SiteID, _LocationID, _Sublocation, departmentInfo.ID, AuditSearchBar.Text, _connection)); } } } } SearchButton.IsEnabled = true; } catch (Exception exc) { SearchButton.IsEnabled = true; DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); await DisplayAlert("OK", exc.Message, "OK"); } }