Esempio n. 1
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);
        }
Esempio n. 2
0
        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);
        }