Exemplo n.º 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var classroom = new Classroom
                    {
                        Name = textBox2.Text.ToString(),
                        Capacity = Convert.ToInt32(textBox3.Text)
                    };
                    ctx.Classrooms.Add(classroom);
                    ctx.SaveChanges();
                    var len = ctx.Classrooms.ToArray().Length;
                    this.Close();

                    //Adding ClassroomTimeRestriction

                    foreach (var r in restrictions)
                    {
                        var restriction = new ClassroomTimeRestriction
                        {
                            TimeslotId = r,
                        };
                        ctx.ClassroomTimeRestrictions.Add(restriction);
                        ctx.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (comboBox1.SelectedItem.ToString() == "" || comboBox2.SelectedItem.ToString() == "" || comboBox3.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Missing required input from dropdown menu.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    int groupId     = Convert.ToInt32(comboBox1.SelectedValue);
                    int courseId    = Convert.ToInt32(comboBox2.SelectedValue);
                    int professorId = Convert.ToInt32(comboBox3.SelectedValue);
                    if (ctx.GroupCourseProfessors.Any(gcp => gcp.GroupId == groupId && gcp.CourseId == courseId && gcp.ProfessorId == professorId))
                    {
                        this.Close();
                        return;
                    }

                    var g = new GroupCourseProfessor
                    {
                        GroupId     = groupId,
                        CourseId    = courseId,
                        ProfessorId = professorId,
                        Timeslots   = Convert.ToInt32(textBox1.Text)
                    };

                    ctx.GroupCourseProfessors.Add(g);
                    ctx.SaveChanges();
                    this.Close();
                }
            }
        }
Exemplo n.º 3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var classroom = new Classroom
                    {
                        Name     = textBox2.Text.ToString(),
                        Capacity = Convert.ToInt32(textBox3.Text)
                    };
                    ctx.Classrooms.Add(classroom);
                    ctx.SaveChanges();
                    var len = ctx.Classrooms.ToArray().Length;
                    this.Close();

                    //Adding ClassroomTimeRestriction

                    foreach (var r in restrictions)
                    {
                        var restriction = new ClassroomTimeRestriction
                        {
                            TimeslotId = r,
                        };
                        ctx.ClassroomTimeRestrictions.Add(restriction);
                        ctx.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var prof = new Professor
                    {
                        // Podesi input, automatski increase ID
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Professors.Add(prof);
                    ctx.SaveChanges();

                    //Adding ProfessorTimeRestriction

                    foreach (var r in restrictions)
                    {
                        var restriction = new ProfessorTimeRestriction
                        {
                            ProfessorId = prof.Id,
                            TimeslotId = r,
                        };
                        ctx.ProfessorTimeRestrictions.Add(restriction);
                        ctx.SaveChanges();
                    }
                    this.Close();
                }
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (comboBox1.SelectedItem.ToString() == "" || comboBox2.SelectedItem.ToString() == "" || comboBox3.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Missing required input from dropdown menu.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    int groupId = Convert.ToInt32(comboBox1.SelectedValue);
                    int courseId = Convert.ToInt32(comboBox2.SelectedValue);
                    int professorId = Convert.ToInt32(comboBox3.SelectedValue);
                    if (ctx.GroupCourseProfessors.Any(gcp => gcp.GroupId == groupId && gcp.CourseId == courseId && gcp.ProfessorId == professorId))
                    {
                        this.Close();
                        return;
                    }

                    var g = new GroupCourseProfessor
                    {
                        GroupId = groupId,
                        CourseId = courseId,
                        ProfessorId = professorId,
                        Timeslots = Convert.ToInt32(textBox1.Text)
                    };

                    ctx.GroupCourseProfessors.Add(g);
                    ctx.SaveChanges();
                    this.Close();
                }
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var prof = new Professor
                    {
                        // Podesi input, automatski increase ID
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Professors.Add(prof);
                    ctx.SaveChanges();

                    //Adding ProfessorTimeRestriction

                    foreach (var r in restrictions)
                    {
                        var restriction = new ProfessorTimeRestriction
                        {
                            ProfessorId = prof.Id,
                            TimeslotId  = r,
                        };
                        ctx.ProfessorTimeRestrictions.Add(restriction);
                        ctx.SaveChanges();
                    }
                    this.Close();
                }
            }
        }
