Esempio n. 1
0
        /// <summary>
        /// Populates select control with staff types stored in database
        /// </summary>
        public void FillStaffType()
        {
            List <StaffType> staffTypes = new List <StaffType>();

            staffTypes = StaffType.GetAll();

            staffType.ValueMember   = "staffTypeID";
            staffType.DisplayMember = "name";
            staffType.DataSource    = staffTypes;
        }
Esempio n. 2
0
        private void staffType_SelectedIndexChanged(object sender, EventArgs e)
        {
            StaffType selectedStaff = staffType.SelectedItem as StaffType;;

            switch (selectedStaff.Id)
            {
            case 1:
                label_ContactDetails.Text       = "Mobile number";
                pictureBox_ContactDetails.Image = Resources.icon_Mobile;
                break;

            case 2:
                label_ContactDetails.Text       = "Email";
                pictureBox_ContactDetails.Image = Resources.icon_Email;
                break;
            }
        }
Esempio n. 3
0
        private void Button_Register_Click(object sender, EventArgs e)
        {
            string username        = textBox_username.Text;
            string password        = textBox_password.Text;
            string passwordConfirm = textBox_ConfirmPassword.Text;
            string contactDetails  = textBox_ContactDetails.Text;

            //check input from password and confirm password match
            if (password != passwordConfirm)
            {
                MessageBox.Show("The two passwords need to match! Please try again.", "Password mismatch");
                return;
            }

            StaffType selectedStaff = staffType.SelectedItem as StaffType;

            try
            {
                switch (selectedStaff.Id)
                {
                case 1:
                    Nurse nurse = new Nurse(1, username, password, contactDetails);
                    nurse.Save();
                    break;

                case 2:
                    Consultant consultant = new Consultant(2, username, password, contactDetails);
                    consultant.Save();
                    break;
                }

                MessageBox.Show("Registration successful! Please Log in.", "Success");


                // close this form window
                this.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error! Message: " + error.Message + ". Please try again.", "Error");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Retrieves all records from database
        /// </summary>
        /// <returns>List of all staffTypes in database</returns>
        public static List <StaffType> GetAll()
        {
            DataSet   staffTypesDataSet = DatabaseConnection.Instance.GetDataSet(selectStatement);
            DataTable staffTypeTable    = staffTypesDataSet.Tables[0];

            List <StaffType> staffTypes = new List <StaffType>();

            foreach (DataRow row in staffTypeTable.Rows)
            {
                StaffType staffType = new StaffType
                {
                    Id   = (int)row["staffTypeID"],
                    Name = row["name"].ToString()
                };

                staffTypes.Add(staffType);
            }

            return(staffTypes);
        }