コード例 #1
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            String user = txtUsername.Text;
            String pass = txtPassword.Password;

            btnLogin.IsEnabled = false;
            user logUser;

            new Thread(() => {
                if ((logUser = hms.getUser(user, pass)) != null)
                {
                    if (logUser.type.Equals("admin"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate {
                            new AdminPanel(logUser, this).Show();
                        }));
                    }
                    else if (logUser.type.Equals("doctor"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate {
                            new DoctorPanel(logUser, this).Show();
                        }));
                    }
                    else if (logUser.type.Equals("nurse"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate {
                            new NursePanel(logUser, this).Show();
                        }));
                    }
                    else if (logUser.type.Equals("pharmacist"))
                    {
                        this.Dispatcher.Invoke(new Action(delegate {
                            new PharmacistPanel(logUser, this).Show();
                        }));
                    }
                }
                else
                {
                    this.Dispatcher.Invoke(new Action(delegate {
                        MessageBox.Show("Invalid user/pass combination.", "Invalid User", MessageBoxButton.OK, MessageBoxImage.Stop);
                        this.Show();
                    }));
                }
            }).Start();

            this.Hide();
            btnLogin.IsEnabled = true;
        }
コード例 #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            String firstname  = txtFirstName.Text;
            String lastname   = txtLastName.Text;
            String username   = txtUsername.Text;
            String password   = txtPassword.Text;
            String type       = "nurse";
            String phone      = txtPhone.Text;
            String experience = txtExperience.Text;

            DateTime dob = new DateTime();

            if (txtDob.SelectedDate != null)
            {
                dob = (DateTime)txtDob.SelectedDate;
            }
            int    salary = Convert.ToInt32(txtSalary.Text);
            String gender = "female";

            if (!string.IsNullOrEmpty(firstname) && !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) &&
                !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(phone) &&
                !string.IsNullOrEmpty(txtDob.Text) && !string.IsNullOrEmpty(txtSalary.Text) &&
                !string.IsNullOrEmpty(experience))
            {
                if (hms.getUser(username) != null)
                {
                    MessageBox.Show("Username already exists!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                user u = new user();
                u.username = username;
                u.password = password;
                u.type     = type;


                employee emp = new employee();
                emp.firstname = firstname;
                emp.lastname  = lastname;
                emp.dob       = dob;
                emp.salary    = salary;
                emp.gender    = gender;
                emp.phone     = phone;
                emp.user      = u;

                nurse n = new nurse();
                n.experience = experience;
                n.employee   = emp;


                hms.addNurse(n);
                NurseList.Add(n);


                this.Close();
            }
            else
            {
                MessageBox.Show("All fields are required.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #3
0
        private void btnUpdate_Doctor_Click(object sender, RoutedEventArgs e)
        {
            if (docSelected == null)
            {
                return;
            }



            String   firstname = txtFirstName.Text;
            String   lastname  = txtLastName.Text;
            String   username  = txtUsername.Text;
            String   password  = txtPassword.Text;
            String   type      = "doctor";
            int      catid     = int.Parse(cboCategory.SelectedValue.ToString());
            String   phone     = txtPhone.Text;
            DateTime dob       = (DateTime)txtDob.SelectedDate;
            int      salary    = Convert.ToInt32(txtSalary.Text);
            String   gender    = "male";

            if (((radioFemale.IsChecked ?? false) || (radioMale.IsChecked ?? false)) && !string.IsNullOrEmpty(firstname) &&
                !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) &&
                !string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(txtDob.Text) &&
                !string.IsNullOrEmpty(txtSalary.Text) && !string.IsNullOrEmpty(cboCategory.Text))
            {
                if (radioFemale.IsChecked ?? false)
                {
                    gender = "female";
                }
            }
            else
            {
                MessageBox.Show("Please make sure all attributes are compelted.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (username != docSelected.employee.user.username && hms.getUser(username) != null)
            {
                MessageBox.Show("Username already exists!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            docSelected.employee.firstname = firstname;
            docSelected.employee.lastname  = lastname;
            docSelected.employee.dob       = dob;
            docSelected.employee.salary    = salary;
            docSelected.employee.phone     = phone;
            docSelected.employee.gender    = gender;

            docSelected.employee.user.username = username;
            docSelected.employee.user.password = password;
            docSelected.employee.user.type     = type;

            docSelected.catid = catid;

            hms.updateDoctor(docSelected);

            MessageBox.Show("Record updated success.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            dataGrid_Doctor.Items.Refresh();
            PatientList = hms.getPatientList();
            dataGrid_Patient.Items.Refresh();
        }
コード例 #4
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            String firstname = txtFirstName.Text;
            String lastname  = txtLastName.Text;
            String username  = txtUsername.Text;
            String password  = txtPassword.Text;
            String type      = "doctor";
            String phone     = txtPhone.Text;


            DateTime dob = new DateTime();

            if (txtDob.SelectedDate != null)
            {
                dob = (DateTime)txtDob.SelectedDate;
            }
            int    salary = Convert.ToInt32(txtSalary.Text);
            String gender = "male";

            if (((radioFemale.IsChecked ?? false) || (radioMale.IsChecked ?? false)) && !string.IsNullOrEmpty(firstname) &&
                !string.IsNullOrEmpty(lastname) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) &&
                !string.IsNullOrEmpty(phone) && !string.IsNullOrEmpty(txtDob.Text) &&
                !string.IsNullOrEmpty(txtSalary.Text) && !string.IsNullOrEmpty(cboSpecialization.Text))
            {
                if (radioFemale.IsChecked ?? false)
                {
                    gender = "female";
                }
            }
            else
            {
                MessageBox.Show("Please make sure all attributes are completed.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (salary <= 999)
            {
                MessageBox.Show("Salary should be greater than 1000.", "Reminder", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            long catid = int.Parse(cboSpecialization.SelectedValue.ToString());

            if (hms.getUser(username) != null)
            {
                MessageBox.Show("Username already exists!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            user u = new user();

            u.username = username;
            u.password = password;
            u.type     = type;

            employee emp = new employee();

            emp.firstname = firstname;
            emp.lastname  = lastname;
            emp.dob       = dob;
            emp.salary    = salary;
            emp.gender    = gender;
            //emp.uid = uid;
            emp.phone = phone;
            emp.user  = u;


            doctor d = new doctor();

            //d.eid = hms.getEid(uid);
            d.catid    = catid;
            d.employee = emp;

            docList.Add(hms.addDoctor(d));

            //EmployeeList.Add(new DataLayer.EmployeeData() { userData = u, empData = emp, docData = d });
            //docList = hms.getDoctors();
            this.Close();
        }