예제 #1
0
        public void Add_classroom_click(object sender, EventArgs e)
        {
            if ((os1.IsChecked == false && os2.IsChecked == false) || desc.Text == "" || id.Text == "" || seats.Text == "")
            {
                MessageBox.Show("Mandatory fields are not filled.");
                return;
            }

            string _id = id.Text.ToString();
            int    ns  = Int32.Parse(seats.Text.ToString());
            string des = desc.Text.ToString();

            bool   proj = false;
            bool   b    = false;
            bool   sb   = false;
            string sys  = "";


            if (projector.IsChecked == true)
            {
                proj = true;
            }

            if (board.IsChecked == true)
            {
                b = true;
            }

            if (smart_board.IsChecked == true)
            {
                sb = true;
            }


            if (os1.IsChecked == true)
            {
                sys = "windows";
            }

            if (os2.IsChecked == true)
            {
                sys = "linux";
            }

            if (os1.IsChecked == true && os2.IsChecked == true)
            {
                sys = "Windows/Linux";
            }


            foreach (Model.Classroom el in MainWindow._mainWindow.Classrooms)
            {
                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 kolekcija.ItemsSource)
            {
                SoftwareTableItem i = (SoftwareTableItem)item;

                if (i.MyBool == true)
                {
                    softveri.Add(MainWindow._mainWindow.Softwares[brojac]);
                }
                brojac++;
            }


            Model.Classroom c = new Model.Classroom(_id, des, ns, proj, b, sb, sys, softveri);

            MainWindow.AddClassroom(c);

            ResetWindow();
            this.Hide();
        }
예제 #2
0
        private void Edit_Classroom(object sender, RoutedEventArgs e)
        {
            if ((os1.IsChecked == false && os2.IsChecked == false) || desc.Text == "" || id.Text == "" || seats.Text == "")
            {
                MessageBox.Show("Mandatory fields are not filled.");
                return;
            }
            c.ID = this.id.Text;

            int b = 0;

            foreach (Model.Classroom el in MainWindow._mainWindow.Classrooms)
            {
                if (el.ID.Equals(c.ID) && b != index)
                {
                    MessageBox.Show("id already exists !!!");
                    //ResetWindow();
                    //this.Hide();
                    return;
                }
                b++;
            }



            c.NoOfSeats   = Int32.Parse(this.seats.Text);
            c.Description = this.desc.Text;

            c.Projector  = this.projector.IsChecked == true;
            c.Board      = this.board.IsChecked == true;
            c.SmartBoard = this.smart_board.IsChecked == true;

            if (this.os1.IsChecked == true)
            {
                c.System = "windows";
            }

            if (this.os2.IsChecked == true)
            {
                c.System = "linux";
            }

            if (this.os1.IsChecked == true && this.os2.IsChecked == true)
            {
                c.System = "Windows/Linux";
            }



            int brojac = 0;

            c.Software = new List <Software>();
            foreach (var item in kolekcija.ItemsSource)
            {
                SoftwareTableItem i = (SoftwareTableItem)item;

                if (i.MyBool == true)
                {
                    c.Software.Add(MainWindow._mainWindow.Softwares[brojac]);
                }
                brojac++;
            }

            MainWindow._mainWindow.Classrooms.RemoveAt(index);

            MainWindow._mainWindow.Classrooms.Insert(index, this.c);

            ResetWindow();
            this.Hide();

            edit(this, EventArgs.Empty);
        }
        private void Edit_Subject(object sender, RoutedEventArgs e)
        {
            if (desc.Text == "" || id.Text == "" || n.Text == "" || n_students.Text == "" || n_terms.Text == "" || len.Text == "")
            {
                MessageBox.Show("Mandatory fields are not filled.");
                return;
            }

            this.s.ID = this.id.Text.Trim();
            int b = 0;

            foreach (Model.Subject el in MainWindow._mainWindow.Subjects)
            {
                if (el.ID.Equals(this.s.ID) && b != index)
                {
                    MessageBox.Show("id already exists !!!");
                    //ResetWindow();
                    //this.Hide();
                    return;
                }
                b++;
            }



            this.s.Name        = this.n.Text.Trim();
            this.s.GroupSize   = Int32.Parse(this.n_students.Text);
            this.s.ClassLength = Int32.Parse(this.len.Text);
            this.s.NoOfClasses = Int32.Parse(this.n_terms.Text);
            this.s.Description = this.desc.Text;

            this.s.Projector  = this.projector.IsChecked == true;
            this.s.Board      = this.board.IsChecked == true;
            this.s.SmartBoard = this.smart_board.IsChecked == true;

            if (this.win.IsChecked == true)
            {
                this.s.OS = "windows";
            }
            else if (this.lin.IsChecked == true)
            {
                this.s.OS = "linux";
            }
            else
            {
                this.s.OS = "Windows/Linux";
            }

            int brojac = 0;

            s.Software = new List <Software>();
            foreach (var item in soft.ItemsSource)
            {
                SoftwareTableItem i = (SoftwareTableItem)item;

                if (i.MyBool == true)
                {
                    s.Software.Add(MainWindow._mainWindow.Softwares[brojac]);
                }
                brojac++;
            }
            indeks_smera = smer.SelectedIndex;

            this.s.Course = MainWindow._mainWindow.Courses[indeks_smera];

            MainWindow._mainWindow.Subjects.RemoveAt(index);

            MainWindow._mainWindow.Subjects.Insert(index, this.s);


            ResetWindow();
            this.Hide();
            edit(this, EventArgs.Empty);
        }
예제 #4
0
        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();
        }