예제 #1
0
 /// <summary>
 /// Метод для добавлення групи
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBoxGroupname.Text != string.Empty && comboBox1.SelectedIndex != -1 && textBox1.Text != string.Empty && comboBoxSemester.SelectedIndex != -1)
     {
         int semestr = int.Parse(comboBoxSemester.Text);
         dataBase.Groups.Add(new ProgramLogicDll.Group
         {
             Name         = textBoxGroupname.Text,
             Profession   = comboBox1.Text,
             HoursOfStudy = textBox1.Text,
             Semesters    = dataBase.Semesters.Where(sem => sem.SemesterNumber == semestr).FirstOrDefault(),
             Students     = students,
             Teachers     = teachers
         });
         dataBase.SaveChanges();
         foreach (var item in students)
         {
             dataBase.Students.Where(stud => stud.StudentId == item.StudentId).FirstOrDefault().Groups = dataBase.Groups.Where(id => id.Name == textBoxGroupname.Text).FirstOrDefault();
             dataBase.SaveChanges();
         }
         foreach (var item in teachers)
         {
             dataBase.Teachers.Where(teacher => teacher.TeacherId == item.TeacherId).FirstOrDefault().Groups.Add(dataBase.Groups.Where(id => id.Name == textBoxGroupname.Text).FirstOrDefault());
             dataBase.SaveChanges();
         }
         textBoxGroupname.Text = textBox1.Text = string.Empty;
         listBox1.Items.Clear(); listBox2.Items.Clear(); UpdateData();
         MessageBox.Show("Group added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для добавлення студента
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && textBox4.Text != string.Empty && textBox5.Text != string.Empty && comboBox1.SelectedIndex != -1)
     {
         dataBase.Students.Add(new ProgramLogicDll.Student
         {
             FirstName      = textBox1.Text,
             LastName       = textBox2.Text,
             Age            = int.Parse(textBox3.Text),
             PhoneNumber    = textBox4.Text,
             Email          = textBox5.Text,
             Profession     = comboBox1.SelectedItem.ToString(),
             DateOfReceipt  = dateTimePicker1.Value,
             ExpirationDate = dateTimePicker2.Value,
             Groups         = null
         });
         dataBase.SaveChanges();
         textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = string.Empty;
         MessageBox.Show("Student add", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для видалення компютера з аудиторії
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button2_Click(object sender, EventArgs e)
 {
     if (listBox2.SelectedIndex != -1)
     {
         listBox1.Items.Add(listBox2.SelectedItem);
         int Id = int.Parse(listBox2.SelectedItem.ToString());
         computers.Remove(dataBase.Computers.Where(id => id.ComputerId == Id).FirstOrDefault());
         dataBase.Computers.Where(id => id.ComputerId == Id).FirstOrDefault().Audiences = null;
         dataBase.SaveChanges();
         listBox2.Items.RemoveAt(listBox2.SelectedIndex);
     }
     else
     {
         MessageBox.Show("Choise computer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #4
0
 /// <summary>
 /// Метод для добавлення аудиторії
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != null && textBox2.Text != null)
     {
         if (Convert.ToInt32(textBox2.Text) > listBox2.Items.Count)
         {
             int audienceNumber = int.Parse(textBox1.Text);
             if (dataBase.Audiences.Where(number => number.AudienceNumber == audienceNumber).FirstOrDefault() == null)
             {
                 dataBase.Audiences.Add(new ProgramLogicDll.Audience
                 {
                     AudienceNumber = int.Parse(textBox1.Text),
                     NumberOfSeats  = int.Parse(textBox2.Text),
                     Computers      = computers,
                     Groups         = Groups
                 });
                 dataBase.SaveChanges();
                 foreach (var item in computers)
                 {
                     dataBase.Computers.Where(id => id.ComputerId == item.ComputerId).FirstOrDefault().Audiences = dataBase.Audiences.Where(number => number.AudienceNumber == audienceNumber).FirstOrDefault();
                     dataBase.SaveChanges();
                 }
                 foreach (var item in Groups)
                 {
                     dataBase.Groups.Where(id => id.GroupId == item.GroupId).FirstOrDefault().Audiences = dataBase.Audiences.Where(number => number.AudienceNumber == audienceNumber).FirstOrDefault();
                     dataBase.SaveChanges();
                 }
                 textBox1.Text = textBox2.Text = string.Empty;
                 UpdateData();
                 MessageBox.Show("Audience added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("This audience already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("There are more computers than seats", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Enter all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для зберігання відредактованого компютера
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && comboBox1.SelectedIndex != -1)
     {
         int Id       = int.Parse(comboBox1.SelectedItem.ToString());
         var computer = dataBase.Computers.Where(computerId => computerId.ComputerId == Id).FirstOrDefault();
         computer.GraphicsCard = textBox1.Text;
         computer.Processor    = textBox2.Text;
         computer.RAM          = int.Parse(textBox3.Text);
         computer.Softwares    = softwares;
         dataBase.SaveChanges();
         textBox1.Text = textBox2.Text = textBox3.Text = string.Empty;
         listBox1.Items.Clear(); listBox2.Items.Clear();
         UpdateComputers(); softwares.Clear();
         MessageBox.Show("Computer edited", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Choise computer or add all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #6
0
 /// <summary>
 /// Метод для збереження відредактованого ПЗ
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex != -1 && textBox1.Text != string.Empty)
     {
         if (dataBase.Softwares.Where(software => software.Name == textBox1.Text).FirstOrDefault() == null)
         {
             dataBase.Softwares.Where(software => software.Name == comboBox1.SelectedItem.ToString()).FirstOrDefault().Name = textBox1.Text;
             dataBase.SaveChanges();
             textBox1.Text = string.Empty;
             UpdateSoftwares();
             MessageBox.Show("Software edited", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("This software already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Choise software", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Збереження відредактованого предмету
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && comboBox1.SelectedIndex != -1)
     {
         if (dataBase.Subjects.Where(subject => subject.Name == textBox1.Text).FirstOrDefault() == null)
         {
             dataBase.Subjects.Where(subject => subject.Name == comboBox1.SelectedItem.ToString()).FirstOrDefault().Name = textBox1.Text;
             dataBase.SaveChanges();
             textBox1.Text = string.Empty;
             UpdateSubjects();
             MessageBox.Show("Subject edited", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("This subject already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Enter or choise subject", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для зберігання відредактованого студента
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && textBox4.Text != string.Empty && textBox5.Text != string.Empty && comboBox2.SelectedIndex != -1 && comboBox1.SelectedIndex != -1)
     {
         int studentId = students[comboBox1.SelectedIndex].StudentId;
         var student   = dataBase.Students.Where(Id => Id.StudentId == studentId).FirstOrDefault();
         student.FirstName      = textBox1.Text;
         student.LastName       = textBox2.Text;
         student.Age            = int.Parse(textBox3.Text);
         student.PhoneNumber    = textBox4.Text;
         student.Email          = textBox5.Text;
         student.Profession     = comboBox2.SelectedItem.ToString();
         student.DateOfReceipt  = dateTimePicker1.Value;
         student.ExpirationDate = dateTimePicker2.Value;
         textBox1.Text          = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = comboBox2.Text = string.Empty;
         dataBase.SaveChanges(); UpdateStudets();
         MessageBox.Show("Student edited", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields or choise student", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для добавлення ПЗ
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty)
     {
         if (dataBase.Softwares.Where(soft => soft.Name == textBox1.Text).FirstOrDefault() == null)
         {
             dataBase.Softwares.Add(new ProgramLogicDll.Software {
                 Name = textBox1.Text
             });
             dataBase.SaveChanges();
             textBox1.Text = string.Empty;
             MessageBox.Show("Software added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("This software already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Enter software", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для добавлення семестру
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty)
     {
         int number = int.Parse(textBox1.Text);
         if (dataBase.Semesters.Where(sem => sem.SemesterNumber == number).FirstOrDefault() == null)
         {
             dataBase.Semesters.Add(new ProgramLogicDll.Semester {
                 SemesterNumber = int.Parse(textBox1.Text)
             });
             dataBase.SaveChanges();
             textBox1.Text = string.Empty;
             MessageBox.Show("Semester added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("This semester already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Enter semester", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Добавлення вчителя
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && textBox4.Text != string.Empty && textBox5.Text != string.Empty && textBox6.Text != string.Empty)
     {
         dataBase.Teachers.Add(new ProgramLogicDll.Teacher
         {
             FirstName   = textBox1.Text,
             LastName    = textBox2.Text,
             Age         = int.Parse(textBox3.Text),
             PhoneNumber = textBox4.Text,
             Email       = textBox5.Text,
             Salary      = double.Parse(textBox6.Text),
             Subjects    = subjects
         });
         dataBase.SaveChanges();
         textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = string.Empty;
         listBox2.Items.Clear(); UpdateSubjects();
         MessageBox.Show("Teacher added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }