예제 #1
0
        private void btnAddVacine_Click(object sender, RoutedEventArgs e)
        {
            PetVaccine          selectedVaccine = (PetVaccine)cbVaccine.SelectedItem;
            DataBase            dataBase        = new DataBase("LAPTOP-N5V21FUT\\SQLEXPRESS", "AdoPetDB");
            string              query           = @"INSERT INTO AnimalVaccines (VaccineID, AnimalID, Comment, InoculationDate) VALUES (@vaccineid, @animalid,@comment, @inoculationdate)";
            List <SqlParameter> sqlParameters   = new List <SqlParameter>()
            {
                new SqlParameter("@vaccineid", SqlDbType.Int)
                {
                    Value = selectedVaccine.ID
                },
                new SqlParameter("@animalid", SqlDbType.Int)
                {
                    Value = selectedAnimal.ID
                },
                new SqlParameter("@comment", SqlDbType.NVarChar)
                {
                    Value = txtComments.Text
                },
                new SqlParameter("@inoculationdate", SqlDbType.DateTime)
                {
                    Value = (DateTime)(dpVaccinesDate.SelectedDate)
                }
            };

            dataBase.ExecuteQuery(query, sqlParameters);
            MessageBox.Show("Pomyślnie dodano szczepienie");
            refreshVaccines();
        }
예제 #2
0
        private void dpVaccinesDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            PetVaccine selectedVaccine = (PetVaccine)cbVaccine.SelectedItem;
            DateTime   dateNextVaccine = ((DateTime)dpVaccinesDate.SelectedDate).AddMonths(selectedVaccine.ValidInMonths);

            txtDateNextVaccine.Text = dateNextVaccine.ToString("dd/MM/yyyy");
        }
예제 #3
0
        private void btnDelete_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                PetVaccine pv = (PetVaccine)dgVaccines.SelectedItem;



                DataBase            dataBase      = new DataBase("LAPTOP-N5V21FUT\\SQLEXPRESS", "AdoPetDB");
                string              query         = @"UPDATE Vaccines SET RemovalDate=@removaldate WHERE ID=@id";
                List <SqlParameter> sqlParameters = new List <SqlParameter>()
                {
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = pv.ID
                    },
                    new SqlParameter("@removaldate", SqlDbType.DateTime)
                    {
                        Value = DateTime.Now
                    }
                };
                dataBase.ExecuteQuery(query, sqlParameters);
                RefreshVaccines();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wystąpił nieoczekiwany błąd");
            }
        }
예제 #4
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            PetVaccine pv = (PetVaccine)dgVaccines.SelectedItem;

            txtVaccine.Text = pv.Name.ToString();
            txtMonth.Text   = pv.ValidInMonths.ToString();
            EditedID        = pv.ID;
        }
예제 #5
0
        private void lstVaccines_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            PetVaccine pv = (PetVaccine)dgVaccines.SelectedItem;

            txtVaccine.Text       = pv.Name;
            txtMonth.Text         = pv.ValidInMonths.ToString();
            btnAddVaccine.Content = "Edytuj szczepienie";
        }