private void CreateIssueButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TitleBox.Text))
            {
                MessageBox.Show("No issue title provided", "Attention", MessageBoxButtons.OK);
                return;
            }

            if (string.IsNullOrWhiteSpace(DiscovererBox.Text))
            {
                MessageBox.Show("No issue discoverer provided", "Attention", MessageBoxButtons.OK);
                return;
            }

            if (string.IsNullOrWhiteSpace(ComponentBox.Text))
            {
                MessageBox.Show("No issue component provided", "Attention", MessageBoxButtons.OK);
                return;
            }

            if (string.IsNullOrWhiteSpace(StatusBox.Text))
            {
                MessageBox.Show("No issue status provided", "Attention", MessageBoxButtons.OK);
                return;
            }

            Issue newIssue = new Issue();

            newIssue.ID                 = Int32.Parse(IssueIDBox.Text);
            newIssue.title              = TitleBox.Text;
            newIssue.projectId          = selectedProject;
            newIssue.discoveryDate      = dateTimePicker.Value;
            newIssue.discoverer         = DiscovererBox.Text;
            newIssue.initialDescription = DescriptionBox.Text;
            newIssue.component          = ComponentBox.Text;

            FakeIssueStatusRepository formStatusRepo = new FakeIssueStatusRepository();

            foreach (IssueStatus s in formStatusRepo.GetAll())
            {
                if (s.Value == StatusBox.Text)
                {
                    newIssue.status = s.Id;
                }
            }

            foreach (Issue i in formIssueRepo.GetAll(selectedProject))
            {
                if (i.title == newIssue.title)
                {
                    MessageBox.Show("Duplicate issue names not allowed", "Attention", MessageBoxButtons.OK);
                    return;
                }
            }

            formIssueRepo.Add(newIssue);
            Dispose();
        }
Ejemplo n.º 2
0
        private void crtIssue_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.discoverers.Text))
            {
                MessageBox.Show("A Discoverer must be selected.", "Error!");
            }
            else if (string.IsNullOrEmpty(this.statuses.Text))
            {
                MessageBox.Show("A Status has to  be assigned.", "Error!");
            }
            else
            {
                Issue newIssue = new Issue();
                FakeIssueStatusRepository iss     = new FakeIssueStatusRepository();
                FakeIssueRepository       new_Iss = new FakeIssueRepository();

                newIssue.id                 = Int32.Parse(this.Iss_Id.Text);
                newIssue.project_id         = currentProjectId;
                newIssue.Discoverer         = this.discoverers.Text;
                newIssue.Component          = this.comp.Text;
                newIssue.initialDescription = this.initDesc.Text;
                newIssue.IssueStatusid      = iss.GetIdByStatus(this.statuses.Text);
                newIssue.DiscoveryDate      = DateTime.ParseExact(this.disc_dateTime.Text, "hh:mm:ss tt d MMM yyyy", null);
                newIssue.Title              = this.titleBox.Text.Trim();

                string res = new_Iss.Add(newIssue);

                if (string.IsNullOrEmpty(res) == true)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(res, "Error !");

                    //this.DialogResult = DialogResult.Cancel;
                    //this.DialogResult = DialogResult.Abort;
                    //this.Close();
                }
            }
        }