private void login_click(object sender, RoutedEventArgs e)
        {
            login_btn.IsEnabled = false;
            String user = txtName.Text;
            String pass = txtpassword.Password;
            User   loguser;

            new Thread(() =>
            {
                if ((loguser = hmsfac.getUser(user, pass)) != null)
                {
                    if (loguser.user_type.Equals("admin"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Switcher.stacktest.Navigate(new admincontrol());
                        }));
                    }
                    else if (loguser.user_type.Equals("pharmacist"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Switcher.stacktest.Navigate(new PharmacistPanelUc());
                        }));
                    }
                    else if (loguser.user_type.Equals("doctor"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Switcher.stacktest.Navigate(new DoctorPanelUc(loguser, this));
                        }));
                    }
                    else if (loguser.user_type.Equals("nurse"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Switcher.stacktest.Navigate(new NursePanelUc(loguser, this));
                        }));
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    this.Dispatcher.Invoke(new Action(delegate
                    {
                        txtName.Text         = "";
                        txtpassword.Password = "";
                        txtName.Focus();
                        lberror.Content     = " Invalid username/password!";
                        login_btn.IsEnabled = true;
                    }));
                }
            }).Start();
        }
        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   gender    = "male";
            String   type      = "pharmacist";
            int      payment   = Convert.ToInt32(paymenttxt.Text);
            DateTime dob       = new DateTime();

            if (datepicker.SelectedDate != null)
            {
                dob = (DateTime)datepicker.SelectedDate;
            }
            if (((radiofemale.IsChecked ?? false) || (radiomale.IsChecked ?? false)) && !string.IsNullOrEmpty(firstname) &&
                !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) &&
                !string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(datepicker.Text) &&
                !string.IsNullOrEmpty(paymenttxt.Text))
            {
                if (radiofemale.IsChecked ?? false)
                {
                    gender = "female";
                }
            }
            else
            {
                MessageBox.Show("Please make sure all attributes are completed.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                this.save_btn.IsEnabled = true;
                return;
            }
            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;



            hmsfac.addPharmacist(emp);

            firstnametxt.Text       = "";
            lastnametxt.Text        = "";
            usernametxt.Text        = "";
            passwordbox.Password    = "";
            cellno.Text             = "";
            radiomale.IsChecked     = true;
            paymenttxt.Text         = "";
            datepicker.Text         = "";
            this.save_btn.IsEnabled = true;
        }
Esempio n. 3
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;
            }
        }