private void BtnAdd_Click(object sender, EventArgs e)
        {
            var info = GetCandidateInfo();

            _candidateRepository.Create(info);

            SharedViewLogic.LoadCandidatesTree(_treeView, _candidateRepository);

            var selectedNode = GetOrAddParentNode(info);

            SharedViewLogic.LoadCandidatesGrid(_dgvCandidates, selectedNode.Nodes);

            Close();
        }
Exemple #2
0
        private void BtnGenerate_Click(object sender, EventArgs e)
        {
            var info = _candidateRepository.Get(_info.FirstName, _info.LastName);

            if (info == null)
            {
                Helper.Logger.Error($"Podaci o kandidatu: {_info.FirstName} {_info.LastName} ne mogu biti nadjeni");
                MessageBox.Show($"Podaci o kandidatu: {_info.FirstName} {_info.LastName} ne mogu biti nadjeni");
                Close();

                return;
            }

            var exam = new ExamInfo
            {
                Id       = Guid.NewGuid().ToString("N"),
                Category = txtCategory.Text.Trim(),
                TakenOn  = dtpTakenOn.Value,
                IncludesTrafficRegulationsTest = chxIncludesTrafficRegulationTest.Checked,
                IncludesFirstAidTest           = chxIncludesFirstAidTest.Checked,
                IncludesDrivingTest            = chxIncludesDrivingTest.Checked,
                Day        = cbxExamDay.SelectedItem.ToString(),
                Location   = txtLocation.Text.Trim(),
                Instructor = _instructorRepository.Get(cbxInstructors.SelectedItem.ToString())
            };

            info.Exams.Add(exam);

            Helper.CreateExamForm(Helper.GetPdfTemplateLocation(), _info, exam);

            _candidateRepository.Update(info);


            SharedViewLogic.LoadCandidatesTree(_treeCandidates, _candidateRepository);

            var selectedNode = _treeCandidates.Nodes.Find(info.LastName.First().ToString(), false).FirstOrDefault();

            SharedViewLogic.LoadCandidatesGrid(_dgvCandidates, selectedNode?.Nodes ?? (IEnumerable)Enumerable.Empty <TreeNode>());
            SharedViewLogic.LoadExamHistory(info.Exams ?? Enumerable.Empty <ExamInfo>(), _dgvExamHistory);

            Close();
        }