예제 #1
0
        private void BackCase_Click(object sender, EventArgs e)
        {
            Hide();
            CaseEditor caseEditor = new CaseEditor();

            caseEditor.ShowDialog();
        }
예제 #2
0
        private void CaseAddBtn_Click(object sender, EventArgs e)
        {
            var title       = CaseTitleTxt.Text;
            var description = CaseDescriptionTxt.Text;
            var startDate   = CaseStartPicker.Value;

            if (String.IsNullOrWhiteSpace(title))
            {
                MessageBox.Show("Title required", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (String.IsNullOrWhiteSpace(description))
            {
                MessageBox.Show("Description required", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var @case = new Case
            {
                Title       = title,
                Description = description,
                StartDate   = startDate
            };

            _repository.Of <Case>().Insert(@case);
            _repository.SaveChanges();
            MessageBox.Show("Case successfull add!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Hide();
            CaseEditor caseEditor = new CaseEditor();

            caseEditor.ShowDialog();
        }
예제 #3
0
        private void CaseEditBtn_Click(object sender, EventArgs e)
        {
            int Id = int.Parse(caseIdTxt.Text);

            var @case = _repository.Of <Case>()
                        .Search(x => x.Id == Id).FirstOrDefault();

            if (@case != null)
            {
                @case.Title       = CaseTitleTxt.Text;
                @case.Description = CaseDescriptionTxt.Text;
                @case.StartDate   = CaseStartPicker.Value;

                _repository.SaveChanges();

                MessageBox.Show("The case was successfully edited.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Hide();
                CaseEditor caseEditor = new CaseEditor();
                caseEditor.ShowDialog();
            }
            else
            {
                MessageBox.Show("Could not edit this case.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
        private void CaseDelete_Click(object sender, EventArgs e)
        {
            int Id    = int.Parse(caseIdTxt.Text);
            var @case = _repository.Of <Case>().GetById(Id);

            var lawyers = _repository.Of <Lawyer>()
                          .Search(x => x.Cases.Any(y => y.Id == Id))
                          .Count();

            if (lawyers > 0)
            {
                MessageBox.Show("Case busy", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            _repository.Of <Case>().Delete(@case);
            _repository.SaveChanges();

            MessageBox.Show("The case was successfully deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Hide();
            CaseEditor caseEditor = new CaseEditor();

            caseEditor.ShowDialog();
        }