Ejemplo n.º 1
0
 private void ClearTextFields()
 {
     NameTextBox.Clear();
     MailTextBox.Clear();
     MailUserLabel.Content  = $"Mail: ";
     MailAdminLabel.Content = $"Mail: ";
 }
Ejemplo n.º 2
0
        private void LogginButton_Click(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Text = "";

            string UserMail     = MailTextBox.Text;
            string userPassword = PasswordBox.Password;


            if (userPassword.Length == 0)
            {
                ErrorMessage.Text = "Nebylo zadáno heslo";
                PasswordBox.Focus();
                return;
            }

            if (UserMail.Length == 0)
            {
                ErrorMessage.Text = "Nebyl zadán přihlašovací email";
                MailTextBox.Focus();
                return;
            }
            if (AutentizationVerify(UserMail, userPassword))
            {
                LoggedUserID.LoggedUserMail = UserMail; //  Který uživatel je přihlášený
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                LoggedUserID.mainWindow = mainWindow;
                Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Click event, Send a mail on the contact section.
        /// </summary>
        private void ContactSendButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(NameTextBox.Text) || String.IsNullOrEmpty(MailTextBox.Text) ||
                String.IsNullOrEmpty(SubjectTextBox.Text) || String.IsNullOrEmpty(ContentTextBox.Text))
            {
                Alert.AlertCreation("Fill Every Field!", AlertType.error);
                return;
            }
            else
            {
                string emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\." +
                                    "[a-zA-Z0-9_+&*-]+)*@" +
                                    "(?:[a-zA-Z0-9-]+\\.)+[a-z" +
                                    "A-Z]{2,7}$";

                bool isEmail = Regex.IsMatch(MailTextBox.Text, emailRegex);
                if (isEmail)
                {
                    bool result = informationParser.SendMail(mailSender, log, SubjectTextBox.Text,
                                                             "Mail sender Name: " + NameTextBox.Text + "<br>" + "Mail Sender Address: " + MailTextBox.Text + "<br>" + ContentTextBox.Text, null);
                    if (result)
                    {
                        Alert.AlertCreation("Mail has been sent.", AlertType.success);
                        NameTextBox.Clear();
                        MailTextBox.Clear();
                        SubjectTextBox.Clear();
                        ContentTextBox.Clear();
                    }
                    else
                    {
                        Alert.AlertCreation("Mail Problem. (Check SMTP)", AlertType.error);
                        return;
                    }
                }
                else
                {
                    Alert.AlertCreation("Mail Address Format Problem.", AlertType.error);
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            resetProgress.IsActive = true;
            try
            {
                string tenDangNhap = TenDangNhapTextBox.Text.Trim();
                if (tenDangNhap.Length < 1)
                {
                    TenDangNhapTextBox.Focus(FocusState.Keyboard);
                    textBlockError.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                    throw new Exception("Tên đăng nhập quá ngắn.Vui lòng kiểm tra lại.");
                }
                string email   = MailTextBox.Text.Trim();
                bool   isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
                if (email.Length < 1 || !isEmail)
                {
                    MailTextBox.Focus(FocusState.Keyboard);
                    textBlockError.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                    throw new Exception("Định dạng email không hợp lệ.Vui lòng kiểm tra lại.");
                }
                var result = await TaiKhoanNguoiDung.resetMatKhau(tenDangNhap, email);

                if (result)
                {
                    textBlockError.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                    throw new Exception("Thông tin mật khẩu mới đã được cập đặt lại và gửi đến email đăng ký. Vui lòng kiểm tra email để nhận mật khẩu đăng nhập mới.");
                }
                else
                {
                    textBlockError.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
                    throw new Exception("Thông tin tên đăng nhập và email đăng ký không hợp lệ. Vui lòng kiểm tra lại.");
                }
            }
            catch (Exception ex)
            {
                textBlockError.Text = ex.Message;
                textBlockError.UpdateLayout();
            }
            resetProgress.IsActive = false;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// テキストボックスのキーダウンイベント
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Control_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Enter)
         {
             if (sender.Equals(SenderNameTextBox))
             {
                 SenderAddressTextBox.Focus();
             }
             if (sender.Equals(SenderAddressTextBox))
             {
                 ReceiverNameTextBox.Focus();
             }
             if (sender.Equals(ReceiverNameTextBox))
             {
                 ReceiverAddressTextBox.Focus();
             }
             if (sender.Equals(ReceiverAddressTextBox))
             {
                 MailTitleTextBox.Focus();
             }
             if (sender.Equals(MailTitleTextBox))
             {
                 MailAttach1TextBox.Focus();
             }
             if (sender.Equals(MailAttach1TextBox))
             {
                 MailAttach2TextBox.Focus();
             }
             if (sender.Equals(MailAttach2TextBox))
             {
                 MailAttach3TextBox.Focus();
             }
             if (sender.Equals(MailAttach3TextBox))
             {
                 MailAttach4TextBox.Focus();
             }
             if (sender.Equals(MailAttach4TextBox))
             {
                 MailAttach5TextBox.Focus();
             }
             if (sender.Equals(MailAttach5TextBox))
             {
                 MailTextBox.Focus();
             }
             if (sender.Equals(MailHostTextBox))
             {
                 PortNoTextBox.Focus();
             }
             if (sender.Equals(PortNoTextBox))
             {
                 UserNameTextBox.Focus();
             }
             if (sender.Equals(UserNameTextBox))
             {
                 PasswordTextBox.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Ejemplo n.º 6
0
        private void RegistrationButton_Click(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Text = ""; // vyynulování Error message pokud opravim data a chci se registrovat
            OKMessage.Text    = "";

            string email      = MailTextBox.Text;
            string name       = JmenoTextBox.Text;
            string surname    = PrijmeniTextBox.Text;
            string tel_number = TelTextBox.Text;

            string password       = heslo1PasswordBox.Password;
            string password_again = heslo2PasswordBox.Password;


            if (name.Length < 1)
            {
                ErrorMessage.Text = "Jméno uživatele není zadáno";
                JmenoTextBox.Focus();
                return;
            }

            if (surname.Length < 1)
            {
                ErrorMessage.Text = "Příjmení uživatele není zadáno";
                PrijmeniTextBox.Focus();
                return;
            }

            if (email.Length < 1)
            {
                ErrorMessage.Text = "Emailová adresa není zadána";
                MailTextBox.Focus();
                return;
            }
            if (!Regex.IsMatch(email, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                ErrorMessage.Text = "Nebyl zadán platný email";
                MailTextBox.Focus();
                return;
            }

            if (tel_number.Length < 1)
            {
                ErrorMessage.Text = "Telefonní číslo uživatele není zadáno";
                TelTextBox.Focus();
                return;
            }

            if (password.Length < 1)
            {
                ErrorMessage.Text = "Nebylo zadáno heslo";
                heslo1PasswordBox.Focus();
                return;
            }

            if (password_again.Length < 1)
            {
                ErrorMessage.Text = "Nutné zadat heslo 2x pro ověření";
                heslo2PasswordBox.Focus();
                return;
            }

            if (password.Length < 6)
            {
                ErrorMessage.Text = "Heslo musí obsahovat alespoň 6 znaků";
                heslo1PasswordBox.Focus();
                return;
            }
            if (password != password_again)
            {
                ErrorMessage.Text = "Zadaná hesla nejsou stejná";
                heslo2PasswordBox.Focus();
                return;
            }

            if (RegisterNewuser(email, name, surname, tel_number, password))
            {
                OKMessage.Text = "Registrace proběhla úspěšně";
                return;
            }
            //}
        }
Ejemplo n.º 7
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserPassword.Password == UserPasswordEnsure.Password)
            {
                user.Password = UserPassword.Password;
                if ((UserType)UserTypeComboBox.SelectedItem == BE.UserType.Host)
                {
                    try
                    {
                        if (myIBL.AddHostCanMoveOn(user))
                        {
                            Window NewHostRegWindow = new HostRegWindow(user);
                            NewHostRegWindow.Show();
                            this.Close();
                        }
                    }
                    catch (UserAlreadyExistsException)
                    {
                        UserName.Focus();
                        MessageBox.Show("The UserName you entered is alredy used.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (NotValidEmailAddressException)
                    {
                        MailTextBox.Focus();
                        MessageBox.Show("The MailAddress you entered is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There was a problem!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if ((UserType)UserTypeComboBox.SelectedItem == BE.UserType.Guest)
                {
                    try
                    {
                        myIBL.AddGuest(user);
                        Window loginWindow = new LoginWindow();
                        loginWindow.Show();
                        this.Close();
                    }
                    catch (UserAlreadyExistsException)
                    {
                        UserName.Focus();
                        MessageBox.Show("The UserName you entered is alredy used.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (NotValidEmailAddressException)
                    {
                        MailTextBox.Focus();
                        MessageBox.Show("The MailAddress you entered is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There was a problem!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            else
            {
                UserPasswordEnsure.Focus();
                MessageBox.Show("Check Your Password again!!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 8
0
        //enters in the details of the textboxes as a new employee or replacing a deleted employee
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ForeTextBox.Text))//Employee won't be entered if Forename text box is empty
            {
                MessageBox.Show("You have not entered the forename of this new employee");
            }
            else
            {
                if (string.IsNullOrEmpty(SurTextBox.Text))//Employee won't be entered if Surname text box is empty
                {
                    MessageBox.Show("You have not entered the surname of this new employee");
                }
                else
                {
                    if (string.IsNullOrEmpty(MailTextBox.Text))//Employee won't be entered if Email text box is empty
                    {
                        MessageBox.Show("You have not entered the email of this new employee");
                    }
                    else
                    {
                        if (!MailTextBox.Text.Contains("@"))//Employee won't be entered if Email text box does not contain @
                        {
                            MessageBox.Show("You have not entered the email of this new employee correctly");
                        }
                        else
                        {
                            connection = new SqlConnection(connectionString);


                            String query = "declare @a int; " +
                                           "declare @b int; " +
                                           "declare @c int; " +
                                           "if ((select count(*) from Employee) > 0) Begin set @c = (select max(EmployeeID) from Employee) end else Begin set @c = 0 end " + // if there are no employees in the table c = 0 but if there's at least 1 employee, c = the highest employee ID in the table
                                           "set @a = (select count(*)  from Employee where Forename is null and Surname is null and Email is null) " +                       //a = the number of jobs with no details except the EmployeeID
                                           "if @a > 0 " +
                                           "Begin " +
                                           "set @b = (select min(EmployeeID) from Employee where Forename is null and Surname is null and Email is null) " +                                       //b = the ID number of the employee with the lowest ID number with no other details
                                           "update Employee set Forename = (@Forename), Surname = @Surname, Email = @Email, JobID = @JobID, [Works Under] = @WorksUnder where EmployeeID = @b  " + //updates the details of the Employee with the EmployeeID of b with the details from the text boxes
                                           "end " +
                                           "else " +
                                           "begin " +
                                           "DBCC CHECKIDENT(Employee, RESEED, @c) " +
                                           "Insert into [Employee](Forename, Surname, Email, JobID, [Works Under]) Values (@Forename, @Surname, @Email, @JobID, @WorksUnder); " + //inserts the details from the text boxes at the end of the table
                                           "end";

                            using (connection = new SqlConnection(connectionString))
                                using (SqlCommand command = new SqlCommand(query, connection))
                                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                                    {
                                        connection.Open();

                                        command.Parameters.AddWithValue("@Forename", ForeTextBox.Text);
                                        command.Parameters.AddWithValue("@Surname", SurTextBox.Text);
                                        command.Parameters.AddWithValue("@Email", MailTextBox.Text);
                                        if (string.IsNullOrEmpty(JobIDBox.Text))//allows the employee to be entered if there are no jobs since there is the chance that the user will chose to enter in the employees first
                                        {
                                            command.Parameters.AddWithValue("@JobID", DBNull.Value);
                                        }
                                        else
                                        {
                                            command.Parameters.AddWithValue("@JobID", JobIDBox.Text);
                                        }

                                        if (string.IsNullOrEmpty(WUIDBox.Text))//allows the employee to be entered if there are no other employees since there will be no other employees when the database is cleared
                                        {
                                            command.Parameters.AddWithValue("@WorksUnder", DBNull.Value);
                                        }
                                        else
                                        {
                                            command.Parameters.AddWithValue("@WorksUnder", WUIDBox.Text);
                                        }

                                        try
                                        {
                                            command.ExecuteReader();
                                            MessageBox.Show("Employee Entered");
                                        }
                                        catch (System.Data.SqlClient.SqlException ex)
                                        {
                                            MessageBox.Show(ex.Message);
                                        }
                                    }
                            ForeTextBox.Clear();
                            SurTextBox.Clear();
                            MailTextBox.Clear();
                            showchngJobName();
                            showID();
                            showWID();
                        }
                    }
                }
            }
        }