示例#1
0
    private bool ValidDog(bool isUpdate)
    {
        bool valid = true;

        if (!Is_Dam_Or_Sire)
        {
            if (string.IsNullOrEmpty(lstDogBreeds.SelectedValue) || lstDogBreeds.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Breed must be specified.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(lstGender.SelectedValue) || lstGender.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Gender must be specified.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(Reg_No))
            {
                MessageLabel.Text = "The Kennel Club Registration Number must be included.";
                valid             = false;
            }
        }
        else
        {
            if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid             = false;
            }
        }
        if (!isUpdate)
        {
            List <Dogs> tblDogs;
            Dogs        dog = new Dogs(_connString);
            tblDogs = dog.GetDogs();
            foreach (Dogs d in tblDogs)
            {
                if (!d.IsReg_NoNull && d.Reg_No != "Unknown" && d.Reg_No == Reg_No)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Registration Number already exists.";
                    valid             = false;
                }
                else if (!d.IsDog_KC_NameNull && d.Dog_KC_Name != "NAF" && d.Dog_KC_Name == Dog_KC_Name)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Name already exists.";
                    valid             = false;
                }
            }
        }


        return(valid);
    }
示例#2
0
    protected void btnDogSearch_Click(object sender, EventArgs e)
    {
        //ResetPage();
        //ClearEntryFields();
        string      searchValue = txtDogFilter.Text;
        Dogs        dog         = new Dogs(_connString);
        List <Dogs> tblDogs     = null;

        if (DogSearchType.SelectedValue == "c")
        {
            searchValue = string.Format("%{0}", searchValue);
        }

        switch (DogFilterBy.SelectedValue)
        {
        case "KC_Name":
            tblDogs = dog.GetDogsLikeDog_KC_Name(searchValue);
            break;

        case "Pet_Name":
            tblDogs = dog.GetDogsLikeDog_Pet_Name(searchValue);
            break;

        case "Breed_ID":
            DogBreeds        dogBreeds    = new DogBreeds(_connString);
            List <DogBreeds> lkpDogBreeds = null;
            lkpDogBreeds = dogBreeds.GetDog_BreedsByDog_Breed_Description(searchValue);
            tblDogs      = dog.GetDogsByDog_Breed_ID(lkpDogBreeds);
            break;

        default:
            tblDogs = dog.GetDogs();
            break;
        }

        Common.Dog_GridViewData = tblDogs;
        PopulateDogGridView(Common.Dog_GridViewData, 1);
        txtDogFilter.Text           = string.Empty;
        DogFilterBy.SelectedIndex   = -1;
        DogSearchType.SelectedIndex = -1;
    }