Пример #1
0
        private void AddEditNA_Load(object sender, EventArgs e)
        {
            var unitofwork = new UnitOfWork();
            AllEmployees =unitofwork.EmployeeRepository.Get(x => x.DateInactive == null).ToList();
            cbEmployees.DataSource = AllEmployees.ToList();
            cbEmployees.ValueMember="Id";
            cbEmployees.DisplayMember = "FullName";
            if(NAID!=null)
            {
                workingNA = unitofwork.EmployeeNARepository.Get(x => x.Id == NAID,includeProperties: "Employee").FirstOrDefault();
                EditedUser = workingNA.Employee;
                tbNotes.Text = workingNA.Notes;

            }
            if (EditedUser != null)
            {
                cbEmployees.SelectedValue = EditedUser.Id;
                cbEmployees.Enabled = false;

            }
        }
Пример #2
0
        private EmployeeNA GetFields(EmployeeNA ena)
        {
            var unitOfWork = new UnitOfWork();
            ena.Employee = unitOfWork.EmployeeRepository.GetByID(cbEmployees.SelectedValue);
            ena.StartDate = dtpStartDate.Value;
            ena.EndDate = dtpEndDate.Value;
            if(cbStartTime.Checked)
            {
                ena.StartDate = ena.StartDate.Date.AddHours(dtpStartTime.Value.Hour).AddMinutes(dtpStartTime.Value.Minute);
            }
            else
            {
                ena.StartDate = ena.StartDate.Date;
            }
            if (cbEndTime.Checked)
            {
                ena.EndDate = ena.EndDate.Date.AddHours(dtpEndTime.Value.Hour).AddMinutes(dtpEndTime.Value.Minute);
            }
            else
            {
                ena.EndDate = ena.EndDate.Date.AddDays(1).AddTicks(-1);
            }
            ena.SubmittedBy= unitOfWork.EmployeeRepository.GetByID(User.Id);

            ena.SubmittedDate = DateTime.Today;
            ena.Notes = tbNotes.Text;

            return ena;
        }