public async Task <int> AddEmployment(int id)
        {
            var employee = await Employees.GetById(id, new string[1] {
                "Employments"
            });

            var newEmployment = new Employment()
            {
                HireDate = DateTime.Now.Date, EmployeeId = employee.EmployeeId
            };

            return(await Employments.Add(newEmployment));
        }
示例#2
0
        public void Employ(Employment employment, bool force = false)
        {
            Requires.NotNull(employment, nameof(employment));
            Requires.NotNull(Employments, nameof(Employments));

            if (IsOffice)
            {
                throw new InvalidOperationException(); // TODO: specify text
            }
            if (!IsEmployee)
            {
                if (force)
                {
                    MakeEmployee();
                }
                else
                {
                    throw new InvalidOperationException(); // TODO: specify text
                }
            }

            Employments.Add(employment);
        }
示例#3
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (!((cmbDiscipline1.Text != "" && cmbRooms1.Text != "" &&
                   cmbTypeLesson1.SelectedValue != null && cmbTeacher1.Text != "") ||
                  ((cmbDiscipline1.Text == "" && cmbRooms1.Text == "" &&
                    cmbTypeLesson1.SelectedValue == null && cmbTeacher1.Text == ""))))
            {
                MessageBox.Show("Введены не все \n\rзначения для 1-2 недели", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!((cmbDiscipline2.Text != "" && cmbRooms2.Text != "" &&
                   cmbTypeLesson2.SelectedValue != null && cmbTeacher2.Text != "") ||
                  ((cmbDiscipline2.Text == "" && cmbRooms2.Text == "" &&
                    cmbTypeLesson2.SelectedValue == null && cmbTeacher2.Text == ""))))
            {
                MessageBox.Show("Введены не все \n\rзначения для 3-4 недели", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Lesson1 != null)
            {
                Employments.Remove(Lesson1.Teacher, Lesson1.Groups, Lesson1.Room, Time1);
            }

            if (Lesson1 == null)
            {
                Lesson1 = Shedule.GetLesson(Time1, cmbRooms1.Text);
            }

            if (Lesson1 != null)
            {
                Lesson1.Discipline = cmbDiscipline1.Text;

                Lesson1.Room = cmbRooms1.Text;

                Lesson1.Type = (LessonType)cmbTypeLesson1.SelectedValue;

                Lesson1.Teacher = cmbTeacher1.Text;

                Lesson1.Groups.Clear();
                foreach (ListViewItem Item in lvSelectGroup1.Items)
                {
                    Lesson1.Groups.Add(Item.Text);
                }

                Lesson1.Dates.Clear();
                foreach (ListViewItem Item in lvDates1.Items)
                {
                    Lesson1.Dates.Add(Convert.ToDateTime(Item.Text));
                }

                Employments.Add(Lesson1.Teacher, Lesson1.Groups, Lesson1.Room, Time1, ReasonEmployment.UnionLesson);
            }

            //-------------------------------------------
            if (Lesson2 != null)
            {
                Employments.Remove(Lesson2.Teacher, Lesson2.Groups, Lesson2.Room, Time2);
            }

            if (Lesson2 == null)
            {
                Lesson2 = Shedule.GetLesson(Time2, cmbRooms2.Text);
            }

            if (Lesson2 != null)
            {
                Lesson2.Discipline = cmbDiscipline2.Text;

                Lesson2.Room = cmbRooms2.Text;

                Lesson2.Type = (LessonType)cmbTypeLesson2.SelectedValue;

                Lesson2.Teacher = cmbTeacher2.Text;

                Lesson2.Groups.Clear();
                foreach (ListViewItem Item in lvSelectGroup2.Items)
                {
                    Lesson2.Groups.Add(Item.Text);
                }

                Lesson2.Dates.Clear();
                foreach (ListViewItem row in lvDates2.Items)
                {
                    Lesson2.Dates.Add(Convert.ToDateTime(row.Text));
                }

                Employments.Add(Lesson2.Teacher, Lesson2.Groups, Lesson2.Room, Time2, ReasonEmployment.UnionLesson);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;

            this.Close();
        }