Exemple #1
0
 private void init()
 {
     for (int i = 0; i < signs.Length; i++)
     {
         SaveLoad.AppendData(new UserData(signs[i], id[i].ToString(), "", "", domains[i]));
     }
 }
Exemple #2
0
        /// <summary>
        /// Changes selected event's status to "Nekad"
        /// </summary>
        private void Disapprove_event_Click(object sender, EventArgs e)
        {
            EventData selectedEntry = SaveLoad.events.eventsData[EventsList_events.SelectedItems[0].Index];

            selectedEntry.Status = "Nekad";
            SaveLoad.AppendData(selectedEntry);

            RefreshEvents();
            calForm.RefreshCal(null);
        }
        /// <summary>
        /// Add button event
        /// Tries to create a new event from inputted data and writes it to the save file
        /// </summary>
        private void Add_AddEvent_Click(object sender, EventArgs e)
        {
            string    sign           = SignInput_AddEvent.Text.Split(',')[0];
            DateTime  dateFrom       = DateFromInput_AddEvent.Value.Date;
            DateTime  dateTo         = MultipleDays_AddEvent.Checked ? DateToInput_AddEvent.Value.Date : DateFromInput_AddEvent.Value.Date;
            PartOfDay partOfDay      = DayPart_amfm_AddEvent.Checked ? PartOfDay.Heldag : DayPart_am_AddEvent.Checked ? PartOfDay.Förmiddag : PartOfDay.Eftermiddag;
            int       eventTypeIndex = EventTypeInput_AddEvent.SelectedIndex;
            string    additionalInfo = InfoInput_AddEvent.Text;

            if (ValidateAddEvent(sign, dateFrom, dateTo, eventTypeIndex))
            {
                EventType eventType = eventTypes[eventTypeIndex];
                EventData eventData = new EventData(sign, dateFrom, dateTo, partOfDay, eventType, additionalInfo);
                SaveLoad.AppendData(eventData);

                UsersData users = SaveLoad.users;
                UserData  user  = users.FindUser(sign);

                if (user != null)
                {
                    string[] mailAddresses = (user.Domain == "Bro") ? eventType.ConfirmEmails_Bro :
                                             (user.Domain == "Industri") ? eventType.ConfirmEmails_Industri :
                                             (user.Domain == "Koordination") ? eventType.ConfirmEmails_Koord : null;

                    MessageBox.Show($"Händelse tillagd!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

#if false
                    if (mailAddresses != null)
                    {
                        MailHelper.SendMail(mailAddresses, eventData);
                    }
#endif

                    ClearFields();
                }
            }

            calendarForm.RefreshCal(null);
        }
        /// <summary>
        /// Tries to create a new user from inputted data and writes it to the save file
        /// </summary>
        private void Add_AddUser_Click(object sender, System.EventArgs e)
        {
            string sign       = SignInput_AddUser.Text;
            string employeeNr = UserNrInput_AddUser.Text;
            string firstName  = FirstNameInput_AddUser.Text;
            string lastName   = LastNameInput_AddUser.Text;
            string domain     = DomainInput_AddUser.Text;

            if (ValidateAddUser(sign, employeeNr, domain))
            {
                SaveLoad.AppendData(new UserData(sign, employeeNr, firstName, lastName, domain));
                MessageBox.Show($"Användare tillagd!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearFields();

                adminForm.RefreshUsers();
                adminForm.calForm.AddUsers();
            }
            else
            {
                MessageBox.Show($"Fyll i alla fält", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }