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 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"); } }
private void LoadSites() { var sitesList = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection); foreach (SitesClass siteClass_ in sitesList) { PropertyPassSite.Items.Add(siteClass_.SiteName); } }
private void AssetSite__SelectedIndexChanged(object sender, EventArgs e) { if (assetSite_.SelectedIndex != -1) { assetLocation_.Items.Clear(); var siteName = assetSite_.Items[assetSite_.SelectedIndex]; var SiteForLocation = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteName == siteName); LoadLocation(SiteForLocation.SiteIdInternal); } }
List <SitesClass> GetSites(string searchText = null) { //Return List od SitesClass var sites = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection, Names_); if (String.IsNullOrWhiteSpace(searchText)) { return(sites); } return(sites.Where(c => (c.SiteName.Contains(searchText) || c.SiteCode.Contains(searchText))).ToList()); }
public LocationPage(SQLiteConnection connection_, SitesClass site, AssetDetailNames Names_) { _Names = Names_; MessagingCenter.Subscribe <string>(this, "Datawedge", (sender) => { SearchBar_.Text = sender; }); BindingContext = site ?? throw new ArgumentNullException(); InitializeComponent(); BarcodeImage.Source = ImageSource.FromResource("eQuipMobile.Images.Camera_icon.png"); _connection = connection_; _locationSiteID = site.SiteIdInternal; locationListView.ItemsSource = GetLocations(_locationSiteID); }
private async void AddPropertyPass(object sender, EventArgs e) { string siteName, personName; SitesClass siteInfo = new SitesClass(); PeopleClass personInfo = new PeopleClass(); var field = CheckValues(); if (field == "") { //gets site if (PropertyPassSite.SelectedIndex >= 0) { siteName = PropertyPassSite.Items[PropertyPassSite.SelectedIndex]; siteInfo = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).Single(cm => cm.SiteName == siteName); } //gets people if (PropertyPassPerson.SelectedIndex >= 0) { personName = PropertyPassPerson.Items[PropertyPassPerson.SelectedIndex]; personInfo = PeopleClass.DbToPeople(Database.People.GetTableData(_connection), _connection).Single(cm => cm.PeopleName == personName); } var PPdata = new PropertyPassDbTable() { AssignedToEmail = PropertyPassEmail.Text, CreationDate = DateTime.Now.ToString("s"), AssignedToPhone = PropertyPassPhone.Text, ModifiedOn = DateTime.Now.ToString("s"), Comments = PropertyPassComments.Text, DueDate = PropertyPassDueDate.Date.ToString("s"), PeopleID_Internal = personInfo.PeopleIDInternal, SiteIDInternal = siteInfo.SiteIdInternal, PropertyPassID_Internal = GUID.Generate(), Assigned_By = Application.Current.Properties["user"].ToString(), Synced = true }; Database.PropertyPassTable.Insert(_connection, PPdata); await DisplayAlert("Complete", "The property pass table has been added.", "OK"); await Navigation.PopAsync(); } else { await DisplayAlert("Error", "The " + field + " field is required", "OK"); } }
private void assetSite__SelectedIndexChanged(object sender, EventArgs e) { if (assetSite_.SelectedIndex != -1) { assetLocation_.Items.Clear(); var siteName = assetSite_.Items[assetSite_.SelectedIndex]; var SiteForLocation = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection).First(cm => cm.SiteName == siteName); if (Application.Current.Properties.ContainsKey("AuditedLocation") && Application.Current.Properties["AuditedLocation"] != null) { LoadLocation(SiteForLocation.SiteIdInternal, Application.Current.Properties["AuditedLocation"].ToString()); } else { LoadLocation(SiteForLocation.SiteIdInternal); } } }
private void LoadSites(string siteID = null) { var selectedSiteName = ""; var sitesList = SitesClass.DbToSite(Database.Sites.GetTableData(_connection), _connection); foreach (SitesClass siteClass_ in sitesList) { assetSite_.Items.Add(siteClass_.SiteName); if (siteID != null) { if (siteClass_.SiteIdInternal == siteID) { selectedSiteName = siteClass_.SiteName; } } } if (selectedSiteName != "") { assetSite_.SelectedItem = selectedSiteName; } }
public static List <SitesClass> DbToSite(IEnumerable <SitesDbTable> SitesDb, SQLiteConnection _connection, AssetDetailNames Names = null) { var SitesList = new List <SitesClass>(); foreach (SitesDbTable SiteDbRecord in SitesDb) { var intermediateSite = new SitesClass { SiteIdInternal = SiteDbRecord.SiteIdInternal, SiteName = SiteDbRecord.SiteName, SiteCode = SiteDbRecord.SiteCode, SiteDescription = SiteDbRecord.SiteDescription, Count = Database.Locations.GetTableDataFromSites(_connection, SiteDbRecord.SiteIdInternal).Count() }; if (Names != null) { intermediateSite.SiteName_ = Names.Site; intermediateSite.LocationName = Names.Location; } SitesList.Add(intermediateSite); } return(SitesList); }
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"); } }