예제 #1
0
파일: homeForm.cs 프로젝트: logoffro1/ROSA
        private const int nrOfPictures = 5; //the number of Help pictures
        public homeForm(Employee employee)
        {
            InitializeComponent();

            Employee_Service es = new Employee_Service();

            this.employee = employee;
            this.employee.personalNotes = es.GetNotes(employee);
        }
        //When the user presses OK, modify the employee
        public override void OnClickOK(object sender, EventArgs e)
        {
            //Check that the user really wants to edit
            CP_Popup_Sure popup = new CP_Popup_Sure();

            popup.SetAsEdit(CP_PopopEditEmployee_txtFirstName.Text);
            popup.ShowDialog();

            if (!(popup.DialogResult == DialogResult.OK))
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }

            //Edit the employee. Use the values from the input boxes
            Employee_Service employeeService = new Employee_Service();

            string       firstName  = CP_PopopEditEmployee_txtFirstName.Text;
            string       lastName   = CP_PopupEditEmployee_txtLastName.Text;
            DateTime     birthDate  = CP_PopopEditEmployee_dtpBirthdate.Value;
            DateTime     employment = CP_PopopEditEmployee_dtpEmployment.Value;
            Gender       gender;
            string       password = CP_PopopEditEmployee_txtPassword.Text;
            EmployeeType employeeType;

            if (CP_PopopEditEmployee_rbtnMale.Checked)
            {
                gender = Gender.Male;
            }
            else
            {
                gender = Gender.Female;
            }

            if (CP_PopupEditEmployee_rbtnWaiter.Checked)
            {
                employeeType = EmployeeType.Waiter;
            }
            else if (CP_PopupEditEmployee_rbtnOwner.Checked)
            {
                employeeType = EmployeeType.Owner;
            }
            else if (CP_PopupEditEmployee_rbtnBartender.Checked)
            {
                employeeType = EmployeeType.Bartender;
            }
            else
            {
                employeeType = EmployeeType.Chef;
            }

            employeeService.ModifyEmployee(new Employee(id, firstName, lastName, birthDate, employment, gender, password, employeeType));
        }
예제 #3
0
        private void btnEditAccount_Click(object sender, EventArgs e)
        {
            Employee_Service employeeService = new Employee_Service();

            // check if textboxes are empty
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                txtUsername.Text = employeeToEdit.username;
            }
            if (string.IsNullOrEmpty(txtFirstNName.Text))
            {
                txtFirstNName.Text = employeeToEdit.firstName;
            }
            if (string.IsNullOrEmpty(txtLastName.Text))
            {
                txtLastName.Text = employeeToEdit.lastName;
            }
            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                txtPassword.Text = employeeToEdit.password;
            }

            Roles newRole;//assign the new role

            if (btnManager.Checked)
            {
                newRole = Roles.Manager;
            }
            else if (btnWaiter.Checked)
            {
                newRole = Roles.Waiter;
            }
            else if (btnChef.Checked)
            {
                newRole = Roles.Chef;
            }
            else
            {
                newRole = Roles.Bartender;
            }

            Employee newEmployee = new Employee() //create new employee
            {
                firstName = txtFirstNName.Text,
                lastName  = txtLastName.Text,
                username  = txtUsername.Text,
                password  = txtPassword.Text,
                role      = newRole
            };

            employeeService.EditAccount(employeeToEdit, newEmployee); //eddit the account
            MessageBox.Show("Account eddited succesfully!", "Edited", MessageBoxButtons.OK);
        }
