コード例 #1
0
        private void buttonLogOut_Click(object sender, RoutedEventArgs e)
        {
            LoginWindow lg = new LoginWindow();

            CurrentDriver.Logout();
            this.Close();
            lg.ShowDialog();
        }
コード例 #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            //var customer = new Customer()
            //{
            //    FirstName = "Ivan",
            //    LastName = "Petrenko",
            //    Login = "******",
            //    //pass = 12345
            //    Password = "******",

            //};

            //_unitOfWork.CustomerRepository.Insert(customer);
            //_unitOfWork.Save();



            var login        = textBoxLogin.Text;
            var password     = Encrypt.GetHash(passwordBox.Password);
            var userCustomer = _unitOfWork.CustomerRepository
                               .Get(x => x.Login == login && x.Password == password)
                               .FirstOrDefault();

            if (userCustomer == null)
            {
                var userDriver = _unitOfWork.DriverRepository
                                 .Get(x => x.Login == login && x.Password == password)
                                 .FirstOrDefault();


                if (userDriver == null)
                {
                    MessageBox.Show(this, "Invalid user name or password", "Authentication Error");
                }
                else
                {
                    //CurrentUser.Initialize(user);
                    //this.DialogResult = true;
                    DriverWindow m = new DriverWindow();
                    CurrentDriver.Initialize(userDriver);
                    // MessageBox.Show("Driver!!");
                    this.Close();
                    //m.fullName = name;
                    //m.Owner = this;
                    m.ShowDialog();
                }
            }
            else
            {
                CustomerWindow m = new CustomerWindow();
                //MessageBox.Show("User!!");
                CurrentCustomer.Initialize(userCustomer);
                this.Close();
                m.ShowDialog();
            }
        }