private void btnSave_Click(object sender, EventArgs e) { var result = _todoService.Add(new TodoEntity { Id = Guid.NewGuid(), Title = txtBoxTitle.Text, ShortDescription = txtBoxShortDesc.Text, Description = txtBoxDesc.Text, Status = (Status)cmbBoxStatus.SelectedItem, ImportanceLevel = Convert.ToInt32(txtBoxImportanceLevel.Text) }); if (result > 0) { MessageBox.Show(GlobalConstants.AddSuccess, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult dialogResult = MessageBox.Show( GlobalConstants.AddOperationContinue, GlobalConstants.CaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { ClearTextBoxesValue(); } else { Form getAllForm = Application.OpenForms["GetAllForm"]; if (getAllForm == null) { getAllForm = new GetAllForm(); getAllForm.MdiParent = Application.OpenForms["ToDoListForm"]; getAllForm.StartPosition = FormStartPosition.CenterScreen; getAllForm.Show(); this.Close(); } else { GroupBox listGroupBox = (GroupBox)getAllForm.Controls["grpList"]; DataGridView dataGrid = (DataGridView)listGroupBox.Controls["dataGrdGetAll"]; dataGrid.DataSource = null; dataGrid.DataSource = _todoService.GetAll(); dataGrid.Columns["Id"].Visible = false; this.Close(); } } } else { MessageBox.Show(GlobalConstants.AddError, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGetAll_Click(object sender, EventArgs e) { if (Application.OpenForms["GetAllForm"] != null) { _form = Application.OpenForms["GetAllForm"]; _form.Focus(); } else { if (_todoService.Count() > 0) { GetAllForm getAllForm = new GetAllForm(); getAllForm.MdiParent = Application.OpenForms["ToDoListForm"]; getAllForm.StartPosition = FormStartPosition.CenterScreen; getAllForm.Show(); } else { MessageBox.Show(GlobalConstants.EmptyList, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }