private void LoadLocation(string siteID = null, string LocationID = null) { var selectedLocationName = ""; //site ID set so that it can be used to get locations later _siteID = siteID; var locationList = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, siteID), _connection); foreach (LocationClass locations_ in locationList) { assetLocation_.Items.Add(locations_.LocationName); if (LocationID != null) { if (locations_.LocationIdInternal == LocationID) { selectedLocationName = locations_.LocationName; } } } if (selectedLocationName != "") { assetLocation_.SelectedItem = selectedLocationName; } else { assetLocation_.SelectedIndex = 0; } }
public static List <LocationClass> DbToLocation(IEnumerable <LocationsDbTable> LocationDb, SQLiteConnection _connection, AssetDetailNames Names = null) { var LocationClassList = new List <LocationClass>(); foreach (LocationsDbTable LocationDbrecord in LocationDb) { var _intLoc = new LocationClass { LocationIdInternal = LocationDbrecord.LocationIdInternal, LocationBarcode = LocationDbrecord.LocationBarcode, LocationDescription = LocationDbrecord.LocationDescription, LocationName = LocationDbrecord.LocationName, SiteIdInternal = LocationDbrecord.SiteIdInternal, SubCount = Database.SubLocations.GetTableDataFromLocations(_connection, LocationDbrecord.LocationIdInternal).Count(), Count = Database.Assets.GetTableDataFromSiteLocation(_connection, LocationDbrecord.SiteIdInternal, LocationDbrecord.LocationIdInternal).Count() }; if (Names != null) { _intLoc.LocationName_ = Names.Location; _intLoc.SublocationName_ = Names.SubLocation; } LocationClassList.Add(_intLoc); } return(LocationClassList); }
public AssetListPage(SQLiteConnection connection_, LocationClass location, AssetDetailNames Names_, SublocationClass sublocation = null, DepartmentClass department = null) { _Names = Names_; MessagingCenter.Subscribe <string>(this, "Datawedge", (sender) => { SearchBar_.Text = sender; }); if (department != null) { BindingContext = department ?? throw new ArgumentNullException(); } else if (sublocation != null) { BindingContext = sublocation ?? throw new ArgumentNullException(); } else { BindingContext = location ?? throw new ArgumentNullException(); } _location = location; _sublocation = sublocation; _department = department; InitializeComponent(); BarcodeImage.Source = ImageSource.FromResource("eQuipMobile.Images.Camera_icon.png"); _connection = connection_; AssetListView.ItemsSource = GetAssetList(_location, _sublocation, _department); }
private void GetDropDownData() { var siteName = assetSite_.Items[assetSite_.SelectedIndex]; _Site = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteName == siteName).SiteIdInternal; var LocationName = assetLocation_.Items[assetLocation_.SelectedIndex]; var __ = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _Site), _connection); _Location = __.First(cm => (cm.LocationName == LocationName && cm.SiteIdInternal == _Site)).LocationIdInternal; if (assetSubLocation_.SelectedIndex > 0) { _Sublocation = assetSubLocation_.Items[assetSubLocation_.SelectedIndex]; } if (_Assign) { if (person_.SelectedIndex >= 0) { var personName = person_.Items[person_.SelectedIndex]; _People = PeopleClass.DbToPeople(Database.People.GetTableData(_connection), _connection).First(cm => cm.PeopleName == personName).PeopleIDInternal; } } }
private void GetData() { //instead of doing this, get all assets data from that location and send it to audit list string locationName; LocationClass LocationInfo = new LocationClass(); //gets location id internal if (assetLocation_.SelectedIndex >= 0) { locationName = assetLocation_.Items[assetLocation_.SelectedIndex]; LocationInfo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _siteID), _connection).First(cm => cm.LocationName == locationName); } if (assetSubLocation_.SelectedIndex >= 1) { try { var sublocation = SublocationClass.DbToSubLocation(Database.SubLocations.GetTableData(_connection)).First(cm => cm.SubLocationName == assetSubLocation_.Items[assetSubLocation_.SelectedIndex]); Navigation.PushAsync(new AssetListPage(_connection, LocationInfo, Names_, sublocation)); } catch (Exception exc) { DependencyService.Get <IError>().SendRaygunError(exc, Application.Current.Properties["user"].ToString() ?? "unsynced", Application.Current.Properties["url"].ToString() ?? "unsynced", null); Navigation.PushAsync(new AssetListPage(_connection, LocationInfo, Names_)); } } else { Navigation.PushAsync(new AssetListPage(_connection, LocationInfo, Names_)); } }
private void AddTransferAsset(string data) { try { var data_ = JsonConvert.DeserializeObject <TransferClassData>(data); if (transferList == null) { var toSite = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteIdInternal == data_.ToSite); data_.SiteNameTo = toSite.SiteName; var fromsite = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteIdInternal == data_.FromSite); data_.SiteNameFrom = fromsite.SiteName; data_.LocationNameTo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, toSite.SiteIdInternal), _connection).First(cm => cm.LocationIdInternal == data_.ToLocation).LocationName; data_.LocationNameFrom = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, fromsite.SiteIdInternal), _connection).First(cm => cm.LocationIdInternal == data_.FromLocation).LocationName; transferList = new List <TransferClassData> { data_ }; } else { var toSite = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteIdInternal == data_.ToSite); data_.SiteNameTo = toSite.SiteName; var fromsite = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteIdInternal == data_.FromSite); data_.SiteNameFrom = fromsite.SiteName; data_.LocationNameTo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, toSite.SiteIdInternal), _connection).First(cm => cm.LocationIdInternal == data_.ToLocation).LocationName; data_.LocationNameFrom = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, fromsite.SiteIdInternal), _connection).First(cm => cm.LocationIdInternal == data_.FromLocation).LocationName; transferList.Add(data_); } scanned_.Text = transferList.Count.ToString(); }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"); } }
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()); }
List <LocationClass> GetLocations(string site_id, string searchText = null) { var locations = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, site_id), _connection, _Names); if (String.IsNullOrWhiteSpace(searchText)) { return(locations); } return(locations.Where(c => (c.LocationName.Contains(searchText) || c.LocationBarcode.Contains(searchText))).ToList()); }
List <SublocationClass> GetSublocations(LocationClass location_Class, string searchText = null) { var Sublocations = SublocationClass.DbToSubLocation(Database.SubLocations.GetTableDataFromLocations(_connection, location_Class.LocationIdInternal), _Names); if (String.IsNullOrWhiteSpace(searchText)) { return(Sublocations); } return(Sublocations.Where(c => c.SubLocationName.Contains(searchText)).ToList()); }
private void AssetLocation__SelectedIndexChanged(object sender, EventArgs e) { if (assetLocation_.SelectedIndex != -1) { assetSubLocation_.Items.Clear(); if (assetLocation_.SelectedIndex > -1) { var locationName = assetLocation_.Items[assetLocation_.SelectedIndex]; var LocationInfo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _siteID), _connection).First(cm => cm.LocationName == locationName); LoadSublocations(LocationInfo.LocationIdInternal); } } }
public SublocationPage(SQLiteConnection _connection_, LocationClass location, AssetDetailNames Names_) { _Names = Names_; MessagingCenter.Subscribe <string>(this, "Datawedge", (sender) => { SearchBar_.Text = sender; }); BindingContext = location ?? throw new ArgumentNullException(); _location = location; _connection = _connection_; var SublocationsPresent = Database.SubLocations.GetTableDataFromLocations(_connection, _location.LocationIdInternal); InitializeComponent(); BarcodeImage.Source = ImageSource.FromResource("eQuipMobile.Images.Camera_icon.png"); SublocationListView.ItemsSource = GetSublocations(_location); }
private void assetLocation__SelectedIndexChanged(object sender, EventArgs e) { if (assetLocation_.SelectedIndex != -1) { assetSubLocation_.Items.Clear(); if (assetLocation_.SelectedIndex > -1) { var locationName = assetLocation_.Items[assetLocation_.SelectedIndex]; var LocationInfo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _siteID), _connection).First(cm => cm.LocationName == locationName); if (Application.Current.Properties.ContainsKey("AuditedSublocation") && Application.Current.Properties["AuditedSublocation"] != null) { LoadSublocations(LocationInfo.LocationIdInternal, Application.Current.Properties["AuditedSublocation"].ToString()); } else { LoadSublocations(LocationInfo.LocationIdInternal); } } } }
private void assetLocation__SelectedIndexChanged(object sender, EventArgs e) { if (assetLocation_.SelectedIndex != -1) { if (assetLocation_.SelectedIndex == 0) { MissingLocationStack.IsVisible = true; } else { MissingLocationStack.IsVisible = false; assetSubLocation_.Items.Clear(); if (assetLocation_.SelectedIndex > -1) { var locationName = assetLocation_.Items[assetLocation_.SelectedIndex]; var LocationInfo = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _siteID), _connection).First(cm => cm.LocationName == locationName); LoadSublocations(); } } } }
private async void SaveAndContinue(object sender, EventArgs e) { if (assetSite_.SelectedIndex < 0 || assetLocation_.SelectedIndex < 0) { await DisplayAlert("Error", "Please select values from the dropdown", "OK"); } else { var siteName = assetSite_.Items[assetSite_.SelectedIndex]; var SiteDetails = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteName == siteName); var LocationName = assetLocation_.Items[assetLocation_.SelectedIndex]; var LocationDetails = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, SiteDetails.SiteIdInternal), _connection).First(cm => cm.LocationName == LocationName); if (assetSubLocation_.SelectedIndex <= 0) { await Navigation.PushAsync(new SaveAndContinuePage(_connection, Names_, SiteDetails.SiteIdInternal, LocationDetails.LocationIdInternal)); } else { await Navigation.PushAsync(new SaveAndContinuePage(_connection, Names_, SiteDetails.SiteIdInternal, LocationDetails.LocationIdInternal, assetSubLocation_.Items[assetSubLocation_.SelectedIndex])); } } }
private async void Button_Clicked_1(object sender, EventArgs e) { try { if (CheckValues()) { LocationClass LocationInfo = new LocationClass(); string _LocationID = "00000000-0000-0000-0000-00000000"; string _Sublocation = null; int _Department = 0; string desc = "Asset created during audit. "; string siteName = assetSite_.Items[assetSite_.SelectedIndex]; string _SiteID = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteName == siteName).SiteIdInternal; //gets location id internal if (assetLocation_.SelectedIndex >= 0) { _LocationID = GUID.Generate().Substring(0, 7); if (assetLocation_.SelectedIndex == 0) { if (MissingLoc.Text == null) { MissingLoc.Text = "Location added without name"; } Database.Locations.Insert(_connection, new LocationsDbTable { LocationBarcode = "Added " + _Names.Location, LocationDescription = "Added " + _Names.Location, LocationIdInternal = _LocationID, LocationName = MissingLoc.Text, SiteIdInternal = _SiteID, }); desc = desc + MissingLoc.Text; } else { string locationName = assetLocation_.Items[assetLocation_.SelectedIndex]; _LocationID = LocationClass.DbToLocation(Database.Locations.GetTableDataFromSites(_connection, _siteID), _connection).First(cm => cm.LocationName == locationName).LocationIdInternal; } } if (assetSubLocation_.SelectedIndex == -1) { _Sublocation = null; } else { _Sublocation = assetSubLocation_.Items[assetSubLocation_.SelectedIndex]; } if (assetDepartment_.SelectedIndex >= 0) { string departmentName = assetDepartment_.Items[assetDepartment_.SelectedIndex]; _Department = DepartmentClass.DbToDepartment(Database.Department.GetTableData(_connection)).First(cm => cm.DepartmentName == departmentName).ID; } //gets condition ConditionClass conditionInfo = new ConditionClass(); if (assetCondition_.SelectedIndex >= 0) { string conditionName = assetCondition_.Items[assetCondition_.SelectedIndex]; conditionInfo = ConditionClass.DbToCondition(Database.Condition.GetTableData(_connection), _connection).First(cm => cm.ConditionLabel == conditionName); } //gets usages UsageClass UsageInfo = new UsageClass(); if (assetUsage_.SelectedIndex >= 0) { string usageName = assetUsage_.Items[assetUsage_.SelectedIndex]; UsageInfo = UsageClass.DbToUsage(Database.Usage.GetTableData(_connection), _connection).First(cm => cm.UsageLabel == usageName); } string defcategory = Database.Category.GetTableData(_connection).First().AssetCategoryIDInternal; AssetJsonObject newAsset = new AssetJsonObject { SiteIDInternal = _SiteID, LocationIDInternal = _LocationID, SubLocation = _Sublocation, DataGatherID = _Department, AssetIDInternal = GUID.Generate(), IsActive = true, DateModified = DateTime.Now, AuditDate = DateTime.Now, AuditStatus = "RECON-Added", AssetName = "RECON-Added Asset", AssetDescription = desc, Barcode = assetBarcode_.Text, PeopleIDInternal = "00000000-0000-0000-0000-000000000000", AssetStatus = "", AssetSerialNo = "", Price = 0, PurchaseDate = Convert.ToDateTime("1/1/1900"), PurchaseOrderNo = "", Quantity = 1, ShortageOverage = 1, Vendor = "", Asset_UID = "", ThumbnailImage = "", OriginalPartNo = "", POStatus = "N", POLine = 0, Model = "", Mfg = "", AssetConditionID = conditionInfo.ConditionID, AssetUsageID = UsageInfo.UsageID, AssetCategoryIDInternal = defcategory }; //make into class AssetClass asset = new AssetClass(newAsset); ///make into databse format var AssetForDb = AssetClass.AssetClassToDb(asset, false); //save to database Database.Assets.Insert(_connection, AssetForDb); Application.Current.Properties["AuditedSite"] = newAsset.SiteIDInternal; Application.Current.Properties["AuditedLocation"] = newAsset.LocationIDInternal; Application.Current.Properties["AuditedSublocation"] = newAsset.SubLocation; Application.Current.Properties["LastAssetID"] = newAsset.AssetIDInternal; Application.Current.Properties["Department"] = newAsset.DataGatherID; await DisplayAlert("Complete", "Asset Audited", "OK"); await Navigation.PopModalAsync(); } else { await DisplayAlert("Error", "There is a missing required data field. \"" + MissingField + "\" ", "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"); } }