public NewLoanToKeyWindow(KeyRegister keyRegister, int keyDbId)
     : base(keyRegister, "Add new loan for " + keyRegister.getKeyById(keyDbId).Identifier)
 {
     keyIdEntry.Text      = keyRegister.getKeyById(keyDbId).Identifier;
     keyIdEntry.Sensitive = false;
     keyIdLabel.Text      = "Key identifier (locked)";
     somethingChanged     = false;
 }
Example #2
0
        /// <summary>
        /// Opening edit key window.
        /// </summary>
        protected void editKeyClicked(object o, EventArgs e)
        {
            Key key;

            // If getKeyById throws KeyIdNotFoundException nothing is selected.
            try
            {
                key = keyRegister.getKeyById(keyView.SelectedDbId);
            }
            catch (KeyRegister.KeyIdNotFoundException)
            {
                return;
            }
            Window editKeyWindow = new EditKeyWindow(keyRegister, "Edit key", key);

            editKeyWindow.Destroyed += editKeyWindowDestroyed;
        }
 /// <summary>
 /// Gets information about key with specified dbId.
 /// </summary>
 /// <param name="dbId">DbId of the key to get.</param>
 private void getKeyDetails(int dbId)
 {
     try {
         Key key = keyRegister.getKeyById(dbId);
         Console.Write(key.ToString());
     }
     catch (KeyRegister.KeyIdNotFoundException e) {
         Console.WriteLine(e.Message);
     }
 }
Example #4
0
        public EditLoanWindow(KeyRegister keyRegister, int loanDbId)
            : base(keyRegister, "Edit loan " + loanDbId)
        {
            Loan loan = keyRegister.getLoanById(loanDbId);

            this.loanDbId = loanDbId;
            string keyIdentifier = keyRegister.getKeyById(loan.KeyId).Identifier;

            keyIdEntry.Text        = keyIdentifier;
            this.Title             = "Edit loan for key " + keyIdentifier;
            keyIdEntry.Sensitive   = false;
            keyIdEntry.TooltipText = "Key identifier cannot be changed. " +
                                     "Issue new loan for new key if you want to transfer loan";
            keyIdLabel.Text = "Key identifier (locked)";

            // Setting calendars.
            dateStartCal.Year  = loan.parseStartDate() [0];
            dateStartCal.Month = loan.parseStartDate() [1] - 1;
            dateStartCal.Day   = loan.parseStartDate() [2];

            if (loan.DateEnd != null)
            {
                noDueDate.Active = false;
                dateDueCal.Year  = loan.parseDueDate() [0];
                dateDueCal.Month = loan.parseDueDate() [1] - 1;
                dateDueCal.Day   = loan.parseDueDate() [2];
            }
            else
            {
                dateDueCal.Date  = dateStartCal.Date;
                noDueDate.Active = true;
            }

            // Setting button text.
            actionButton.Label = "Edit loan";

            // Setting loaner
            loanerEntry.Text = loan.LoanedTo;

            // Setting addInfo
            additionalEntry.Text = loan.AdditionalInformation;

            somethingChanged = false;
        }
        public KeyDetailsWindow(KeyRegister keyRegister, int keyDbId)
            : base(keyRegister, "Details of key " + keyRegister.getKeyById(keyDbId).Identifier)
        {
            key                        = keyRegister.getKeyByIdentifier(keyRegister.getKeyById(keyDbId).Identifier);
            idEntry.Text               = key.Identifier;
            idEntry.Sensitive          = false;
            nameEntry.Text             = key.Name;
            nameEntry.Sensitive        = false;
            descriptionEntry.Text      = key.Description;
            descriptionEntry.Sensitive = false;

            idLabel.Text   = "Identifier:";
            nameLabel.Text = "Name:";

            // Destroying button and its label becouse they are not needed here.
            actionButton.Destroy();
            buttonInstructionLabel.Destroy();

            // Displaying missing information.
            Label missingInfoLabel = new Label(null);

            if (key.IsMissing)
            {
                missingInfoLabel.Markup = "Key is marked as missing. It cannot be loaned.";
            }
            else
            {
                missingInfoLabel.Markup = "Key is not marked as missing.";
            }
            container.Put(missingInfoLabel, 10, 10 + groupSpacing * 3);

            // Displaying loan information.
            Label loanInfoLabel = new Label(null);

            loanInfoLabel.Markup = "<b>Loan information:</b>";
            container.Put(loanInfoLabel, 10, 10 + groupSpacing * 4 - 40);
            Label loanInfoDescLabel = new Label();

            Loan loan = keyRegister.getActiveLoanByKeyId(key.DbId);

            // If loan object references to null, there is no loan for this key.
            if (loan != null)
            {
                if (loan.LoanedTo.Length > 0)
                {
                    loanInfoDescLabel.Text = "Currently loaned to '" + loan.LoanedTo + "'.";
                }
                else
                {
                    loanInfoDescLabel.Text = "Key is currently loaned. No loaner specified.";
                }
                loanInfoDescLabel.Text += "\n";
                if (loan.DateEnd.Length > 0)
                {
                    loanInfoDescLabel.Text += "Loan due at " + loan.DateEnd + ".";
                }
                else
                {
                    loanInfoDescLabel.Text += "No due date specified.";
                }
            }
            else
            {
                loanInfoDescLabel.Text = "Key is not currently loaned.";
            }
            container.Put(loanInfoDescLabel, 10, 10 + groupSpacing * 4 - 20);

            somethingChanged = false;

            ShowAll();
        }