Exemplo n.º 1
0
        List <DepartmentClass> GetDepartments(string searchText = null)
        {
            var Departments = DepartmentClass.DbToDepartment(Database.Department.GetTableData(_connection));

            if (String.IsNullOrWhiteSpace(searchText))
            {
                return(Departments);
            }
            return(Departments.Where(c => c.DepartmentName.Contains(searchText)).ToList());
        }
Exemplo n.º 2
0
 private void ShowSummary(object sender, EventArgs e)
 {
     if (assetDepartment_.SelectedIndex >= 1)
     {
         var departmentName = assetDepartment_.Items[assetDepartment_.SelectedIndex];
         var departmentInfo = DepartmentClass.DbToDepartment(Database.Department.GetTableData(_connection)).First(cm => cm.DepartmentName == departmentName);
         Navigation.PushModalAsync(new ShowSummaryPage(_connection, _Names, _SiteID, _LocationID, _Sublocation, departmentInfo.ID));
     }
     else
     {
         Navigation.PushModalAsync(new ShowSummaryPage(_connection, _Names, _SiteID, _LocationID, _Sublocation));
     }
 }
Exemplo n.º 3
0
        private void LoadDepartment(int DepartmentId = 0)
        {
            var selectedDepartment = "";
            var DepartmentsList    = DepartmentClass.DbToDepartment(Database.Department.GetTableData(_connection));

            foreach (DepartmentClass DepartmentClass_ in DepartmentsList)
            {
                assetDepartment_.Items.Add(DepartmentClass_.DepartmentName);
                if (DepartmentId != 0)
                {
                    if (DepartmentClass_.ID == DepartmentId)
                    {
                        selectedDepartment = DepartmentClass_.DepartmentName;
                    }
                }
            }
            if (selectedDepartment != "")
            {
                assetDepartment_.SelectedItem = selectedDepartment;
            }
        }
Exemplo n.º 4
0
        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");
            }
        }
Exemplo n.º 5
0
        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");
            }
        }