// Helper method to validate record details private bool ValidateRecord(OrdersCl record) /*****M*/ { string validationErrors = string.Empty; bool hasErrors = false; if (string.IsNullOrWhiteSpace(record.Date)) { hasErrors = true; validationErrors = "Name must not be empty\n"; } if (string.IsNullOrWhiteSpace(record.Date)) { hasErrors = true; validationErrors = "Surname must not be empty\n"; } // Email address is a series of characters that do not include a space or @ // followed by @ // followed by a series of characters that do not include a space or @ // followed by . // followed by a series of characters that do not include a space or this.LastError = validationErrors; return(!hasErrors); }
// Utility method for copying the details of a record private void CopyRecord(OrdersCl source, OrdersCl destination) /*****M*/ { destination.OrderID = source.OrderID; destination.EmpID = source.EmpID; destination.SupID = source.SupID; destination.Date = source.Date; }
// Create a new (empty) record // and put the form into Adding mode private void Add() { OrdersCl newRecord = new OrdersCl { OrderID = 0 }; /*****2*/ this.recordList.Insert(recordIndex, newRecord); this.IsAdding = true; this.OnPropertyChanged(nameof(Current)); }
private OrdersCl oldRecord; /*****/ private void Edit() { this.oldRecord = new OrdersCl(); /*****/ this.CopyRecord(this.Current, this.oldRecord); this.IsEditing = true; }