コード例 #1
0
ファイル: EmployeeVm.cs プロジェクト: DVR98/TruTextApp
        // Helper method to validate record details
        private bool ValidateRecord(EmployeeCl record)  /*****M*/
        {
            string validationErrors = string.Empty;
            bool   hasErrors        = false;

            if (string.IsNullOrWhiteSpace(record.EmpFirstname))
            {
                hasErrors        = true;
                validationErrors = "Name must not be empty\n";
            }

            if (string.IsNullOrWhiteSpace(record.EmpSurname))
            {
                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 @
            Regex emailRegex = new Regex(@"^[^@ ]+@[^@ ]+\.[^@ ]+$");

            if (string.IsNullOrWhiteSpace(record.Email) ||
                !emailRegex.IsMatch(record.Email))
            {
                hasErrors         = true;
                validationErrors += "Invalid Email Address\n";
            }

            this.LastError = validationErrors;
            return(!hasErrors);
        }
コード例 #2
0
ファイル: EmployeeVm.cs プロジェクト: DVR98/TruTextApp
 // Utility method for copying the details of a record
 private void CopyRecord(EmployeeCl source, EmployeeCl destination)  /*****M*/
 {
     destination.EmpID        = source.EmpID;
     destination.EmpFirstname = source.EmpFirstname;
     destination.EmpSurname   = source.EmpSurname;
     destination.RoleID       = source.RoleID;
     destination.Email        = source.Email;
 }
コード例 #3
0
ファイル: EmployeeVm.cs プロジェクト: DVR98/TruTextApp
        // Create a new (empty) record
        // and put the form into Adding mode
        private void Add()
        {
            EmployeeCl newRecord = new EmployeeCl {
                EmpID = 0
            };                                                    /*****2*/

            this.recordList.Insert(recordIndex, newRecord);
            this.IsAdding = true;
            this.OnPropertyChanged(nameof(Current));
        }
コード例 #4
0
ファイル: EmployeeVm.cs プロジェクト: DVR98/TruTextApp
 private EmployeeCl oldRecord;  /*****/
 private void Edit()
 {
     this.oldRecord = new EmployeeCl();  /*****/
     this.CopyRecord(this.Current, this.oldRecord);
     this.IsEditing = true;
 }