예제 #1
0
        public DoctorPanel(user u, Login login)
        {
            InitializeComponent();
            this.login     = login;
            owner          = u;
            docOwner       = hms.getDoctorByUid(owner.uid);
            NewPatientList = hms.getMyPatients(docOwner);
            OldPatientList = hms.getMyOldPatients(docOwner);
            medicineList   = hms.getMedicines();
            presList       = hms.getMyPrescriptions(docOwner);

            cboMed1.ItemsSource     = medicineList;
            cboMed2.ItemsSource     = medicineList;
            cboMed3.ItemsSource     = medicineList;
            cboMed_Pres.ItemsSource = medicineList;
            cboMedName.ItemsSource  = medicineList;

            cboMed1.SelectedValuePath     = "mid";
            cboMed1.DisplayMemberPath     = "name";
            cboMed2.SelectedValuePath     = "mid";
            cboMed2.DisplayMemberPath     = "name";
            cboMed3.SelectedValuePath     = "mid";
            cboMed3.DisplayMemberPath     = "name";
            cboMed_Pres.DisplayMemberPath = "name";
            cboMed_Pres.SelectedValuePath = "mid";

            cboMedName.SelectedValuePath = "mid";
            cboMedName.DisplayMemberPath = "name";

            dataGrid_NewPatient.ItemsSource    = NewPatientList;
            dataGrid_Pres.ItemsSource          = presList;
            dataGrid_MyOldPatients.ItemsSource = OldPatientList;
        }
        private void dataGrid_Doctor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.indexSelected = dataGrid_Doctor.SelectedIndex;
            if (indexSelected == -1 || DoctorList.Count <= indexSelected)
            {
                docSelected = null;
                btnDelete_Doctor.IsEnabled = false;
                btnUpdate_Doctor.IsEnabled = false;
                return;
            }
            ;

            btnDelete_Doctor.IsEnabled = true;
            btnUpdate_Doctor.IsEnabled = true;
            //docSelected = (doctor)DoctorList.ElementAt<doctor>(dataGrid_Doctor.SelectedIndex);
            docSelected = (doctor)dataGrid_Doctor.SelectedItem;

            txtFirstName.Text = docSelected.employee.firstname;
            txtLastName.Text  = docSelected.employee.lastname;
            txtDob.Text       = docSelected.employee.dob.ToString();
            txtUsername.Text  = docSelected.employee.user.username;
            txtPassword.Text  = docSelected.employee.user.password;
            txtPhone.Text     = docSelected.employee.phone;
            txtSalary.Text    = docSelected.employee.salary.ToString();
            cboCategory.Text  = docSelected.category.name;

            if (docSelected.employee.gender.Equals("female"))
            {
                radioFemale.IsChecked = true;
            }
            else
            {
                radioMale.IsChecked = true;
            }
        }
        private void txtSearch_Doctor_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox         t      = (TextBox)sender;
            string          filter = t.Text;
            ICollectionView cv     = CollectionViewSource.GetDefaultView(dataGrid_Doctor.ItemsSource);

            if (filter == "")
            {
                cv.Filter = null;
            }
            else
            {
                cv.Filter = o =>
                {
                    doctor d = o as doctor;
                    if (cboSearch_Doctor.SelectedValue != null)
                    {
                        String selected = cboSearch_Doctor.SelectedValue.ToString().ToLower();
                        if (selected == "first name")
                        {
                            return(d.employee.firstname.ToLower().StartsWith(filter.ToLower()));
                        }
                        else if (selected == "last name")
                        {
                            return(d.employee.lastname.ToLower().StartsWith(filter.ToLower()));
                        }
                        else if (selected == "gender")
                        {
                            return(d.employee.gender.ToLower().StartsWith(filter.ToLower()));
                        }
                        else if (selected == "username")
                        {
                            return(d.employee.user.username.ToLower().StartsWith(filter.ToLower()));
                        }
                        else if (selected == "phone")
                        {
                            return(d.employee.phone.ToLower().StartsWith(filter.ToLower()));
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                };
            }
            btnUpdate_Doctor.IsEnabled = false;
            btnDelete_Doctor.IsEnabled = false;
        }
예제 #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();
        }