private void EditJewelry(Object parameter) { try { if (SelectedJewelry == string.Empty) { MessageBox.Show("Please choose jewelry."); return; } var editedIndex = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry); Jewelry editedJewelry = JewelryList.Find(x => x.ToString() == SelectedJewelry); if (editedJewelry == null) { MessageBox.Show($"Choose one jewerly from dropdown menu."); return; } editJewelryView.InitJewelryFields(ref editedJewelry); JewelryList.RemoveAt(editedIndex); JewelryListUI.RemoveAt(editedIndex); JewelryList.Add(editedJewelry); JewelryListUI.Add(editedJewelry); CurrentAppScreen = (int)ApplicationScreen.EditJewelry; } catch (Exception ex) { MessageBox.Show($"Could not edit jewerly. Reason: {ex.Message}"); } }
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); } }
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; } } }
private void DeleteJewelry(object p) { if (string.IsNullOrEmpty(SelectedJewelry)) { MessageBox.Show("Please choose a jewelry from the list."); return; } try { var removalIndex = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry); JewelryList.RemoveAt(removalIndex); JewelryListUI.RemoveAt(removalIndex); MessageBox.Show($"Successfully removed."); } catch (Exception ex) { MessageBox.Show($"Could not remove jewelry. Reason: {ex.Message}"); } }
private void AddJewelry(Object parameter) { try { CurrentJewelryMaterials.RemoveAll(x => !IsMaterialAlterred(x)); if (CurrentJewelryMaterials.Count == 0) { MessageBox.Show("No materials were choosen for this jewelry. Please add some."); return; } if (string.IsNullOrEmpty(JewelryName)) { MessageBox.Show("Please choose some name for your jewelry."); return; } var jewelry = jewelryFactory.NewJewelry(SelectedJewelryType); var visitor = new JewelryVisitor(this); jewelry.Accept(visitor); MessageBox.Show($"Successfully added {jewelry.Name}."); JewelryList.Add(jewelry); JewelryListUI.Add(jewelry); ClearFields(); CurrentJewelryMaterials = null; CurrentJewelryMaterials = new List <Material>(); } catch (Exception ex) { MessageBox.Show($"Can't add jewelry. Reason: {ex.Message}."); } }