示例#1
0
        /// <summary>
        /// Load the table with all events data
        /// </summary>
        private void AddDataToTable()
        {
            IAgenda           agenda        = new CAgenda();
            DisplayEventsForm displayEvents = new DisplayEventsForm();
            DateTime          date          = DeleteDatePicker.Value;

            var availableEvents = agenda.GetEvents(date.Date, "all");

            if (availableEvents != null)
            {
                for (int i = 0; i < availableEvents.Count; i++)
                {
                    dataGridViewDelete.Rows.Add(
                        new object[]
                    {
                        availableEvents[i].Id,
                        availableEvents[i].Name,
                        displayEvents.ConvertDateFormat(availableEvents[i].Date.Value),
                        displayEvents.ConvertTimeFormat(availableEvents[i].Time.Value),
                        availableEvents[i].Description
                    }
                        );
                }
            }
        }
示例#2
0
        /// <summary>
        /// Display the events from the Database based on a Day/Week/All user choice
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DisplayButton_Click(object sender, EventArgs e)
        {
            IAgenda  agenda = new CAgenda();
            DateTime date   = dateTimePicker.Value;

            string intervalChoice  = GetUserChoice();
            var    availableEvents = agenda.GetEvents(date.Date, intervalChoice);

            ReloadWindow();

            if (availableEvents != null)
            {
                for (int i = 0; i < availableEvents.Count; i++)
                {
                    dataGridViewDisplay.Rows.Add(
                        new object[]
                    {
                        availableEvents[i].Id,
                        availableEvents[i].Name,
                        ConvertDateFormat(availableEvents[i].Date.Value),
                        ConvertTimeFormat(availableEvents[i].Time.Value),
                        availableEvents[i].Description
                    }
                        );
                }
            }
        }
示例#3
0
        /// <summary>
        /// Delete the selected event from the Database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            IAgenda       agenda = new CAgenda();
            DialogManager dialog = new DialogManager();

            if (selectedRowId == default)
            {
                dialog.ShowErrorWindow("No selected item to delete");
            }
            else
            {
                dialog.ShowSuccessWindow("Event successfully deleted");
            }

            agenda.RemoveEvent(selectedRowId);
            ReloadWindow();
        }
示例#4
0
        /// <summary>
        /// Modify a Event data on click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            DialogManager dialog = new DialogManager();
            IAgenda       agenda = new CAgenda();

            _event.name        = UpdEventNameTextBox.Text;
            _event.date        = UpdDatePicker.Value;
            _event.time        = UpdTimePicker.Value;
            _event.description = UpdDescriptionTextBox.Text;

            bool validate = agenda.EditEventDetails(_event);

            if (validate)
            {
                dialog.ShowSuccessWindow("Event successfully modified");
            }
            else
            {
                dialog.ShowErrorWindow("No selected item or invalid event data");
            }

            ReloadWindow();
        }
示例#5
0
        /// <summary>
        /// Will asign the data introduced by the user to the database handler method to save
        /// a new event
        /// </summary>
        private void SetNewEventDetails()
        {
            IAgenda       agenda = new CAgenda();
            DialogManager dialog = new DialogManager();

            _event.name        = EventNameTextBox.Text;
            _event.date        = DatePicker.Value;
            _event.time        = TimePicker.Value;
            _event.description = DescriptionTextBox.Text;

            bool validate = agenda.CreateNewEvent(_event);

            if (validate)
            {
                dialog.ShowSuccessWindow("Event successfully created");
            }
            else
            {
                dialog.ShowErrorWindow("Invalid provided event data");
            }

            ClearFields();
        }