public void Add_course(object sender, RoutedEventArgs e) { if (id.Text == "" || n.Text == "" || desc.Text == "" || d.Text == "") { MessageBox.Show("Mandatory fields are not filled."); return; } string _id = id.Text.ToString(); string name = n.Text.ToString(); DateTime date = DateTime.Parse(d.Text.ToString()); string description = desc.Text.ToString(); foreach (Model.Course c in MainWindow._mainWindow.Courses) { if (c.ID.Equals(_id)) { MessageBox.Show("id already exists !!!"); //ResetWindow(); //this.Hide(); return; } } Model.Course course = new Model.Course(_id, name, date, description); MainWindow.AddCourse(course); ResetWindow(); this.Hide(); }
public void Add_subject_click(object sender, EventArgs e) { if (desc.Text == "" || id.Text == "" || n.Text == "" || n_students.Text == "" || n_terms.Text == "" || len.Text == "") { MessageBox.Show("Mandatory fields are not filled."); return; } string _id = id.Text.ToString(); string name = n.Text.ToString(); int size_of_group = Int32.Parse(n_students.Text.ToString()); int l = Int32.Parse(len.Text.ToString()); int terms = Int32.Parse(n_terms.Text.ToString()); string des = desc.Text.ToString(); bool proj = false; bool b = false; bool sb = false; if (projector.IsChecked == true) { proj = true; } if (board.IsChecked == true) { b = true; } if (smart_board.IsChecked == true) { sb = true; } foreach (Model.Subject el in MainWindow._mainWindow.Subjects) { if (el.ID.Equals(_id)) { MessageBox.Show("id already exists !!!"); //ResetWindow(); //this.Hide(); return; } } //!!! List <Model.Software> softveri = new List <Model.Software>(); int brojac = 0; foreach (var item in soft.ItemsSource) { SoftwareTableItem i = (SoftwareTableItem)item; if (i.MyBool == true) { softveri.Add(MainWindow._mainWindow.Softwares[brojac]); } brojac++; } brojac = 0; Model.Course c = new Model.Course(); foreach (string str in smerovi) { if (smer.ToString().Equals(smer)) { c = MainWindow._mainWindow.Courses[brojac]; } brojac++; } Model.Subject s = new Model.Subject(_id, name, c, des, size_of_group, l, terms, 0, proj, b, sb, ops, softveri); MainWindow.AddSubject(s); ResetWindow(); this.Hide(); }