/// <summary>
 /// Gets information about loan with specified dbId.
 /// </summary>
 /// <param name="dbId">DbId of the loan to get.</param>
 private void getLoanDetails(int dbId)
 {
     try {
         Loan key = keyRegister.getLoanById(dbId);
         Console.Write(key.ToString());
     }
     catch (KeyRegister.LoanIdNotFoundException e) {
         Console.WriteLine(e.Message);
     }
 }
Пример #2
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;
        }