Ejemplo n.º 1
0
        private void BtnEditPet_Click(object sender, EventArgs e)
        {
            int    userId  = (Int32)((DGWAdmData.SelectedRows[0].Cells[0]).Value);
            string PetName = ((DGWAdmData.SelectedRows[0].Cells[2]).Value).ToString().Trim(' ');

            connection.Open();
            SqlCommand    command = new SqlCommand($"select ID from Pet where Name = '{PetName}'", connection);
            SqlDataReader reader  = command.ExecuteReader();

            reader.Read();
            int petId = reader.GetInt32(0);

            reader.Close();
            connection.Close();
            EditPet EP = new EditPet(userId, petId);

            EP.ShowDialog();
            ShowPets();
        }
Ejemplo n.º 2
0
 private void BtnEditPet_Click(object sender, EventArgs e)
 {
     try
     {
         string selectedName = (DGWPets.SelectedRows[0].Cells[0]).Value.ToString().Trim(' ');
         connection.Open();
         SqlCommand    command = new SqlCommand($"select ID from Pet where Name = '{selectedName}'", connection);
         SqlDataReader reader  = command.ExecuteReader();
         reader.Read();
         petId = reader.GetInt32(0);
         reader.Close();
         connection.Close();
         EditPet EP = new EditPet(userId, petId);
         EP.ShowDialog();
     }
     catch (Exception)
     {
         MessageBox.Show("Сначала необходимо добавить питомца", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     ShowPets();
 }