// Utility method for copying the details of a record private void CopyRecord(BooksCl source, BooksCl destination) { destination.BookID = source.BookID; destination.Title = source.Title; destination.Author = source.Author; destination.OrderPrice = source.OrderPrice; destination.SellingPrice = source.SellingPrice; }
// Create a new (empty) record // and put the form into Adding mode private void Add() { BooksCl newRecord = new BooksCl { BookID = 0 }; this.recordList.Insert(recordIndex, newRecord); this.IsAdding = true; this.OnPropertyChanged(nameof(Current)); }
// Helper method to validate record details private bool ValidateRecord(BooksCl record) { string validationErrors = string.Empty; bool hasErrors = false; if (string.IsNullOrWhiteSpace(record.Title)) { hasErrors = true; validationErrors = "Role Name must not be empty\n"; } this.LastError = validationErrors; return(!hasErrors); }
private void Edit() { this.oldRecord = new BooksCl(); this.CopyRecord(this.Current, this.oldRecord); this.IsEditing = true; }