Exemplo n.º 1
0
        /// <summary>
        /// Stworzenie nowego użytkownika
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            var studentFirstName = textBoxName.Text;
            var studentLastName  = textBoxLastName.Text;
            var birthDate        = dateTimePickerBirthDate.Text;
            var faculty          = textBoxFaculty.Text;
            var fieldOfStudy     = textBoxField.Text;
            var level            = comboBoxLevels.Text;
            int index            = 0;

            try
            {
                index = Int32.Parse(textBoxIndex.Text);
            } catch (Exception exc)
            {
            }
            var login    = textBoxLogin.Text;
            var password = textBoxPassword.Text;

            Student newStudent = new Student
            {
                FirstName       = studentFirstName,
                LastName        = studentLastName,
                BirthDate       = Convert.ToDateTime(birthDate),
                Faculty         = faculty,
                FieldOfStudy    = fieldOfStudy,
                Level           = level,
                StudentIDNumber = index,
                Login           = login,
                Password        = password
            };

            if (_students.LoginTaken(login))
            {
                MessageBox.Show("Ten login jest już zajęty!");
            }
            else
            {
                try
                {
                    _students.Create(newStudent);
                    _students.Save();
                    main.Show();
                    this.Hide();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Wprowadzono niepoprawne dane.");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Dodanie nowego kursu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAddCourse_Click(object sender, EventArgs e)
        {
            var courseName  = textBoxCourseName.Text;
            var teacherName = textBoxTutor.Text;
            var groupCode   = textBoxGroupCode.Text;
            var term        = textBoxTerm.Text;
            var ectsPoints  = -1;

            try
            {
                ectsPoints = Int32.Parse(textBoxECTS.Text);
            } catch (Exception exc)
            {
                MessageBox.Show("Niepoprawny format ECTS");
            }

            if (ectsPoints == -1)
            {
                return;
            }

            Course course = new Course()
            {
                CourseName  = courseName,
                TeacherName = teacherName,
                CodeOfGroup = groupCode,
                Term        = term,
                ECTS        = ectsPoints
            };

            try
            {
                _courses.Create(course);
                _courses.Save();
                MessageBox.Show("Pomyślnie utworzono nowy kurs.");
                textBoxCourseName.Text         = "";
                textBoxTutor.Text              = "";
                textBoxGroupCode.Text          = "";
                textBoxGroupCode.Text          = "";
                dataGridViewCourses.DataSource = _courses.GetAll();
            }
            catch (Exception exc)
            {
                MessageBox.Show("Podano błędne wartości");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Wysłanie wiadomości danemu studentowi
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSendMessage_Click(object sender, EventArgs e)
        {
            int studentsIndex = -1;

            try
            {
                studentsIndex = (int)dataGridViewStudents.SelectedRows[0].Cells[0].Value;
            } catch (Exception exc)
            {
            }

            if (textBoxAuthor.Text == "")
            {
                MessageBox.Show("Nie wprowadzono nadawcy");
                return;
            }
            else if (studentsIndex == -1)
            {
                MessageBox.Show("Nie wybrano studenta");
            }
            else
            {
                var author  = textBoxAuthor.Text;
                var subject = textBoxSubject.Text;
                var message = textBoxMessage.Text;

                Models.Message messageToSend = new Models.Message()
                {
                    From           = author,
                    Subject        = subject,
                    MessageContent = message,
                    StudentId      = studentsIndex
                };

                _messages.Create(messageToSend);
                _messages.Save();
                textBoxAuthor.Text  = "";
                textBoxSubject.Text = "";
                textBoxMessage.Text = "";
                MessageBox.Show("Wysłano wiadomość");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Wystawienie oceny za dany kurs danemu uczniowi
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSendGrade_Click(object sender, EventArgs e)
        {
            int studentsIndex = -1;
            int courseIndex   = -1;

            try
            {
                studentsIndex = (int)dataGridViewStudents.SelectedRows[0].Cells[0].Value;
                courseIndex   = (int)dataGridViewCourses.SelectedRows[0].Cells[0].Value;
            }
            catch (Exception exc)
            {
            }

            if (studentsIndex == -1)
            {
                MessageBox.Show("Nie wybrano studenta");
            }
            else if (courseIndex == -1)
            {
                MessageBox.Show("Nie wybrano kursu");
            }
            else
            {
                var mark = Double.Parse(comboBoxGrades.Text);
                var date = DateTime.Now;

                Grade grade = new Grade()
                {
                    Mark      = (float)mark,
                    Date      = date,
                    CourseId  = courseIndex,
                    StudentId = studentsIndex
                };

                _grades.Create(grade);
                _grades.Save();
                MessageBox.Show("Wystawiono ocenę");
            }
        }