Exemple #1
0
        /// <summary>
        /// Registers the given user in the system, if all fields are valid.
        /// </summary>
        /// <param name="sender">The object sender</param>
        /// <param name="e">The event args</param>
        private void registerCreateNewUserButton_Click(object sender, EventArgs e)
        {
            if (_isFirstnameOk && _isLastnameOk && _isPhoneOk && _isEmailOk && _isCprOk && _isAdressOk &&
                _isCityOk && _isZipOk && _isUsernameOk && _isPasswordOk && _isVerifyPasswordOk && _isSignatureOk)
            {
                bool UserCreated = DatabaseParser.AddUser(registerFirstnameBox.Text, registerLastnameBox.Text,
                                                          registerPhoneBox.Text, registerEmailBox.Text,
                                                          registerCprBox.Text, registerAdressBox.Text, registerZipBox.Text, registerCityBox.Text,
                                                          registerUsernameBox.Text, registerPasswordBox.Text, _uploader.SaveProfilePicture(ProfileImage, Properties.Settings.Default["PictureUpload"].ToString()),
                                                          _uploader.SavePicture(_signatureImage, Properties.Settings.Default["PictureUpload"].ToString()));

                if (UserCreated)
                {
                    CustomMsgBox.ShowOk("You have succesfully created a user", "Sucess", CustomMsgBoxIcon.Complete);
                    this.Dispose();
                    _loginForm.Show();
                }
                else
                {
                    CustomMsgBox.ShowOk("Failed to create new user, please try again later!", "Failed",
                                        CustomMsgBoxIcon.Error);
                }
            }
            else
            {
                foreach (TextboxBorderColor tb in this.Controls.OfType <TextboxBorderColor>())
                {
                    if (string.IsNullOrEmpty(tb.Text))
                    {
                        tb.BorderColor = Color.Crimson;
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Logs into the system if the username and password match.
        /// </summary>
        /// <param name="sender">The object sender</param>
        /// <param name="e">The event args</param>
        private void loginButton_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            if (UsernameBox.Text != "Username")
            {
                User user = DatabaseParser.GetUserByUsername(UsernameBox.Text);
                if (user == null || user.Password != PasswordBox.Text)
                {
                    CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error);

                    // resets password with false login information
                    if (PasswordBox.Text != "Password")
                    {
                        PasswordBox.Clear();
                    }
                    return;
                }

                Session.LoadUser(user);

                this.Hide();
                MainWindow main = new MainWindow();
                main.ShowDialog(this);
                Session.LogOut();
                // resets information after logout
                ResetInformation();
                Cursor = Cursors.Arrow;
            }
            else
            {
                CustomMsgBox.ShowOk("Wrong username or password", "Error", CustomMsgBoxIcon.Error);
            }
        }
Exemple #3
0
        /// <summary>
        /// Method used to add the selected period as an appointment to the database
        /// </summary>
        /// <param name="sender">The Object Sender</param>
        /// <param name="e">The EventArgs</param>
        private void AddAppointmentButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(LessonTypecomboBox.Text) && !String.IsNullOrEmpty(StartTimecomboBox.Text) && !String.IsNullOrEmpty(lessonsComboBox.Text))
            {
                TimeSpan startTime = TimeSpan.Parse(StartTimecomboBox.Text);
                DateTime dateToAdd = date.Date + startTime;

                bool appointmentAdded = DatabaseParser.AddAppointment(LessonTypecomboBox.Text, dateToAdd, (int)lessonsComboBox.SelectedItem,
                                                                      Session.LoggedInUser.Id.ToString());

                if (appointmentAdded)
                {
                    CustomMsgBox.ShowOk("Succes", "Appointment succesfully added", CustomMsgBoxIcon.Complete);

                    AppointmentStructure appointmentStructure =
                        new AppointmentStructure(-1, Session.LoggedInUser.Id,
                                                 dateToAdd, (int)lessonsComboBox.SelectedItem, LessonTypecomboBox.Text, false,
                                                 Session.LoggedInUser.Fullname);

                    _appointments.Add(new Appointment(appointmentStructure));
                    this.Dispose();
                }
                else
                {
                    CustomMsgBox.ShowOk("Failure", "Appointment failed to upload", CustomMsgBoxIcon.Error);
                }
            }
            else
            {
                CustomMsgBox.ShowOk("Failure", "Some fields need to be filled", CustomMsgBoxIcon.Warrning);
            }
        }
