Exemplo n.º 1
0
        private void AddAssetData(int department_)
        {
            try
            {
                var AssetCategory  = Database.Category.GetTableData(_connection).First().AssetCategoryIDInternal;
                var AssetUsage     = Database.Usage.GetTableData(_connection).First().UsageID;
                var AssetCondition = Database.Condition.GetTableData(_connection).First().ConditionID;
                var time           = DateTime.Now;
                var newAsset       = new AssetJsonObject
                {
                    DateModified            = time,
                    SubLocation             = _Sublocation,
                    AssetName               = "RECON-Added Asset",
                    AssetDescription        = "Asset created during audit.",
                    Barcode                 = AuditSearchBar.Text,
                    AssetIDInternal         = GUID.Generate(),
                    AssetCategoryIDInternal = AssetCategory,
                    LocationIDInternal      = _LocationID,
                    SiteIDInternal          = _SiteID,
                    PeopleIDInternal        = "00000000-0000-0000-0000-000000000000",
                    AssetUsageID            = AssetUsage,
                    AssetConditionID        = AssetCondition,
                    AssetStatus             = "",
                    AssetSerialNo           = "",
                    Price           = 0,
                    PurchaseDate    = Convert.ToDateTime("1/1/1900"),
                    PurchaseOrderNo = "",
                    Quantity        = 1,
                    ShortageOverage = 1,
                    Vendor          = "",
                    IsActive        = true,
                    AuditDate       = time,
                    AuditStatus     = "RECON-Added",
                    Asset_UID       = "",
                    DataGatherID    = department_,
                    Mfg             = "",
                    Model           = "",
                    POLine          = 0,
                    POStatus        = "N",
                    OriginalPartNo  = "",
                    ThumbnailImage  = "",
                };
                Application.Current.Properties["LastAssetID"] = newAsset.AssetIDInternal;

                AssetClass asset = new AssetClass(newAsset);
                ///make into databse format
                var AssetForDb = AssetClass.AssetClassToDb(asset, false);
                //save to database
                Database.Assets.Insert(_connection, AssetForDb);
                LoadSound(1);
                //DisplayAlert("Complete", "Asset Audited", "OK");
                LoadAssetData();
            }
            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");
            }
        }
Exemplo n.º 2
0
 public AssetClass(AssetDbClass AssetJSON_, AssetJsonObject AssetJsonObj, List <Changesmade> ChangesMade_, bool Synced_ = false)
 {
     AssetIdInternal             = AssetJSON_.AssetIdInternal;
     Asset_Department            = AssetJSON_.Asset_Department;
     Asset_SiteIdInternal        = AssetJSON_.Asset_SiteIdInternal;
     Asset_locationIdInternal    = AssetJSON_.Asset_locationIdInternal;
     Asset_SublocationIdInternal = AssetJSON_.Asset_SublocationIdInternal;
     AssetName              = AssetJSON_.AssetName;
     AssetSerialNumber      = AssetJSON_.AssetSerialNumber;
     Asset_PeopleIdInternal = AssetJSON_.Asset_PeopleIdInternal;
     Barcode        = AssetJSON_.Barcode;
     AssetJSON      = AssetJsonObj;
     Synced         = AssetJSON_.Synced;
     ChangesMade    = ChangesMade_;
     AssetChangesDb = JsonConvert.SerializeObject(ChangesMade);
     AssetJSONDb    = JsonConvert.SerializeObject(AssetJSON_);
 }
Exemplo n.º 3
0
 public AssetClass(AssetJsonObject AssetJSON_ = null, bool Synced_ = false)
 {
     if (AssetJSON_ != null)
     {
         AssetIdInternal             = AssetJSON_.AssetIDInternal;
         Asset_Department            = AssetJSON_.DataGatherID;
         Asset_SiteIdInternal        = AssetJSON_.SiteIDInternal;
         Asset_locationIdInternal    = AssetJSON_.LocationIDInternal;
         Asset_SublocationIdInternal = AssetJSON_.SubLocation;
         AssetName              = AssetJSON_.AssetName;
         AssetSerialNumber      = AssetJSON_.AssetSerialNo;
         Asset_PeopleIdInternal = AssetJSON_.PeopleIDInternal;
         Barcode        = AssetJSON_.Barcode;
         AssetJSON      = AssetJSON_;
         Synced         = Synced_;
         AssetChangesDb = JsonConvert.SerializeObject(ChangesMade);
         AssetJSONDb    = JsonConvert.SerializeObject(AssetJSON_);
     }
 }
Exemplo n.º 4
0
        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;
            //}
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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");
            }
        }