Exemple #1
0
        string IDataErrorInfo.this[string columnName]
        {
            get
            {
                if (columnName == "FName")
                {
                    if (this.fName == null)
                    {
                        return("Please enter reader's first name");
                    }
                    else if (fName.Trim() == string.Empty)
                    {
                        return("First name is required");
                    }
                    else if (this.fName.Length > 50)
                    {
                        return("First name must not exceed 50 characters");
                    }
                    else if (isNumeric(this.fName))
                    {
                        return("First name cannot contain numeric characters");
                    }
                }
                else if (columnName == "LName")
                {
                    if (this.lName == null)
                    {
                        return("Please enter reader's last name");
                    }
                    else if (this.lName.Trim() == string.Empty)
                    {
                        return("Last name is required");
                    }
                    else if (this.lName.Length > 50)
                    {
                        return("Last name must not exceed 50 characters");
                    }
                    else if (isNumeric(this.lName))
                    {
                        return("Last name cannot contain numeric characters");
                    }
                }
                else if (columnName == "Id")
                {
                    int entered_id, max_id = ReaderService.GetMaxId();

                    if (!int.TryParse(this.id, out entered_id))
                    {
                        return("ID must be an integer");
                    }
                    else
                    {
                        if (entered_id < 1)
                        {
                            return("ID must be at least 1");
                        }
                        else if (entered_id > max_id)
                        {
                            return("ID must not excced " + max_id.ToString());
                        }
                    }
                }
                return(null);
            }
        }