Exemple #4
0
 /// <summary>
 /// Checks if changes were made else show warning
 /// </summary>
 /// <param name="sender">The object sender</param>
 /// <param name="e">The EventArgs</param>
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (edited)
     {
         this.Hide();
     }
     else
     {
         CustomMsgBox.ShowOk("Please write your signature in the box", "Missing Signature",
                             CustomMsgBoxIcon.Error);
     }
 }
        /// <summary>
        /// Saves all the changes made
        /// </summary>
        /// <param name="sender">The object sender</param>
        /// <param name="e">The event args</param
        private void saveChangesButton_Click(object sender, EventArgs e)
        {
            if (!(usernameOk && passwordOk && verifyPasswordOk && firstnameOk && lastnameOk && phoneOk && emailOk && addressOk && zipOk && cityOk))
            {
                CustomMsgBox.ShowOk("Please fix the red boxes before saving", "Failed", CustomMsgBoxIcon.Warrning);
                return;
            }

            bool   updateSuccess;
            string picturePath   = uploader.SaveProfilePicture(ProfilePicture, Settings.Default["PictureUpload"].ToString());
            string signaturePath = uploader.SavePicture(_signatureImage, Settings.Default["PictureUpload"].ToString());

            if (picturePath == null)
            {
                picturePath = _user.PicturePath;
            }

            if (signaturePath == null)
            {
                signaturePath = _user.SignaturePath;
            }

            if (editPasswordBox.Text != editPasswordBox.defaultText)
            {
                updateSuccess = DatabaseParser.UpdateUser(_user.Cpr, firstnameBox.Text, lastnameBox.Text, phoneBox.Text, emailBox.Text, addressBox.Text,
                                                          zipBox.Text, cityBox.Text, usernameBox.Text, editPasswordBox.Text, picturePath, signaturePath, instructorCheckBox.Checked ? "true" : "false");
                _user.PicturePath   = picturePath;
                _user.SignaturePath = signaturePath;
            }
            else
            {
                updateSuccess = DatabaseParser.UpdateUser(_user.Cpr, firstnameBox.Text, lastnameBox.Text, phoneBox.Text, emailBox.Text, addressBox.Text,
                                                          zipBox.Text, cityBox.Text, usernameBox.Text, _user.Password, picturePath, signaturePath, instructorCheckBox.Checked ? "true" : "false");
                _user.PicturePath   = picturePath;
                _user.SignaturePath = signaturePath;
            }

            if (updateSuccess)
            {
                CustomMsgBox.ShowOk("You have succesfully updated the profile", "Success", CustomMsgBoxIcon.Complete);
                Session.LoggedInUser = DatabaseParser.GetUserByUsername(usernameBox.Text);
                this.Dispose();
            }
            else
            {
                CustomMsgBox.ShowOk("No connection could be made to the database, please try again later", "No Connection", CustomMsgBoxIcon.Error);
            }
        }
Exemple #6
0
        /// <summary>
        /// Method used when a user clicks on add appointment, makes sure that the selected perido is added to the database
        /// </summary>
        /// <param name="sender">The Object Sender</param>
        /// <param name="e">The EventArgs</param>
        private void AddAppointmentButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(lessonsComboBox.Text) && !String.IsNullOrWhiteSpace(StartTimecomboBox.Text))
            {
                bool result = AddLesson();

                if (result)
                {
                    CustomMsgBox.ShowOk("Successfully booked!", "Sucess", CustomMsgBoxIcon.Complete);
                    _appointment.AppointmentHighlight(ColorScheme.CalendarBooked);
                    this.Dispose();
                }
                else
                {
                    CustomMsgBox.ShowOk("Error connecting to database", "Failure", CustomMsgBoxIcon.Error);
                }
            }
            else
            {
                CustomMsgBox.ShowOk("Please select a timeperiod you wish to book your appointment", "Warning", CustomMsgBoxIcon.Warrning);
            }
        }