예제 #1
0
        public NewEmployee(EmployeeItem item, bool isNewEmployee, ListView list)
        {
            InitializeComponent();

            this.item          = item;
            this.isNewEmployee = isNewEmployee; // true = making a new employee, not editing
            this.list          = list;
        }
예제 #2
0
        /// <summary>
        /// When the user clicks on the create new employee window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newEmployeeBtn_Click(object sender, RoutedEventArgs e)
        {
            EmployeeItem newItem = new EmployeeItem(user.employee_type);

            newItem.FirstName = user.first_name;
            newItem.LastName  = user.last_name;
            newItem.Email     = user.email;
            newItem.Username  = user.username;
            newItem.OfficeID  = user.office_id;

            NewEmployee newWindow = new NewEmployee(newItem, true, employeeGridView);

            newWindow.Show();
        }
예제 #3
0
        private void FillEmployeeTab(ListView list)
        {
            // Get all of the employees and fill the list
            using (var context = new Model()) {
                // Only get the employees under the current brokers authority
                SqlParameter idParam = new SqlParameter("id", user.office_id);

                // employee listing
                var employees = context.Employees.SqlQuery("SELECT * FROM Employee WHERE office_id = @id", idParam).ToList <Employee>();

                foreach (Employee employee in employees)
                {
                    if (employee.fired != null || employee.username.Equals(user.username))
                    {
                        continue;
                    }

                    EmployeeItem newItem = new EmployeeItem(employee.employee_type);
                    newItem.FirstName        = employee.first_name;
                    newItem.LastName         = employee.last_name;
                    newItem.Email            = employee.email;
                    newItem.Username         = employee.username;
                    newItem.OfficeID         = employee.office_id;
                    newItem.securityQuestion = employee.security_question;
                    newItem.securityAnswer   = employee.security_answer;

                    if (employee.Administrator != null || employee.employee_type.Equals("S"))
                    {
                        newItem.Salary = employee.Administrator.salary;
                    }
                    else if (employee.Agent != null)
                    {
                        newItem.PhoneNumber = employee.Agent.phone_number;
                        newItem.Commission  = employee.Agent.commission_percentage;
                        newItem.BrokerShare = employee.Agent.broker_share;
                    }

                    list.Items.Add(newItem);
                }
            }
        }
예제 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Set address field
            officeAddress.Content = item.Address;

            // Set office contact information
            officePhoneNumber.Content = item.PhoneNumber;
            officeFaxNumber.Content   = item.FaxNumber;
            officeEmail.Content       = item.Email;

            // Set broker information and employee listing
            using (var context = new Model()) {
                // Broker information
                SqlParameter officeIDParam   = new SqlParameter("id", item.ID);
                SqlParameter brokerNameParam = new SqlParameter("broker", item.BrokerUsername);
                Object[]     parameters      = new object[] { officeIDParam, brokerNameParam };

                Employee broker = context.Employees.SqlQuery("SELECT * FROM Employee WHERE username = @broker AND office_id = @id", parameters).FirstOrDefault <Employee>();

                brokerName.Content  = broker.first_name + " " + broker.last_name;
                brokerEmail.Content = broker.email;

                // employee listing
                var employees = context.Employees.SqlQuery("SELECT * FROM Employee WHERE office_id = @id", new SqlParameter("id", item.ID)).ToList <Employee>();

                foreach (Employee employee in employees)
                {
                    EmployeeItem newItem = new EmployeeItem(employee.employee_type);
                    newItem.FirstName = employee.first_name;
                    newItem.LastName  = employee.last_name;
                    newItem.Email     = employee.email;

                    employeeListView.Items.Add(newItem);
                }
            }
        }