Beispiel #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();
                    }
                }
            }
        }
Beispiel #2
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();
                }
            }
        }
Beispiel #3
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();
                }
            }
        }
Beispiel #4
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();
                    }
                }
            }
        }
Beispiel #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();
                }
            }
        }
Beispiel #6
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();
                }
            }
        }
Beispiel #7
0
 private void button3_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in classroomDataGridView.SelectedRows)
     {
         Classroom sch = row.DataBoundItem as Classroom;
         if (sch != null)
         {
             _context.Classrooms.Remove(sch);
             _context.SaveChanges();
         }
     }
 }
Beispiel #8
0
 private void button3_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in timeslotDataGridView.SelectedRows)
     {
         Timeslot sch = row.DataBoundItem as Timeslot;
         if (sch != null)
         {
             _context.Timeslots.Remove(sch);
             _context.SaveChanges();
         }
     }
 }
Beispiel #9
0
 private void button6_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in scheduleDataGridView.SelectedRows)
     {
         Schedule sch = row.DataBoundItem as Schedule;
         if (sch != null)
         {
             _context.Schedules.Remove(sch);
             _context.SaveChanges();
         }
     }
 }
Beispiel #10
0
 private void button3_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in professorDataGridView.SelectedRows)
     {
         Professor sch = row.DataBoundItem as Professor;
         if (sch != null)
         {
             _context.Professors.Remove(sch);
             _context.SaveChanges();
         }
     }
 }
Beispiel #11
0
 private void button3_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in groupDataGridView.SelectedRows)
     {
         Group sch = row.DataBoundItem as Group;
         if (sch != null)
         {
             _context.Groups.Remove(sch);
             _context.SaveChanges();
         }
     }
 }
Beispiel #12
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();
                }
            }
        }
Beispiel #13
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();
                }
            }
        }
Beispiel #14
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();
                }
            }
        }
Beispiel #15
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();
                }
            }
        }
Beispiel #16
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();
                }
            }
        }
Beispiel #17
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();
                }
            }
        }
Beispiel #18
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();
                }
            }
        }
Beispiel #19
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();
                }
            }
        }