Пример #1
0
        public HomeScreenViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
            : base(LibraryScreens.HOME, bridge, currUser)
        {
            DisplayName = "Home";

            if (currUser == null)
                LoginAnimationDone = false;

            if (currUser == null)
            {
                LoginBoxVisible = true;
                AdminButtonsVisible = false;
            }
            else
            {
                LoginBoxVisible = false;
                AdminButtonsVisible = true;
            }

            Application.Current.Properties["BorrowLimit"] = 15;

            //For testing
            //			LoginBoxVisible=false;
            //			AdminButtonsVisible = true;
        }
Пример #2
0
        ObservableCollection<WorkspaceViewModel> _workspaces; //In the demo, this was ObsvColl<CloseableVM

        #endregion Fields

        #region Constructors

        public MainWinViewModel(ProtoBridge bridge)
        {
            _bridge = bridge;

            //Create default workspace:
            this.CreateNewWorkspace();
        }
Пример #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWin window = new MainWin();
            ProtoBridge bridge = new ProtoBridge();
            MainWinViewModel vm = new MainWinViewModel(bridge);
            vm.RequestClose += delegate { window.Close(); };
            window.DataContext = vm;

            window.Show();
        }
Пример #4
0
        public ScreenBaseViewModel(LibraryScreens screenType, ProtoBridge bridge,
            StaffAccountBLL currUser)
        {
            ScreenType = screenType;
            _Bridge = bridge;
            _CurrentUser = currUser;

            if (_CurrentUser != null)
                IsLoggedIn = true;
            else
                IsLoggedIn = false;
        }
        public ManipBookDetailsViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
            : base(LibraryScreens.MANIPULATE_RECORDS, bridge, currUser)
        {
            _internalSet = false;

            _dialogHoster = new DialogHoster();
            //			_chooseAuthDiagBox = new ChooseAuthorsDialogViewModel

            _selectedAuthors = new List<ChooseAuthorsDialogViewModel.AuthorSummary>();

            ManipulateBar = new ManipulateBarViewModel<BookDetailsBLL>(_Bridge.BookDetailsMgr, OnCurrentItemChanged);
            OnCurrentItemChanged();
        }
Пример #6
0
        public WorkspaceViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
        {
            _bridge = bridge;
            _currentUser = currUser;

            _activeScreen = new HomeScreenViewModel(bridge, currUser);
            _activeScreen.ScreenTransition += OnTransition;
            _activeScreen.LoggedOut += OnLoggedOut;
            _activeScreen.LoggedIn += OnLoggedIn;
            ActiveLayer = _activeScreen;
            PassiveLayer = null;

            DisplayName = _activeScreen.DisplayName;
        }
        public MemberAccountViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
            : base(LibraryScreens.TRANSACTIONS, bridge, currUser)
        {
            int chosenId = (int)Application.Current.Properties["EnteredMemId"];
            _chosenMem = bridge.MemberMgr.GetByID(chosenId);

            if (_chosenMem == null)
            {
                Console.Beep();
            }
            else
            {
                MemberID = _chosenMem.ItemID.ToString();
                MemberName = _chosenMem.FirstName + " " + _chosenMem.MiddleName + " " + _chosenMem.LastName;
                TimeSpan ts = DateTime.Now - _chosenMem.JoinDate;
                Age = (ts.Days/365).ToString();
                Address = _chosenMem.Contact.AddressLine1 + " " + _chosenMem.Contact.AddressLine2 + " " + _chosenMem.Contact.AddressLine3
                    + " " + _chosenMem.Contact.City + " " + _chosenMem.Contact.Pin + " " + _chosenMem.Contact.StateOrProvince + " " + _chosenMem.Contact.Country;
                Gender = _chosenMem.Gender;
                JoinDate = _chosenMem.JoinDate.ToString();

                List<TransactionBLL> transs = bridge.TransactionMgr.GetMemberTransactions(_chosenMem.ItemID);

                string err;
                bridge.TransactionMgr.IssueBook(120, chosenId, out err);
                if (err != null)
                    MessageBox.Show(err);

                foreach (TransactionBLL t in transs)
                {
                    if (t.ReturnedOn == null)
                        TransHistory.Add(new TransactionDetails(bridge, t, true));
                    else
                        CurrentTrans.Add(new TransactionDetails(bridge, t, false));
                }

            }
        }
 public SearchHostScreenViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
     : base(LibraryScreens.SEARCH, bridge, currUser)
 {
     //_activeSearchScreen =
 }
 public EnterMemberIdViewModel(ProtoBridge bridge, StaffAccountBLL currUser)
     : base(LibraryScreens.TRANSACTIONS_ENTERID, bridge, currUser)
 {
     BadInput += (o, e) => {};
 }
Пример #10
0
            public TransactionDetails(ProtoBridge bridge, TransactionBLL trans, bool historyMode = false)
            {
                if (trans != null)
                {
                    BookID = trans.BookID.ToString();

                    LibraryBookBLL libBook = bridge.LibraryBookMgr.GetByID(trans.BookID);
                    BookDetailsBLL bookInfo = bridge.BookDetailsMgr.GetByID(libBook.BookDetailsId);

                    Title = bookInfo.Description.Title;
                    List<AuthorBLL> auths = new List<AuthorBLL>();
                    foreach(int aid in bookInfo.AuthorIDs)
                        auths.Add(bridge.AuthorsMgr.GetByID(aid));

                    foreach(AuthorBLL a in auths)
                        Authors += (", " + a.FirstName + " " + a.LastName);

                    Authors = Authors.Substring(1);

                    IssueDate = trans.CheckedOutOn.ToLongDateString();

                    if (trans.ReturnedOn == null)
                        DueDate = null;
                    else
                        DueDate = ((DateTime)trans.ReturnedOn).ToLongDateString();

                    int borrowLimit = (int)Application.Current.Properties["BorrowLimit"];
                    int fineAmt = 2;

                    if (historyMode == false)
                    {
                        if (trans.ReturnedOn == null)
                            Status = "Checked out";
                        else
                        {
                            TimeSpan ts = DateTime.Now - trans.CheckedOutOn;

                            if (ts.Days > borrowLimit)
                            {
                                Status = "Overdue by " + ts.Days.ToString() + " days";
                            }

                        }
                    }
                    else
                    {
                        TimeSpan ts = (DateTime)trans.ReturnedOn - trans.CheckedOutOn;
                        if (ts.Days > borrowLimit)
                        {
                            Status = ts.Days.ToString() + " days overdue. Fined Rs. " + (fineAmt * ts.Days).ToString() + ".";

                        }
                        else
                        {
                            Status = "Returned on time";
                        }
                    }
                }
            }