示例#1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            string imageBase64;

            if (OfdImage.FileName != "")
            {
                byte[] imageBytes = File.ReadAllBytes(OfdImage.FileName);
                imageBase64 = Convert.ToBase64String(imageBytes);
            }
            else
            {
                imageBase64 = oldAnimal.image;
            }


            Animal newAnimal = new Animal()
            {
                name  = TxtAnimalName.Text,
                breed = TxtBreed.Text,

                age    = (int)NudAnimalAge.Value,
                cage   = (int)NudAnimalCage.Value,
                price  = (float)NudAnimalPrice.Value,
                weight = (int)NudAnimalWeight.Value,

                species = (Animal.Species)Enum.Parse(typeof(Animal.Species), CbAnimalType.Text),
                gender  = RadAnimalMale.Checked ? Animal.Genders.Male : Animal.Genders.Female,

                characteristics = RtbCharacteristics.Text.Split('\n').ToList(),
                about           = RtbAbout.Text,

                image    = imageBase64,
                reserved = oldAnimal.reserved
            };

            animalLogic.EditAnimal(oldAnimal, newAnimal);
            this.Dispose();
        }
示例#2
0
 public void EditAnimal(AnimalEntity animal)
 {
     _animalLogic.EditAnimal(animal);
 }