Exemplo n.º 7
0
 private void GroupACD_Load(object sender, EventArgs e)
 {
     _context = new ScheduleContext();
     _context.Groups.Load();
     comboBox1.DataSource    = _context.Groups.ToList();
     comboBox1.ValueMember   = "id";
     comboBox1.DisplayMember = "name";
 }
Exemplo n.º 8
0
 public SchedulePreview(int id)
 {
     InitializeComponent();
     ctx = new ScheduleContext();
     dataGridView1.AllowUserToAddRows = false;
     ctx.Schedules.Load();
     s = ctx.Schedules.Find(id);
 }
Exemplo n.º 9
0
 public SchedulePreview(int id)
 {
     InitializeComponent();
     ctx = new ScheduleContext();
     dataGridView1.AllowUserToAddRows = false;
     ctx.Schedules.Load();
     s = ctx.Schedules.Find(id);
 }
Exemplo n.º 10
0
 private void GroupACD_Load(object sender, EventArgs e)
 {
     _context = new ScheduleContext();
     _context.Groups.Load();
     comboBox1.DataSource = _context.Groups.ToList();
     comboBox1.ValueMember = "id";
     comboBox1.DisplayMember = "name";
 }
Exemplo n.º 11
0
 private void ProfessorView_Load(object sender, EventArgs e)
 {
     professorDataGridView.MultiSelect   = false;
     professorDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Professors.Load();
     this.professorBindingSource.DataSource =
         _context.Professors.Local.ToBindingList();
 }
Exemplo n.º 12
0
 private void GroupView_Load(object sender, EventArgs e)
 {
     groupDataGridView.MultiSelect = false;
     groupDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Groups.Load();
     this.groupBindingSource.DataSource =
         _context.Groups.Local.ToBindingList();
 }
Exemplo n.º 13
0
 private void Form1_Load(object sender, EventArgs e)
 {
     scheduleDataGridView.MultiSelect   = false;
     scheduleDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Schedules.Load();
     this.scheduleBindingSource.DataSource =
         _context.Schedules.Local.ToBindingList();
 }
Exemplo n.º 14
0
 private void ProfessorView_Load(object sender, EventArgs e)
 {
     professorDataGridView.MultiSelect = false;
     professorDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Professors.Load();
     this.professorBindingSource.DataSource =
         _context.Professors.Local.ToBindingList();
 }
Exemplo n.º 15
0
 private void ClassroomView_Load(object sender, EventArgs e)
 {
     classroomDataGridView.MultiSelect = false;
     classroomDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Classrooms.Load();
     this.classroomBindingSource.DataSource =
         _context.Classrooms.Local.ToBindingList();
 }
Exemplo n.º 16
0
 private void TimeslotsView_Load(object sender, EventArgs e)
 {
     timeslotDataGridView.MultiSelect   = false;
     timeslotDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Timeslots.Load();
     this.timeslotBindingSource.DataSource =
         _context.Timeslots.Local.ToBindingList();
 }
Exemplo n.º 17
0
 private void GroupView_Load(object sender, EventArgs e)
 {
     groupDataGridView.MultiSelect   = false;
     groupDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Groups.Load();
     this.groupBindingSource.DataSource =
         _context.Groups.Local.ToBindingList();
 }
Exemplo n.º 18
0
 private void ClassroomView_Load(object sender, EventArgs e)
 {
     classroomDataGridView.MultiSelect   = false;
     classroomDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Classrooms.Load();
     this.classroomBindingSource.DataSource =
         _context.Classrooms.Local.ToBindingList();
 }
Exemplo n.º 19
0
        public void GenerateSchedule()
        {
            var ctx = new ScheduleContext();
            ctx.GroupCourseProfessors.Load();
            ctx.Timeslots.Load();

            List<int> timeslots = new List<int>();
            foreach (Timeslot t in ctx.Timeslots)
            {
                timeslots.Add(t.Id);
            }
        }
Exemplo n.º 20
0
        public void GenerateSchedule()
        {
            var ctx = new ScheduleContext();

            ctx.GroupCourseProfessors.Load();
            ctx.Timeslots.Load();

            List <int> timeslots = new List <int>();

            foreach (Timeslot t in ctx.Timeslots)
            {
                timeslots.Add(t.Id);
            }
        }
