private void ButtonAdd_Click(object sender, EventArgs e)
        {
            int      x1, x2;
            OwnerDog ownerdog = new OwnerDog();

            if (textBoxIDDog.Text != "" && textBoxIDOwner.Text != "")
            {
                try
                {
                    ownerdog.IDDog   = Convert.ToInt32(textBoxIDDog.Text);
                    ownerdog.IDOwner = Convert.ToInt32(textBoxIDOwner.Text);
                    sql.AddOwnerDog(ownerdog);

                    x1 = Convert.ToInt32(textBoxIDDog.Text);
                    x2 = Convert.ToInt32(textBoxIDOwner.Text);

                    MessageBox.Show(
                        "You added a new row (Owner - Dog):\n" +
                        "ID Dog: " + x1 + "\n" +
                        "ID Owner: " + x2 + "\n"
                        );
                }
                catch
                {
                    MessageBox.Show("This Dog already have owner or there is no such dog.");
                }
            }
            else
            {
                MessageBox.Show("Enter all fields");
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("DogID,UserID,ImageUrl,Breed,FirstName,LastName,Birthday,SpecialRemarks,Misc")] OwnerDog ownerDog)
        {
            if (id != ownerDog.DogID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ownerDog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnerDogExists(ownerDog.DogID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ownerDog));
        }
Esempio n. 3
0
        private void ButtonUpdate_Click(object sender, EventArgs e)
        {
            OwnerDog selectOwnerDog = (OwnerDog)comboBox1.SelectedItem;

            selectOwnerDog.IDDog = Convert.ToInt32(textBoxUpdateOwmerID.Text);
            updateSQL.Update();
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("DogID,UserID,ImageUrl,Breed,FirstName,LastName,Birthday,SpecialRemarks,Misc")] OwnerDog ownerDog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ownerDog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ownerDog));
        }
Esempio n. 5
0
        public void AddOwnerDog(OwnerDog ownerdog)
        {
            Dog dog = GetDogTable().Where(x => x.ID == ownerdog.IDDog).First();

            ownerdog.Dogs = dog;
            Owners owner = GetOwnersTable().Where(y => y.ID == ownerdog.IDOwner).First();

            ownerdog.OwnerID = owner;
            GetOwnerDogTable().InsertOnSubmit(ownerdog);
            Dc.SubmitChanges();
        }
 private void ButtonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         OwnerDog selectOwnerDog = (OwnerDog)comboBoxDeleteOwnerDog.SelectedItem;
         deleteSQL.DeleteOwnerDog(selectOwnerDog);
         MessageBox.Show("The row is deleted");
     }
     catch
     {
         MessageBox.Show("That ID Dog is already used");
     }
 }
Esempio n. 7
0
 public void DeleteOwnerDog(OwnerDog ownerdog)
 {
     GetOwnerDogTable().DeleteOnSubmit(ownerdog);
     Dc.SubmitChanges();
 }
Esempio n. 8
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            OwnerDog selected = (OwnerDog)comboBox1.SelectedValue;

            textBoxUpdateOwmerID.Text = Convert.ToString(selected.IDOwner);
        }