예제 #1
0
        private void Save_Btn_Click(object sender, RoutedEventArgs e)
        {
            this.Save_btn.IsEnabled = false;
            String   firstname = firstnametxt.Text;
            String   lastname  = lastnametxt.Text;
            String   username  = usernametxt.Text;
            String   password  = passwordbox.Password;
            String   phone     = cellno.Text;
            String   type      = "nurse";
            String   gender    = "female";
            int      payment   = Convert.ToInt32(paymenttxt.Text);
            DateTime dob       = new DateTime();

            if (datepicker.SelectedDate != null)
            {
                dob = (DateTime)datepicker.SelectedDate;
            }
            String experience = experty.Text;

            if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) &&
                !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(phone) &&
                !string.IsNullOrEmpty(datepicker.Text) && !string.IsNullOrEmpty(paymenttxt.Text) &&
                !string.IsNullOrEmpty(experience))
            {
                if (hmsfac.getUser(username) != null)
                {
                    MessageBox.Show("Username already exists!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
                User u = new User();
                u.user_name     = username;
                u.user_password = password;
                u.user_type     = type;

                Employee emp = new Employee();

                emp.emp_firstname = firstname;
                emp.emp_lastname  = lastname;
                emp.emp_phone     = phone;
                emp.emp_salary    = payment;
                emp.emp_dob       = dob;
                emp.emp_gender    = gender;
                emp.User          = u;

                Nurse nurse = new Nurse();
                nurse.nurse_experience = experience;
                nurse.Employee         = emp;

                hmsfac.addNurse(nurse);
                nurselist.Add(nurse);

                firstnametxt.Text    = "";
                lastnametxt.Text     = "";
                usernametxt.Text     = "";
                passwordbox.Password = "";
                cellno.Text          = "";
                paymenttxt.Text      = "";
                experty.Text         = "";
                datepicker.Text      = "";
            }
            else
            {
                MessageBox.Show("All fields are required.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                this.Save_btn.IsEnabled = true;
                return;
            }
        }