Beispiel #1
0
 private void Save_Button_Click(object sender, RoutedEventArgs e)
 {
     ReturnPerson = (Nobel_Prize_winner)PersonForm.DataContext;
     if (ReturnPerson.cansave == true)
     {
         baza.SavePerson(ReturnPerson);
         this.Close();
     }
     else
     {
         MessageBox.Show("Wrong data.");
     }
 }
Beispiel #2
0
        private void BtnLoadFromFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                Uri fileUri = new Uri(openFileDialog.FileName);
                imgDynamic.Source    = new BitmapImage(fileUri);
                Picture              = new BitmapImage(fileUri);
                ReturnPerson         = (Nobel_Prize_winner)PersonForm.DataContext;
                ReturnPerson.Picture = Picture;
            }
        }
Beispiel #3
0
        private void New_Person_Click(object sender, RoutedEventArgs e)
        {
            NewWindow          addPerson = new NewWindow(baza);
            Nobel_Prize_winner person    = new Nobel_Prize_winner();

            addPerson.PersonForm.DataContext = person;

            addPerson.ShowDialog();
            if ((addPerson.ReturnPerson != null && addPerson.ReturnPerson.FirstName != null && addPerson.ReturnPerson.LastName != null && addPerson.ReturnPerson.Year > 1900))
            {
                NobelList.Add(addPerson.ReturnPerson);
            }

            ListPersons.ItemsSource = NobelList;
            ListPersons.Items.Refresh();
        }
Beispiel #4
0
        public void SavePerson(Nobel_Prize_winner person)
        {
            command = new SqlCommand();

            command.CommandText = "InsertPerson";
            command.CommandType = CommandType.StoredProcedure;
            command.Connection  = cnn;

            command.Parameters.Add("@DB", SqlDbType.Date).Value      = person.BirthD;
            command.Parameters.Add("@DD", SqlDbType.Date).Value      = person.DeathD;
            command.Parameters.Add("@FN", SqlDbType.NVarChar).Value  = person.FirstName;
            command.Parameters.Add("@LN", SqlDbType.NVarChar).Value  = person.LastName;
            command.Parameters.Add("@N", SqlDbType.NVarChar).Value   = person.Nationality;
            command.Parameters.Add("@F", SqlDbType.NVarChar).Value   = person.Field;
            command.Parameters.Add("@Y", SqlDbType.Int).Value        = person.Year;
            command.Parameters.Add("@PIC", SqlDbType.NVarChar).Value = Convert.ToBase64String(person.LargeIconSerialized);
            command.ExecuteNonQuery();
        }