private void btnGetAll_Click(object sender, EventArgs e)
 {
     if (Application.OpenForms[GlobalConstants.GetAllForm] != null)
     {
         _form = Application.OpenForms["getAllForm"];
         _form.Focus();
     }
     else
     {
         if (_todoService.Count() > 0)
         {
             if (Application.OpenForms[GlobalConstants.NewTodoForm] != null)
             {
                 Application.OpenForms[GlobalConstants.NewTodoForm].Close();
             }
             getAllForm form = new getAllForm
             {
                 MdiParent     = this,
                 StartPosition = FormStartPosition.CenterScreen
             };
             form.Show();
         }
         else
         {
             MessageBox.Show(GlobalConstants.EmptyList, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
             DialogResult result = MessageBox.Show(GlobalConstants.AddTodoQuestion, GlobalConstants.CaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
             if (result == DialogResult.Yes)
             {
                 if (Application.OpenForms[GlobalConstants.NewTodoForm] == null)
                 {
                     NewTodoForm newTodoForm = new NewTodoForm
                     {
                         MdiParent     = this,
                         StartPosition = FormStartPosition.CenterScreen
                     };
                     newTodoForm.Show();
                 }
                 else
                 {
                     Form form = Application.OpenForms[GlobalConstants.NewTodoForm];
                     form.Focus();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int result = 0;

            if (!GlobalMethods.TextBoxIsNullOrEmpty(this))
            {
                result = _todoService.Add(new TodoEntity
                {
                    Id               = Guid.NewGuid(),
                    Title            = txtTitle.Text,
                    ShortDescription = txtShort.Text,
                    Description      = txtDesc.Text,
                    ImportanceLevel  = (ImportanceLevel)cmbImportanceLevel.SelectedItem,
                    Status           = (Status)cmbStatus.SelectedItem
                });
            }

            if (result > 0)
            {
                MessageBox.Show(GlobalConstants.AddSuccess, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult dialogResult = MessageBox.Show(GlobalConstants.AddOperationAgain, GlobalConstants.CaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    GlobalMethods.Clear(this);
                }
                else
                {
                    Form getAllForm = new getAllForm
                    {
                        MdiParent     = Application.OpenForms[GlobalConstants.TodoAppForm],
                        StartPosition = FormStartPosition.CenterScreen
                    };
                    getAllForm.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show(GlobalConstants.AddError, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                GlobalMethods.Clear(this);
            }
        }