예제 #4
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            Employee_Service employeeService = new Employee_Service();
            DialogResult     results         = MessageBox.Show($"Are you sure you want to remove user {employee.username}?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (results == DialogResult.Yes)
            {
                employeeService.RemoveAccount(employee);
                MessageBox.Show($"User {employee.username} removed!", "Remove", MessageBoxButtons.OK);
                managementForm.LoadEmployees();
            }
        }
        public override void OnClickOK(object sender, EventArgs e)
        {
            Employee_Service employeeService = new Employee_Service();

            //Store the values of all of the inputs
            string       firstName  = CP_PopopNewEmployee_txtFirstName.Text;
            string       lastName   = CP_PopupNewEmployee_txtLastName.Text;
            DateTime     birthDate  = CP_PopopNewEmployee_dtpBirthdate.Value;
            DateTime     employment = CP_PopopNewEmployee_dtpEmployment.Value;
            Gender       gender;
            string       password = CP_PopopNewEmployee_txtPassword.Text;
            EmployeeType employeeType;

            if (CP_PopopNewEmployee_rbtnMale.Checked)
            {
                gender = Gender.Male;
            }
            else
            {
                gender = Gender.Female;
            }

            if (CP_PopupNewEmployee_rbtnWaiter.Checked)
            {
                employeeType = EmployeeType.Waiter;
            }
            else if (CP_PopupNewEmployee_rbtnOwner.Checked)
            {
                employeeType = EmployeeType.Owner;
            }
            else if (CP_PopupNewEmployee_rbtnBartender.Checked)
            {
                employeeType = EmployeeType.Bartender;
            }
            else
            {
                employeeType = EmployeeType.Chef;
            }

            //Add a new employee to the system
            try
            {
                employeeService.AddEmployee(new Employee(firstName, lastName, birthDate, employment, gender, password, employeeType));
            }
            catch (Exception ex)
            {
                ErrorHandler.Instance.HandleError("Nieuwe medewerker kon niet toegevoegd worden!", "Medewerker niet toegevoegd", ex);

                //Tell the ControlPanel form that the action didn't succeed
                DialogResult = DialogResult.Cancel;
            }
        }
예제 #6
0
        private void CheckCredentials() //validate the credentials
        {
            Employee_Service employeeService = new Employee_Service();

            if (txtUsername.Text == string.Empty || txtPassword.Text == string.Empty)
            {
                //if the textboxes are empty, give error message
                lblError.Show();
                lblError.Text = "Username and Password required!";
            }
            else //if they are not empty, read the employees from the database and compare them with the input from the user
            {
                lblError.Hide();
                //return from the database only the employee that matches those credentials
                Employee employee = employeeService.GetAccount(txtUsername.Text, txtPassword.Text);

                if (employee == null)
                {
                    //if the employee doesn't exist, give error message
                    lblError.Show();
                    lblError.Text = "Username or Password incorrect!";
                }
                else
                {
                    //if the employee exists, login the user and open the correct form
                    switch (employee.role)
                    {
                    case Roles.Waiter:
                        new SwitchForms(employee, this, new tableViewForm(employee));
                        break;

                    case Roles.Bartender:
                        new SwitchForms(employee, this, new BarKitchenForm(employee));
                        break;

                    case Roles.Chef:
                        new SwitchForms(employee, this, new BarKitchenForm(employee));
                        break;

                    case Roles.Manager:
                        new SwitchForms(employee, this, new ManagementForm(employee));
                        break;

                    default:
                        new SwitchForms(employee, this, new homeForm(employee));
                        break;
                    }
                }
            }
        }
예제 #7
0
        public void LoadEmployees()
        {
            Employee_Service employeeService = new Employee_Service();
            List <Employee>  employees       = employeeService.GetEmployees();

            employeeUC employeeControl;

            pnlEmployees.Controls.Clear();      //clear the existing panels

            foreach (Employee emp in employees) //for each employee, show a custom control and put it in the panel
            {
                employeeControl = new employeeUC(employee, emp, this);
                pnlEmployees.Controls.Add(employeeControl);
            }
        }
예제 #8
0
        private void btn_Ucheck_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txt_User.Text))
            {
                ChapooLogic.Employee_Service service = new Employee_Service();
                Employee employee = new Employee();

                employee.username = txt_User.Text;
                lbl_question.Text = service.forgotpassquestion(employee);

                if (lbl_question.Text == "")
                {
                    MessageBox.Show("Wrong Username");
                }
            }
        }
예제 #9
0
파일: homeForm.cs 프로젝트: logoffro1/ROSA
        private void WriteNotes()
        {
            Employee_Service es = new Employee_Service();

            //get each new line into a separate string
            string[] txtLines = txtNotes.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            string formattedLines = "";

            foreach (string s in txtLines)//loop through the txtLines array and add each string into formattedLines
            {
                formattedLines += s + ";";
            }

            es.EditAccount(employee.username, formattedLines);
        }
