public TransferModalpage(AssetDetailNames Names_, SQLiteConnection _connection_, int count, AssetDisplayClass assetData, string Site, string Location, string Sublocation = null, string Person = null) { _connection = _connection_; _Names = Names_; _globalcount = count; _Site = Site; _Location = Location; _Sublocation = Sublocation; _assetData = assetData; _People = Person; BindingContext = _assetData; InitializeComponent(); AssetName_.Text = _Names.Name; Barcode.Text = _Names.Barcode; SiteName_.Text = _Names.Site; LocationName_.Text = _Names.Location; SublocationName_.Text = _Names.SubLocation; QuantityName_.Text = _Names.Quantity; if (_People != null) { TransferButton.Text = "Assign"; QtyName_to_assign.Text = _Names.Quantity + " to assign"; } else { QtyName_to_assign.Text = _Names.Quantity + " to move"; } }
public static IEnumerable <AssetDisplayClass> FullDetails(IEnumerable <AssetDisplayClass> AssetDisplay, AssetDetailNames Name) { List <AssetDisplayClass> returnedAssetDb = new List <AssetDisplayClass>(); foreach (AssetDisplayClass display_ in AssetDisplay) { var details = JsonConvert.DeserializeObject <AssetJsonObject>(display_.AssetJSONDb); var singledisplay = new AssetDisplayClass { AssetIdInternal = display_.AssetIdInternal, Quantity = details.Quantity, AssetSerialNo = details.AssetSerialNo, Cost = details.Price, Barcode = display_.Barcode, AssetName = display_.AssetName, SiteName = display_.SiteName, LocationName = display_.LocationName, Asset_SublocationIdInternal = display_.Asset_SublocationIdInternal, AssetJSONDb = display_.AssetJSONDb, AssetBarcode_ = Name.Barcode, AssetSiteName_ = Name.Site, AssetLocationName_ = Name.Location, AssetSerialNo_ = Name.SerialNo, AssetSubLocationName_ = Name.SubLocation, AssetQuantity_ = Name.Quantity, AssetCost_ = Name.Price }; returnedAssetDb.Add(singledisplay); } return(returnedAssetDb); }
public static AssetDisplayClass GetDetails(AssetDisplayClass display_) { var details = JsonConvert.DeserializeObject <AssetJsonObject>(display_.AssetJSONDb); var returnedAssetDb = display_; returnedAssetDb.AssetSerialNo = details.AssetSerialNo; returnedAssetDb.Cost = details.Price; returnedAssetDb.Quantity = details.Quantity; return(returnedAssetDb); }
public TransferListPage(AssetDetailNames Names_, SQLiteConnection _connection_, IEnumerable <AssetDisplayClass> transferList_, string Site, string Location, string Sublocation = null, string People = null) { _Names = Names_; _connection = _connection_; InitializeComponent(); _Site = Site; _People = People; _Location = Location; _Sublocation = Sublocation; TransferListView.ItemsSource = AssetDisplayClass.FullDetails(transferList_, _Names); }
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 void loadvalues() { try { AssetDetailNames Names = JsonConvert.DeserializeObject <AssetDetailNames>(Application.Current.Properties["DesignInformation"].ToString()); _Names = Names; List <AssetDisplayClass> defaultList_ = new List <AssetDisplayClass> { AssetDisplayClass.FullDetails( new AssetDisplayClass { AssetName = "Asset Name", Barcode = "Example barcode", LocationName = "Example Location", SiteName = "Example Site", Quantity = 0, Asset_SublocationIdInternal = "Example sublocation", AssetIdInternal = "00", AssetSerialNo = "oo", Cost = 4, AssetBarcode_ = "Barcode", AssetCost_ = "Cost", AssetLocationName_ = "Location", AssetQuantity_ = "Qty", AssetSerialNo_ = "Serial", AssetSubLocationName_ = "SubLocation", AssetSiteName_ = "Site" }, _Names) }; defaultList = defaultList_; } catch (Exception exc) { DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); DisplayAlert("Error", exc.Message, "OK"); } }
public static AssetDisplayClass FullDetails(AssetDisplayClass display_, AssetDetailNames Name) { AssetJsonObject details = new AssetJsonObject(); if (display_.AssetJSONDb != null) { details = JsonConvert.DeserializeObject <AssetJsonObject>(display_.AssetJSONDb); } else { details.Quantity = 0; details.AssetSerialNo = "000000"; details.Price = 0; } var returnedAssetDb = new AssetDisplayClass { AssetIdInternal = display_.AssetIdInternal, Barcode = display_.Barcode, AssetName = display_.AssetName, Quantity = details.Quantity, AssetSerialNo = details.AssetSerialNo, Cost = details.Price, SiteName = display_.SiteName, LocationName = display_.LocationName, Asset_SublocationIdInternal = display_.Asset_SublocationIdInternal, AssetJSONDb = display_.AssetJSONDb, AssetBarcode_ = Name.Barcode, AssetSiteName_ = Name.Site, AssetLocationName_ = Name.Location, AssetSerialNo_ = Name.SerialNo, AssetSubLocationName_ = Name.SubLocation, AssetQuantity_ = Name.Quantity, AssetCost_ = Name.Price }; return(returnedAssetDb); }
private async void Button_Clicked(object sender, EventArgs e) { if (TransferSearchBar.Text == null) { await DisplayAlert("Warning", "Please enter a barcode.", "OK"); } else { if (assetLocation_.SelectedIndex < 0) { await DisplayAlert("Warning", "Please select from the dropdown where the asset will be moved to.", "OK"); } else { GetDropDownData(); var dataList = AssetDisplayClass.FullDetails(Database.Assets.GetDisplayeDataByBarcodeLike(_connection, TransferSearchBar.Text), _Names); if (dataList.Count() > 0) { if (dataList.Count() == 1) { //single asset await Navigation.PushModalAsync(new TransferModalpage(_Names, _connection, 0, dataList.First(), _Site, _Location, _Sublocation, _People)); } else { //multiple assets await Navigation.PushModalAsync(new TransferListPage(_Names, _connection, dataList, _Site, _Location, _Sublocation, _People)); } } else { await DisplayAlert("Warning", "That asset was not found in the database.", "OK"); } } } }
private async void Update(object sender, EventArgs e) { try { bool quantityUsed = true; bool costUsed = true; bool updated = false; if (quantity_.Text == null) { quantityUsed = false; } if (price_.Text == null) { costUsed = false; } if (quantityUsed && int.TryParse(quantity_.Text, out var n)) { //quantity is being used and is a valid number _Asset.Quantity = _Asset.Quantity + n; updated = true; //add n to quantity } if (costUsed && double.TryParse(price_.Text, out var o)) { _Asset.Price = o; updated = true; } if (updated) { updated = false; var assetDetailsold = Database.Assets.GetAssetDataByAssetIDInternal(_connection, _Asset.AssetIDInternal); var assetRecord = Database.Assets.Compare(assetDetailsold.First(), _Asset); if (assetRecord.ChangesMade.Count < 1) { await DisplayAlert("Error", "Nothing was changed in this asset.", "OK"); } else { var time = DateTime.Now; assetRecord.AssetJSON.DateModified = time; //Convert to be stored var AssetForDb = AssetClass.AssetClassToDb(assetRecord, assetDetailsold.First().Synced); //store to the database Database.Assets.Update(_connection, AssetForDb); // Update Record on List var display = Database.Assets.GetDisplayeDataByAssetIDInternal(_connection, AssetForDb.AssetIdInternal); display.First().Quantity = _Asset.Quantity; display.First().Cost = _Asset.Price; var __ = new List <AssetDisplayClass>() { AssetDisplayClass.FullDetails(display.First(), _Names) }; scanbarcodeupdateasset.ItemsSource = __; await DisplayAlert("Complete", "Asset Updated", "OK"); } } else { await DisplayAlert("Error", "There is no data to update.", "OK"); } } catch (Exception exe) { DependencyService.Get <IError>().SendRaygunError(exe, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); await DisplayAlert("Error", exe.Message, "OK"); } }
private async void SearchBar_SearchButtonPressed(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(searchbar.Text)) { await DisplayAlert("Error", "Nothing was entered.", "OK"); assetbarcodeListview.ItemsSource = defaultList; } else { if (_PropertyPass) { //check if the asset is already in the property pass item table, if not, continue var AssetForPropertyPass = Database.Assets.GetDisplayeDataByBarcode(_connection, searchbar.Text); if (AssetForPropertyPass.Count() > 0) { if (Database.PropertyPassItem.GetTableDataByAssetID(_connection, AssetForPropertyPass.First().AssetIdInternal).Count() > 0) { await DisplayAlert("Error", "That asset has already been checked out", "OK"); } else { if (_PropertyPassDisplayList == null) { _PropertyPassDisplayList = new List <AssetDisplayClass>(); CheckOutButton.IsVisible = true; } // check if the list already contains that value if (_PropertyPassDisplayList.Exists(x => x.AssetIdInternal == AssetForPropertyPass.First().AssetIdInternal)) { await DisplayAlert("Error", "That asset has already been scanned for this property pass.", "OK"); } else { _PropertyPassDisplayList.Add(AssetDisplayClass.FullDetails(AssetForPropertyPass.First(), _Names)); assetbarcodeListview.ItemsSource = null; assetbarcodeListview.ItemsSource = _PropertyPassDisplayList; } } } else { await DisplayAlert("Error", "No asset was found matching that value. The full barcode is required.", "OK"); } } else { try { if (IsIUID()) { SearchIUID(); } else { var results = Database.Assets.GetDisplayeDataByBarcodeLike(_connection, searchbar.Text); if (results.Count() > 0) { var test = new List <AssetDisplayClass>(); foreach (AssetDisplayClass Asset in results) { test.Add(AssetDisplayClass.FullDetails(Asset, _Names)); } assetbarcodeListview.ItemsSource = test; } else { assetbarcodeListview.ItemsSource = defaultList; await DisplayAlert("Error", "No assets with that " + _Names.Barcode + " were found", "OK"); } } } catch (Exception exp) { DependencyService.Get <IError>().SendRaygunError(exp, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); await DisplayAlert("Error", exp.Message, "OK"); } } } }
private void SearchIUID() { //bool UIUDtype; string PartNum; string SerialNum_; var IUIDval = searchbar.Text.Trim(); var start_ = IUIDval.IndexOf("~d0291P"); var end = IUIDval.Substring(start_ + 7).IndexOf("~d029"); if (start_ == -1) { //UIUDtype = true; start_ = IUIDval.IndexOf("~d03006~d029"); end = IUIDval.Substring(start_ + 12).IndexOf("~d030~d004"); SerialNum_ = IUIDval.Substring(start_, end); SerialNum_ = cutDown(cutDown(SerialNum_)); if (SerialNum_.Length > IAC_len) { IAD = SerialNum_.Substring(0, IAC_len); SerialNum_ = SerialNum_.Substring(IAC_len); if (SerialNum_.Length > 0) { //search using serial number var results = Database.Assets.GetDisplayeDataBySerailNumberLike(_connection, SerialNum_); if (results.Count() > 0) { var test = new List <AssetDisplayClass>(); foreach (AssetDisplayClass Asset in results) { test.Add(AssetDisplayClass.FullDetails(Asset, _Names)); } assetbarcodeListview.ItemsSource = test; } else { assetbarcodeListview.ItemsSource = defaultList; DisplayAlert("Error", "No assets with that " + _Names.SerialNo + " were found", "OK"); } } else { DisplayAlert("Error", "No " + _Names.SerialNo + " was parsed from that query string.", "OK"); } } else { DisplayAlert("Error", "The UID barcode could not be parsed, please check it and try again", "OK"); } } else { // UIUDtype = false; PartNum = IUIDval.Substring(start_ + 7, end); start_ = IUIDval.IndexOf("~d029S"); end = IUIDval.Substring(start_ + 6).IndexOf("~d030~d004"); SerialNum_ = IUIDval.Substring(start_ = 6, end); start_ = IUIDval.IndexOf("~d03006~d029"); end = IUIDval.Substring(start_ + 12).IndexOf("~d0291P"); IAD = cutDown(IUIDval.Substring(start_ + 12, end)); if (PartNum.Length > 0 && SerialNum_.Length > 0) { var results = Database.Assets.GetDisplayeDataBySerailandPartNumberLike(_connection, SerialNum_, PartNum); if (results.Count() > 0) { var test = new List <AssetDisplayClass>(); foreach (AssetDisplayClass Asset in results) { test.Add(AssetDisplayClass.FullDetails(Asset, _Names)); } assetbarcodeListview.ItemsSource = test; } else { assetbarcodeListview.ItemsSource = defaultList; DisplayAlert("Error", "No assets with that " + _Names.SerialNo + " were found", "OK"); } } else { DisplayAlert("Error", "The UID barcode could not be parsed, please check it and try again", "OK"); } } }