private void Usun_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Czy na pewno chcesz usunąć dane studentów ?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { while (StudentsDataGrid.SelectedItems.Count > 0) { StudentsDbService sdb = (StudentsDbService)StudentsDataGrid.SelectedItem; ListaStudentow.RemoveAt(StudentsDataGrid.SelectedIndex); string index = sdb.NrIndeksu; using (var con = new SqlConnection("Data Source=db-mssql16.pjwstk.edu.pl;Initial Catalog=s15269;Integrated Security=True")) using (var comm = new SqlCommand()) { comm.Connection = con; comm.CommandText = "DELETE FROM s15269.apbd.Student WHERE IndexNumber = " + index; con.Open(); comm.ExecuteNonQuery(); con.Close(); } } IdCounter = 0; } }
private void Button1_Click(object sender, RoutedEventArgs e) { Regex reg = new Regex(@"s([0-9]{4})"); Match match = reg.Match(textBoxIndeks.Text); selectedItem = new List <string>(); foreach (String item in listBoxPrzedmioty.SelectedItems) { selectedItem.Add(item); } if (match.Success && selectedItem.Count >= 1 && textBoxImie.Text.Length >= 3 && textBoxNazwisko.Text.Length >= 3 && comboBoxStudia.SelectedItem != null && listBoxPrzedmioty.SelectedItem != null ) { student = new StudentsDbService { Nazwisko = textBoxNazwisko.Text, Imie = textBoxImie.Text, NrIndeksu = textBoxIndeks.Text, Studia = comboBoxStudia.Text, przedmioty = selectedItem }; MainWindow.listaStudentow.Add(student); this.Close(); } else { MessageBox.Show("Nieprawidlowo uzupełnione pola!"); } }
//private ObservableCollection<> ListaStudentow; public MainWindow() { InitializeComponent(); Student._ListaStudentow = StudentsDbService.Polaczenie(); StudentsDataGrid.ItemsSource = Student._ListaStudentow; StudentsDataGrid.Items.Refresh(); }
public ViewMode2(StudentsDbService sd) { Studia = new List <string>(); przedmioty = new List <string>(); NrIndeksu = sd.NrIndeksu; Imie = sd.Imie; Nazwisko = sd.Nazwisko; Adres = sd.Adres; Studia.Add(sd.Studia); przedmioty = sd.przedmioty; }
private void StudentsDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { StudentsDbService sd = (StudentsDbService)StudentsDataGrid.SelectedItem; var edyt = new Edycja(sd); edyt.ShowDialog(); if (!edyt.IsActive) { ListaStudentow.Add(sd); ListaStudentow.Remove(sd); } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { List <Student> toRemove = StudentsDataGrid.SelectedItems.Cast <Student>().ToList(); foreach (Student student in toRemove) { ListaStudentow.Remove(student); } var DbProvider = new StudentsDbService(); DbProvider.RemoveStudents(toRemove); }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { var DbProvider = new StudentsDbService(); if (editMode) { DbProvider.UpdateStudent(CurrentStudent); } else { CurrentStudent.IdStudent = DbProvider.AddStudent(CurrentStudent); } Close(); }
public void DodajStudenta(StudentsDbService st) { ListaStudentow.Add(st); //IdCounter = 0; //StudentsDataGrid.ItemsSource = ListaStudentow; }
public Edycja(StudentsDbService student) { this.student = student; DataContext = new ViewMode2(student); InitializeComponent(); }
private void InitializeData() { var DbProvider = new StudentsDbService(); studies = new ObservableCollection <Study>(DbProvider.AllStudies()); }
private void InitializeData() { var DbProvider = new StudentsDbService(); ListaStudentow = new ObservableCollection <Student>(DbProvider.AllStudents()); }