Example #1
0
        private void AddLoanTransactionProc()
        {
            if (InputCustomerAddress != null && InputCustomerContactNumber != null && InputCustomerName != null &&
                InputJewelryDiscount != null && InputJewelryOtherDetails != null && InputJewelryValue != null &&
                InputJewelryWeight != null && InputLoanValue != null)
            {
                Random rnd = new Random();
                NewJewelry  = new Jewelry();
                NewCustomer = new Customer();
                NewLoan     = new Loan();

                NewJewelry.JewelryType         = SelectedJewelryType;
                NewJewelry.JewelryQuality      = SelectedJewelryQuality;
                NewJewelry.JewelryWeight       = double.Parse(InputJewelryWeight);
                NewJewelry.JewelryDiscount     = double.Parse(InputJewelryDiscount);
                NewJewelry.JewelryValue        = double.Parse(InputJewelryValue);
                NewJewelry.JewelryOtherDetails = (InputJewelryOtherDetails);
                NewJewelry.JewelryID           = "J-" + Convert.ToString(rnd.Next(1, 9999));
                JewelryList.Add(NewJewelry);

                NewCustomer.CustomerName          = InputCustomerName;
                NewCustomer.CustomerContactNumber = InputCustomerContactNumber;
                NewCustomer.CustomerAddress       = InputCustomerAddress;
                NewCustomer.CustomerID            = "C-" + Convert.ToString(rnd.Next(1, 9999));
                CustomerList.Add(NewCustomer);

                NewLoan.LoanValue       = double.Parse(InputLoanValue);
                NewLoan.Balance         = NewLoan.LoanValue * 1.13;
                NewLoan.TransactionDate = DateTime.Today;
                NewLoan.TransactionID   = "L-" + Convert.ToString(rnd.Next(1, 9999));
                NewLoan.JewelryID       = NewJewelry.JewelryID;
                NewLoan.CustomerID      = NewCustomer.CustomerID;
                ListOfLoans.Add(NewLoan);

                MessageBox.Show("Transaction submitted!", "Loan Transaction Successful", MessageBoxButton.OK,
                                MessageBoxImage.Information);

                InputCustomerAddress       = null;
                InputCustomerContactNumber = null;
                InputCustomerName          = null;
                InputJewelryDiscount       = null;
                InputJewelryOtherDetails   = null;
                InputJewelryValue          = null;
                InputJewelryWeight         = null;
                InputLoanValue             = null;
            }
            else
            {
                MessageBox.Show("Please fill in all details.", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #2
0
        private void SetFirstData()
        {
            Random   rnd           = new Random();
            Jewelry  firstJewelry  = new Jewelry();
            Customer firstCustomer = new Customer();
            Loan     firstLoan     = new Loan();
            Payback  firstPayback  = new Payback();

            firstJewelry.JewelryID           = "J-8044";
            firstJewelry.JewelryType         = JewelryType.Bracelets;
            firstJewelry.JewelryQuality      = JewelryQuality.TwentyOneKarats;
            firstJewelry.JewelryWeight       = 50;
            firstJewelry.JewelryDiscount     = 5;
            firstJewelry.JewelryValue        = rnd.Next(35000, 45000);
            firstJewelry.JewelryOtherDetails = "Perfectly Fine";
            JewelryList.Add(firstJewelry);

            firstCustomer.CustomerID            = "C-" + Convert.ToString(rnd.Next(1, 9999));
            firstCustomer.CustomerName          = "Emery Huang";
            firstCustomer.CustomerContactNumber = "0931 123 1423";
            firstCustomer.CustomerAddress       = "Suite 3, California Street";
            CustomerList.Add(firstCustomer);

            firstLoan.TransactionID   = "L-" + Convert.ToString(rnd.Next(1, 9999));
            firstLoan.LoanValue       = 40000;
            firstLoan.Balance         = firstLoan.LoanValue * 1.13;
            firstLoan.TransactionDate = DateTime.Today;
            firstLoan.JewelryID       = firstJewelry.JewelryID;
            firstLoan.CustomerID      = firstCustomer.CustomerID;
            ListOfLoans.Add(firstLoan);

            firstPayback.JewelryID         = firstLoan.JewelryID;
            firstPayback.TransactionID     = "P-" + Convert.ToString(rnd.Next(1, 9999));
            firstPayback.CustomerID        = firstLoan.CustomerID;
            firstPayback.LoanValue         = firstLoan.LoanValue;
            firstPayback.TransactionDate   = DateTime.Today;
            firstPayback.Payment           = 4000;
            firstPayback.FullInterestValue = firstPayback.LoanValue * 1.13;
            firstPayback.Balance           = firstLoan.Balance;
            firstPayback.Balance           = firstPayback.Balance - firstPayback.Payment;
            ListOfPaybacks.Add(firstPayback);

            foreach (var loan in ListOfLoans)
            {
                if (firstPayback.JewelryID == loan.JewelryID)
                {
                    loan.Balance = firstPayback.Balance;
                }
            }
        }