protected override void LoadChildren()
 {
     foreach (Models.AssetModel am in SQLiteQueries.GetDeletedChildAssets(Asset.ID))
     {
         base.Children.Add(new TVDeletedAssetViewModel(am, this));
     }
 }
        protected override void LoadChildren()
        {
            FullyObservableCollection <Models.AssetModel> _assets = SQLiteQueries.GetChildAssets(Asset.ID);

            foreach (Models.AssetModel am in _assets)
            {
                base.Children.Add(new TVAssetViewModel(am, this));
            }
        }
Beispiel #3
0
        private void DeletePhoto(object parameter)
        {
            IMessageBoxService msg = new MessageBoxService();

            if (msg.ShowMessage("Are you sure you want to remove this photo?", "Removing Photo from Asset", GenericMessageBoxButton.YesNo, GenericMessageBoxIcon.Question).Equals(GenericMessageBoxResult.Yes))
            {
                Photos.Remove(parameter as PhotoModel);
                SQLiteQueries.DeletePhoto((parameter as PhotoModel));
            }
            msg = null;
        }
        /// <summary>
        /// Drop data into this ViewModel
        /// </summary>
        void IDropable.Drop(object data, int index)
        {
            if (data is TVAssetViewModel source)
            {
                if (source.Asset.ParentAssetID == 0 && Customer.ID == source.Asset.CustomerID) //if dragged and dropped yourself, don't need to do anything
                {
                    return;
                }

                SQLiteQueries.UpdateParentAssetID(source.Asset.ID, 0, Customer.ID);
                AssetTreeExViewModel.MoveAsset(source.Asset.ID, 0, Customer.ID);
            }
        }
        /// <summary>
        /// Drop data into this ViewModel
        /// </summary>
        void IDropable.Drop(object data, int index)
        {
            //if moving within customer, reassign the children to the
            //level above first

            if (data is TVAssetViewModel source)
            {
                if (source.Asset.ID == Asset.ID || source.Asset.ParentAssetID == Asset.ID) //if dragged and dropped yourself, don't need to do anything
                {
                    return;
                }
                SQLiteQueries.UpdateParentAssetID(source.Asset.ID, Asset.ID, Asset.CustomerID);
                AssetTreeExViewModel.MoveAsset(source.Asset.ID, Asset.ID, Asset.CustomerID);
            }
        }
Beispiel #6
0
 public static bool LoadAll()
 {
     try
     {
         GetConnStr();
         SetCurrentUser();
         Defaults    = SQLiteQueries.GetDefaultSettings();
         Statuses    = SQLiteQueries.GetStatuses();
         AssetAreas  = SQLiteQueries.GetAssetAreas();
         AssetGroups = SQLiteQueries.GetAssetGroups();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #7
0
        public static void SetCurrentUser()
        {
            try
            {
                AdministratorUserModel _currentuser;
                IsAdministrator = false;
                _currentuser    = new AdministratorUserModel();
                _currentuser    = SQLiteQueries.GetAdministratorNameFromUserLogin(Environment.UserName);

                if (!string.IsNullOrEmpty(_currentuser.Name))
                {
                    IsAdministrator = true;
                }
            }
            catch
            {
                IsAdministrator = false;
            }

#if DEBUG
            IsAdministrator = true;
#endif
        }
Beispiel #8
0
        private void AddPhoto(object parameter)
        {
            IMessageBoxService msg      = new MessageBoxService();
            string             filename = msg.OpenFileDlg("Select the file containing the asset's photo", true, false, "Asset Photos(*.PNG; *.JPG)| *.PNG; *.JPG", string.Empty, null);

            if (!string.IsNullOrEmpty(filename) && !string.IsNullOrWhiteSpace(filename))
            {
                FileInfo fi = new FileInfo(filename);
                if (fi.Length > Defaults.MaxPhotoSize)
                {
                    msg.ShowMessage("The photo file size is too large (" + (Defaults.MaxPhotoSize / 1000).ToString() + " kB)", "Photo Size", GenericMessageBoxButton.OK, GenericMessageBoxIcon.Information);
                }
                else
                {
                    //PhotoModel Photo = new PhotoModel(){ ID = 0, AssetID = Asset.ID, Photo = File.ReadAllBytes(filename), PhotoFileName = filename };

                    filename = Path.GetFileName(filename);

                    PhotoModel Photo = new PhotoModel()
                    {
                        ID = 0, AssetID = Asset.ID, PhotoFileName = filename
                    };

                    Photo.ID = SQLiteQueries.AddPhoto(Photo);

                    if (Photo.ID > 0)
                    {
                        Photos.Add(Photo);
                        SelectedPhotoIndex = Photos.Count - 1;
                    }
                }
            }
            else
            {
                //not added
            }
        }
 public DefaultCustomerViewModel()
 {
     _customers = SQLiteQueries.GetCustomers();// GlobalClass.Customers;
 }
Beispiel #10
0
 public dbController()
 {
     query               = new DBFactory().GetSQLiteQueries();
     queryTimer          = new QueryTimer();
     returnStatusHandler = new ReturnStatusHandler();
 }