コード例 #1
0
        public string this[string propName]
        {
            get
            {
                string result = "";
                if (propName == "ClientId")
                {
                    if (string.IsNullOrWhiteSpace(this.ClientId))
                    {
                        result = "CNIC is required";
                    }
                    else if (ClientId != null && ClientId.IndexOf("_") != -1)
                    {
                        result = "CNIC is Incomplete";
                    }
                }
                if (propName == "ClientName")
                {
                    if (string.IsNullOrEmpty(this.ClientName))
                    {
                        result = "Name is required";
                    }
                    else if (ClientName.Length > 25)
                    {
                        result = "Name should be less then 25 Charactes";
                    }
                    else if (ClientName.Any(x => char.IsNumber(x)))
                    {
                        result = "name don't have number";
                    }
                }

                if (propName == "ClientFname")
                {
                    if (string.IsNullOrEmpty(this.ClientFname))
                    {
                        result = "Father Name is required";
                    }
                    else if (ClientFname.Length > 25)
                    {
                        result = "Father Name should be less then 25 Charactes";
                    }
                    else if (ClientFname.Any(x => char.IsNumber(x)))
                    {
                        result = "name don't have number";
                    }
                }
                if (propName == "ClientContact")
                {
                    if (string.IsNullOrWhiteSpace(this.ClientContact))
                    {
                        result = "Contact is required";
                    }
                    else if (ClientContact != null && ClientContact.IndexOf("_") != -1)
                    {
                        result = "Contact is incomplete";
                    }
                }
                if (propName == "ClientAddress")
                {
                    if (string.IsNullOrEmpty(this.ClientAddress))
                    {
                        result = "Adress is required";
                    }
                    else if (ClientAddress.Length > 60)
                    {
                        result = "Address should be less then 60 character";
                    }
                }
                return(result);
            }
        }