Example #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
           UserLogic user1 = new UserLogic();
           check = user1.Login_Logic(mytext1.Text, mytext2.Text);
           if (check == true)
           {
                if (MainWindow.user.Role == true)
                {
                    Admin adminPage = new Admin();
                    this.NavigationService.Navigate(adminPage);
                }
                else
                {
                    UserLogic userPage = new UserLogic();
                    this.NavigationService.Navigate(userPage);
                }
           }
            else
                MessageBox.Show("Wrong username or password");
       
         
            //ConnectionStringSettings connection =  ConfigurationManager.ConnectionStrings["PharmacyFinalEntities"];
            //MessageBox.Show(connection.IsReadOnly().ToString());

            //try
            //{
            //    MainWindow.user = db.Accounts.Single(acc => acc.Name == mytext1.Text && acc.Password == mytext2.Text);

               
          
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //Account account = new Account();
            //account.Name = this.textBox1.Text;
            //account.Password = this.PasswordTextField.Password;
            //account.Role = (bool)AdminRadioBtn.IsChecked;

            //MessageBox.Show(account.Name + "\n" + account.Password + "\n" + account.Role);

            //MainWindow.db.Accounts.Add(account);
            //MainWindow.db.SaveChanges();

            UserLogic addUser = new UserLogic();

            if (addUser.add_user_logic(textBox1.Text, PasswordTextField.Password, (bool)AdminRadioBtn.IsChecked))
                dataGrid.ItemsSource = MainWindow.db.Accounts.ToList();
            else
                MessageBox.Show("Error adding user, please fill all the fields.");


        }