Exemplo n.º 21
0
        private void GCP_Load(object sender, EventArgs e)
        {
            _context = new ScheduleContext();
            _context.Groups.Load();
            comboBox1.DataSource = _context.Groups.ToList();
            comboBox1.ValueMember = "id";
            comboBox1.DisplayMember = "name";

            _context.Courses.Load();
            comboBox2.DataSource = _context.Courses.ToList();
            comboBox2.ValueMember = "id";
            comboBox2.DisplayMember = "name";

            _context.Professors.Load();
            comboBox3.DataSource = _context.Professors.ToList();
            comboBox3.ValueMember = "id";
            comboBox3.DisplayMember = "name";
        }
Exemplo n.º 22
0
        private void GCP_Load(object sender, EventArgs e)
        {
            _context = new ScheduleContext();
            _context.Groups.Load();
            comboBox1.DataSource    = _context.Groups.ToList();
            comboBox1.ValueMember   = "id";
            comboBox1.DisplayMember = "name";

            _context.Courses.Load();
            comboBox2.DataSource    = _context.Courses.ToList();
            comboBox2.ValueMember   = "id";
            comboBox2.DisplayMember = "name";

            _context.Professors.Load();
            comboBox3.DataSource    = _context.Professors.ToList();
            comboBox3.ValueMember   = "id";
            comboBox3.DisplayMember = "name";
        }
Exemplo n.º 23
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var schedule = new Schedule
                    {
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Schedules.Add(schedule);
                    ctx.SaveChanges();

                    this.Close();
                }
            }
        }
Exemplo n.º 24
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var schedule = new Schedule
                    {
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Schedules.Add(schedule);
                    ctx.SaveChanges();

                    this.Close();
                }
            }
        }
Exemplo n.º 25
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    var course = new Course
                    {
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Courses.Add(course);
                    ctx.SaveChanges();
                    var len = ctx.Classrooms.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    var course = new Course
                    {
                        Name = textBox2.Text.ToString(),
                    };

                    ctx.Courses.Add(course);
                    ctx.SaveChanges();
                    var len = ctx.Classrooms.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 27
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var group = new Group
                    {
                        Name = textBox2.Text.ToString(),
                        Members = Convert.ToInt32(textBox3.Text.ToString()),
                        ParentId = Convert.ToInt32(comboBox1.SelectedValue),
                    };

                    ctx.Groups.Add(group);
                    ctx.SaveChanges();
                    var len = ctx.Groups.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 28
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (comboBox1.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Missing required input from dropdown menu.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var timeslot = new Timeslot
                    {
                        From = Convert.ToInt32(textBox2.Text),
                        To   = Convert.ToInt32(textBox3.Text),
                        Day  = comboBox1.SelectedItem.ToString(),
                    };

                    ctx.Timeslots.Add(timeslot);
                    ctx.SaveChanges();
                    var len = ctx.Timeslots.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 29
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (comboBox1.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Missing required input from dropdown menu.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var timeslot = new Timeslot
                    {
                        From = Convert.ToInt32(textBox2.Text),
                        To = Convert.ToInt32(textBox3.Text),
                        Day = comboBox1.SelectedItem.ToString(),
                    };

                    ctx.Timeslots.Add(timeslot);
                    ctx.SaveChanges();
                    var len = ctx.Timeslots.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (textBox2.Text == "" || textBox3.Text == "")
                {
                    MessageBox.Show("Missing required input.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var group = new Group
                    {
                        Name     = textBox2.Text.ToString(),
                        Members  = Convert.ToInt32(textBox3.Text.ToString()),
                        ParentId = Convert.ToInt32(comboBox1.SelectedValue),
                    };

                    ctx.Groups.Add(group);
                    ctx.SaveChanges();
                    var len = ctx.Groups.ToArray().Length;
                    this.Close();
                }
            }
        }
Exemplo n.º 31
0
 private void Form1_Load(object sender, EventArgs e)
 {
     scheduleDataGridView.MultiSelect = false;
     scheduleDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Schedules.Load();
     this.scheduleBindingSource.DataSource =
         _context.Schedules.Local.ToBindingList();
 }
Exemplo n.º 32
0
 private void TimeslotsView_Load(object sender, EventArgs e)
 {
     timeslotDataGridView.MultiSelect = false;
     timeslotDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
     _context = new ScheduleContext();
     _context.Timeslots.Load();
     this.timeslotBindingSource.DataSource =
         _context.Timeslots.Local.ToBindingList();
 }