예제 #10
0
        private void btn_check_Click(object sender, EventArgs e)
        {
            // check is entered string is valid
            if (!string.IsNullOrWhiteSpace(txt_answer.Text))
            {
                ChapooLogic.Employee_Service service = new Employee_Service();
                Employee employee = new Employee();

                employee.username = txt_User.Text;
                string answer;

                //get answer
                answer = service.forgotpass(employee);

                // check if answer matches
                if (txt_answer.Text.ToLower() == answer.ToLower())
                {
                    // if passwords match
                    if (txt_newpass == txt_repeatpass)
                    {
                        //call hashing function
                        HashwithSalt hash = new HashwithSalt();
                        // create salt and create hash
                        string salt   = hash.CreateSalt(64);
                        string hashed = hash.GenerateHash(txt_newpass.Text, salt);
                        //grab and parse username
                        int username = int.Parse(txt_User.Text);

                        // change password
                        service.Alterpass(username, hashed, salt);
                        // show success
                        MessageBox.Show("Je wachtwoord is succesvol veranderd");


                        // open login form again
                        LoginForm loginForm = new LoginForm();
                        loginForm.Show();
                        this.Close();
                    }
                }
                else //display fail if answer is wrong
                {
                    MessageBox.Show("Foutief antwoord op de vraag");
                }
            }
        }
예제 #11
0
        public void Verify()
        {
            if (usernameinput.Text == "" || passwordinput.Text == "")
            {
                usernametest.Text = "Please enter something";
                return;
            }

            Employee_Service employee_service = new Employee_Service();
            Employee         employee         = employee_service.GetEmployee(usernameinput.Text, int.Parse(passwordinput.Text));

            if (employee != null)
            {
                ShowCorrectPage(employee);
                usernameinput.Text = "";
                passwordinput.Text = "";
            }
            else
            {
                usernametest.Text = "Wrong username or password";

                passwordinput.Text = "";
            }
        }
예제 #12
0
 public EmployeeController()
 {
     this.empService = new Employee_Service();
 }
예제 #13
0
        private void btnAddAcount_Click(object sender, EventArgs e)
        {
            Employee_Service employeeService = new Employee_Service();
            bool             emptyField      = false; // to check if a field is empty

            if (
                string.IsNullOrEmpty(txtFirstNName.Text) ||
                string.IsNullOrEmpty(txtLastName.Text) ||
                string.IsNullOrEmpty(txtUsername.Text) ||
                string.IsNullOrEmpty(txtPassword.Text))    //if the textboxes are empty, set emptyField to true
            {
                emptyField = true;
            }

            //if all the  radio buttons are unchecked, set emptyField to truue
            if (!btnManager.Checked && !btnWaiter.Checked && !btnChef.Checked && !btnBartender.Checked)
            {
                emptyField = true;
            }

            if (emptyField) //show warning if there are empty fields
            {
                MessageBox.Show("All fields must be filled!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // set the employeeRole based on what was checked
                Roles employeeRole;
                if (btnManager.Checked)
                {
                    employeeRole = Roles.Manager;
                }
                else if (btnWaiter.Checked)
                {
                    employeeRole = Roles.Waiter;
                }
                else if (btnChef.Checked)
                {
                    employeeRole = Roles.Chef;
                }
                else
                {
                    employeeRole = Roles.Bartender;
                }


                Employee tempEmployee = employeeService.GetAccountByUsername(txtUsername.Text);
                if (tempEmployee != null) //check if that username already exists
                {
                    MessageBox.Show("This username already exists!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    Employee newEmployee = new Employee() //create the new employee
                    {
                        firstName = txtFirstNName.Text,
                        lastName  = txtLastName.Text,
                        username  = txtUsername.Text,
                        password  = txtPassword.Text,
                        role      = employeeRole
                    };
                    employeeService.AddAccount(newEmployee); //add the new employee to the DB
                    MessageBox.Show("New account added!", "Added", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }