Beispiel #1
0
        private void CreateProjectButton_Click(object sender, RoutedEventArgs e)
        {
            string   ProjectNameString        = ProjectNameTextBox.Text;
            DateTime DueDate                  = DueDatePicker.SelectedDate.Value;
            DateTime StartDate                = StartDatePicker.SelectedDate.Value;
            string   ProjectDescriptionString = ProjectDescriptionBox.Text;
            bool     Completed                = CompletedCheckBox.IsChecked.Value;

            Project project = new Project()
            {
                ProjectComplete    = Completed,
                ProjectDescription = ProjectDescriptionString,
                ProjectDueDate     = DueDate,
                ProjectStartDate   = StartDate,
                ProjectName        = ProjectNameString,
                ProjectType        = 0,
                UserID             = LoggedInUser.UserID
            };

            Projects.Add(project);

            _db.Projects.Add(project);
            _db.SaveChanges();

            Dialog dialog = new Dialog("Project Has Been Added", "okay", "", false);

            dialog.ShowDialog();

            ProjectNameTextBox.Text     = "";
            DueDatePicker.Text          = "";
            StartDatePicker.Text        = "";
            ProjectDescriptionBox.Text  = "";
            CompletedCheckBox.IsChecked = false;
        }
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            string UserName        = UserEmail.Text;
            string UserFirstname   = UserFirstName.Text;
            string Usersurname     = UserSurname.Text;
            string ConfirmPassword = "";

            int NewUserID = 0;

            if (Users.Count > 0)
            {
                NewUserID = Users[Users.Count - 1].UserID + 1;
            }
            else
            {
                NewUserID = 1;
            }

            if (UserPassword.Password.Equals(UserConfirmPassword.Password))
            {
                ConfirmPassword = UserPassword.Password;
            }
            else
            {
                //Message messageBox = new Message(this, "Passwords Do Not Match", "Okay" , "", false);
                //messageBox.ShowDialog();
            }

            if (UserName != "" && UserFirstname != "" && Usersurname != "" && ConfirmPassword != "" && NewUserID != 0)
            {
                if (Users.Where(x => x.Username.Equals(UserName)).Count() == 0)
                {
                    UserInfo userInfo = new UserInfo()
                    {
                        FirstName = UserFirstname,
                        LastName  = Usersurname,
                        Username  = UserName,
                        Password  = ConfirmPassword,
                        UserID    = NewUserID,
                        UserType  = 0
                    };

                    _db.Users.Add(userInfo);
                    _db.SaveChanges();

                    MainWindow main = new MainWindow();
                    main.Show();
                    this.Close();
                }
            }
        }