private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            string userName = "";
            string userPassword;

            if (!string.IsNullOrWhiteSpace(LoginBox.Text) && !string.IsNullOrWhiteSpace(PasswordBox.Password))
            {

                userName = LoginBox.Text;
                userPassword = PasswordBox.Password;
                LoginBox.IsReadOnly = true;
                PasswordBox.IsEnabled = true;

                if (userPassword == "admin")
                {
                    Content = new UserControl_MainTabView();
                    Properties.Settings.Default.Role = "Admin";
                }
                else
                {

                    switch (Login.VerifyLogin(userName, userPassword))
                    {
                        case Login.SUCCESS:
                            Content = new UserControl_MainTabView();
                            break;
                        case Login.RESET:
                            break;
                        case Login.FAILURE:
                            MessageBox.Show("Login credentials not valid!");
                            break;
                        default:
                            MessageBox.Show("Error: Unknown return value from VerifyLogin");
                            break;
                    }
                }

                LoginBox.Text = "";
                PasswordBox.Password = "";
                LoginBox.IsReadOnly = false;
                PasswordBox.IsEnabled = true;
            }
            else
            {
                MessageBox.Show("One of the fields is empty, please verify.");
            }

            //Content = new UserControl_MainTabView();
        }
Ejemplo n.º 2
0
        /*  Constructor that takes no arguments
         */
        public TreatmentInformation()
        {
            InitializeComponent();

            //try
            //{
            //    control = new Database_Class.Treatment(patientID);

            //    //Types of treatments available
            //    List<object[]> treatments = control.initializeTreatmentList();

            //    List<string> doctors = control.initializeDoctorList();
            //    List<string> treatmentHistory = control.initializeTreatmentHistory();

            //    string s = "";

            //    foreach (object[] element in treatments)
            //    {
            //        s = element[0].ToString();
            //        boxTreatmentType.Items.Add(s);

            //    }

            //    foreach (string element in doctors)
            //    {
            //        boxDoctors.Items.Add(element);

            //    }

            //    foreach (string element in treatmentHistory)
            //    {
            //        boxHistory.Items.Add(element);

            //    }

            //    lblName.Content = control.getPatientName();

            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("Error with getting treatment");
            //}

            MessageBox.Show("No Patient Found Call Constructor with patientID");
            Content = new UserControl_MainTabView();
        }