Esempio n. 1
0
 /// <returns>Returns true when session result added correctly</returns>
 static public bool SessionResultADD(string StudentNumber, SessionResult sessionResult)
 {
     using (StudentContext db = new StudentContext())
     {
         var student = db.Students.Find(StudentNumber);
         if (student != null)
         {
             student.sessionResults.Add(sessionResult);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 2
0
        private Student Stud; //Authentificated student
        public StudentForm(string studnumber)
        {
            InitializeComponent();
            StudentContext context = new StudentContext();

            Stud         = context.Students.Find(studnumber);
            DisciplineID = null;
            LoadData();

            StudentID.Text   = Stud.StudentNumber; // Set info about student
            FIO.Text         = Stud.Name;
            Group.Text       = Stud.Group;
            Specialty.Text   = Stud.Specialty;
            Faculty.Text     = Stud.Faculty;
            Gender.Text      = Stud.Gender;
            DateOfBirth.Text = Stud.DateOfBirth.ToString("d");


            ResultDGV.Columns["ExamDate"].HeaderText = "Дата экзамена";
            ResultDGV.Columns["ExamMark"].HeaderText = "Отметка за экзамен";
        }
Esempio n. 3
0
        public AdminForm()
        {
            InitializeComponent();
            context  = new StudentContext();
            dContext = new DisciplineContext();
            LoadData();
            dataGridView1.Columns[0].ReadOnly   = true;
            dataGridView1.AllowUserToDeleteRows = true;

            dataGridView1.Columns["StudentNumber"].HeaderText = "Номер зачетной книги";
            dataGridView1.Columns["Name"].HeaderText          = "ФИО";
            dataGridView1.Columns["Gender"].HeaderText        = "Пол";
            dataGridView1.Columns["DateOfBirth"].HeaderText   = "Дата рождения";
            dataGridView1.Columns["Group"].HeaderText         = "Группа";
            dataGridView1.Columns["Specialty"].HeaderText     = "Специальность";
            dataGridView1.Columns["Faculty"].HeaderText       = "Факультет";


            //dataGridView1.Columns["DateOfBirth"].DefaultCellStyle.Format = "dd.MM.yyyy";

            AdminsDGV.Columns["Login"].HeaderText = "Логин";
            AdminsDGV.Columns["Pass"].Visible     = false;

            DisciplineDGV.Columns["ID"].HeaderText      = "Идентификационный номер";
            DisciplineDGV.Columns["Name"].HeaderText    = "Название дисциплины";
            DisciplineDGV.Columns["Teacher"].HeaderText = "Преподаватель";

            ToolTip tooltip = new ToolTip
            {
                AutoPopDelay = 5000,
                InitialDelay = 100,
                ReshowDelay  = 200
            };

            tooltip.SetToolTip(this.HelpBtn, "Для удаления записи, выделите ее в таблице и нажмите кнопку \"Delete\"");
        }
 static public void Init()
 {
     DataBase = new StudentContext();
 }
Esempio n. 5
0
        private void StudentAdd_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show(
                $"Вы действительно хотите добавить студента?",
                "Вы уверены?",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning
                );

            if (dialog == DialogResult.Yes)
            {
                if (StudentID.Text.Trim() != "" &&
                    FIO.Text.Trim() != "" &&
                    GroupTextbox.Text.Trim() != "" &&
                    Specialty.Text.Trim() != "" &&
                    Faculty.Text.Trim() != ""
                    )
                {
                    string   id        = StudentID.Text.Trim();
                    string   fio       = FIO.Text.Trim();
                    string   group     = GroupTextbox.Text.Trim();
                    string   specialty = Specialty.Text.Trim();
                    string   faculty   = Faculty.Text.Trim();
                    string   gender;
                    DateTime birthday = DateOfBirth.Value;
                    if (isMale.Checked)
                    {
                        gender = "Мужской";
                    }
                    else
                    {
                        gender = "Женский";
                    }

                    using (StudentContext StudentsDb = new StudentContext())
                    {
                        var std = StudentsDb.Students.Find(id);
                        if (std == null)
                        {
                            Student student = new Student
                            {
                                StudentNumber  = id,
                                Name           = fio,
                                Group          = group,
                                Specialty      = specialty,
                                Faculty        = faculty,
                                Gender         = gender,
                                DateOfBirth    = birthday,
                                sessionResults = new List <SessionResult> {
                                }
                            };
                            StudentsDb.Students.Add(student);
                            StudentsDb.SaveChanges();
                            MessageBox.Show(
                                "Успех!",
                                "Успех!",
                                MessageBoxButtons.OK
                                );
                        }
                        else
                        {
                            MessageBox.Show(
                                "Студент с таким номером зачетной книги уже существует!",
                                "Ошибка!",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
                        }
                    }
                }
                else
                {
                    MessageBox.Show(
                        "Все поля должны быть заполнены!",
                        "Ошибка",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
        }
Esempio n. 6
0
 static public Student GetStudent(string StudentNumber)
 {
     using (StudentContext db = new StudentContext())
         return(db.Students.Find(StudentNumber));
 }
Esempio n. 7
0
 static public bool StudentInput(string id)
 {
     using (StudentContext db = new StudentContext())
         return(db.Students.Find(id) != null);
 }